This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set incsearch | |
set expandtab | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=0 | |
set autoindent | |
set smartindent | |
syntax on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isNaN(NaN); // true | |
isNaN("foo"); // true | |
isNaN(undefined); // true | |
isNaN({}); // true | |
isNaN({ valueOf: "foo" }); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#user nobody; | |
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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&); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer