Skip to content

Instantly share code, notes, and snippets.

@xbee
xbee / gist:9224894
Created February 26, 2014 06:55
erlang 常见错误提示
7> math3:area({rect, 2, 3}).
** exception error: no function clause matching math3:area({rect,2,3}) (math3.erl, line 4)
8> math3:area({rectangle, 2, 3}).
6
9> c(math3).
math3.beam: Module name 'math2' does not match file name 'math3'
error
11> A =5.
** exception error: no match of right hand side value 5
@xbee
xbee / gbk_to_utf8_transcoder.py
Last active August 29, 2015 14:27
A small Python script that converts a file encoded in Code Page 936 (aka GBK) to UTF-8.
#! /usr/bin/env python3.4
# Code Page 936 (GBK) to UTF-8 Transcoder
# Author: Kristian Tang (@Krisiouz)
# A small script that converts a file encoded in Code Page 936 (GBK) to UTF-8.
def gbk_to_utf8(input_file, output_file):
# Load Files
input_file_opened = open(input_file, 'r', encoding='cp936')
input_file_read = input_file_opened.read()
@xbee
xbee / android_replace_in_manifest.gradle
Last active August 30, 2015 04:09 — forked from saadfarooq/android_replace_in_manifest.gradle
Gradle function to replace a placeholder string in AndroidManifest.xml with productFlavor package name
replaceInManifest = {variant, fromString, toString ->
def flavor = variant.productFlavors.get(0)
def buildtype = variant.buildType
def manifestFile = "$buildDir/manifests/${flavor.name}/${buildtype.name}/AndroidManifest.xml"
def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll(fromString, toString)
new File(manifestFile).write(updatedContent, 'UTF-8')
}
@xbee
xbee / build.gradle
Last active August 30, 2015 05:46 — forked from MarkMjw/build.gradle
build.gradle base on Android Studio, and modify manifest when building different channel.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
@xbee
xbee / BlockPropagation.md
Created March 6, 2016 13:19 — forked from gavinandresen/BlockPropagation.md
O(1) block propagation

O(1) Block Propagation

The problem

Bitcoin miners want their newly-found blocks to propagate across the network as quickly as possible, because every millisecond of delay increases the chances that another block, found at about the same time, wins the "block race."

@xbee
xbee / ec_lsag_test.py
Created March 18, 2016 11:04 — forked from jesperborgstrup/ec_lsag_test.py
Python implementation of Linkable Ring Signatures over Elliptic curves
# MIT License
#
# Copyright (C) 2014 Jesper Borgstrup
# -------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
@xbee
xbee / Makefile
Created April 4, 2016 10:54 — forked from Arachnid/Makefile
include $(GOROOT)/src/Make.$(GOARCH)
TARG=kademlia
GOFILES=\
nodeid.go\
routingtable.go\
contact.go\
kademlia.go
include $(GOROOT)/src/Make.pkg
@xbee
xbee / ElasticSearch.sh
Created May 17, 2016 16:30 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@xbee
xbee / pagerank.go
Created October 14, 2016 16:51 — forked from BYVoid/pagerank.go
Calculate pagerank of every vertex in a graph using Go language
package main
import (
"bufio"
"errors"
"fmt"
"io"
"math"
"os"
"strings"
@xbee
xbee / blind_oleg.go
Created November 25, 2016 09:18 — forked from kac-/blind_oleg.go
Blind signatures for Bitcoin transactions
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/sha256"
"fmt"
"math/big"
)