Skip to content

Instantly share code, notes, and snippets.

# var xs = [1,2,3]
# doubleMe(doubleMe(doubleMe(xs)))
#這樣寫法有很多缺點,太多層次要把全部層次讀完才能知道最後結果。
#在墮性語言之中
#我們要做到調用 doubleMe 時並不會立即求值,它會說“嗯嗯,待會兒再做!”
#在真正執行時只會是一個平面,像 xs *2 *2 *2;
(a, b, c) --> a * b * c
#代替了
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
uploader = $fileUploader.create(
scope: $scope
url: "http://#{$rootScope.api}/proposal/upload"
formData: [{
key: \value
}]
filters: [
(item) ->
if item.size >10000000
alert \size不得超過10mb
/**
* 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;

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 / A.cpp
Last active December 27, 2015 20:18
Exception
// Class "MyException"
class MyException: public exception
{
...
};
// Class "A"
class A
{
public:
/**
Handle multiple socket connections with select and fd_set on Linux
Silver Moon ( m00n.silv3r@gmail.com)
*/
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
@evenchange4
evenchange4 / callback.js
Last active December 11, 2015 15:19
callback function
function invoke_and_add(a,b){
return a()+b();
}
function one(){
return 1;
}
function two(){
return 2;
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
@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