Skip to content

Instantly share code, notes, and snippets.

Avatar

Zhou Hao upbit

  • China
View GitHub Profile
@thynson
thynson / k_from_n.js
Last active Aug 29, 2015
Get random k numbers from an iterator of arbitrary N length array where N is unknown. (pseudo code)
View k_from_n.js
function(iter, k) {
var array = [];
var count = 0;
for (var val = iter(); val !== undefined; val = iter()) {
count ++;
if (array.length < k)
array.push_back(val);
else {
var luck = rand() % count;
if (luck < k) {
@andrzejsliwa
andrzejsliwa / cowboy_debug.erl
Last active Aug 26, 2016
erlang - cowboy debugging helper request/response
View cowboy_debug.erl
%% See LICENSE for licensing information.
-module(cowboy_debug).
-export([onrequest_hook/1]).
-export([onresponse_hook/4]).
onrequest_hook(Req) ->
Method = to_string(extract(cowboy_req:method(Req))),
Path = to_string(extract(cowboy_req:path(Req))),
Params = params_to_string(extract(cowboy_req:qs_vals(Req))),
@kevsmith
kevsmith / example.erl
Created Sep 12, 2011
Example of gen_server template output
View example.erl
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%% @author Kevin Smith <kevin@opscode.com>
%% @copyright 2011 Opscode, Inc.
-module(example).
-behaviour(gen_server).
-export([start_link/0]).
View vm.args
## Name of the riak node
-name riak@127.0.0.1
## Cookie for distributed erlang. All nodes in the same cluster
## should use the same cookie or they will not be able to communicate.
-setcookie riak
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
## (Disabled by default..use with caution!)
##-heart
@reyjrar
reyjrar / elasticsearch.yml
Last active Aug 18, 2021
ElasticSearch config for a write-heavy cluster
View elasticsearch.yml
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
@goraj
goraj / incremental_lightgbm.py
Last active Oct 1, 2021
incremental learning lightgbm
View incremental_lightgbm.py
# -*- coding: utf-8 -*-
"""
@author: goraj
"""
import lightgbm as lgbm
from sklearn.datasets import load_digits
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
View homebridge
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
@sajithneyo
sajithneyo / bracket-pair-colorizer-2-settings
Created Jun 25, 2019
Settings you need for bracket pair colorizer 2
View bracket-pair-colorizer-2-settings
{
"bracket-pair-colorizer-2.colors": [
"Gold",
"Orchid",
"LightSkyBlue",
"Salmon",
"LawnGreen",
"DarkOrange",
"Cornsilk"
],
@ololobus
ololobus / Spark+ipython_on_MacOS.md
Last active Aug 3, 2022
Apache Spark installation + ipython/jupyter notebook integration guide for macOS
View Spark+ipython_on_MacOS.md

Apache Spark installation + ipython/jupyter notebook integration guide for macOS

Tested with Apache Spark 2.1.0, Python 2.7.13 and Java 1.8.0_112

For older versions of Spark and ipython, please, see also previous version of text.

Install Java Development Kit

@rvagg
rvagg / README.md
Last active Sep 13, 2022
Kindleberry "Paperwhite" Pi
View README.md

Work in progress, I'll write this up properly when I'm done.

Almost all credit goes to @maxogden for putting me on to this and pointing me in the right direction for each of these items.

Prerequisites:

  • Raspberry Pi
  • Kindle Paperwhite freed from its locked down state (jailbroken) http://www.mobileread.com/forums/showthread.php?t=198446
    • You have to downgrade your Kindle to 5.3.1 to install the current jailbreak; that's just a matter of getting the old version image, putting it on your Kindle via USB and telling it to install "upgrade". Then you put in the Jailbreak files, load the ebook and break.
  • Your kindle will be quick to detect an upgrade is available so it'll want to upgrade soon afterwards but the jailbreak will last but you have to reinstall the developer certificates so it's a bit of a pain but doable. Find all the instructions on the mobileread.com forums and wiki.