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
find . -type f -print0 | xargs -0 sed -i 's/oldword/newword/g' |
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/nkoCRTss | |
#Solve the code from today's (04/19/2009) FoxTrot comic. | |
#**NOT** the best (definitely not the most elegant) way to do this, but I banged it out in 5 minutes... | |
from math import * | |
code = [16,11,13,5,10,2,15,18,13,23,8,11,17,11,12,22,11,12,19] | |
def solve(num): |
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
(function(){var a=[["0","1","2","3","4","5","6","7","8","9"],["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]];pass="";for(var b=8;b>0;b--){var c=a[Math.floor(Math.random()*a.length)];pass+=c[Math.floor(Math.random()*c.length)]}prompt("Random Password:",pass)})(); |
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] |
OlderNewer