Skip to content

Instantly share code, notes, and snippets.

@coodoo
coodoo / quick-guide-to-react-flux
Last active May 1, 2017 12:04
這是 jsdc 2014 演講後提供的快速學習指南。有問題請到 [React.tw 中文群組](https://www.facebook.com/groups/reactjs.tw/) 討論
# 內容
# repo 位置
- https://github.com/facebook/react
- https://github.com/facebook/flux
# 官網
- React
* http://facebook.github.io/react/
# var xs = [1,2,3]
# doubleMe(doubleMe(doubleMe(xs)))
#這樣寫法有很多缺點,太多層次要把全部層次讀完才能知道最後結果。
#在墮性語言之中
#我們要做到調用 doubleMe 時並不會立即求值,它會說“嗯嗯,待會兒再做!”
#在真正執行時只會是一個平面,像 xs *2 *2 *2;
(a, b, c) --> a * b * c
#代替了
@iamblue
iamblue / .ls
Last active August 29, 2015 14:07
建構式的原型擴充
# extent 擴充(繼承)
# 在js之中 沒有class概念,但是是拿建構式來實現class
class Animal
(@name, kind) ->
@kind = kind
action: (what) -> "*#{@name} (a #{@kind}) #{what}*"
class Cat extends Animal
(@name) -> super @name, 'cat'
purr: -> @action 'purrs'
uploader = $fileUploader.create(
scope: $scope
url: "http://#{$rootScope.api}/proposal/upload"
formData: [{
key: \value
}]
filters: [
(item) ->
if item.size >10000000
alert \size不得超過10mb
@sebmarkbage
sebmarkbage / react_legacyfactory.md
Last active March 15, 2020 00:32
Use a factory or JSX

React Element Factories and JSX

You probably came here because your code is calling your component as a plain function call. This is now deprecated:

var MyComponent = require('MyComponent');

function render() {
 return MyComponent({ foo: 'bar' }); // WARNING
@asafge
asafge / ng-really.js
Created November 12, 2013 13:06
ng-really? An AngularJS directive that creates a confirmation dialog for an action.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@james2doyle
james2doyle / scrollTo.js
Last active November 29, 2023 11:41
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
#特殊的require 可以輕鬆使用參數
### read argument
require 'optparse'
$options = {}
OptionParser.new do |opts|
opts.on("-r") { |s| $options[:r] = true }
opts.on("-i", '-i INPUT', "input ") { |s| $options[:i] = s } # ./queries/origin/query-5.xml
opts.on("-o", '-o OUTPUT',"output") { |s| $options[:o] = s } # ans
opts.on("-m", '-m MODEL', "model ") { |s| $options[:m] = s } # ./model-files
@cobyism
cobyism / gh-pages-deploy.md
Last active June 12, 2024 20:14
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@evenchange4
evenchange4 / Colorful_Terminal .md
Last active October 14, 2015 01:37
Colorful Terminal

漂漂終端機懶人包

Mac iTerm2 截圖

[Mac] vi ~/.bash_profile 加入以下幾行

# Change prompt
PS1_OLD=${PS1}
export PS1="[\[\033[0;32m\]\w\[\033[0m\]] $ "
#enables color in the terminal bash shell