Skip to content

Instantly share code, notes, and snippets.

@boozook
boozook / Tools.hx
Last active August 29, 2015 14:18 — forked from nadako/Main.hx
Enum fast extract
class Tools {
public static macro function extract(value:haxe.macro.Expr.ExprOf<EnumValue>, pattern:haxe.macro.Expr) {
return switch (pattern) {
case macro $a => $b:
macro switch ($value) {
case $a:
$b;
default:
throw "no match";
}
using Tools;
class Main {
static function main() {
var a = haxe.ds.Option.Some(42);
var s = a.extract(Some(v) => {value: v});
trace(s);
}
}
@nadako
nadako / Main.hx
Last active February 19, 2019 02:07
Tuple builder using new Rest feature of @:genericBuild
class Main {
static function main() {
var a = getValue();
}
static function getValue():Tuple<Bool,Int> {
return new Tuple(true, 10);
}
}
@dextorer
dextorer / strip.conf
Created July 6, 2014 13:01
google-play-services-strip-script
actions=true
ads=true
analytics=true
appindexing=true
appstate=true
auth=true
cast=true
common=true
drive=false
dynamic=true
@bahayman
bahayman / gist:9369651
Created March 5, 2014 15:38
tcpdump http monitor
Use TCPDUMP to Monitor HTTP Traffic
1. To monitor HTTP traffic including request and response headers and message body:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
2. To monitor HTTP traffic including request and response headers and message body from a particular source:
tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
3. To monitor HTTP traffic including request and response headers and message body from local host to local host:
@BrandonSmith
BrandonSmith / AndroidManifest.xml
Last active July 19, 2023 19:11
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
@m2ym
m2ym / Map.hx
Created August 27, 2013 10:30
Immutable Map implementation using Red-Black Tree in Haxe
private enum Color { Red; Black; }
private enum TreeT<T> {
Leaf;
Node(color: Color, left: TreeT<T>, label: T, right: TreeT<T>);
}
private class TreeF {
private function new() {}
@yorb
yorb / Snap to Pixels.jsx
Created April 23, 2013 16:52
A Photoshop script to snap all path points on selected shape layers to nearest pixels.
// Based on Adobe Community Forums member BlipAdobe's script:
// http://forums.adobe.com/message/3908198#3908198
#target photoshop
// Constants
var QUANTIZE_PIXELS = 1; // The number of whole pixels we wish the path points to be quantized to
var PIXEL_RATIO = app.activeDocument.resolution / 72; // Standardize pixels and points
// Some helpers
@bxt
bxt / proxy.py
Last active August 30, 2020 15:57
A very basic caching python HTTP proxy server.
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
@tong
tong / haxelib-completion.sh
Last active December 25, 2015 21:03
Haxelib shell completion script
#!bash
#
# Haxelib bash completion (3.2.0-rc.3)
#
__haxelib_commands() {
echo "install upgrade update remove list set search info user config path version help submit register local dev git setup newrepo deleterepo selfupdate convertxml run proxy"
}
_haxelib_complete(){