Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@brandon-lockaby
brandon-lockaby / proxy.js
Last active March 1, 2022 21:55
node.js tcp proxy
var net = require("net");
var Proxy = function() {
};
Proxy.to = function(dst_host, dst_port) {
var proxy = new Proxy();
proxy.dstHost = dst_host;
proxy.dstPort = dst_port;
proxy.mid = [];
return proxy;
@thabongshot
thabongshot / epoll.c
Created November 6, 2012 17:07
craftIk epoll test
#include "event.h"
void craftIk_epoll_init( struct craftIk_epoll* epoll, int listenfd, int max_clients)
{
struct epoll_event ev;
epoll->listenfd = listenfd;
epoll->max_clients = max_clients;
epoll->events = (struct epoll_event*)malloc( sizeof(struct epoll_event) * max_clients );
@gcmurphy
gcmurphy / epoll.go
Created November 30, 2012 06:08
Basic epoll usage using Go
package main
import (
"fmt"
"os"
"syscall"
)
const (
MaxEpollEvents = 32
@sysroad
sysroad / mt19937-64.cs
Created May 7, 2013 09:42
mt19937-64 C 구현 코드를 C# 으로 옮긴 것.
using System;
namespace MersenneTwister
{
// Implementation porting from C version of mt19937-64
// coded by Makoto Matsumoto and Takuji Nishimura
//
// Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
// All rights reserved.
//
@renexu
renexu / iparesign
Last active December 17, 2015 10:49
#!/usr/bin/env bash
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
-f "$2" &&
# ...and it has an .mobileprovision extension
@dmichael
dmichael / httpclient.go
Last active October 18, 2023 20:07
Light wrapper for the Go http client adding (essential) timeouts for both connect and readwrite.
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@artyom
artyom / epoll.go
Created November 1, 2013 12:21
Using epoll from Go.
package main
import (
"log"
"os"
"syscall"
)
func main() {
f, err := os.Open("/tmp/pipe")
@yuitest
yuitest / rainbow
Last active December 30, 2015 16:59
いえい!
#!/usr/bin/env dash
base64 -d <<__EOH__ | exec gzip -dc
H4sIAK1zzVIAA7VaUXajMAx8+c0V+sMRYCHk5XGUPQP3/900JViWZiTZ6farxa5tzUgjWTAM8ufr
77jNy3bblnGbxnH/eXATD85Zk3z4ejLW/7cPnT9XdZ5Rn2eyB1wmOTY9xya5v551UytM37s8xm1Z
ytH18w6bTksOO47lvyFe9M7jTtEPjAP2LZqKaqv1mHV//QrHECCd/J1LTefS0/aYElYNcD4z4w3D
2nPo95k1UcbV4GFfI7MYqc4972LC/Jww7/L/tC8WeyLS5h5+roAZai2NE85d0vTCVtZ6OfwOorXT
emh+bFzOtmPWvD3mMusuf9XKueon3McbA3kn9uZguxaehJcYh2U41QhonDxYIu4dDUhgpCWiflZv
3Kop1zOJeooeAMj0xAFUoznrPeRsPAOEImHkjhyXJbaCYkXSgWYdydZ9FTd1IDRIwLU4slvdYB2c
7Rxh+oX4q0YY+CRC/P58cLeIw5OZ8mF6/RqKK4uT9kpBpd/WwkEUC71bt0NpZlwEeBdSBruaAyes
@cloudwu
cloudwu / dh.c
Last active June 19, 2022 15:38
Diffie-Hellman Key Exchange
// The biggest 64bit prime
#define P 0xffffffffffffffc5ull
#define G 5
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
// calc a * b % p , avoid 64bit overflow