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
def cartesian (lists): | |
if lists == []: return [()] | |
return [x + (y,) for x in cartesian(lists[:-1]) for y in lists[-1]] | |
print cartesian([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) |
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
private static byte[] xor(byte[] left, byte[] right, int len) | |
{ | |
byte[] output = new byte[len]; | |
for (int i = 0; i < len; i++) { | |
output[i] = (byte) ((byte) left[i]) ^ ((byte) right[i]); | |
} | |
return output; | |
} |
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
__kernel void | |
aes128_expand_encryption_key ( __global uint4 *key , | |
__global uint4 *expandedkeys ) | |
{ | |
uint rd; | |
uint global_id = get_global_id(0); | |
__global uint4 * ex = (expandedkeys + (global_id * 11)); |
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
for (round = 1; round <= 9; round++) { | |
temp.x = | |
key[round].x | |
^ Te0[(ciphertext.x >> 24) & 0xFF] | |
^ Te1[(ciphertext.y >> 16) & 0xFF] | |
^ Te2[(ciphertext.z >> 8) & 0xFF] | |
^ Te3[(ciphertext.w >> 0) & 0xFF]; | |
temp.y = | |
key[round].y | |
^ Te0[(ciphertext.y >> 24) & 0xFF] |
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
[bgeiger@Maximus][~]$ ls -l /Library/Internet\ Plug-Ins/ | |
total 12 | |
drwxrwxr-x 3 root wheel 102 Oct 31 09:08 AdobeExManDetect.plugin | |
lrwxr-xr-x 1 root wheel 91 Oct 17 09:56 AmazonMP3DownloaderPlugin1017287.plugin -> /Applications/Amazon MP3 Downloader.app/Contents/Resources/AmazonMP3DownloaderPlugin.plugin | |
drwxrwxr-x 3 root wheel 102 Jan 9 15:10 Flash Player.plugin | |
drwxr-xr-x 3 root wheel 102 Aug 24 17:33 Flip4Mac WMV Plugin.plugin | |
lrwxr-xr-x 1 root wheel 86 Jan 9 17:03 JavaAppletPlugin.plugin -> /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin | |
drwxr-xr-x 3 root wheel 102 Jun 20 2012 Quartz Composer.webplugin | |
drwxr-xr-x 3 root wheel 102 Jun 20 2012 QuickTime Plugin.plugin | |
drwxrwxr-x 3 root wheel 102 Apr 2 2012 SharePointBrowserPlugin.plugin |
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
import re | |
# Get a list of all stories. (This will have to be written at some point.) | |
stories = get_stories() | |
for story in stories: | |
summary = story.get_summary() | |
body = story.get_body() | |
if (not summary) or len(summary.trim()) == 0: |
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
In [1]: foo = [1, 2, 3, 4, 5] | |
In [2]: def bar(lst): | |
...: lst.append(6) | |
...: | |
In [3]: bar(foo) | |
In [4]: foo | |
Out[4]: [1, 2, 3, 4, 5, 6] |
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
foo = [[0] * 10] * 10 | |
print(foo) | |
foo[3][5] = 1 | |
print(foo) |
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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); | |
#include <EEPROM.h> | |
/* | |
** Hardware configuration. | |
*/ |
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
infile = open(inputfilename, "r") | |
outfile = open(outputfilename, "w") | |
filter1 = subprocess.Popen(commandline1, stdin=infile, stdout=subprocess.PIPE, stderr=None) | |
filter2 = subprocess.Popen(commandline2, stdin=filter1.stdout, stdout=outfile, stderr=None) | |
filter1.stdout.close() # required so filter2 can get SIGPIPE, apparently | |
filter1.wait() | |
filter2.wait() |