Skip to content

Instantly share code, notes, and snippets.

@evenchange4
evenchange4 / github.md
Created September 25, 2012 20:20
push git to github
class AbstractNode
@@root = nil
def initialize(n, keys, parent)
@slot = n
@keys = keys
@parent = parent
@@root = self unless @@root
end
@sodastsai
sodastsai / converter.py
Created October 22, 2012 01:47
Convert CSV to PLIST
#!/usr/bin/env python3
import sys
import csv
import plistlib
import os
csv_file = sys.argv[1]
with open(csv_file, 'r', encoding='utf-8') as f:
result = list(csv.DictReader(f))
@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
@cobyism
cobyism / gh-pages-deploy.md
Last active December 7, 2025 08:10
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).

#特殊的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
@james2doyle
james2doyle / scrollTo.js
Last active October 25, 2024 14:12
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;
};
@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;
@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
uploader = $fileUploader.create(
scope: $scope
url: "http://#{$rootScope.api}/proposal/upload"
formData: [{
key: \value
}]
filters: [
(item) ->
if item.size >10000000
alert \size不得超過10mb