Skip to content

Instantly share code, notes, and snippets.

@south37
south37 / .vimrc
Created October 10, 2013 09:40
vimの設定
set incsearch
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=0
set autoindent
set smartindent
syntax on
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
Class = {}
Class.def = do ->
curry = (fn) ->
slice = Array.prototype.slice
storedArgs = slice.call(arguments, 1)
return ->
newArgs = slice.call(arguments)
args = storedArgs.concat(newArgs)
fn.apply(null, args)
isNaN(NaN); // true
isNaN("foo"); // true
isNaN(undefined); // true
isNaN({}); // true
isNaN({ valueOf: "foo" }); // true
def my_hex(hex_str)
result = 0
hex_str.split('').reverse.each_with_index do |ch, i|
low, high = ['1'..'9'], ['a'..'f']
result += 16 ** i *
case ch
when *low then ch.to_i
when *high then ch.ord - 'a'.ord + 10
else 0
end
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
local path, ext =
ngx.var.path, ngx.var.ext
local images_dir = "/usr/local/var/www/manga/img/" -- where images come from
local cache_dir = "/usr/local/var/www/manga/cache/" -- where images are cached
local function return_not_found(msg)
ngx.status = ngx.HTTP_NOT_FOUND
ngx.header["Content-type"] = "text/html"
ngx.say(msg or "not found")
#include <cstddef>
template <class T> class List {
public:
typedef std::size_t size_type;
typedef T value_type;
List() : next(nullptr), val(0) {}
explicit List(size_type n, const value_type& newVal = value_type());
List(const List& l) { create(l); }
List& operator=(const List&);
@south37
south37 / file0.txt
Last active September 14, 2016 02:23
Ruby で ES7 の async/await を超絶簡単に実装する ref: http://qiita.com/south37/items/99a60345b22ef395d424
1 var request = require('./request.js');
2 var headers = { 'User-Agent': 'lukehoban', 'Authorization': 'token 665021d813ad67942206d94c47d7947716d27f66' };
3
4 // Promise-returning asynchronous function
5 async function getCollaboratorImages(full_name) {
6 // any exceptions thrown here will propogate into try/catch in callers - same as synchronous
7 var url = 'https://api.github.com/repos/' + full_name + '/collaborators';
8 // await a promise-returning async HTTP GET - same as synchronous
9 var [response, body] = await request({url: url, headers: headers});
10 return JSON.parse(body).map(function(collab) {
require 'set'
class NFAStateFactory
class << self
def create_new(start:)
@label_counter ||= 0
state = NFAState.new(@label_counter, start: start)
@label_counter += 1
state
end