Skip to content

Instantly share code, notes, and snippets.

View phil-r's full-sized avatar
🤖
resistance is futile

Phil Rukin phil-r

🤖
resistance is futile
View GitHub Profile
@phil-r
phil-r / .tmux.conf
Last active March 1, 2019 15:57
My tmux config
# 0 is too far from ` ;)
set -g base-index 1
setw -g pane-base-index 1
# Rebind the C-b to C-a
set-option -g prefix C-a
# Double C-a to switch to last window
bind-key C-a last-window
@phil-r
phil-r / octodex-download.js
Created April 4, 2018 15:44
Download all octocat images from octodex
const fs = require("fs");
const request = require("request");
const async = require("async");
// client side
// const list = [];
//
// $("img").each(function(i, el) {
// var _src;
@phil-r
phil-r / simple-luvit-proxy.lua
Created October 7, 2016 20:02
Simple luvit proxy <3
local http = require('http')
local options = {
host = "www.google.de"
}
http.createServer(function (req, res)
p(req.url)
local destReq = http.request(options, function (destRes)
destRes:pipe(res)
destRes:on('end', function ()
function hslToRgb(h, s, l) {
h /= 360;
s /= 100;
l /= 100;
var r, g, b;
if (s === 0) {
r = g = b = l; // achromatic
} else {
var hue2rgb = function(p, q, t) {
@phil-r
phil-r / code.py
Created September 11, 2014 14:48
from string import ascii_letters, digits
ALPHABET = digits + ascii_letters
__author__ = 'phil'
def convert_to_code(number, minimal_length=1, alphabet=ALPHABET):
"""Converts a decimal id number into a shortened code."""
base = len(alphabet) # base to convert to
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
@phil-r
phil-r / tweepy.py
Created June 24, 2014 12:35
tweepy example
# Below is the code to test the twitter auth
from lib import tweepy
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret, secure=True)
# step 1
# print auth.get_authorization_url()
from google.appengine.api import urlfetch, files
from google.appengine.api.urlfetch_errors import ResponseTooLargeError, DeadlineExceededError
GS_PICTURES_BUCKET = 's-pictures/'
GS_FULL = 'http://commondatastorage.googleapis.com/'
GS_FULL_PICTURES = GS_FULL + GS_PICTURES_BUCKET
GS_PATH = '/gs/'
GS_PICTURES_PATH = GS_PATH + GS_PICTURES_BUCKET
@phil-r
phil-r / lexer.rb
Created March 27, 2014 16:09 — forked from dustalov/lexer.rb
# encoding: utf-8
# Processor of Link Grammar for Russian output.
#
class LinkParser::Lexer
# This exception raises when link grammar is invalid and Lexer
# is unable to understand the output.
#
class InvalidLinkGrammar < RuntimeError
attr_reader :input