Skip to content

Instantly share code, notes, and snippets.

View Ceasar's full-sized avatar

Ceasar Ceasar

View GitHub Profile
"""
fab -H [hostname] [command]
"""
from fabric.api import run
HOME = '/Users/ceasarbautista'
def authorize():
_ = require "lodash"
memoize = (f) ->
cache = {}
memoizer = ->
args = Array.prototype.slice.call(arguments)
if _.has(cache, args) then cache[args] else cache[args] = f.apply this, args
return memoizer
fib = (n) ->
@Ceasar
Ceasar / lex.py
Last active August 29, 2015 14:01
problem with python scope.
"""
there is no way good way to make this append() function, which is unfortuante because we want the two lines in it to be atomic.
"""
def _lex(line):
tokens = []
token = ""
whitespace = {' '}
escape_chars = {'\\'}
escape = False
@Ceasar
Ceasar / imap
Last active August 29, 2015 14:05
Gmail IMAP bug
* OK Gimap ready for requests from 67.164.75.146 cz17mb41670502pac
x login [email protected] PASSWORD
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH
x OK [email protected] Ceasar Bautista authenticated (Success)
x select Gregory
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotJunk NotJunk $NotPhishing $Junk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotJunk NotJunk $NotPhishing $Junk \*)] Flags permitted.
* OK [UIDVALIDITY 619011903] UIDs valid.
* 69 EXISTS
* 0 RECENT
@Ceasar
Ceasar / deps.py
Created August 28, 2014 21:20
Different ways to resolve dependencies
# Manual constructor injection
class Charlie:
pass
class Beta:
def __init__(self, charlie):
self.charlie = charlie
class Alpha:
@Ceasar
Ceasar / representation.py
Last active October 28, 2015 17:28
A representation object for consuming RESTful APIs.
"""
REST client over requests.
"""
import logging
import requests
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@Ceasar
Ceasar / uri_template.py
Last active August 29, 2015 14:25
Implements a Level 3 expand function for RFC 6570 URI Templates.
from urllib import quote
_OP_LEVEL_2 = {'+', '#'}
_OP_LEVEL_3 = {'.', '/', ';', '?', '&'}
OPERATORS = _OP_LEVEL_2 | _OP_LEVEL_3
_RESERVED = ':/?#[]@' + '!$&\'()*+,;='
class Token(object):
#/usr/bin/ruby
require "cgi"
require "base64"
require "openssl"
require "digest/sha1"
require "uri"
require "net/https"
require "rexml/document"
require "time"
import json
from flask import Flask, request, url_for, jsonify
app = Flask(__name__)
with open('photos.json') as fp:
PHOTOS = json.loads(fp.read())
with open('albums.json') as fp:
@Ceasar
Ceasar / eredan_arean.py
Last active February 12, 2018 06:51
Computes how an attack will go for some heroes in Eredan Arena.
"""
http://www.kongregate.com/games/feerik/eredan-arena
"""
import itertools
die = ['R', 'R', 'B', 'Y', 'S', 'S']
sides = set(die)