Skip to content

Instantly share code, notes, and snippets.

@frgomes
frgomes / bootstrap_setup.py
Last active August 27, 2017 17:07
Python - Installing packages programmatically
#!/usr/bin/env python
from __future__ import print_function
REQUIREMENTS = [ 'distribute', 'version', 'Cython', 'sortedcollection' ]
try:
from setuptools import find_packages
from distutils.core import setup
from Cython.Distutils import build_ext as cython_build
import sortedcollection
@Chrisedmo
Chrisedmo / sublime-icloud.txt
Created November 11, 2014 13:53
Sync Sublime Text Plugins iCloud Drive
Sublime Text Plugins iCloud Drive
First Machine
On your first machine, use the following instructions.
$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
$ mkdir ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Web\ Dev/Plugins
$ mv User ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Web\ Dev/Plugins
$ ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Web\ Dev/Plugins/User
@c0ldlimit
c0ldlimit / index.html
Created September 4, 2014 19:10
#python #tornado pass arguments from tornado to js and not just html
# http://stackoverflow.com/questions/19112296/how-to-pass-arguments-from-tornado-to-a-js-file-but-not-html
$ tree
.
├── static
│ └── scripts
│ └── test.js
├── templates
│ └── index.html
└── test.py
from socket import *
sockets = {}
s = socket()
s.bind(('', 1234))
s.listen()
ns, na = s.accept()
sockets[na] = ns
@itsthejb
itsthejb / main.swift
Created April 17, 2017 15:18
Simple Async Swift commandline tool outline
#!/usr/bin/swift
import Foundation
var keepAlive = true
dump(ProcessInfo().arguments)
let runLoop = RunLoop.current
let distantFuture = Date.distantFuture
@cjgiridhar
cjgiridhar / tornadocrud.py
Created September 10, 2012 17:36
Tornado - CRUD Web Service
import tornado.ioloop
import tornado.web
from datetime import datetime
import urlparse
from bson.json_util import dumps
import pymongo
from pymongo import Connection
class Home(tornado.web.RequestHandler):
@ianlivingstone
ianlivingstone / ast_test.py
Created July 9, 2011 18:05
Uses Python AST Module to build a dict/list representaiton of only module/function/classes and then pulls keywords from their docstrings
import ast
import sys
import pprint
import re
type_lookup = {
ast.Module: 'Module',
ast.FunctionDef: 'Function',
ast.ClassDef: 'Class'
}
@boredzo
boredzo / gist:1696100
Created January 28, 2012 22:57
Creating font(s) from a URL
//Core Graphics method
CGDataProviderRef provider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontURL);
CGFontRef graphicsFont = CGFontCreateWithDataProvider(provider);
CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, fontSize, /*matrix*/ NULL, /*attributes*/ NULL);
if (coreTextFont) {
NSFont *font = (__bridge NSFont *)coreTextFont;
[fonts addObject:font];
CFRelease(coreTextFont);
}
CGFontRelease(graphicsFont);
@mivade
mivade / tornadosse.py
Last active February 8, 2024 02:17
Tornado server-sent events
"""Demonstration of server-sent events with Tornado. To see the
stream, you can either point your browser to ``http://localhost:8080``
or use ``curl`` like so::
$ curl http://localhost:8080/events
"""
import signal
from tornado import web, gen
@blueyed
blueyed / xterm-bg.sh
Last active March 19, 2024 01:02
Query background setting from terminal (xterm / rxvt-unicode)
#!/bin/sh
#
# Query a property from the terminal, e.g. background color.
#
# XTerm Operating System Commands
# "ESC ] Ps;Pt ST"
oldstty=$(stty -g)
# What to query?