Results 1 to 30 of 193
-
2013-12-21, 08:06 AM (ISO 8601)
- Join Date
- May 2005
- Location
- control+apple+alt+8
Programmers in the Playground II: It's not a bug, it's a feature
Hello fellow Playgrounders!
The return of the infamous programming thread: a place to posit all your programming queries, brag about your latest accomplishments, and complain about how language X is so bad compared to language Y.
Here's a picture to kick off the discussion:
=PLast edited by TSGames; 2013-12-27 at 08:19 AM.
TopSecret's First Ever Two Page Tabletop ContestIf you have any questions, want to talk about the contest entries, or you just want to hang out with cool people, visit our forums.
-
2013-12-21, 12:45 PM (ISO 8601)
- Join Date
- Jul 2005
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Here's a fun story about using Java to fix a simple problem:
At work I was migrating <Software Product> from one server to another, and updating the software to the latest version. I got the software installed and running and pulled over the database. When I started the software it said: "Error: Can not have more then 64 keys!" I tries this 3-4 times and got the same result, so I looked online. The internet pretty much said: "You're dumb, why are you using that many keys? Recompile MySQL to allow more keys or better yet, fix your DB code." I have run this software on several servers before and I never had to do this, so this did not sound right.
So I opened a ticket with <Software Product's Company>. They said "have you tried recompiling MySQL from source to allow for MySQL to have more then 64 keys?" (Apparently 5min on google was all their IT dept was capable of) My boss didn't like it either so he spent several hours sifting through <Software Company>'s FAQ pages and found a nugget from 2006: "If you receive and error "Can not have more then 32 keys" while upgrading the database, please delete all duplicate entries under "indexes" for each table.
Ah Ha! Problem solved, except there were approximately 1500-2000 entries that needed to be removed, and my boss expected me to do this by hand. Yea right. So I whipped up a java program that went through every table and deleted all redundant entries, and I did it in under 3 hours. Also I haven't made Java talk to a database in a few years so it was a good refresher course too! For the next 15 min I sat back like a proud parent and watched my code clean the database. When it was done the software ran like a charm, no issues.
When I notified <Software Company>'s helpdesk, there were uninterested in my solution. The tech asked me to submit a feature request and closed the ticket. All of this could have been avoided if their software cleaned up after itself when it updated, instead of making a new copy every index in the DB each time it was updated. To be fair, this issue did end with my boss being very impressed with my ability to use code to solve problems quickly.Proud 1st edtion player!
-
2013-12-27, 08:18 AM (ISO 8601)
- Join Date
- May 2005
- Location
- control+apple+alt+8
Re: Programmers in the Playground II: It's not a bug, it's a feature
XD
Yeah... I've run into the 'feature request for nearly-essential functionality that the program should already have' before. It's never ended productively, or well for me.
I figure I'll kick off the discussion then: Anyone got a project they feel like posting/ranting/bragging about?TopSecret's First Ever Two Page Tabletop ContestIf you have any questions, want to talk about the contest entries, or you just want to hang out with cool people, visit our forums.
-
2013-12-27, 02:03 PM (ISO 8601)
- Join Date
- May 2005
- Location
- Somerville, MA
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Sure. I feel like gushing about docopt. If you're not into the command line you probably won't care.
My least favorite task in writing cli apps is parsing the options and arguments. When I'm done with that I have to go back and update the documentation to match the new options.
Docopt fixes that.
There are many libraries for handling command line options. Docopt's approach is to define those options in the documentation. So you come up with your help message that describes the options, where they can be used, what their defaults are, whether they're required or optional, etc. Just write the documentation, let docopt parse that and your options all in one fell swoop. Now your options and documentation won't get out of sync again.
I'm gushing about docopt because I finally got the bash version to work. (There's a core python version and support for calling it from a number of languages, but the bash one was tricky. Actually the problem was that github was eating some of the syntax which ruined the example, but that's another matter.)
I rewrote a music selection script I had using docopt. The switch made it a whole lot more versatile and cut down LOC by about 25%. I hate bragging, but it's probably the most beautiful shell script I've made so far. You point it at your music directory, describe the directory (ie, the default is genre/artist/album, but if yours is ordered by artist/year/album you could change that with the --structure option), tell it which criteria to filter by, and it lets you pick one of those items and plays it. So I could call my script with "-l album" and it'll let me choose an album and play it. Or "-l genre" would let me single out a genre. Or I could combine that with "--random" and it'd pick the same type of item randomly.
Here's the script. The eval at the top is the docopt documentation I've been babbling about. dmenu is a program that takes stdin, prints it all, and lets you select a line, and prints it back out for further processing. cmus-remote controls cmus, my music player of choice.
SpoilerPHP Code:#!/bin/bash
# applies filters to cmus based on your music directory's structure
# requires docopts and dmenu
eval "$(docopts -A args -V - -h - : "$@" <<EOF
Usage: cmus_select.sh [--list <tag>] [--random] [--structure=</alt/dir/structure>] [--dir=/path/to/music]
-h --help Show help
-r --random Randomize selection instead of using a dmenu
-l --list TAG List music by tag. Unless you use -s, genre, artist, album, and song are expected. [default: song]
-s --structure STRUCT Directory structure for your music. [default: genre/artist/album/song]
-d --dir DIR Location of music [default: $HOME/Music/]
----
cmus_select.sh 0.0.1
EOF
)"
# find position of this tag in the given dir strcuture
for tag in ${args['--structure']//\// } ; do
POS=$(( $POS + 1 ))
[[ "${args['--list']}" == "$tag" ]] && break
done
# set up find args to get this item
if [[ "${args['--list']}" == "song" ]] ; then
FINDARGS=" -mindepth $POS -type f -iregex .*\.\(mp3\) " # no maxdepth - some albums have cd1/cd2 subdirs
else
FINDARGS=" -mindepth $POS -maxdepth $POS -type d"
CAP='/*'
fi
# Prep our pipes. FORMAT affects display. SELECT runs the dmenu.
OFFSET=$(echo ${args['--dir']//\// } | wc -w )
FORMAT="cut -f $((POS + $OFFSET + 1)) -d/"
SELECT="dmenu -i -l 20 -b -s 0"
[[ "${args['--random']}" == 'true' ]] && SELECT="shuf -n 1"
# Get a song or dir and send it to cmus
DIR=$(find "${args['--dir']}" $FINDARGS | $FORMAT | sort | $SELECT )
if [[ "$DIR" != "" ]] ; then
cmus-remote -C "live-filter ~f */$(echo $DIR | tr '()' '*')$CAP" # cmus treats parens as grouping.
cmus-remote -C "echo Playing: $DIR"
cmus-remote -n -p
fi
If you like what I have to say, please check out my GMing Blog where I discuss writing and roleplaying in greater depth.
-
2013-12-27, 05:21 PM (ISO 8601)
- Join Date
- Aug 2007
- Location
- The skirting board
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
I've been playing with Project Euler to keep my hand in. I have finally realised that Python is easier to write, and far faster to play with in this kind of case. (I'm a C++ chappie with a chunk of Java thrown in) got to problem 18 in less than a week. I'm out of practice so please don't rant at me for being slow!
Why cannot life be simple? I am simple, therefore surely something that i try to do must also be simple
-
2013-12-27, 07:15 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Is anyone here experienced with adding holidays to KDE? I'm trying to add LITERALLY hundreds of religious holidays, and some have semi-complex rules for calculating the date. Such as "Normally on this day, unless it's less than a week before Easter, when it's this other day instead"
I'm trying the following, but not only will my computer not accept it, it'll actually ignore any lines after it.
(Actually all on one line)
Code:white "Solemnity of the Annunciation of the Lord" white on ([easter] - [25.3] <= 7 ? [easter plus 8 days] : [25.3])
Last edited by Razanir; 2013-12-27 at 07:16 PM.
Avatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2013-12-28, 10:30 AM (ISO 8601)
- Join Date
- Aug 2009
Re: Programmers in the Playground II: It's not a bug, it's a feature
The thread starter tells to brag about achievements so here goes:
I just finished a course in mobile development, which was basically about making html/Javascript apps for Android using Phonegap. I had only went to a basic Java course before, and had never done anything with Javascript.
I'm proud to present my final product: Javascript Trainer - an app that presents you with a block of code, and your job is to spot the errors in it. The idea came from myself noticing that I spent lots and lots of time trying to fix my code by tweaking the logic of it, when the problem was in a simple syntax error that I just didn't notice.
The app is available on Google Play
-
2013-12-30, 07:34 AM (ISO 8601)
- Join Date
- Feb 2013
Re: Programmers in the Playground II: It's not a bug, it's a feature
Another Pythonist is born! Welcome to the land of easy coding.
As for me, I don't have much to brag about at the moment, but I did just finish up a huge project experimenting with multi-threading in python. Contrary to popular belief, it handles it quite well and I was able to speed up execution time by a factor of 8 on a 4 core system. =DHello, I'm Finlam: content creator for D&D5e and writer.
Playable Slimes for D&D5e
>>>So You Want To Be A Slime?<<<
5eHeroic - Make high level D&D feel heroic and fun again.
-Game Content-
Roleplay Warm-up - Exercises to get into Character
3 Traps to Get Your Players Excited
GM's Easy Creation Kit (G.E.C.K.)
-Character Builds-
Building a Super SAD Tank - Using a Paladin/Hexblade to build an unstoppable tank.
Let's chat sometime.
-
2013-12-30, 11:04 AM (ISO 8601)
- Join Date
- Jun 2011
Re: Programmers in the Playground II: It's not a bug, it's a feature
Any advice on where to pick up information on Python? As of a few days ago, I've got a Raspberry Pi on my desk, and Python seems to be the intended language of choice.
I've been rather light on programming lately, and most of my experience is in C. I'd like a quick overview/intro that would also be a decent reference, rather than something intended for a complete beginner with no experience.
-
2013-12-30, 11:23 AM (ISO 8601)
- Join Date
- Feb 2013
- Location
- Prime Material Plane
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
The best place to go is the official Python tutorial. Note that there are two types of Python: Python 2.7, and Python 3. 3 is newer, but 2 is more portable. Here are links to both tutorials:
2.7: http://docs.python.org/2/tutorial/
3: http://docs.python.org/3/tutorial/
-
2013-12-30, 02:29 PM (ISO 8601)
- Join Date
- Aug 2009
- Location
- Maryland
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Hey, I code all the things! Java's the main language these days, but I dabble in all manner of stuff. Python was the last language picked up, and I must say, it's reasonably easy to pick up. JMonkey is my current dabblin' project, though finding spare time for more coding is rough.
-
2013-12-30, 02:37 PM (ISO 8601)
- Join Date
- Jun 2011
-
2013-12-30, 04:16 PM (ISO 8601)
- Join Date
- Jul 2005
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Proud 1st edtion player!
-
2013-12-30, 05:34 PM (ISO 8601)
- Join Date
- Feb 2010
- Location
- Calgary
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
I would like to brag that I made it through last semester with B's. As much as learning assembly and machine code was a pain, I appreciate not programming in assembly and really really really appreciate not programming in machine code.
-
2013-12-30, 06:16 PM (ISO 8601)
- Join Date
- Dec 2010
- Location
- The Great White North
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Obligatory xkcd: Real Programmers.
Last edited by shawnhcorey; 2013-12-30 at 06:16 PM.
How do you keep a fool busy? Turn upside down for answer.
˙ɹǝʍsuɐ ɹoɟ uʍop ǝpısdn uɹnʇ ¿ʎsnq ןooɟ ɐ dǝǝʞ noʎ op ʍoɥ
-
2013-12-30, 07:57 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Avatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2013-12-30, 08:18 PM (ISO 8601)
- Join Date
- Feb 2013
- Location
- Prime Material Plane
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
-
2013-12-30, 08:31 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Avatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2013-12-31, 07:14 AM (ISO 8601)
- Join Date
- Feb 2013
Re: Programmers in the Playground II: It's not a bug, it's a feature
Yeah, you can do a lot of cool stuff with FPGAs. VHDL is awesome to program in, but I found (for me) that it took a little while to get into the everything asynchronous mindset. After you're there, it can be a ton of fun, plus working on the hardware at that level makes it really really fast.
Hello, I'm Finlam: content creator for D&D5e and writer.
Playable Slimes for D&D5e
>>>So You Want To Be A Slime?<<<
5eHeroic - Make high level D&D feel heroic and fun again.
-Game Content-
Roleplay Warm-up - Exercises to get into Character
3 Traps to Get Your Players Excited
GM's Easy Creation Kit (G.E.C.K.)
-Character Builds-
Building a Super SAD Tank - Using a Paladin/Hexblade to build an unstoppable tank.
Let's chat sometime.
-
2014-01-03, 06:40 AM (ISO 8601)
- Join Date
- Jun 2007
- Location
- Switzerland
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
This year, we acquired two new customers for our software and we now optimize the power portfolios of the three largest Swiss power companies (among others). Pretty good for a two man company and with the software written by one person (me!).
Last edited by Ashtar; 2014-01-03 at 06:40 AM.
-
2014-01-03, 01:01 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Avatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2014-01-07, 08:03 PM (ISO 8601)
- Join Date
- Sep 2012
-
2014-01-08, 04:14 PM (ISO 8601)
- Join Date
- Aug 2009
- Location
- Maryland
- Gender
-
2014-01-08, 04:33 PM (ISO 8601)
- Join Date
- Jul 2005
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
A REAL programer uses a "binary-like system of ropes, knots, and simple machines operated by a rotating cylindrical cogwheel"
See Heron of Alexandria
Rope computers, go big or go home.Last edited by Drumbum42; 2014-01-08 at 04:33 PM.
Proud 1st edtion player!
-
2014-01-08, 04:55 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
This seems relevant:
K'nex calculatorAvatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2014-01-08, 07:40 PM (ISO 8601)
- Join Date
- Dec 2010
- Location
- The Great White North
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Real programmers make it out of Lego.
How do you keep a fool busy? Turn upside down for answer.
˙ɹǝʍsuɐ ɹoɟ uʍop ǝpısdn uɹnʇ ¿ʎsnq ןooɟ ɐ dǝǝʞ noʎ op ʍoɥ
-
2014-01-08, 07:45 PM (ISO 8601)
- Join Date
- Oct 2011
- Location
- The last place you look
- Gender
Re: Programmers in the Playground II: It's not a bug, it's a feature
Avatar by Venetian Mask. It's of an NPC from a campaign I may yet run (possibly in PbP) who became a favorite of mine while planning.
I am a 10/14/11/15/12/14 LG Clr 2
-
2014-01-09, 12:30 PM (ISO 8601)
- Join Date
- Nov 2006
Re: Programmers in the Playground II: It's not a bug, it's a feature
Anyone here any good with databases? My knowledge of them is limited to "Hi, I'm a frontend dev. Here is some stuff I want to save."
I'm looking for something nice and simple that just lets me save my structured data somewhere, without having to write queries. Something similar to Google's NDB, but for Node/Javascript.
Best case scenario would be Redis backed by schemaless Postgres (9.3 using the new JSON type if possible)... anyone?Last edited by Neftren; 2014-01-09 at 12:33 PM.
Avatar by araveugnitsuga | Play by Post (Guide) | Steam
Homebrewers' Extended Signatures
Hey Look, a Summer Reading List!
-
2014-01-09, 12:49 PM (ISO 8601)
- Join Date
- Jan 2012
-
2014-01-09, 12:58 PM (ISO 8601)
- Join Date
- Jul 2005
- Gender