Skip to content

Instantly share code, notes, and snippets.

@stevenchanin
stevenchanin / Benchmarking Data & Functional Implementations of List
Created September 20, 2010 19:35
Benchmarking Data & Functional Implementations of List
#This is the code underneath the blog post:
#http://stevechanin.blogspot.com/2010/09/benchmarking-functional-vs-data-based.html
List = Struct.new(:head, :tail)
Cons = ->(h,t) { List.new(h,t) }
Car = ->(list) { list.head }
Cdr = ->(list) { list.tail }
#[1, [2, 3], 4, 5]
lst = Cons.(1, Cons.(Cons.(2, Cons.(3, nil)), Cons.(4, Cons.(5,nil))))
@stevenchanin
stevenchanin / digitalocean.md
Last active December 20, 2021 17:18 — forked from JamesDullaghan/digitalocean.md
Setup instructions for Digital Ocean VPS using Ubuntu and Rails 3.2 #digitalocean #vps #setup

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.04 x32) Use an xx.04 LTS version

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

### Router.js.coffee
App.Router.reopen
rootURL: '/'
location: 'auto'
App.Router.map ->
@resource 'users', ->
@resource 'user', path: '/:id', ->
@route 'edit'
#javascripts/models/cleints.js.coffee
App.Client = DS.Model.extend
name: DS.attr('string')
active: DS.attr('boolean')
owner: DS.belongsTo('user')
contracts: DS.hasMany('contract')
@stevenchanin
stevenchanin / gist:00cc81a8d308b13c52ca
Last active August 29, 2015 14:23
NVM / NodeJS / NPM / SANE setup on Ubuntu

Initial

Download and setup 14.04 LTS 64 bit

NOTE: Mongo doesn't seem to work with 32 bit

Update all software using the Software Updater (click on the top left icon and type update, then click on the program). This will require a restart.

Update all your package definitions

sudo apt-get update
@stevenchanin
stevenchanin / sane_up_output.txt
Created June 15, 2015 18:30
Errors from sane up
server |
server | info: Starting app...
server |
client | version: 0.2.3
client |
client | A new version of ember-cli is available (0.2.7). To install it, type ember update.
client | Could not find watchman, falling back to NodeWatcher for file system events.
client | Visit http://www.ember-cli.com/#watchman for more info.
server | Code did not pass lint rules
server | /home/steven/Projects/how-to-sane/server/api/controllers/AlbumController.js
@stevenchanin
stevenchanin / terminal window
Created June 25, 2015 19:56
How to Sane Output
server | info: POST /api/v1/users
client | POST /api/v1/users 400 77.773 ms - 686
require 'capistrano-db-tasks'
# config valid only for current version of Capistrano
lock '3.7.1'
# Change these
server 'myproject.com', port: 54321, roles: [:web, :app, :db], primary: true
set :repo_url, 'git@bitbucket.org:steven_chanin/myproject.git'
set :application, 'myproject'
@stevenchanin
stevenchanin / shell transcript.md
Last active February 24, 2017 00:12
Trying to do a berks vendor
steven@ubuntu:~/projects/rails-server-template$ berks vendor
W, [2017-02-23T15:50:00.037000 #1151]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-23T15:50:00.037197 #1151]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-23T15:50:00.037330 #1151]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-23T15:50:00.037456 #1151]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Att
@stevenchanin
stevenchanin / Modify Event
Created June 19, 2020 18:28
OpenLayers - Find point on polygon near mouse click
this.modifyInteraction = new Modify({
// source: this.vectorSource, // all features in vector source
features: this.selectInteraction.getFeatures(), // only selected features
condition: (event) => {
// clear out all selectedVertex properties on all features
this.vectorLayer.getSource().forEachFeature((feature) => {
feature.set("selectedVertex", undefined);
});