Skip to content

Instantly share code, notes, and snippets.

View lgh06's full-sized avatar

Daniel Liu lgh06

View GitHub Profile
@lgh06
lgh06 / web
Created December 20, 2015 12:31
a bash in ubuntu to launch an application
#!/bin/bash
~/WebStorm9/bin/webstorm.sh
@lgh06
lgh06 / jetbrains-webstorm.desktop
Created December 20, 2015 12:39
a laucher in ubuntu 14.04 LTS desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=WebStorm
Icon=/home/xxgov/WebStorm9/bin/webide.png
Exec="/home/xxgov/idea-IU-143.1184.17/bin/idea.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-webstorm
@lgh06
lgh06 / testCallApply.js
Last active January 5, 2016 06:38
simple code for learning call and apply
function Product(name, price) {
this.name = name;
this.price = price;
}
function Food(name, price) {
Product.call(this, name, price);
this.category = 'food';
}
@lgh06
lgh06 / sublime3.setting.json
Created February 18, 2016 08:52
sublime3.setting.json
{
"default_encoding": "UTF-8",
"default_line_ending": "unix",
"draw_white_space": "all",
"font_size": 16,
"ignored_packages":
[
"Autoprefixer",
"Vintage"
],
@lgh06
lgh06 / nginx-part.conf
Created March 21, 2016 02:35
nginx expire cache-control
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 1h;
}
location ~* \.(?:html)$ {
expires 1h;
}
@lgh06
lgh06 / getQueryStringByName.js
Created April 1, 2016 07:13
getQueryStringByName
function getQueryStringByName(name){
var result = location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));
if(result == null || result.length < 1){
return "";
}
return result[1];
}
@lgh06
lgh06 / fileCssToInlineCss.js
Last active April 25, 2016 13:54
a js file conbines csses to inline css,used in phantomjs
var j = document.createElement('script');
j.async = "async";
j.src = 'https://lib.sinaapp.com/js/jquery/1.10.2/jquery-1.10.2.min.js';
j.onload = genPic;
document.querySelector('head').appendChild(j);
@lgh06
lgh06 / RetinaCanvasFix
Created June 8, 2016 08:02
canvas on a retina display fix.
document.addEventListener("DOMContentLoaded", function(event) {
mycanvas();
});
function mycanvas(){
var ratio = window.devicePixelRatio || 1,
canvas = document.querySelector('canvas'),
context = canvas.getContext('2d');
width = canvas.width = window.innerWidth;
@lgh06
lgh06 / 2019-package.json
Last active September 26, 2019 02:39
gulp+webpack
{
"name": "xxx-frontend-html",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "gulp",
"build": "gulp build"
},
@lgh06
lgh06 / handlebars-helper-x.js
Created July 14, 2016 09:04 — forked from akhoury/handlebars-helper-x.js
Handlebars random JavaScript expression execution, with an IF helper with whatever logical operands and whatever arguments, and few more goodies.
// for demo: http://jsbin.com/jeqesisa/7/edit
// for detailed comments, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381
/* a helper to execute an IF statement with any expression
USAGE:
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes
-- to access any global function or property you should use window.functionName() instead of just functionName()
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later
<p>
{{#xif " this.name == 'Sam' && this.age === '12' " }}