Skip to content

Instantly share code, notes, and snippets.

View geminixiang's full-sized avatar
🦜

Ying Xiang geminixiang

🦜
  • GliaCloud
  • Taipei
View GitHub Profile
@benui-dev
benui-dev / chinese_restaurant.py
Created June 16, 2011 07:37
Chinese Restaurant process in Python
import random
# Play with different concentrations
for concentration in [0.0, 0.5, 1.0]:
# First customer always sits at the first table
# To do otherwise would be insanity
tables = [1]
# n=1 is the first customer
@justinfx
justinfx / enc_dec_test.py
Last active October 16, 2022 13:28
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson ujson yajl msgpack
"""
from timeit import timeit
from tabulate import tabulate
setup = '''d = {
'words': """
function utf8_to_b64( str ) {
return window.btoa(encodeURIComponent( escape( str )));
}
function b64_to_utf8( str ) {
return unescape(decodeURIComponent(window.atob( str )));
}
// Usage:
utf8_to_b64('✓ à la mode'); // JTI1dTI3MTMlMjUyMCUyNUUwJTI1MjBsYSUyNTIwbW9kZQ==
@fokayx
fokayx / git_remote_set-url.md
Last active July 18, 2024 03:36
Git switch remote URLs. Git 更換遠端伺服器倉庫網址

Git 更換遠端伺服器倉庫網址URL

1.確認目前Git遠端伺服器網址: git remote -v

git remote -v
origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
origin  https://github.com/USERNAME/REPOSITORY.git (push)

2.更換Git遠端伺服器位網址,使用:git remote set-url

@ianaya89
ianaya89 / favicons.html
Last active November 20, 2023 20:47
All Favicons for All Devices and Sizes
<link rel="shortcut icon" sizes="16x16 24x24 32x32 48x48 64x64" href="favicon.ico">
<!-- Mobile (Android, iOS & others) -->
<link rel="apple-touch-icon" sizes="57x57" href="favicon-57.png">
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="favicon-57.png">
<link rel="apple-touch-icon" sizes="72x72" href="favicon-72.png">
<link rel="apple-touch-icon" sizes="114x114" href="favicon-114.png">
<link rel="apple-touch-icon" sizes="120x120" href="favicon-120.png">
<link rel="apple-touch-icon" sizes="144x144" href="favicon-144.png">
<link rel="apple-touch-icon" sizes="152x152" href="favicon-152.png">
@StuartGordonReid
StuartGordonReid / DistanceMetrics.py
Created June 15, 2015 14:36
Implementation of various distance metrics in Python
import math
import random
import csv
import cProfile
import numpy as np
import hashlib
memoization = {}
@iamtekeste
iamtekeste / Download Google Drive files with WGET
Created July 8, 2015 11:00
Download Google Drive files with WGET
Download Google Drive files with WGET
Example Google Drive download link:
https://docs.google.com/open?id=[ID]
To download the file with WGET you need to use this link:
https://googledrive.com/host/[ID]
Example WGET command:
@rcotrina94
rcotrina94 / setup.md
Last active May 6, 2021 09:48
Install Moodle on NGINX
@d2s
d2s / installing-node-with-nvm.md
Last active March 13, 2024 12:09
Installing Node.js to Linux & macOS & WSL with nvm

Installing Node.js with nvm to Linux & macOS & WSL

A quick guide on how to setup Node.js development environment.

Install nvm for managing Node.js versions

nvm allows installing several versions of Node.js to the same system. Sometimes applications require a certain versions of Node.js to work. Having the flexibility of using specific versions can help.

  1. Open new Terminal window.
console.log(`%c ________________________________________
< mooooooooooooooooooooooooooooooooooooo >
----------------------------------------
\\ ^__^
\\ (oo)\\_______
(__)\\ )\\/\\
||----w |
|| ||`, "font-family:monospace")