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
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
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
#!/usr/bin/python3 | |
import yaml | |
import sys | |
import csv | |
# create root yaml | |
matches = [] | |
# open file |
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
for(i = 1; i<=9999; i++) { | |
console.log("Iteration # --> " + i); | |
document.querySelectorAll('div[role=checkbox]').forEach(div=>div.click()); | |
document.querySelectorAll('div[aria-label*="Select all photos"]').forEach(div=>div.click()); | |
await new Promise(r => setTimeout(r, 3000)); | |
try{console.log("Selected documents count for iteration [" + i + "]: " + document.evaluate('/html/body/div[1]/div/c-wiz/c-wiz[2]/span/div[1]/div/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText);}catch(ex){/*do nothing*/} | |
document.querySelector('button[title=Delete]').click(); | |
await new Promise(r => setTimeout(r, 5000)); | |
document.evaluate('//span[text()="Move to trash"]', document, null, XPathResult.ANY_TYPE, null ).iterateNext().click(); |
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 |
OlderNewer