Skip to content

Instantly share code, notes, and snippets.

View cyanly's full-sized avatar
😽
✧˖° Rust

Chao Yan cyanly

😽
✧˖° Rust
View GitHub Profile
@cyanly
cyanly / jquery.parseParams.js
Created May 30, 2014 17:41
jQuery.parseParams - parse query string paramaters into an object, handles nested objects, array with and without index, and array of objects.
// Add an URL parser to JQuery that returns an object
// This function is meant to be used with an URL like the window.location
// Use: $.parseParams('http://mysite.com/?var=string') or $.parseParams() to parse the window.location
// Simple variable: ?var=abc returns {var: "abc"}
// Simple object: ?var.length=2&var.scope=123 returns {var: {length: "2", scope: "123"}}
// Simple array: ?var[]=0&var[]=9 returns {var: ["0", "9"]}
// Array with index: ?var[0]=0&var[1]=9 returns {var: ["0", "9"]}
// Nested objects: ?my.var.is.here=5 returns {my: {var: {is: {here: "5"}}}}
// All together: ?var=a&my.var[]=b&my.cookie=no returns {var: "a", my: {var: ["b"], cookie: "no"}}
// You just cant have an object in an array, ?var[1].test=abc DOES NOT WORK
@cyanly
cyanly / ireserve.js
Last active August 29, 2015 14:06
nodejs iPhone6 UK-GB availability check
var request = require('superagent');
var stores = {};
var models = {
'MGA82ZP/A': 'iPhone 6 Plus 16G Grey ',
'MGA92ZP/A': 'iPhone 6 Plus 16G Silver',
'MGAA2ZP/A': 'iPhone 6 Plus 16G Gold ',
'MGAH2ZP/A': 'iPhone 6 Plus 64G Grey ',
'MGAJ2ZP/A': 'iPhone 6 Plus 64G Silver',
'MGAK2ZP/A': 'iPhone 6 Plus 64G Gold ',
@cyanly
cyanly / gist:665fa6823b543aa084bb
Last active February 11, 2016 21:01
Go-lang javascript methods benchmark

Javascript benchmark idea

function fib(n) {
  if (n < 2) return n;
  return fib(n - 2) + fib(n - 1);
}

console.log(fib(35));
@cyanly
cyanly / Golang Rate limiting Concurrent Queue Worker Example.md
Last active March 24, 2018 20:10
Golang Rate limiting Concurrent Queue Worker Example
package main

import (
	"fmt"
	"time"
)

func main() {
	concurrency := 2
@cyanly
cyanly / keybase.md
Created February 15, 2019 13:16
keybase.md

Keybase proof

I hereby claim:

  • I am cyanly on github.
  • I am cyanly (https://keybase.io/cyanly) on keybase.
  • I have a public key ASCdQxtnNBa7R40HSOA5XjIp_2RfcGaAB6aX1mB0V2Bniwo

To claim this, I am signing this object:

@cyanly
cyanly / main.go
Created October 25, 2023 09:51 — forked from donvito/main.go
AES-256 encrypt/decrypt in Go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
)