Skip to content

Instantly share code, notes, and snippets.

View legendtang's full-sized avatar
:shipit:
Coding

legendtang

:shipit:
Coding
View GitHub Profile
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@matt-west
matt-west / pearson-correlation.js
Created September 9, 2013 20:24
Pearson Correlation (JavaScript)
/**
* @fileoverview Pearson correlation score algorithm.
* @author matt.west@kojilabs.com (Matt West)
* @license Copyright 2013 Matt West.
* Licensed under MIT (http://opensource.org/licenses/MIT).
*/
/**
* Calculate the person correlation score between two items in a dataset.
QMA 4 GEM 2007/01/11
IIDX GOLD GLD 2007/02/21
pop'n 15 G15 2007/04/25
Otomedius GGG 2007/11/02
DJ Troopers HDD 2007/12/19
QMA 5 HAL 2008/01/12
pop'n 16 H16 2008/03/24
Horseriders G23 2008/04/09
GFDM V5 H32/H33 2008/06/18
Empress I00 2008/11/19
@jbinto
jbinto / howto-recover-google-authenticator-keys.txt
Created February 8, 2014 04:20
Recovering Google Authenticator keys from Android device for backup
### Last tested February 7 2014 on a Galaxy S3 (d2att) running Cyanogenmod 11 nightly, with Google Authenticator 2.49.
### Device with Google Authenticator must have root.
### Computer requires Android Developer Tools and SQLite 3.
### Connect your device in USB debugging mode.
$ cd /tmp
$ adb root
$ adb pull /data/data/com.google.android.apps.authenticator2/databases/databases
@mlouro
mlouro / gulpfile.js
Last active June 21, 2022 23:20
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@chaping
chaping / requestAnimationFrame.js
Last active April 24, 2018 00:44
兼容各浏览器的requestAnimationFrame
var lastTime = 0;
var prefixes = 'webkit moz ms o'.split(' '); //各浏览器前缀
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame;
var prefix;
//通过遍历各浏览器前缀,来得到requestAnimationFrame和cancelAnimationFrame在当前浏览器的实现形式
for( var i = 0; i < prefixes.length; i++ ) {
if ( requestAnimationFrame && cancelAnimationFrame ) {
@simonlynen
simonlynen / clang_omp_osx.sh
Last active April 7, 2017 07:59
clang omp osx
# Stolen and altered from here: http://stackoverflow.com/questions/20321988/error-enabling-openmp-ld-library-not-found-for-lgomp-and-clang-errors/21789869#21789869
INTEL_OPENMP_LATEST_BUILD_LINK=https://www.openmprtl.org/sites/default/files/libomp_20140926_oss.tgz
CLANG_INCLUDE=~/clang_omp/llvm/include
CLANG_BIN=~/clang_omp/llvm/build/Release/bin
CLANG_LIB=~/clang_omp/llvm/build/Release/lib
OPENMP_INCLUDE=~/clang_omp/libomp_oss/exports/common/include
OPENMP_LIB=~/clang_omp/libomp_oss/exports/mac_32e/lib.thin
cd ~/
此API KEY为 Weico.Android 的API。复制后粘贴到BL的自定义API对话框的任意一个框框内即可(开头结尾不要带空格之类的,如果没反应,尝试将光标移到最后删除最后的不可见字符)
SSMjExMTYwNjc5OjoxZTZlMzNkYjA4ZjkxOTIzMDZjNGFmYTBhNjFhZDU2Yzo6aHR0cDovL29hdXRoLndlaWNvLmNjOjplbWFpbCxkaXJlY3RfbWVzc2FnZXNfcmVhZCxkaXJlY3RfbWVzc2FnZXNfd3JpdGUsZnJpZW5kc2hpcHNfZ3JvdXBzX3JlYWQsZnJpZW5kc2hpcHNfZ3JvdXBzX3dyaXRlLHN0YXR1c2VzX3RvX21lX3JlYWQsZm9sbG93X2FwcF9vZmZpY2lhbF9taWNyb2Jsb2csaW52aXRhdGlvbl93cml0ZTo6Y29tLmVpY28ud2VpY286OkVFEE
/*
1. Generator
可以暂停,可以重新运行。在内部暂停,在外部重新启动
普通函数只是一开始接收参数,至完成时返回。yield 返回信息,send发送信息重启
*/
function *foo() {
/*
generator跟普通函数差不多,只是多了一个*号表示这是一个generator函数。
主要的还是yield这个关键字