Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
vladimir-e / 1.cart.rb
Created August 12, 2013 15:09
Shopping cart
class Cart
include ActiveAttr::Model
attribute :items # has_many
attribute :qty, :type => Integer
attribute :subtotal_chf, :type => Integer
attribute :subtotal_eur, :type => Integer
attribute :order_id, :type => Integer
def initialize(storage)
@vladimir-e
vladimir-e / force_drop_db.sql
Created August 26, 2013 06:41
Force DROP DATABASE #postgresql #pg
update pg_database set datallowconn = 'false' where datname = 'dbname';
DROP DATABASE 'dbname'
@vladimir-e
vladimir-e / git_workflow_rebase.sh
Created September 11, 2013 12:33
Git workflow
# start on task
git checkout dev
git pull
git checkout -b branchname
# work & commit
# send to central repo everyday
git push origin branchname
@vladimir-e
vladimir-e / gist:6670838
Created September 23, 2013 14:03
remove versioned file to add it to gitignore #git
git rm --cached file_name
@vladimir-e
vladimir-e / gist:6711434
Created September 26, 2013 08:34
Reload / refresh page #backbone #bb
Backbone.history.loadUrl
@vladimir-e
vladimir-e / gist:7024773
Last active December 25, 2015 18:59
init postgres
initdb /usr/local/var/postgres -E utf8 # create a database cluster
postgres -D /usr/local/var/postgres # serve that database
PGDATA=/usr/local/var/postgres postgres # …alternatively
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
http://www.postgresql.org/docs/9.3/static/upgrading.html
@vladimir-e
vladimir-e / show_hidden.sh
Created November 3, 2013 18:19
Display all files in finder - to restore hidden file from time machine
defaults write com.apple.finder AppleShowAllFiles TRUE
# restart finder in alt+cmd+esc dialog window
@vladimir-e
vladimir-e / support_cyrillic.sh
Created December 11, 2013 03:41
Support cyrillic / russian input in rails console and IRB
$ brew install openssl readline
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p353
@vladimir-e
vladimir-e / fixpostgis.sh
Created January 3, 2014 07:36
Can't create postgis extension in postgres (geometry field)
postgres=# create extension if not exists postgis;
ERROR: could not load library "/usr/local/Cellar/postgresql/9.3.2/lib/rtpostgis-2.1.so": dlopen(/usr/local/Cellar/postgresql/9.3.2/lib/rtpostgis-2.1.so, 10): Library not loaded: /usr/local/opt/sqlite/lib/libsqlite3.0.8.6.dylib
Referenced from: /usr/local/lib/libspatialite.5.dylib
Reason: image not found
# Solution is to create symlink to sqlite with "the right" name
ln -s /usr/local/opt/sqlite/lib/libsqlite3.0.dylib /usr/local/opt/sqlite/lib/libsqlite3.0.8.6.dylib
@vladimir-e
vladimir-e / amortization_calculator.js.coffee
Created January 10, 2014 10:18
Amortization Calculator (accounting project)
#
# @author Vladimir E <[email protected]>
#
class Finliner.Models.AmortizationCalculator extends Finliner.Models.BaseModel
available_methods: [
"linear_period" # Линеийный способ (от срока)
"linear_percent" # Линеийный способ (от процента)
"residual_reducing" # Способ уменьшения остатка
"years_amount" # По сумме чисел лет