This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Originally from: http://codepad.org/9Gl9VQ0u | |
#Extremely obnoxious Python solution to FizzBuzz | |
#http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html | |
import sys | |
map(lambda i: sys.stdout.write("FizzBuzz\n") if i%15==0 else (sys.stdout.write("Fizz\n") if i%3==0 else (sys.stdout.write("Buzz\n") if i%5==0 else sys.stdout.write(str(i)+"\n"))), range(1,101)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get datetime for the beginning of the next month in the timezone that's currently set. | |
one_month_ahead = Time.zone.now.at_beginning_of_month.next_month | |
#You can format the datetime the way you want as well. | |
one_month_ahead = Time.zone.now.at_beginning_of_month.next_month.strftime("%Y-%m-%d %T %z") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stat -c '%a' myfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model.columns.map {|c| puts "field :#{c.name}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x,y; | |
void setup() { | |
x = 0; | |
y = 0; | |
size(640,480); // size of the window in pixels | |
frameRate(30); // call the draw() @ 30 fps | |
background(0,0,0); // background color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void hexagon(int x, int y, int edge_length) { | |
float c = (float) edge_length; | |
float a = .5 * c; | |
float b = sin(radians(60)) * c; | |
float xf = (float) x; | |
float yf = (float) y; | |
/* Fill with a color of your choice. */ | |
fill(0,174,239); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
rgb_hex_to_rgb_list | |
Example input: | |
rgb_hex_to_rgb_list("ffffff"); | |
Output: | |
[255,255,255] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Basic HTML5 Template</title> | |
<link href="stylesheets/style.css" rel="stylesheet" type="text/css" media="screen" /> | |
<script src="example.js"></script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
(find . -name "*.png")|while read pngfile | |
do | |
PNG_FILE=$pngfile | |
PNG_TMP=$RANDOM.compressallpng.png | |
pngcrush -brute $PNG_FILE $PNG_TMP | |
mv $PNG_TMP $PNG_FILE | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I needed a way to quickly test PHP stuff without setting it up somewhere in Apache. | |
# This works great. You can keep this in your repo and whenever you want to run your code do: | |
# lighttpd -f lighttpd.conf | |
# from the root and off you go. | |
server.bind = "0.0.0.0" | |
server.port = 8000 | |
server.document-root = CWD | |
server.errorlog = CWD + "/logs/lighttpd.error.log" | |
accesslog.filename = CWD + "/logs/lighttpd.access.log" |