Skip to content

Instantly share code, notes, and snippets.

View mturilin's full-sized avatar

Mikhail Turilin mturilin

  • Google
  • San Francisco, CA
View GitHub Profile
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]):
@mturilin
mturilin / multi_pipe.py
Last active August 29, 2015 14:00
Python multi-threading example
from multiprocessing import Process, Pipe
import sys
import time
import random
def worker(p):
while True:
s = p.recv()
if not s:
break
@mturilin
mturilin / quote.py
Last active February 29, 2016 23:36
Email reformatting and quoting workflow for Alfred
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):
@mturilin
mturilin / Readme.txt
Created August 11, 2019 21:52
Duplicate line for XCode
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>
@mturilin
mturilin / hypenation.swift
Created August 12, 2019 18:04
Hypenation in Swift
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)
@mturilin
mturilin / README.txt
Last active September 1, 2019 20:44
Word Count
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
@mturilin
mturilin / commands.txt
Created February 9, 2020 20:13
Bonjour - list services
#
dns-sd -B
# all disconverable services
dns-sd -B _services._dns-sd._udp local.
@mturilin
mturilin / logit.scpt
Last active May 19, 2020 03:04
AppleScript
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
@mturilin
mturilin / dedupe.py
Created March 11, 2021 00:34
CVS dedupe
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'
@mturilin
mturilin / obsidian.css
Created October 31, 2021 23:26 — forked from pihentagy/obsidian.css
Clutter free edit mode
/* 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; } */