Skip to content

Instantly share code, notes, and snippets.

from socket import *
sockets = {}
s = socket()
s.bind(('', 1234))
s.listen()
ns, na = s.accept()
sockets[na] = ns
@fauxpark
fauxpark / applefn.patch
Last active April 3, 2024 05:29
QMK Apple Fn
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
index 18f8b0bbfc..4ef3e230e4 100644
--- a/builddefs/common_features.mk
+++ b/builddefs/common_features.mk
@@ -878,6 +878,10 @@ ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
endif
endif
+ifeq ($(strip $(APPLE_FN_ENABLE)), yes)
+ OPT_DEFS += -DAPPLE_FN_ENABLE
@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
@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?
@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
@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
@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
@zsiegel
zsiegel / gist:3939839
Last active October 11, 2015 23:58
Core Text - Line height property inspection
/* 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 October 4, 2012 18:13 — 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.
//
// CoreTextLabel.h
// Frost
//
// Created by David Kasper on 10/1/12.
//
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>