- LOOK I AM A TURTLE
- May 22, 2003
-
"I'm actually a tortoise."
-
Grimey Drawer
|
Python code:mod = {x: (max(0, x) + 2.0) / (max(0, -x) + 2.0) for x in range(-6, 7)}
You win this round, nielsm.
|
#
?
Aug 20, 2013 11:59
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
?
May 27, 2024 14:29
|
|
- tef
- May 30, 2004
-
-> some l-system crap ->
|
It sounds like it's referring to the form of normalization used. With Unicode there are often equivalent encodings for the same character which are semantically identical but retained to retain round-trip encoding for other character sets. Since a string can contain either, in order to tell if two strings are the same there needs to be some canonical form. NFD is the fully decomposed normal form (everything that can be formed using a base character and combining diacritics is written that way) while NFC is the fully* composed form after full decomposition. I'm not sure how it ties into git.
*For small values of fully.
Some people use NFC names. Mac OSX stores names as NFD. Git treats filenames as opaque filestrings.
*checks out repo on osx, git complains that files are missing*
|
#
?
Aug 20, 2013 13:22
|
|
- substitute
- Aug 30, 2003
-
you for my mum
|
PHP code:function register()
{
if (!empty($_POST)) {
$msg = '';
if ($_POST['user_name']) {
if ($_POST['user_password_new']) {
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) {
if (strlen($_POST['user_password_new']) > 5) {
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) {
if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
$user = read_user($_POST['user_name']);
if (!isset($user['user_name'])) {
if ($_POST['user_email']) {
if (strlen($_POST['user_email']) < 65) {
if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
create_user();
$_SESSION['msg'] = 'You are now registered so please login';
header('Location: ' . $_SERVER['PHP_SELF']);
exit();
} else $msg = 'You must provide a valid email address';
} else $msg = 'Email must be less than 64 characters';
} else $msg = 'Email cannot be empty';
} else $msg = 'Username already exists';
} else $msg = 'Username must be only a-z, A-Z, 0-9';
} else $msg = 'Username must be between 2 and 64 characters';
} else $msg = 'Password must be at least 6 characters';
} else $msg = 'Passwords do not match';
} else $msg = 'Empty Password';
} else $msg = 'Empty Username';
$_SESSION['msg'] = $msg;
}
return register_form();
}
|
#
?
Aug 20, 2013 14:14
|
|
- leftist heap
- Feb 28, 2013
-
-
Fun Shoe
|
Is that what life is like when the only programming construct you understand is if-else?
|
#
?
Aug 20, 2013 15:29
|
|
- substitute
- Aug 30, 2003
-
you for my mum
|
Is that what life is like when the only programming construct you understand is if-else?
It's inside a weird new addition (called "0-one-file version") to this: http://www.php-login.net/
.. which has a full MVC version, along with two other simple class versions. So a new single file option seems like a pointless exercise.
|
#
?
Aug 20, 2013 18:51
|
|
- qntm
- Jun 17, 2009
-
|
PHP code:function register()
{
if (!empty($_POST)) {
$msg = '';
if ($_POST['user_name']) {
if ($_POST['user_password_new']) {
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) {
if (strlen($_POST['user_password_new']) > 5) {
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) {
if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
$user = read_user($_POST['user_name']);
if (!isset($user['user_name'])) {
if ($_POST['user_email']) {
if (strlen($_POST['user_email']) < 65) {
if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
create_user();
$_SESSION['msg'] = 'You are now registered so please login';
header('Location: ' . $_SERVER['PHP_SELF']);
exit();
} else $msg = 'You must provide a valid email address';
} else $msg = 'Email must be less than 64 characters';
} else $msg = 'Email cannot be empty';
} else $msg = 'Username already exists';
} else $msg = 'Username must be only a-z, A-Z, 0-9';
} else $msg = 'Username must be between 2 and 64 characters';
} else $msg = 'Password must be at least 6 characters';
} else $msg = 'Passwords do not match';
} else $msg = 'Empty Password';
} else $msg = 'Empty Username';
$_SESSION['msg'] = $msg;
}
return register_form();
}
This is kind of what my very first ever Java program looked like when I didn't understand try/catch blocks very well.
|
#
?
Aug 20, 2013 19:34
|
|
- Bognar
- Aug 4, 2011
-
I am the queen of France
-
Hot Rope Guy
|
A bunch of my first few months of code looked like that, until I learned about the arrow anti-pattern and early exit from functions.
|
#
?
Aug 20, 2013 19:43
|
|
- Plorkyeran
- Mar 22, 2007
-
To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
|
A bunch of my first few months of code looked like that, until I learned about the arrow anti-pattern and early exit from functions.
The best part is that it even has an early exit, so it's not just SESE insanity.
|
#
?
Aug 20, 2013 20:51
|
|
- Bognar
- Aug 4, 2011
-
I am the queen of France
-
Hot Rope Guy
|
The best part is that it even has an early exit, so it's not just SESE insanity.
Well, not SESE anyway.
|
#
?
Aug 20, 2013 21:00
|
|
- xtal
- Jan 9, 2011
-
by Fluffdaddy
|
I wrote something like this the other day. I can't determine whether it's good or bad.
Python code: raise {
'FARTED_TOO_EARLY': FartedTooEarlyError,
'NOT_A_BUTT': InvalidButtError,
'BUTT_WAS_DIRTY': InvalidButtError,
'MISSING_BUTT': MissingButtError,
}.get(response['status'], ButtError)(response['message'])
The dict/get concept is a popular Python idiom that replaces a standard switch statement. Nothing wrong with it.
|
#
?
Aug 20, 2013 21:21
|
|
- dc3k
- Feb 18, 2003
-
what.
|
PHP code:function register()
{
if (!empty($_POST)) {
$msg = '';
if ($_POST['user_name']) {
if ($_POST['user_password_new']) {
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) {
if (strlen($_POST['user_password_new']) > 5) {
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) {
if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
$user = read_user($_POST['user_name']);
if (!isset($user['user_name'])) {
if ($_POST['user_email']) {
if (strlen($_POST['user_email']) < 65) {
if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
create_user();
$_SESSION['msg'] = 'You are now registered so please login';
header('Location: ' . $_SERVER['PHP_SELF']);
exit();
} else $msg = 'You must provide a valid email address';
} else $msg = 'Email must be less than 64 characters';
} else $msg = 'Email cannot be empty';
} else $msg = 'Username already exists';
} else $msg = 'Username must be only a-z, A-Z, 0-9';
} else $msg = 'Username must be between 2 and 64 characters';
} else $msg = 'Password must be at least 6 characters';
} else $msg = 'Passwords do not match';
} else $msg = 'Empty Password';
} else $msg = 'Empty Username';
$_SESSION['msg'] = $msg;
}
return register_form();
}
I call it the crocodile clause.
|
#
?
Aug 21, 2013 03:34
|
|
- Rocko Bonaparte
- Mar 12, 2002
-
Every day is Friday!
|
It looks like a fire raging out to the right.
|
#
?
Aug 21, 2013 06:50
|
|
- Zombywuf
- Mar 29, 2008
-
|
My life is now made of debug prints fixing data races. Spot the bug fix*:
Python code:if True: # a % 128 == 0:
DEBUG('page elements left:%d' % a)
* Well, the bug goes away.
|
#
?
Aug 21, 2013 11:40
|
|
- Jabor
- Jul 16, 2010
-
#1 Loser at SpaceChem
|
Is the bug fix synchronizing on IO at that point?
|
#
?
Aug 21, 2013 11:42
|
|
- Zombywuf
- Mar 29, 2008
-
|
Is the bug fix synchronizing on IO at that point?
It's more likely that it introduces a slight delay making the race less likely to manifest than any synchronising effect.
|
#
?
Aug 21, 2013 11:57
|
|
- tef
- May 30, 2004
-
-> some l-system crap ->
|
It's more likely that it introduces a slight delay making the race less likely to manifest than any synchronising effect.
iirc (and i probably don't), the bug is pretty much from making QtWebkit do things that it doesn't like doing. An event is fired, and something may or may not happen. A timeout can also happen. However, the events can queue up, so sometimes both the timeout *and* the event fire, and sometimes in an arbitrary order. (Note: Qt is ostensibly single threaded, but QtWebKit isn't)
anyway, bad things can happen.
|
#
?
Aug 21, 2013 14:26
|
|
- Rocko Bonaparte
- Mar 12, 2002
-
Every day is Friday!
|
I've had plenty of times where adding debug prints was enough to eliminate some bizarre asynchronous behavior. But rebooting the machine is also likely to eliminate the particular problem. Heck, restarting the IDE has been sufficient sometimes. This has lead me to make a rule for myself that whenever possible, I attack those kinds of bugs as soon as they happen, where the happen, because it might go hide again soon enough. By the time I've found the bug, I've exposed some nasty rear end thing that was causing all kinds of problems everywhere.
|
#
?
Aug 21, 2013 20:29
|
|
- Drastic Actions
- Apr 7, 2009
-
FUCK YOU!
GET PUMPED!
-
Nap Ghost
|
Not so much coding horror, but management horror. I was fixing an old ASP gantt chart page when I saw this.
code:// this was stupid, embarassing in fact
// if i wasn't so level-headed i would fire someone for this - *** 04-01-02
//if (wt_part <= 25) {
// line_img = 'blue';
//} else if (wt_part > 25 && wt_part <= 50) {
// line_img = 'green';
//} else if (wt_part > 50 && wt_part <= 75) {
// line_img = 'yellow';
//} else if (wt_part > 75) {
// line_img = 'red';
//}
// this sanity replaces the ridiculous crap from directly above - *** 04-02-02
// call me a hothead, but i'm still considering firing someone for this
taskPercentComplete = (twh [ca [pid][i]] / ett [ca [pid][i]]) * 100;
if (isNaN(taskPercentComplete))
taskPercentComplete = 0;
if (taskPercentComplete > 100)
taskPercentComplete = 100;
if (taskPercentComplete <= 25) {
line_img = 'blue';
} else if (taskPercentComplete > 25 && taskPercentComplete <= 50) {
line_img = 'green';
} else if (taskPercentComplete > 50 && taskPercentComplete <= 75) {
line_img = 'yellow';
} else if (taskPercentComplete > 75) {
line_img = 'red';
}
No one knows who exactly wrote that (Both the code itself and the comment). My manager and the rest of my team came on well after this person left, and this was from before they used Subversion or any check in service. This was also a time when they would do live edits of code in production and had only one computer with backups, so it was pretty hosed up all around. Thankfully that does not happen anymore.
|
#
?
Aug 22, 2013 14:18
|
|
- seiken
- Feb 7, 2005
-
hah ha ha
|
This was posted on Stack Overflow under the title How to create an array? It's now deleted. I present it here without comment.
quote:
You are about to be provided with information to start your own Google.
Some people posted comments and said this can not be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling purposes (e.g. google +, google finance, youtube the bandwidth consuming no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine... you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like.. numbers to numbers to words.
in other words let's say in the past 24 hours people searched for some phrases over and over again.. you cache those and assign numbers to them, this way you are matching numbers with numbers in mysql. not words with words.
in other words let's say google uses 1/2 their servers for trolling and 1/2 for search engine.
we need technology and ideas so that you can run a search engine on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers. after you make lots of money.. you probably gonna turn into a troll too like google inc.
because god is brutal. god is void-state it keeps singing you songs when you are sleeping and says "nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start. if you notice google constantly links to other web sites with a trackable way when people click on search results.
this means google knows which web sites are becoming popular are popular, etc. they can see what is rising before it rises. it's like being able to see the future.
the computer tells them " you better get in touch with this guy before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world. updated daily in a cvs file. downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable file on the right side.
everyday they update it. and it is being given away for free. google would never do this. amazon does this.
this list you can use to ensure you show the top sites first in your search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things in a "Generic" way but at the same time not in a "questionable" way by displaying them based on "rank"
of course amazon only gives you URLS of the web sites. you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites. a title and some tags is all you need.
simple. basic. functional will get peoples attention.
i always ask questions on SO but most questions get deleted. here's something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good. do not use python frameworks, it's all lies and b.s. use mod-wsgi use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on. do not put your trust in america. it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA. find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python. it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order to troll.
if you need some xdotool commands to deal with people calling you a troll here it is;
code: xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are
not stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the username in the comments section that called you a 'troll' and click the shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB TAB RETURN
which opens the comment typing box. and then it will type @ + username + comma, and then the rest.
seiken fucked around with this message at 20:40 on Aug 22, 2013
|
#
?
Aug 22, 2013 19:58
|
|
- Hammerite
- Mar 9, 2007
-
And you don't remember what I said here, either, but it was pompous and stupid.
-
Jade Ear Joe
|
I can't imagine why anyone would call that person mentally ill.
I wonder what they think "troll" means, they don't seem to be using it correctly in any sense I recognise.
|
#
?
Aug 22, 2013 20:06
|
|
- Lorem ipsum
- Sep 25, 2007
-
IF I REPORT SOMETHING, BAN ME.
|
Someone should tell him he can run his search engine off AWS
|
#
?
Aug 22, 2013 21:22
|
|
- Suspicious Dish
- Sep 24, 2011
-
2020 is the year of linux on the desktop, bro
-
Fun Shoe
|
Sincerely,
Paul Edward McLaughlin
|
#
?
Aug 23, 2013 00:53
|
|
- RoadCrewWorker
- Nov 19, 2007
-
camels aren't so great
|
I've been waiting for a cuil post-mortem, sad to see their engineer has hit tough times.
|
#
?
Aug 23, 2013 01:08
|
|
- Sticky Profits
- Aug 12, 2011
-
|
I refuse to read any more posts until you guys get with the times and start assigning numbers to the numbers to the words of your posts.
|
#
?
Aug 23, 2013 08:58
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
?
May 27, 2024 14:29
|
|