Skip to content

Instantly share code, notes, and snippets.

View xarg's full-sized avatar

Alex Plugaru xarg

View GitHub Profile
@xarg
xarg / gist:1259106
Created October 3, 2011 13:29
A golang templating language example spec
Assertions:
- I'm not stupid
- I don't want to be limited by some idiotic `people that write templates are stupid` rule.
- I don't want to learn yet another template language.
- I want to use golang expressions if, for..
- I want all the power of indexing, getting attributes and performing operations that golang offers.
- I want to type less stuff and do more.
- I want to include other templates in my template. (jinja?)
- I want to extend templates.
@xarg
xarg / memcache-stats.py
Created October 4, 2011 15:15
Memcache monitoring script
#!/usr/bin/python
import os
import memcache
import time
from pprint import pprint
client = memcache.Client(["127.0.0.1:11211"])
while True:
os.system('clear')
@xarg
xarg / apples_oranges.py
Created November 23, 2011 14:34
Apples and Oranges
class Apple:
worm = "~~~"
class Orange:
def slices(self):
return [1, 2, 3]
def get_slices(basket):
"""For each item in the basket get it's slices"""
slices = []
@xarg
xarg / apple_wrapper.py
Created November 23, 2011 14:55
Apples and Oranges with a wrapper
class Apple:
worm = "~~~"
class Orange:
def slices(self):
return [1, 2, 3]
def get_slices(basket):
"""For each item in the basket get it's slices"""
slices = []
@xarg
xarg / speach_utility.py
Created November 24, 2011 12:11
Speach utility
from zope.component import getGlobalSiteManager
from zope.interface import Interface, implements
#It's is common practice to prefix interfaces with a big "i".
class ISpeach(Interface):
def say(text):
"""Say something"""
class Hello: # Our utility
#I promise that I implement ISpeach interface.
@xarg
xarg / apples_oranges_adapter.py
Created November 24, 2011 13:39
Apples and Oranges with an zope component adapter
from zope.component import getGlobalSiteManager, adapts
from zope.interface import Interface, implements
class IApple(Interface):
"""I'm an apple"""
class Apple:
implements(IApple) # we need this so we can adapt this class
worm = "~~~"
@xarg
xarg / fabric_lexer.py
Created July 10, 2012 20:12
Fabric Pygments Lexer
from pygments.lexer import RegexLexer, bygroups
from pygments.token import Text, Name, Generic, Whitespace, Operator
class FabLexer(RegexLexer):
name = 'FAB'
aliases = ['fab', 'fabric']
filenames = ['*.txt', '*.log']
tokens = {
'root': [
@xarg
xarg / shapping-https.sh
Created February 11, 2013 09:51
Limiting traffic with tc
#!/bin/bash
#
# tc uses the following units when passed as a parameter.
# kbps: Kilobytes per second
# mbps: Megabytes per second
# kbit: Kilobits per second
# mbit: Megabits per second
# bps: Bytes per second
# Amounts of data can be specified in:
# kb or k: Kilobytes
@xarg
xarg / fix_capsulecrm_addresses.py
Last active December 18, 2015 19:19
Fix Capsule CRM addresses using Google Geocoding API
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Using google geocoding API try to fix addresses in capsule
"""
import sys
import argparse
import requests
brew install autoconf automake brew-cask freetype gdbm gettext git-sh gnu-getopt gnupg2 gpg-agent gradle imagemagick jpeg lame libassuan libevent libgcrypt libgpg-error libksba libpng libtool libusb libusb-compat mad memtester node openssl ossp-uuid pass pcre pinentry pkg-config postgresql pth pwgen python readline sox sqlite the_silver_searcher tmux tree
brew cask install f-lux google-drive libreoffice pgadmin3 seashore spectacle webstorm android-file-transfer firefox gimp iterm2 macvim pycharm clipmenu font-dejavu google-chrome keyremap4macbook menumeters rdio sketch unrarx