Skip to content

Instantly share code, notes, and snippets.

//Thanks to:
//http://www.benjiegillam.com/2012/06/node-dot-js-ssl-certificate-chain/
//For the code to pass a CA bundle (multiple certs in one file) as an array
//which fixes certificate errors on some browsers when doing https.createServer(options
//This is how you can fix that with nodejitsu's http-proxy when using SNI
// to have a server listening and returning multiple ssl certs
require "Subprocess"
require "tmpdir"
#
# Currently will only convert a single swift code file into a static library
# and cannot include any Objective-C code.
#
# Usage: generate("/path/to/MyCode.swift", :ios)
#
def generate(file, platform, dst=nil)
@apache2046
apache2046 / gist:9cc611f91636712694e4
Created November 20, 2015 03:38
Mongoose populate an array
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
mongoose.connect('mongodb://localhost/testy2');
var UserSchema = new Schema({
name: String
});
//
// SimpleScrollingStack.swift
// A super-simple demo of a scrolling UIStackView in iOS 9
//
// Created by Paul Hudson on 10/06/2015.
// Learn Swift at www.hackingwithswift.com
// @twostraws
//
import UIKit
import Foundation.NSNotification
#if !COCOAPODS
import PromiseKit
#endif
/**
To import the `NSNotificationCenter` category:
use_frameworks!
pod "PromiseKit/Foundation"
@apache2046
apache2046 / imagenet1000_clsidx_to_labels.txt
Created August 18, 2020 07:26 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@apache2046
apache2046 / iptables-cheatsheet.md
Created September 28, 2020 06:50 — forked from mcastelino/iptables-cheatsheet.md
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@apache2046
apache2046 / route_based_on_uid.sh
Created June 28, 2022 09:39 — forked from gunkaaa/route_based_on_uid.sh
Use separate gateway based on iptables owner (UID)
#!/bin/bash
# (In this case) default gateway is 192.168.1.3, alternate is 192.168.1.1.
# Usually default is either .1 or .254 - pay attention.
# If anything involving CDNs is involved, use https://github.com/hadess/resolvconf-override .
# Add new routing table, which uses alternate gateway by default
echo 100 altgateway >> /etc/iproute2/rt_tables
# Mark traffic sourced from UID as needing to go via other gateway (4 is arbitrary)
@apache2046
apache2046 / how-to.md
Created August 9, 2022 14:21 — forked from reywood/how-to.md
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running python script

Sometimes a python script will simply hang forever with no indication of where things went wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward. Here's a way to see where the program is currently stuck.

Install gdb and pyrasite

Install gdb.

# Redhat, CentOS, etc
@apache2046
apache2046 / dbldbl.h
Created January 28, 2023 08:15 — forked from seibert/dbldbl.h
Version 1.2 of NVIDIA's double-double arithmetic header, distributed in accordance with its BSD License.
/*
* Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,