Skip to content

Instantly share code, notes, and snippets.

View xiaolai's full-sized avatar
🎯
Focusing

xiaolai xiaolai

🎯
Focusing
View GitHub Profile
@xiaolai
xiaolai / pi_generator.py
Created October 19, 2017 01:48 — forked from ikautak/pi_generator.py
calculate pi using python generator.
#!/usr/bin/env python
def pi():
# Wallis' product
numerator = 2.0
denominator = 1.0
while True:
yield numerator/denominator
if numerator < denominator:
numerator += 2
@xiaolai
xiaolai / futures_pi.py
Created October 19, 2017 01:48 — forked from armonge/futures_pi.py
Calculating PI with Python
import functools
import random
import math
from concurrent import futures
def map_d(c):
return math.hypot(random.random(), random.random())
@xiaolai
xiaolai / Sphinx.sublime-build
Created October 10, 2017 16:32
Sphinx build
{
"cmd": ["make", "clean"],
"cmd": ["make", "html"],
"working_dir": "${project_path:${folder}}",
"selector": "text.restructuredtext"
}
@xiaolai
xiaolai / gist:447d8961954dfd28047a797e4f82addd
Created September 22, 2017 16:59 — forked from craiggists/gist:2268146
SublimeText: Tab to move cursor out of parentheses, quotes, brackets
// Original by C0D312
// I added the single quote and curly brace to the regex.
// http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5174
//
// Add the following to your user keybindings:
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)}'\"\\]]", "match_all": true },
@xiaolai
xiaolai / markdown-here-css.css
Created July 1, 2016 02:13
chrome extension css
.markdown-here-wrapper {
font-family: STheiti, 'Open Sans';
padding: 1em;
}
hr {
border: 3px dotted #009688;
}
em, i, a {
@xiaolai
xiaolai / gist:3783233
Created September 25, 2012 17:16
disable dashboard of os x
defaults write com.apple.dashboard mcx-disabled -boolean YES
kill all dock
@xiaolai
xiaolai / sublime_user_settings.js
Created September 24, 2012 16:20
Example user settings for sublime text 2
{
"color_scheme": "Packages/User/textmate-solarized/Solarized (Dark).tmTheme",
// "color_scheme": "Packages/User/textmate-solarized/Solarized (Light).tmTheme",
// "color_scheme": "Packages/User/TextMate-Tomorrow-Theme/Tomorrow-Night-Eighties.tmTheme",
// "color_scheme": "Packages/User/TextMate-Tomorrow-Theme/Tomorrow-Night-Bright.tmTheme",
// "color_scheme": "Packages/User/TextMate-Tomorrow-Theme/Tomorrow-Night.tmTheme",
"font_size": 12,
"font_face": "menlo",
// "font_face": "monaco",
// "font_face": "Inconsolata",
@xiaolai
xiaolai / nokogiri libxml homebrew lion
Created September 30, 2012 12:37 — forked from devpuppy/nokogiri libxml homebrew lion
How to fix: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
libxml_ruby.bundle: dlsym(0x10fde1900, Init_libxml_ruby): symbol not found
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@xiaolai
xiaolai / smser.rb
Created October 2, 2012 15:51 — forked from mimosz/smser.rb
短信宝
# -*- encoding: utf-8 -*-
require 'digest/md5'
require 'nestful'
class Smsbao
attr_accessor :login, :passwd
def initialize(login, passwd)
@login = login
@passwd = Digest::MD5.hexdigest(passwd)
@xiaolai
xiaolai / rspec-syntax-cheat-sheet.rb
Created October 2, 2012 19:02 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")