Skip to content

Instantly share code, notes, and snippets.

View lifesign's full-sized avatar
🎯
Focusing

Feng lifesign

🎯
Focusing
View GitHub Profile
# 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
@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
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 / 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',
/*
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 / index.js
Created August 22, 2014 06:23 — forked from edokeh/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@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 );
# Nested locations
# Resources:
# https://xintron.se/code/nginx-nested-locations-and-pagination
server {
...
location / {
root /path/to/media/cdn/;
set $cache false;
@lifesign
lifesign / getclientmac.php
Created September 25, 2014 08:50
php get client mac
<?php
function getClientMac($ip = '')
{
if (empty($ip)) {
return;
}
$command = sprintf("cat /proc/net/arp | grep %s | awk '{print $4}'", $ip);
$fd = popen($command, 'r');
@lifesign
lifesign / down.js
Created October 13, 2014 02:05
download specify os
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src = '//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g, s);
}(document, 'script'));
;(function(d,n) {
var os = n.platform.match(/(Win|Mac|Linux)/);
var x = n.userAgent.match(/x86_64|Win64|WOW64/) ||