Skip to content

Instantly share code, notes, and snippets.

View c9n's full-sized avatar
🎯
Focusing

Lynn c9n

🎯
Focusing
View GitHub Profile
@c9n
c9n / query_to_json.js
Created March 11, 2014 09:03
Query string to json
'use strict';
var list = location.search.substring(1).split('&');
var map = {};
for (var i = 0; i < list.length; i++) {
var kv = list[i].split('=');
map[kv[0]] = decodeURIComponent(kv[1]);
}
@c9n
c9n / nginx.conf
Created April 22, 2014 04:58
Nginx NO CACHE Demo
server {
server_name try.c9n.me;
listen 80;
root /Users/lynn/Desktop;
index index.html index.htm;
location ~ \.gif {
add_header Last-Modified "";
if_modified_since off;
@c9n
c9n / template.sh
Created May 15, 2014 09:34
Better Bash Scripting
#!/bin/bash
set -o nounset
set -o errexit
(function() {
if (!window.console) {
window.console = {};
}
var m = [
"log", "info", "warn", "error", "debug", "trace", "dir", "group",
"groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
"dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
];
<?php
/**
* An helper file for Laravel 4, to provide autocomplete information to your IDE
* Generated with https://github.com/barryvdh/laravel-ide-helper
* Updated for Laravel 4.2.1 (2014-06-01)
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
*/
namespace {
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@c9n
c9n / shuffle.rb
Created November 13, 2014 04:35
shuffle
#!/usr/bin/env ruby
app = `cat app_rec.lst | awk '{ print $1 }'`.split("\n").shuffle
og = `cat online_game_rec.lst | awk '{ print $1 }'`.split("\n").shuffle
sg = `cat single_game_rec.lst | awk '{ print $1 }'`.split("\n").shuffle
mag = 1
output = []
for i in 1..60
@c9n
c9n / auto_gen_ssl_cert.sh
Created December 9, 2014 04:04
Create self-signed SSL certificate
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@c9n
c9n / WeixinApi.php
Created January 14, 2015 07:17
获取微信 jsapi_ticket
<?php
Class WeixinApi {
private $appid;
private $secret;
function __construct ($appid, $secret) {
$this->appid = $appid;
$this->secret = $secret;
@c9n
c9n / pom.xml
Created January 26, 2015 08:13
Sample
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.redwoods.app</groupId>
<artifactId>demo</artifactId>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>