Skip to content

Instantly share code, notes, and snippets.

View yanzhihong23's full-sized avatar
🏠
Working from home

Hom yanzhihong23

🏠
Working from home
View GitHub Profile
@yanzhihong23
yanzhihong23 / 0_reuse_code.js
Created January 12, 2017 10:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yanzhihong23
yanzhihong23 / angular_providers.js
Created March 14, 2017 07:18
AngularJS Provider/Service/Factory Examples
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
};
});
//factory style, more involved but more sophisticated
@yanzhihong23
yanzhihong23 / unlink-jquery.js
Last active March 25, 2017 09:49
Block jQuery from browser console
@yanzhihong23
yanzhihong23 / command.md
Last active April 22, 2017 10:49
launch sublime text from the command line
sudo mkdir -p /usr/local/bin

sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
@yanzhihong23
yanzhihong23 / pm2-guard.js
Created April 28, 2017 10:24
pm2 cpu guard
'use strict';
const later = require('later');
const logger = require('./logger')('guard');
const pm2 = require('pm2');
const schedule = later.parse.recur().every(10).second();
// set local timezone
later.date.localTime();
@yanzhihong23
yanzhihong23 / avenger-nginx.conf
Created May 19, 2017 11:15
nginx config for angular app deploy in subpath
server {
server_name gist.github.com
root /usr/share/gist;
index index.html
location / {
try_files $uri $uri/ =404;
}
location /avenger/ {
@yanzhihong23
yanzhihong23 / shell.md
Last active June 1, 2017 06:19
Fix nvm ls-remote N/A
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
@yanzhihong23
yanzhihong23 / scroll-iframe-ios.css
Last active June 10, 2017 08:03
Scroll IFRAMEs on iOS
.scroll-wrapper {
-webkit-overflow-scrolling: touch !important;
overflow-y: scroll !important;
position: fixed;
right: 0;
bottom: 0;
left: 0;
top: 0;
}
@yanzhihong23
yanzhihong23 / shell.md
Created June 26, 2017 03:15
centos update server time
yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start
function to64bitFloat(number) {
var i, result = "";
var dv = new DataView(new ArrayBuffer(8));
dv.setFloat64(0, number, false);
for (i = 0; i < 8; i++) {
var bits = dv.getUint8(i).toString(2);
if (bits.length < 8) {
bits = new Array(8 - bits.length).fill('0').join("") + bits;