Skip to content

Instantly share code, notes, and snippets.

View lifesign's full-sized avatar
🎯
Focusing

Feng lifesign

🎯
Focusing
View GitHub Profile
# Nested locations
# Resources:
# https://xintron.se/code/nginx-nested-locations-and-pagination
server {
...
location / {
root /path/to/media/cdn/;
set $cache false;
@lifesign
lifesign / google.js
Created September 12, 2014 08:34
google analytics error
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','analytics.js','ga');
ga('create', '#code#', 'auto');
ga('send', 'pageview');
window.onerror = function(message, url, line) {
if (!url) return;
console.log( message , url , line );
@lifesign
lifesign / index.js
Created August 22, 2014 06:23 — forked from edokeh/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
/*
See dev dependencies https://gist.github.com/isimmons/8927890
Compiles sass to compressed css with autoprefixing
Compiles coffee to javascript
Livereloads on changes to coffee, sass, and blade templates
Runs PHPUnit tests
Watches sass, coffee, blade, and phpunit
Default tasks sass, coffee, phpunit, watch
*/
@lifesign
lifesign / server.js
Created July 7, 2014 03:13
node static server
//from http://agentejo.com/blog/simple-static-web-server-with-node.js
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 3000,
mimeTypes = {
'asc' : 'text/plain',
function consoleTrick() {
console.clear();
var rainbowStyle = 'background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:2em;';
var msg = "来自博主的问候:欢迎来访,美图奉上 \\(^____^)/";
console.log("%c", "padding:50px 300px;line-height:120px;background:url('http://wayouliu.duapp.com/img/tagsImg/youth.gif') no-repeat;");
console.log('%c' + msg, rainbowStyle);
var picNo = getRandomInt(1, 16);
console.log("Print out the " + picNo + "th image.");
console.log("%c", "padding:165px 150px;line-height:350px;background:url('http://wayouliu.duapp.com/img/tagsImg/" + picNo + ".jpg') no-repeat;");
console.log("%c 试试F5刷新", "color:green;");
@lifesign
lifesign / init.bat
Created May 4, 2014 05:03 — forked from 17/init.bat
@echo off
SET CMDER_ROOT=%~dp0
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /ve /d "Cmder Here" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /v "Icon" /d "\"%CMDER_ROOT%cmder.exe\"" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /v "Extended" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder\command" /ve /d "\"%CMDER_ROOT%cmder.exe\" \"%%V\"" /f
pause
# A few examples about how to use Ruby for parsing files as we could do
# with Awk or Grep. This is based on what I learn fro this post:
# http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/
# Split each line with ':' and print the first $F[0] field
awk -F: '{ print $1 }' /etc/passwd
ruby -F: -nae 'puts $F[0]' /etc/passwd
# Parse the 'ps aux' output
# It'll print the ID process for the 'jojeda' user
<?php
set_time_limit(300);
error_reporting(E_ALL);
class test {
function func() {}
}
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',