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 json | |
import unicodecsv as csv | |
import sys | |
def recursive_keys(row): | |
keys = set() | |
for k in row.keys(): | |
if isinstance(row[k], dict): | |
for subkey in recursive_keys(row[k]): |
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
from multiprocessing import Process, Pipe | |
import sys | |
import time | |
import random | |
def worker(p): | |
while True: | |
s = p.recv() | |
if not s: | |
break |
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 find_next_space(text, start): | |
while start < len(text): | |
if text[start] == " ": | |
return start | |
else: | |
start += 1 | |
return start | |
def find_next_non_space(text, start): | |
while start < len(text): |
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
sudo subl /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist | |
add the following: | |
<key>Customized</key> | |
<dict> | |
<key>Duplicate Lines</key> | |
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string> | |
<key>Duplicate Current Line</key> | |
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string> | |
</dict> |
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 Foundation | |
extension String { | |
func hungarianHyphenated() -> String { | |
return hyphenated(locale: Locale(identifier: "hu_HU")) | |
} | |
func hyphenated(languageCode: String) -> String { | |
let locale = Locale(identifier: languageCode) | |
return self.hyphenated(locale: locale) |
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 text file from URL, count all the words, and print top 20 words with the number of times they appear in the file. | |
URL: http://www.gutenberg.org/files/5200/5200.txt | |
(please copy this *exact* URL into your code) | |
Sample output: | |
the - 34 | |
a - 12 | |
hello - 5 |
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
# | |
dns-sd -B | |
# all disconverable services | |
dns-sd -B _services._dns-sd._udp local. |
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
to logit(log_string, log_file) | |
do shell script ¬ | |
"echo `date '+%Y-%m-%d %T: '`\"" & log_string & ¬ | |
"\" >> $HOME/Library/Logs/" & log_file & ".log" | |
end logit |
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 csv | |
uniques = {} | |
with open('original.csv') as csv_file: | |
reader = csv.DictReader(csv_file) | |
for row in reader: | |
if row['Password'] == '': | |
if row['Group'] == 'Root': | |
row['Group'] = 'Root/Non_Login' |
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
/* inline formatting, link targets and [[ ]] disappears if not active line*/ | |
div:not(.CodeMirror-activeline) > .CodeMirror-line span.cm-formatting, | |
div:not(.CodeMirror-activeline) > .CodeMirror-line span.cm-string.cm-url, | |
div:not(.CodeMirror-activeline) > .CodeMirror-line span.cm-formatting-link, | |
div:not(.CodeMirror-activeline)>.CodeMirror-line span.cm-hmd-barelink, | |
div:not(.CodeMirror-activeline)>.CodeMirror-line span.cm-comment | |
{ display: none; } | |
/* hide all html tags -- IT IS COMMENTED OUT BY DEFAULT */ | |
/* div:not(.CodeMirror-activeline) > .CodeMirror-line span.cm-tag{ display: none; } */ |
OlderNewer