Skip to content

Instantly share code, notes, and snippets.

View socket_example.py
from socket import *
sockets = {}
s = socket()
s.bind(('', 1234))
s.listen()
ns, na = s.accept()
sockets[na] = ns
View applefn.patch
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index 08d186d656..2084b728f3 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -766,6 +766,10 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
endif
endif
+ifeq ($(strip $(APPLE_FN_ENABLE)), yes)
+ OPT_DEFS += -DAPPLE_FN_ENABLE
@itsthejb
itsthejb / main.swift
Created Apr 17, 2017
Simple Async Swift commandline tool outline
View main.swift
#!/usr/bin/swift
import Foundation
var keepAlive = true
dump(ProcessInfo().arguments)
let runLoop = RunLoop.current
let distantFuture = Date.distantFuture
@blueyed
blueyed / xterm-bg.sh
Last active May 12, 2022
Query background setting from terminal (xterm / rxvt-unicode)
View xterm-bg.sh
#!/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?
@mivade
mivade / tornadosse.py
Last active Feb 9, 2021
Tornado server-sent events
View tornadosse.py
"""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
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
c0ldlimit / index.html
Created Sep 4, 2014
#python #tornado pass arguments from tornado to js and not just html
View index.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
@frgomes
frgomes / bootstrap_setup.py
Last active Aug 27, 2017
Python - Installing packages programmatically
View bootstrap_setup.py
#!/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
@zsiegel
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(@"*****************************************************************");
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:systemFont]); //Custom function
NSLog(@"*****************************************************************");
NSLog(@"CUSTOM-FONT LINE HEIGHT PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
@mkdynamic
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>