h - move cursor left
j - move cursor down
k - move cursor up
l - move cursor right
w - jump forwards to the start of a word
| require 'rubygems' | |
| require 'dm-core' | |
| require 'dm-postgres-adapter' | |
| require 'adapter.rb' # local; patched | |
| require 'comparison.rb' # local; patched | |
| require 'symbol.rb' | |
| #require 'dm-migrations' | |
| DataMapper::Logger.new($stdout, :debug) | |
| DataMapper.setup(:default, 'postgres://user:password@localhost/database') |
| module DataMapper | |
| module Model | |
| # update_or_create method: finds and updates, or creates; | |
| # merger is a boolean that determines if the conditions are merged with the attributes upon create; | |
| # merge = true => merges conditions to attributes and passes the merge to the create method | |
| # merge = false => only attributes are passed into the create method | |
| def update_or_create(conditions = {}, attributes = {}, merger = true) | |
| (first(conditions) && first(conditions).update(attributes)) || create(merger ? (conditions.merge(attributes)) : attributes ) | |
| end |
| require 'rubygems' | |
| require 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| end |
| // | |
| // NSDate+InternetDateTime.h | |
| // MWFeedParser | |
| // | |
| // Created by Michael Waterfall on 07/10/2010. | |
| // Copyright 2010 Michael Waterfall. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> |
| module DataMapper | |
| module Model | |
| # update_or_create method: finds and updates, or creates; | |
| # -upon create, returns the object | |
| # -upon update, returns the object (by default, returned True) | |
| # @param[Hash] Conditions hash for the search query. | |
| # @param[Hash] Attributes hash with the property value for the update or creation of a new row. | |
| # @param[Boolean] Merger is a boolean that determines if the conditions are merged with the attributes upon create. | |
| # If true, merges conditions to attributes and passes the merge to the create method; | |
| # If false, only attributes are passed into the create method |
| ] wc -l domains.txt | |
| 783 domains.txt | |
| ] time go run domain_lookup_parallel.go | |
| real 0m5.743s | |
| user 0m0.359s | |
| sys 0m0.355s | |
| ] time go run domain_lookup_sequential.go |
| package main | |
| import ( | |
| "net/http" | |
| "database/sql" | |
| "fmt" | |
| "log" | |
| "os" | |
| ) |
| package slicefilter | |
| import "reflect" | |
| import "fmt" | |
| func Filter(src interface{}, filter map[string]interface{}, dst interface{}) error { | |
| srcRV := reflect.ValueOf(src) | |
| dstRV := reflect.ValueOf(dst) | |
| if srcRV.Kind() != reflect.Slice { |
| // MIT license (c) andelf 2013 | |
| import ( | |
| "net/smtp" | |
| "errors" | |
| ) | |
| type loginAuth struct { | |
| username, password string |