Skip to content

Instantly share code, notes, and snippets.

from socket import *
sockets = {}
s = socket()
s.bind(('', 1234))
ns, na = s.accept()
sockets[na] = ns
View applefn.patch
diff --git a/builddefs/ b/builddefs/
index 08d186d656..2084b728f3 100644
--- a/builddefs/
+++ b/builddefs/
@@ -766,6 +766,10 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
+ifeq ($(strip $(APPLE_FN_ENABLE)), yes)
itsthejb / main.swift
Created Apr 17, 2017
Simple Async Swift commandline tool outline
View main.swift
import Foundation
var keepAlive = true
let runLoop = RunLoop.current
let distantFuture = Date.distantFuture
blueyed /
Last active May 12, 2022
Query background setting from terminal (xterm / rxvt-unicode)
# Query a property from the terminal, e.g. background color.
# XTerm Operating System Commands
# "ESC ] Ps;Pt ST"
oldstty=$(stty -g)
# What to query?
mivade /
Last active Feb 9, 2021
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
Chrisedmo / sublime-icloud.txt
Created Nov 11, 2014
Sync Sublime Text Plugins iCloud Drive
View sublime-icloud.txt
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 / index.html
Created Sep 4, 2014
#python #tornado pass arguments from tornado to js and not just html
View index.html
$ tree
├── static
│ └── scripts
│ └── test.js
├── templates
│ └── index.html
frgomes /
Last active Aug 27, 2017
Python - Installing packages programmatically
#!/usr/bin/env python
from __future__ import print_function
REQUIREMENTS = [ 'distribute', 'version', 'Cython', 'sortedcollection' ]
from setuptools import find_packages
from distutils.core import setup
from Cython.Distutils import build_ext as cython_build
import sortedcollection
zsiegel / gist:3939839
Last active Oct 11, 2015
Core Text - Line height property inspection
View gist:3939839
/* Setup our fonts - One system font from Apple and a custom font */
CTFontRef bodyCopyFont = CTFontCreateWithName((__bridge CFStringRef) [Theme fontForBodyOfSize:11].fontName, [Theme fontForBodyOfSize:11].lineHeight, NULL);
CTFontRef systemFont = CTFontCreateWithName((__bridge CFStringRef) [UIFont systemFontOfSize:11].fontName, [UIFont systemFontOfSize:11].lineHeight, NULL);
/* Lets inspect the properties */
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:systemFont]); //Custom function
NSLog(@"CUSTOM-FONT LINE HEIGHT PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
mkdynamic / CoreTextLabel.h
Created Oct 4, 2012 — forked from dkasper/CoreTextLabel.h
A multiline label drawn with core text. Needed it for line spacing, can easily be modified to use any core text properties though.
View CoreTextLabel.h
// CoreTextLabel.h
// Frost
// Created by David Kasper on 10/1/12.
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>