Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View billyct's full-sized avatar
🍎
一只想变成橘子的苹果

billyct billyct

🍎
一只想变成橘子的苹果
View GitHub Profile
@billyct
billyct / script.sh
Created January 11, 2017 09:19 — forked from srph/script.sh
envoyer: remove old releases
# https://laracasts.com/discuss/channels/envoyer/envoyer-inspired-envoy-script
rm -rf `ls -dt {{project}}/releases/* | tail -n +6`;
@billyct
billyct / weibo.js
Created October 16, 2016 12:55 — forked from yongjhih/weibo.js
Weibo Parse Cloud
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
};
function guid() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
};
function guid20() {
@billyct
billyct / do-change-url-in-css.js
Created October 4, 2016 07:44
it work nice when you want change the image url in your css, and copy the image to the new path
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
const filename = path.resolve(__dirname, 'index.css');
fs.readFile(filename, 'utf8', (err, data) => {
if (err) throw err;
var reg = new RegExp(/'([a-zA-z_0-9]+(?:.jpg|.png))'/, 'g');
@billyct
billyct / my-emacs-douban.el
Created August 28, 2016 10:45 — forked from littlehaker/my-emacs-douban.el
Emacs 豆瓣电台
(require 'ht)
(require 'web)
(require 'dash)
(defun my-emacs-douban-play ()
(interactive)
(web-http-get
(lambda (con header data)
;; local variables
(let* ((json (ht<-alist (json-read-from-string data)))
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@billyct
billyct / COMPONENT.js
Created December 25, 2015 09:31
es6 react component live template for webform
import React, {Component, PropTypes} from 'react';
import './COMPONENT.scss';
class COMPONENT extends Component {
render() {
const block = 'COMPONENT';
return (
<div className={`${block}`}></div>
@billyct
billyct / promise.js
Created November 3, 2015 20:07 — forked from jish/promise.js
An example "always" behavior for ES6 promises. This only works if you do not create / return intermediate promises.
// A thing I want to do
// This flow only involves **one** promise, for example an ajax call
// None of the subsequent `then` or `catch` calls, return new promises.
var explode = false;
var promise = new Promise(function(resolve, reject) {
if (explode) {
@billyct
billyct / WebStorage.js
Created October 13, 2015 14:27 — forked from heyimalex/WebStorage.js
localStorage sync with redux
export default class WebStorage {
constructor(key, storageArea = window.localStorage) {
this.key = key;
this.storageArea = storageArea;
}
load(defaultValue) {
const serialized = this.storageArea.getItem(this.key);
return serialized === null ? defaultValue : this.deserialize(serialized);
}
@billyct
billyct / gulpfile.js
Created September 30, 2015 17:38 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@billyct
billyct / casper.addcookies.js
Created September 16, 2015 00:19
casper js add cookies,extend phatom.addCookie()
casper.__addCookies = function (cookies) {
if (Array.isArray(cookies)) {
cookies.forEach(function(cookie) {
if (typeof cookie === 'object') {
phantom.addCookie(cookie);
} else {
this.log('its a object like {name: xxxx, value: xxxx...}?', 'warning');
}
});