This file contains hidden or 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
# take password out of all java files and all git history | |
git filter-branch -f --tree-filter 'git ls-files -z "*.java" |xargs -0 perl -p -i -e "s#Secr3tpassw0rd#xXxXxXxXxXx#g"' -- --all | |
git gc --aggressive --prune | |
# use -f to force push if already on github | |
git push -f github master |
This file contains hidden or 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
private String createShopSearchQuery() throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException { | |
String jsonAction = "http://api.ravelry.com/shops/search.json?"; | |
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ"); | |
Calendar now = Calendar.getInstance(); | |
String timestamp = df.format(now.getTime()); | |
String searchTerm = "yarn"; | |
int shop_type_id = 1; | |
String query = jsonAction; | |
query += "access_key=" + urlEncode(ACCESS_KEY); |
This file contains hidden or 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
######################################################### | |
# | |
# classes is a git repository with many class projects | |
# I want to split one of those projects into its own repo | |
# and I want preserve the commit history | |
# | |
# The super top-level repo is classes.git | |
# Within classes.git is a sub-directory "networks/project2" | |
# we want to create a new repository with just the history of | |
# "networks/project2" |
This file contains hidden or 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
<?php | |
/** | |
* Tests that link to parent node not shown if user doesn't have access to parent. | |
*/ | |
function testParentAccess() { | |
// Create new book. | |
$nodes = $this->createBook(); | |
$book = $this->book; |
This file contains hidden or 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
#!/usr/bin/python | |
# return true if this year is a leap year | |
def checkLeap(inYear): | |
if(year % 4 == 0): | |
if (year % 100 == 0 and year % 400 != 0): | |
return False | |
else: | |
return True | |
else: |
This file contains hidden or 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
def numWords(num): | |
words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", | |
"thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] | |
iwords = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] | |
twords = ["","teen","twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"] | |
myStr = "" | |
huns = "" | |
# if over a thousand, first mod with 1000 to get next lower magnitude |
This file contains hidden or 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
def sieve(MAX): | |
# list of primes | |
primes = [] | |
# list of all numbers, non-primes will be slowly zeroed out | |
nums = [] | |
# start with first prime | |
prime = 2 | |
# populate list from 0 to MAX | |
nums = [i for i in range(MAX+1)] | |
# zero out 1, non-prime |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# code originally from Michael Klier | |
# -- licensed unded CC-NC-SA | |
# http://www.splitbrain.org/blog/2010-12/12-from_scuttle_to_delicious | |
# | |
# 1. change username and password in urls below | |
# 2. change SCUTTLEDOMAIN to the domain of your scuttle site | |
This file contains hidden or 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
/* Exchange places of nodes after, the nodes passed in.*/ | |
exchange(struct node *u, struct node *v) { | |
struct node *x, *y; | |
x = u->next; | |
u->next = u->next->next; | |
y = v->next; | |
v->next = v->next->next; | |
y->next = u->next; |