Skip to content

Instantly share code, notes, and snippets.

View hzj629206's full-sized avatar

Zhijun hzj629206

View GitHub Profile
@hzj629206
hzj629206 / build-libevent-ios.sh
Created March 17, 2016 07:27 — forked from ursachec/build-libevent-ios.sh
libevent build script for iOS
#!/bin/bash
set -u
# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("armv7" "armv7s" "i386")
SDKS=("iphoneos" "iphoneos" "macosx")
LIB_NAME="libevent-2.0.21-stable"
TEMP_DIR="$(pwd)/tmp"
TEMP_LIB_PATH="$(pwd)/tmp/${LIB_NAME}"
@hzj629206
hzj629206 / manifest.plist
Created March 18, 2016 12:33 — forked from palaniraja/manifest.plist
App Manifest file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
@hzj629206
hzj629206 / build-index.html
Created March 18, 2016 12:33 — forked from palaniraja/build-index.html
Download build files
<!DOCTYPE html>
<html>
<head>
<title>My awesome app</title>
</head>
<body>
<h2>beta builds</h2>
<a href="itms-services://?action=download-manifest&amp;url=http://dl.dropbox.com/u/1001/manifest.plist">Awesome App v 0.0.16</a></body>
<h2>alpha builds</h2>
@hzj629206
hzj629206 / rc.d
Created February 23, 2017 05:23 — forked from jippi/rc.d
Logstash Init script
update-rc.d logstash-shipper defaults
update-rc.d logstash-reader defaults
@hzj629206
hzj629206 / rate_limit.py
Last active September 28, 2018 08:13
Django Rate Limiter via Redis
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, division, print_function
import time
import hashlib
import itertools
import functools
from redis.exceptions import RedisError
@hzj629206
hzj629206 / django_partition.py
Last active December 19, 2018 02:07
Django model partition with one connection
# -*- coding: utf-8 -*-
import random
import socket
from contextlib import contextmanager
from functools import partial
from zlib import crc32
from datetime import datetime, date, timedelta
from threading import Lock, local
from django.db import router, connections, DEFAULT_DB_ALIAS
package main
import "fmt"
func skip32Encrypt(number uint32, key string) uint32 {
return skip32(number, key, true)
}
func skip32Decrypt(number uint32, key string) uint32 {
return skip32(number, key, false)
package main
import "fmt"
func teaEncrypt(v [2]uint32, k [4]uint32) [2]uint32 {
var v0, v1, sum uint32 = v[0], v[1], 0 /* set up */
var delta uint32 = 0x9e3779b9 /* a key schedule constant */
k0, k1, k2, k3 := k[0], k[1], k[2], k[3] /* cache key */
for i := 0; i < 32; i++ { /* basic cycle start */
sum += delta
package main
import (
"database/sql"
"log"
"sync"
"time"
_ "github.com/go-sql-driver/mysql"
)