Skip to content

Instantly share code, notes, and snippets.

View dylanninin's full-sized avatar
🏠
Working from home

dylanninin dylanninin

🏠
Working from home
View GitHub Profile
@dylanninin
dylanninin / ballot.sol
Created February 24, 2018 08:38 — forked from anonymous/ballot.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.20+commit.3155dd80.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {

FWIW: I didn't produce the content present here. I've just copy-pasted it from somewhere over the Internet, but I cannot remember exactly the original source. I was also not able to find the author's name, so I cannot give him/her the proper credit.


Effective Engineer - Notes

What's an Effective Engineer?

@dylanninin
dylanninin / alisms.py
Last active November 14, 2020 07:21
阿里云短信的 Python sdk 简直无法直视:1)居然直接提供下载链接,而不能 pip install;2)不支持 Python 3;3)Python 写出了 Java 的感觉。。。以下是 Python 3 的一个简化版本,由同事提供,我做了简单调整。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64
import datetime
import hmac
import json
import urllib
import uuid
@dylanninin
dylanninin / github_webhook.rb
Created February 19, 2017 03:54
WebHook of Github
require 'dotenv/load'
require 'sinatra'
require 'json'
path = '.env.' + ENV.fetch('RUBY_ENV'){ 'development' }
Dotenv.load(path)
JK_USER = ENV.fetch('JK_USER')
JK_API_TOKEN = ENV.fetch('JK_API_TOKEN')
JK_URL = ENV.fetch('JK_URL')
@dylanninin
dylanninin / 0x01_install.md
Last active November 17, 2016 15:33
DNSmasq for Mac
brew info dnsmasq
dnsmasq: stable 2.76 (bottled)
Lightweight DNS forwarder and DHCP server
http://www.thekelleys.org.uk/dnsmasq/doc.html
/usr/local/Cellar/dnsmasq/2.76 (7 files, 504.7K) *
  Poured from bottle on 2016-11-17 at 22:28:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/dnsmasq.rb
==> Dependencies
Build: pkg-config ✔
  • Specifiy release
ubuntu@ubuntu-xenial:~$ export VERSION=1.11.5
  • Download source code
ubuntu@ubuntu-xenial:~$ wget https://nginx.org/download/nginx-${VERSION}.tar.gz
ubuntu@ubuntu-xenial:~$ tar xvf nginx-${VERSION}.tar.gz
@dylanninin
dylanninin / tiny_http.sh
Last active May 16, 2018 04:13
Tiny HTTP Server powered by nc
#!/usr/bin/env bash
# A Tiny HTTP Server powered by nc
port=${1:-8080}
echo "Tiny HTTP Server, listening on localhost:${port}"
while true
do
{
# Status line
echo -e 'HTTP/1.0 200 OK\r';
# Headers
@dylanninin
dylanninin / latency.markdown
Created November 6, 2016 04:19 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@dylanninin
dylanninin / ngx-phase-handlers.stp
Last active November 4, 2016 04:09
ngx-phase-handlers.stp with comments
/*
Dumped by ngx-phase-handlers of openresty-systemtap-tools
- Ubuntu 16.04
- 2016-11-03
*/
/* probe begin event */
probe begin {
/* target() return pid specifed as "stap -x pid ngx-phase-handlers.stp" */
class MiddleWare1
def initialize(app)
@app = app
end
def call env
puts self.class
status, headers, body = @app.call(env)
append_str = "\nGreetings from #{self.class}"