Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
@image72
image72 / switch-case
Created December 14, 2012 12:08
switch case like this?
// switch case!
var add_level = {'5':1,'10':2,'12':3,'15':4}[12] || 0
//>>3
({'5':1,'10':2,'12':3,'15':4})[12] || 0
//>> 3
({'5':-1,'10':20.7e+5,'12':3,'15':"Right",'22':[4,1,16],'log':function() {console.log("that all right!")}})[12] || 0
@image72
image72 / own
Created August 29, 2014 19:07
own
# change files owner to current user
alias own='sudo chown -R $(id -u):$(id -g)'
@image72
image72 / sendFile.js
Created November 28, 2015 09:55
send file & callback
function sendFile(option, cb) {
/* {
field: name,
url: '/path/to/upload',
file: FileObject
} */
var field = option.field;
var xhr = new XMLHttpRequest();
var fd = new FormData();
var resp;
@image72
image72 / eval.stripper.js
Created January 22, 2016 18:50 — forked from ChiChou/eval.stripper.js
Hook eval to deobfuscate javascript
/**
* requires node.js with ES6 support, or babel
*/
'use strict';
const vm = require('vm');
const fs = require('fs');
const __loggers__ = {};
function log(tag) {
@image72
image72 / handler.js
Last active May 23, 2016 06:57 — forked from jeffrafter/handler.js
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
@image72
image72 / build_nginx.sh
Created March 2, 2016 08:28 — forked from Belphemur/build_nginx.sh
Compiling Nginx with LibreSSL (and http2) & RTMP module & PageSpeed (optional)
#!/usr/bin/env bash
# names of latest versions of each package
export NGINX_VERSION=1.9.12
export VERSION_PCRE=pcre-8.38
export VERSION_LIBRESSL=libressl-2.3.2
export VERSION_NGINX=nginx-$NGINX_VERSION
#export NPS_VERSION=1.9.32.10
#export VERSION_PAGESPEED=v${NPS_VERSION}-beta
@image72
image72 / base.css
Last active May 23, 2016 07:47
css base with rem; used PSD or sketch; rem = size / 10
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
@image72
image72 / index.html
Last active July 5, 2016 06:46 — forked from anonymous/index.html
JS Bin// source http://jsbin.com/naguhi / file upload preview
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
#container > img {
width: 200px;
@image72
image72 / index.html
Last active July 28, 2017 06:57 — forked from anonymous/index.html
// source http://jsbin.com/weguzoh angular SPA
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.9/angular-route.min.js"></script>
<style>
a, a:hover {
text-decoration: none;
}
#content{
border:2px solid #e5e5e5;
overflow: hidden;
@image72
image72 / YAML.js
Created June 20, 2016 03:18
parse YAML to JSON
;(function(){
YAML = {
valueOf: function(token) {
return eval('(' + token + ')')
},
tokenize: function(str) {
return str.match(/(---|true|false|null|#(.*)|\[(.*?)\]|\{(.*?)\}|[\w\-]+:|-(.+)|\d+\.\d+|\d+|\n+)/g)
},