Skip to content

Instantly share code, notes, and snippets.

View joshyu's full-sized avatar
💭
I may be slow to respond.

Josh Yu joshyu

💭
I may be slow to respond.
  • dalian,Liaoning, China
  • 14:08 (UTC +08:00)
View GitHub Profile
@joshyu
joshyu / class_decorator.ts
Created January 26, 2017 00:49 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@joshyu
joshyu / introrx.md
Created December 30, 2016 02:15 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@joshyu
joshyu / index.html
Created September 13, 2016 01:18 — forked from anonymous/index.html
render custom react component to string: forked from JS Bin// source http://jsbin.com/kavonowuri
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@joshyu
joshyu / promises.md
Created April 27, 2016 14:05 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
function calCulateReverse(number){
var arr= String(number).split('');
var mid = (arr.length - 1)/2;
var left = 0;
var right = arr.length - 1;
var rightLarge = false;
while(true){
if(left == right){
if(rightLarge){
@joshyu
joshyu / angularjs_directive_attribute_explanation.md
Created December 9, 2015 02:14 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@joshyu
joshyu / gulpfile.js
Last active October 8, 2015 02:14
my gulp file for project
/* global require */
var gulp = require('gulp'),
os = require('os'),
path = require('path'),
gutil = require('gulp-util'),
del = require('del'),
rename = require('gulp-rename'),
karma = require('karma').server,
uglify = require('gulp-uglifyjs'),
less = require('gulp-less'),
@joshyu
joshyu / .jshintrc
Created October 8, 2015 02:11
jshint config
{
// JSHint configuration for server-side development
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
@joshyu
joshyu / .gitconfig
Last active October 8, 2015 02:10
my git config
[user]
name = Josh Yu
email = joshyupeng@gmail.com
[core]
editor = vim
pager = less
autocrlf = true
[color]
ui = auto
[merge]
@joshyu
joshyu / ios safari bookmark icon.md
Last active August 29, 2015 14:28
Customized bookmark icon for safari browser in IOS

IOS safari accept apple-touch-icon to be shown as bookmark icon, the minimal acceptable size is 57x57, otherwise the icon will be shown as internal default icon compass.

define the bookmark icon as below:

<link rel="apple-touch-icon" sizes="57x57" href="touch-icon-ipad.png">