Skip to content

Instantly share code, notes, and snippets.

View mactanxin's full-sized avatar
😆
happy coding

Xin Tan mactanxin

😆
happy coding
  • San Jose
  • 17:21 (UTC +08:00)
View GitHub Profile
@mactanxin
mactanxin / fib.js
Created June 22, 2020 08:07 — forked from guxuerui/fib.js
菲波那切数列
const fib = (num) => {
if (num <= 0) return 0;
if (num === 1 || num === 2) return 1;
if (num > 2) {
let prev = 1, next = 1;
for (let i = 3; i <= num; i++) {
let sum = prev + next;
prev = next;
next = sum;
}
@mactanxin
mactanxin / consoleLog.sublime-snippet
Created May 24, 2017 16:43 — forked from anonymous/consoleLog.sublime-snippet
type log, then tab to get a console.log
<snippet>
<content><![CDATA[
console.log($1);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>log</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.ts</scope>
</snippet>
@mactanxin
mactanxin / restart_bluetooth.sh
Created May 10, 2017 16:55 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
# -*- coding:utf-8-*-
from __future__ import with_statement
import os,sys
def find_condition(filename,condition):
with open(filename) as f:
for i in f:
i = i.strip()
data = i.split('|')
if condition == data[2]:
# encoding: utf-8
import hashlib
import sys
if __name__ == '__main__':
i = bytes(sys.argv[1],'utf8')
k = hashlib.md5(i).hexdigest()
print(k)