Skip to content

Instantly share code, notes, and snippets.

View ugisozols's full-sized avatar

Uģis Ozols ugisozols

View GitHub Profile
App.SignupRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord("user");
}
});
App.SignupController = Ember.ObjectController.extend({
actions: {
signup: function() {
var self = this;
@ugisozols
ugisozols / gist:9684528
Last active August 29, 2015 13:57
Overriding url that's being hit on the backend on a per model basis
// Problem.
//
// I wanted for this.store.find("account") in AccountRoute's model hook to hit /account instead of /accounts so I ended up
// creating App.AccountAdapter where I subclass App.ApplicationAdapter and override pathForType.
// See https://github.com/emberjs/data/blob/v1.0.0-beta.6/packages/activemodel-adapter/lib/system/active_model_adapter.js#L65
//
// Note: In my app I'm using DS.ActiveModelAdapter.
//
// <3 https://github.com/robyurkowski for help.
Rehearsal ----------------------------------------------------
split/map/reject 0.060000 0.000000 0.060000 ( 0.064907)
scan with regex 0.030000 0.000000 0.030000 ( 0.024250)
------------------------------------------- total: 0.090000sec
user system total real
split/map/reject 0.070000 0.000000 0.070000 ( 0.068857)
scan with regex 0.020000 0.000000 0.020000 ( 0.023608)
namespace :db do
require "sequel"
Sequel.extension :migration
DB = Sequel.connect(ENV['DATABASE_URL'])
desc "Prints current schema version"
task :version do
version = if DB.tables.include?(:schema_info)
DB[:schema_info].first[:version]
end || 0
@ugisozols
ugisozols / gist:78db365c2f5a627b00f7
Last active August 29, 2015 14:12
Ruby 2.2.0 and passenger 4.0.56 fix for undefined symbol: rb_thread_blocking_region

After installing Ruby 2.2.0 and the latest version of passenger (as of this writing) 4.0.56 I started to get this error in nginx error.log:

symbol lookup error: /opt/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/passenger-4.0.56/buildout/ruby/ruby-2.2.0-x86_64-linux/passenger_native_support.so: undefined symbol: rb_thread_blocking_region

After a quick google search I found phusion/passenger#1314 (comment).

I'm using ruby-install so I re-installed the Ruby 2.2.0 using this command:

// app/adapters/applictation.js
import DS from "ember-data";
export default DS.FixtureAdapter.extend({ latency: 500 });
class CreateAropenitems < ActiveRecord::Migration
def self.up
create_table :aropenitems do |t|
t.integer :cust_no
t.date :doc_date
t.integer :doc_no
t.string :doc_type, :limit => 1
t.integer :apply_to_no
t.date :doc_due_date
t.decimal :amt1, :precision => 9, :scale => 2
SampleApp::Application.routes.draw do |map|
match ':controller(/:action(/:id(.:format)))'
end
script/generate scaffold company title:string
script/generate scaffold address company_id:integer address:text
script/generate scaffold employee company_id:integer name:string surname:string
# company model
class Company < ActiveRecord::Base
has_one :address
has_many :employees
def score(dice)
points = 0
roll = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0 }
dice.each { |i| roll[i] += 1}
roll.each do |key, value|
case key
when 1