Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <secp256k1.h>
int main() {
secp256k1_context* ctx;
secp256k1_pubkey pubkey;
const unsigned char *seckey = (unsigned char*) "Secret Key Br0!";
pragma solidity ^0.4.8;
contract NegativeCompoundCoin {
address public _minter;
// Ledger
mapping (address => uint) public _balances;
// Last interest duduction blocks, for checking how many periods apply
mapping (address => uint) public _lastCalculated;
// how many blocks per peroid.
uint public _period;
@yutelin
yutelin / latency.markdown
Created October 9, 2016 02:53 — 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

@yutelin
yutelin / geth.patch
Created March 11, 2016 13:46 — forked from barkthins/geth.patch
A patch for geth that will cause it to mine every second. This is useful for accelerating unit test of solidity contracts. I will attempt to keep this patch up to date, no guarantees.
diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go
index d88d919..f03fd30 100644
--- a/eth/fetcher/fetcher.go
+++ b/eth/fetcher/fetcher.go
@@ -34,7 +34,7 @@ import (
const (
arriveTimeout = 500 * time.Millisecond // Time allowance before an announced block is explicitlrd
gatherSlack = 100 * time.Millisecond // Interval used to collate almost-expired announces witfs
- fetchTimeout = 5 * time.Second // Maximum alloted time to return an explicitly requestebk
+ fetchTimeout = 1 * time.Second // Maximum alloted time to return an explicitly requestebk
//Reference: http://stackoverflow.com/questions/12051118/is-there-a-way-to-generate-qr-code-image-on-ios#comment48548881_22296488
import Foundation
import UIKit
extension String{
var qrcode: CIImage {
//let data = self.dataUsingEncoding(NSISOLatin1StringEncoding, allowLossyConversion: false)
let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let filter = CIFilter(name: "CIQRCodeGenerator")
filter.setValue(data, forKey: "inputMessage")
import Foundation
extension NSUserDefaults {
func stringForKey(defaultName: String, defaultValue: String) -> String{
if let value = self.stringForKey(defaultName){
return value
} else {
return defaultValue
}
@yutelin
yutelin / String+AES.swift
Last active January 22, 2024 12:36
String+AES.swift
import Foundation
import CryptoSwift
extension String {
func aesEncrypt(key: String, iv: String) throws -> String{
let data = self.dataUsingEncoding(NSUTF8StringEncoding)
let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7())
let encData = NSData(bytes: enc, length: Int(enc.count))
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0));
@yutelin
yutelin / get_maicoin_access_token.rb
Created May 8, 2015 05:42
Get MaiCoin access token example
require 'oauth2'
client_id = ENV['CLIENT_ID']
client_secret= ENV['CLIENT_SECRET']
redirect_uri = 'https://127.0.0.1' # this must match the url you set during registration
client_options = {
site: 'https://api.maicoin.com',
authorize_url: 'https://www.maicoin.com/oauth/authorize',
token_url: 'https://www.maicoin.com/oauth/token'
}
client = OAuth2::Client.new(client_id, client_secret, client_options)
@yutelin
yutelin / api_key_secret_header.rb
Last active August 29, 2015 14:20
MaiCoin Api key/secret request header example
def request_options (api_key, api_secret, verb, path, options={})
base_uri = 'https://api.maicoin.com/v1'
nonce = options[:nonce] || (Time.now.to_f * 1e6).to_i
if [:get, :delete].include? verb
request_options = {}
path = "#{path}?#{URI.encode_www_form(options)}" if !options.empty?
hmac_message = nonce.to_s + base_uri + path
else
request_options = {body: options.to_json}
hmac_message = nonce.to_s + base_uri + path + options.to_json