Skip to content

Instantly share code, notes, and snippets.

View cold-coder's full-sized avatar
🎯
Focusing

Yao Cheng cold-coder

🎯
Focusing
View GitHub Profile
@cold-coder
cold-coder / main.m
Last active August 29, 2015 13:56
One solution to exercise 6 of Chapter 6 - Making Decision in book <<Programming in Objective-C>>
//
// main.m
// this is one solution to exercise 6 of Chapter 6 - Making Decision in book <Programming in Objective-C>
//
//ex6. Write a program that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English. So if the user types in 932, the program should display the following:
//nine three two
//(Remember to display zero if the user types in just 0.) Note: This exercise is a hard one!
//
// Created by yaocheng on 14-2-5.
// Copyright (c) 2014年 yaocheng. All rights reserved.
@cold-coder
cold-coder / dragAnywhere.html
Created May 7, 2014 10:05
drag and drop element on the page
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
<style>
html{
height: 100%;
}
body{
@cold-coder
cold-coder / Weibo_Style.css
Created August 27, 2014 07:03
新浪微博V5 还我漂漂版
*{font-family: Georgia, "Times New Roman", "Microsoft YaHei", "微软雅黑", STXihei, "华文细黑", serif;}
.WB_feed a.notes {margin: 20px 20px 5px !important;padding: 10px 1px;}
.WB_feed a.notes:hover {background-color:#F7F3C6 !important;text-decoration:none !important;}
Select all and delete (actually move to buffer)
:%d
Select all and copy to buffer
:%y
Use p to paste the buffer.
@cold-coder
cold-coder / server.js
Last active October 21, 2016 23:26
Use ajax approach to submit form, including multipart element.
var multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'public/img/');
},
filename: function (req, file, cb) {
cb(null, file.originalname + Date.now().toString().slice(0,10));
}
})
@cold-coder
cold-coder / Connectivity.js
Last active November 30, 2015 02:55
Check Internet access available in node.js, use book.douban.com to test in this case.
// require('dns').resolve('book.douban.com', function(err) {
// if (err){
// console.log('Oops! Cannot access Douban');
// }
// else{
// console.log('Have Internet Access');
// }
// });
require('http').get("book.douban.com", function(res) {
@cold-coder
cold-coder / .gitignore
Last active January 7, 2016 14:09
WeChat UI Preview
jquery*.js
@cold-coder
cold-coder / index.js
Created June 3, 2016 03:09
ES6 argument destructuring demo
let o = {a:'123',b:'456'}
let f = ({ a }) => {
console.log(a)
return 0
}
f(o) //123
@cold-coder
cold-coder / lucky_draw.js
Last active January 2, 2023 13:46
#PhotoOf2016摄影评比参与奖抽奖程序
// var url = 'https://gist.github.com/cold-coder/4e60e31d254e921255d37874c302bd48';
const guys2017 = ['*晓悦', '*亚玲', '*佳', '*芽琦', '*范贤', '*奕', '*俊余', '*国迁',
'*晓炜', '*bing', '*乐琦', '*晓婷', '*达嵩', '*明明', '*伟中', '*志强', '*建华',
'*慧', '*伟锋', '*传萍', '*霞琴', '*晶晶', '*利华', '*华', '*苗', '*玉娇','*亚松',
'*亮萍'];
const guys2018 = ['*晴怡','Allen','*永成','Rain','*志强','Mira','Jonathan','Rachel',
'*霞琴', '*国迁', '*帆', '*才标', '*俊杰', 'Angela', '*浩宁', '*艳敏','*佳宝',
'chen洁', '*婧', '*承其', '*赛', '*成庆', '*杰', '*奇', '*小静','*成', 'chu洁',
@cold-coder
cold-coder / promise.js
Created January 2, 2017 12:10
Promise the right way
let step1 = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('in step1');
resolve(1);
// reject(new Error('error from step1'));
}, 1000)
})
}