Skip to content

Instantly share code, notes, and snippets.

View seabre's full-sized avatar

Sean Brewer seabre

  • CrowdFiber
  • Chattanooga, TN
View GitHub Profile
@seabre
seabre / fizzbuzz.py
Created September 16, 2011 17:35
Extremely Obnoxious FizzBuzz
#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))
@seabre
seabre / one_month_ahead.rb
Created September 16, 2011 18:21
Get Datetime in the Currently Set Timezone in Rails for the Beginning of the Next Month
#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")
@seabre
seabre / file_permission_octal.sh
Created September 21, 2011 16:15
Easily Show File Permission Octal for a File
stat -c '%a' myfile
@seabre
seabre / get_columns_for_rails_admin.rb
Created September 30, 2011 17:02
Get Columns From Table Formatted For Configuration in Rails Admin
Model.columns.map {|c| puts "field :#{c.name}"}
@seabre
seabre / sketch_template.pde
Created October 12, 2011 16:11
Basic Processing Sketch Template
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
@seabre
seabre / hexagon.pde
Created October 14, 2011 15:24
Drawing a Hexagon in Processing
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);
@seabre
seabre / rgb_conversions.js
Created October 15, 2011 02:01
RGB Conversions
/*
rgb_hex_to_rgb_list
Example input:
rgb_hex_to_rgb_list("ffffff");
Output:
[255,255,255]
@seabre
seabre / basic_html5_template.html
Created October 15, 2011 07:58
Basic HTML5 Template
<!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>
@seabre
seabre / compressallpng.sh
Created October 17, 2011 16:44
Crush All PNGs Starting From Root Directory.
#!/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
@seabre
seabre / lighttpd.conf
Created November 4, 2011 15:53
lighttpd PHP Demo Server Configuration
# 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"