Skip to content

Instantly share code, notes, and snippets.

@NDari
NDari / piggify.py
Last active May 26, 2016 17:32
convert a json file to pig latin
#/usr/bin/env python
import json, sys
def toPigLatin(string):
modifiedWords = []
for word in string.lower().split():
if word[0] in ['a', 'e', 'i', 'o', 'u']:
word += 'ay'
else:
@NDari
NDari / parseJson.rb
Created May 26, 2016 17:32
Parse JSON in ruby
require 'json' # gem install json
data = JSON.parse File.read ARGV.shift
data.each do |key, value|
puts key
puts value
end
import multiprocessing
def euler1(val):
q = sum([i for i in range(val) if (i % 3 == 0 or i % 5 == 0)])
return q
def store(val):
res.append(val)
def runParallel(fn, argTuples, callbackFn, numWorkers = 4):
@NDari
NDari / gist:ead75df7d39e4f8da41ad3205f79031c
Last active September 23, 2016 15:51
How to enable ssh keys
cat .ssh/id_rsa.pub # get your public key, and copy it
# log in to the server to which you'd like to login with your ssh key
vim .ssh/authorized_keys # copy your public key here
# make the file yours so that nobody can use it and login using your credentials
chmod 644 .ssh/authorized_keys
chown user:group .ssh/authorized_keys
# win!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.30196079611778259</real>
<key>Green Component</key>
<real>0.30196079611778259</real>
# Use perl instead of sed, due to differences between OS X sed and gnu sed.
# This will work on both Linux and Unix as long as perl is installed.
find . -type f -exec perl -pi -e 's/OLDSTRING/NEWSTRING/g' {} \;
import code
# at the place where you'd want to debug
code.interact(local=dict(globals(), **locals()))
@NDari
NDari / remotepaste.md
Created September 20, 2017 13:48 — forked from burke/remotepaste.md
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
#!/bin/bash
#exit on error
set -e
# create our directories
mkdir -p $HOME/local $HOME/src
############
# libevent #
############
FROM ubuntu:16.04
# Locales
ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
RUN apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8
# Colors and italics for tmux
COPY xterm-256color-italic.terminfo /root
RUN tic /root/xterm-256color-italic.terminfo