Skip to content

Instantly share code, notes, and snippets.

@telagraphic
telagraphic / expenses.sql
Created December 21, 2015 02:10
expenses trigger to find category PK
CREATE TABLE expenses (
Id SERIAL PRIMARY KEY NOT NULL,
TrxDate DATE DEFAULT now(),
PaymentType VARCHAR(100) NOT NULL,
Location VARCHAR(100) NOT NULL,
What VARCHAR(250) NOT NULL,
CategoryType INTEGER NOT NULL REFERENCES categories (Id),
Amount NUMERIC(9,2) NOT NULL,
Description TEXT NULL,
CONSTRAINT amount_greater_than_zero CHECK (Amount > 0)
@telagraphic
telagraphic / rakefile.rb
Created June 15, 2015 23:44
Rake commands
#list all tasks
rake -T
#list tasks starting with...
rake -T import
#get documentation
angular.module('gridtest', [
'ui.router',
'ngAnimate',
'ngTouch',
'ui.grid',
'ui.grid.edit',
'ui.grid.selection',
'ui.grid.moveColumns',
'ui.bootstrap',
'ui.router'
layout title date categories
post
Shell Set-up Scripts
2015-04-29 10:44:01 -0700
bash setup api-client

Rails, Yeoman Bash Build Script

@telagraphic
telagraphic / angular.js
Created April 24, 2015 12:36
Restangular-CRUD
angular.module('angularails.articles', [])
.service('Articles', function(Restangular) {
var articles = Restangular.all('articles');
return {
all: function() {
return articles.getList();
},
show: function(article) {
return articles.get(article);
// Gruntfile.js
// Generated on 2014-07-18 using generator-angular 0.9.5
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
@telagraphic
telagraphic / finance.rake
Last active August 29, 2015 14:18
Accounter
require 'roo'
require 'spreadsheet'
namespace :finance do
task :import, [:sheet] => [:environment] do |t, args|
excel = File.join Rails.root, 'lib', 'assets', 'Ledger.xlsx'
book = Roo::Excelx.new(excel)
worksheet = book.sheet args[:sheet].to_i
class Testcase < ActiveRecord::Base
require 'spreadsheet'
def self.import(file)
spreadsheet = open_spreadsheet(file)
header = spreadsheet.row(1)
(2..spreadsheet.last_row).each do |i|
row = Hash[[header, spreadsheet.row(i)].transpose]
testcase = find_by_id(row["id"]) || new
testcase.attributes = row.to_hash.slice(*row.to_hash.keys)
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem "bower-rails", "~> 0.8.3"
gem 'pg'
gem 'twitter'
gem 'rails_12factor', group: :production
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :name
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token