Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@inky
inky / ogham.rs
Last active September 6, 2015 09:15
Ogham transliterator in Rust
fn transliterate(ogham: &str) -> String {
ogham.chars().filter_map(|token| match token {
' ' => Some(" "),
'ᚁ' => Some("B"),
'ᚂ' => Some("L"),
'ᚃ' => Some("F"),
'ᚄ' => Some("S"),
'ᚅ' => Some("N"),
'ᚆ' => Some("H"),
'ᚇ' => Some("D"),
@inky
inky / caesar.py
Created August 2, 2015 11:01
Caesar cipher
#!/usr/bin/env python3
import argparse
import string
import sys
def rotate(letters, offset):
return letters[offset:] + letters[:offset]
def cipher(message, map_dict):
return ''.join(map_dict.get(c, c) for c in message)
@inky
inky / flag.py
Last active August 29, 2015 14:23
#!/usr/bin/env python3
import argparse
import string
import sys
CHARS = ("🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲",
"🇳", "🇴", "🇵", "🇶", "🇷", "🇸", "🇹", "🇺", "🇻", "🇼", "🇽", "🇾", "🇿")
OFFSET = ord('A')
@inky
inky / core words.txt
Last active August 29, 2015 14:21
Traumae in Fuþorc
ᚳᛁ ᛉᛁ ᛋᛁ
ᛏᛁ ᛞᛁ ᛚᛁ
ᛈᛁ ᛒᛁ ᚠᛁ
ᚳᚫ ᛉᚫ ᛋᚫ
ᛏᚫ ᛞᚫ ᛚᚫ
ᛈᚫ ᛒᚫ ᚠᚫ
ᚳᚩ ᛉᚩ ᛋᚩ
ᛏᚩ ᛞᚩ ᛚᚩ
#!/usr/bin/env python
"""
This script aims to make it a little easier to work with ConceptNet
relationships using the raw data available. It extracts all of the semantic
relationships for English terms, and saves the results to multiple JSON files
-- one for each letter in the alphabet.
As of Jan 2015, this will require about 9 GB of disk space:
* conceptnet5_flat_json_5.3.tar.bz2 is 644 MB compressed,
#!/usr/bin/env python
# encoding: utf-8
"""
Random Scrabble tiles!
"""
from __future__ import unicode_literals
from random import shuffle
@inky
inky / bots.rb
Created December 17, 2014 00:41
Unfollow everyone. (for twitter_ebooks v2.x)
bot.scheduler.every '1h', :first_in => '1s' do
bot.log "Start unfollowing"
bot.twitter.friend_ids.each do |friend_id|
bot.log "Will unfollow ##{friend_id}"
begin
bot.twitter.unfollow(user_id=friend_id)
rescue Twitter::Error::TooManyRequests => error
bot.log "Rate limit exceeded; will stop unfollowing for now"
return
rescue Exception => error
def str_to_binary(a_string):
return ' '.join(format(ord(c), 'b').zfill(8) for c in a_string)
def ello_string(a_string):
return str_to_binary(a_string).replace('0', 'O').replace('1', 'L')
print ello_string('ello orld')
@inky
inky / tweet.py
Created September 21, 2014 00:31
source code for @coolbot420
import os
import twitter # pip install twitter
def post_tweet(text):
assert len(text) <= 140, 'tweet is too long'
auth = twitter.OAuth(os.environ['TWITTER_USER_TOKEN'],
os.environ['TWITTER_USER_SECRET'],
os.environ['TWITTER_API_KEY'],
os.environ['TWITTER_API_SECRET'])
@inky
inky / .bashrc
Last active August 29, 2015 14:05
Attach to a tmux session or create one if it doesn't exist.
function __inky_tmux_attach()
{
[ -n "$1" ] && session=$1 || session=main
tmux attach-session -d -t "$session" || tmux new-session -s "$session"
}
alias s='__inky_tmux_attach'