Skip to content

Instantly share code, notes, and snippets.

@miyakogi
miyakogi / nim_syntax.md
Last active December 23, 2024 12:18
Syntax of Nim
@sandyxu
sandyxu / rbenv-install-and-using.md
Last active April 1, 2025 00:36
使用 rbenv 安装和管理Ruby版本

常用的几个 Ruby 版本管理工具有:rvmrbenv,ry,rbfu。rvm 应该是最早出现、使用最多的,因为过于强大以至于违背了某个 Linux 软件开发原则,所以出现了很多轻便的替代者,其中来自 37signals 的 rbenv 就很受欢迎。ry 和 rbfu 看上去更轻便,不过使用不广泛。之前使用过rvm, 这次尝试下rbenv。

我的环境是 Ubuntu14.04

1. 安装 rbenv

rbenv的源代码托管在github,在终端中,从 github 上将 rbenv 源码 clone 到本地,然后设置 $PATH。

git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
@JasonReflector
JasonReflector / reg.js
Created November 7, 2013 06:13
正则表达式:匹配非汉字字母数字的字符
/[^a-zA-Z0-9\u4e00-\u9fa5]/g
@alexmic
alexmic / problem_79.py
Created October 5, 2013 22:24
Project Euler problem #79.
from collections import defaultdict, deque
def find_number_universe(keylog):
numbers = set()
for attempt in keylog:
for num in attempt:
numbers.add(num)
return numbers
@cincodenada
cincodenada / rot.py
Created September 14, 2013 00:09
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):
@jhjguxin
jhjguxin / mysql-status.md
Last active July 13, 2022 10:37
通过show status 来优化MySQL数据库 from lxneng
  1. 查看MySQL服务器配置信息
mysql> show variables;
  1. 查看MySQL服务器运行的各种状态值
mysql> show global status;
@jpatters
jpatters / HeidiDecode.js
Last active March 7, 2025 03:33
Decodes a password from HeidiSQL. HeidiSQL passwords can be found in the registry. Use File -> Export Settings to dump all settings. Great for if you forget a password.
function heidiDecode(hex) {
var str = '';
var shift = parseInt(hex.substr(-1));
hex = hex.substr(0, hex.length - 1);
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
return str;
}
document.write(heidiDecode('755A5A585C3D8141786B3C385E3A393'));
@scturtle
scturtle / gist:3060332
Created July 6, 2012 14:05
python 3 语法变化
@spion
spion / a-warning.md
Last active April 19, 2025 05:17
C++ versus V8 versus luajit versus C benchmark - (hash) tables

Warning

This benchmark has been misleading for a while. It was originally made to demonstrate how JIT compilers can do all sorts of crazy stuff to your code - especially LuaJIT - and was meant to be a starting point of discussion about what exactly LuaJIT does and how.

As a result, its not indicative of what its performance may be on more realistic data. Differences can be expected because

  1. the text will not consist of hard-coded constants
@cwalv
cwalv / ctypes_play.py
Created June 27, 2012 00:45
python ctypes win32 Get/SetTimeZoneInformation
from contextlib import contextmanager
import ctypes
from ctypes.wintypes import WORD, DWORD, LONG, WCHAR, HANDLE
k32 = ctypes.windll.kernel32
a32 = ctypes.windll.advapi32
class SYSTEMTIME(ctypes.Structure):