Skip to content

Instantly share code, notes, and snippets.

View xguox's full-sized avatar

XguoX xguox

View GitHub Profile
@xguox
xguox / dabblet.css
Created February 24, 2013 13:06
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(41deg, #f06, blue);
min-height: 100%;
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
ERROR -: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@xguox
xguox / uri.js
Created February 18, 2014 13:22 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@xguox
xguox / bench_rails_memory_usage.rb
Created November 29, 2016 10:44 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
took: 3
timed_out: false
_shards:
total: 5
successful: 5
failed: 0
hits:
total: 5
max_score: 0.2972674
hits:
@xguox
xguox / sorting go
Last active February 19, 2019 03:33
package main
import "fmt"
func insertionSort(a []int) {
if len(a) <= 1 {
return
}
for i := 1; i < len(a); i++ {
iVal := a[i]
package main
import "fmt"
func mergeSort(arr []int) []int {
l := len(arr)
if l <= 1 {
return arr
}
mid := l / 2
@xguox
xguox / quick.go
Last active February 21, 2019 01:42
package main
import (
"fmt"
"math/rand"
"time"
)
func quickSort(arr []int) (s []int) {
l := len(arr)
package main
import (
"fmt"
"math/rand"
"time"
)
func heapSort(arr []int, l int) {
for i := l / 2; i >= 0; i-- {