Sunday, 29 December 2013

config with instance_eval

class Application
attr_reader :router
def initialize
@router = Router.new
end
end
class Router
def initialize
@arr = []
end
attr_reader :arr
def config &block
instance_eval &block
end
def add_more a
arr << a
end
end
myApp = Application.new
myApp.router.config do
add_more "ena"
add_more "dio"
end
p myApp.router.arr
#["ena", "dio"]
view raw gistfile1.rb hosted with ❤ by GitHub

Sunday, 22 December 2013

Rails Middleware Stack

3.3 Internal Middleware Stack

Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them:
Rack::Sendfile
  • Sets server specific X-Sendfile header. Configure this via config.action_dispatch.x_sendfile_header option.
    ActionDispatch::Static
  • Used to serve static assets. Disabled if config.serve_static_assets is false.
    Rack::Lock
  • Sets env["rack.multithread"] flag to false and wraps the application within a Mutex.
    ActiveSupport::Cache::Strategy::LocalCache::Middleware
  • Used for memory caching. This cache is not thread safe.
    Rack::Runtime
  • Sets an X-Runtime header, containing the time (in seconds) taken to execute the request.
    Rack::MethodOverride
  • Allows the method to be overridden if params[:_method] is set. This is the middleware which supports the PUT and DELETE HTTP method types.
    ActionDispatch::RequestId
  • Makes a unique X-Request-Id header available to the response and enables the ActionDispatch::Request#uuid method.
    Rails::Rack::Logger
  • Notifies the logs that the request has began. After request is complete, flushes all the logs.
    ActionDispatch::ShowExceptions
  • Rescues any exception returned by the application and calls an exceptions app that will wrap it in a format for the end user.
    ActionDispatch::DebugExceptions
  • Responsible for logging exceptions and showing a debugging page in case the request is local.
    ActionDispatch::RemoteIp
  • Checks for IP spoofing attacks.
    ActionDispatch::Reloader
  • Provides prepare and cleanup callbacks, intended to assist with code reloading during development.
    ActionDispatch::Callbacks
  • Runs the prepare callbacks before serving the request.
    ActiveRecord::ConnectionAdapters::ConnectionManagement
  • Cleans active connections after each request, unless the rack.test key in the request environment is set to true.
    ActiveRecord::QueryCache
  • Enables the Active Record query cache.
    ActionDispatch::Cookies
  • Sets cookies for the request.
    ActionDispatch::Session::CookieStore
  • Responsible for storing the session in cookies.
    ActionDispatch::Flash
  • Sets up the flash keys. Only available if config.action_controller.session_store is set to a value.
    ActionDispatch::ParamsParser
  • Parses out parameters from the request into params.
    ActionDispatch::Head
  • Converts HEAD requests to GET requests and serves them as so.
    Rack::ConditionalGet
  • Adds support for "Conditional GET" so that server responds with nothing if page wasn't changed.
    Rack::ETag
  • Adds ETag header on all String bodies. ETags are used to validate cache.


API application (using ActionController::API) comes with the following controller modules by default:
  • ActionController::UrlFor: Makes url_for and friends available
  • ActionController::Redirecting: Support for redirect_to
  • ActionController::Rendering: Basic support for rendering
  • ActionController::Renderers::All: Support for render :json and friends
  • ActionController::ConditionalGet: Support for stale?
  • ActionController::ForceSSL: Support for force_ssl
  • ActionController::RackDelegation: Support for the request and response methods returningActionDispatch::Request and ActionDispatch::Response objects.
  • ActionController::DataStreaming: Support for send_file and send_data
  • AbstractController::Callbacks: Support for before_filter and friends
  • ActionController::Instrumentation: Support for the instrumentation hooks defined by ActionController (seethe source for more).
  • ActionController::Rescue: Support for rescue_from.
  • AbstractController::Translation: Support for the l and t localization and translation methods. These delegate to I18n.translate and I18n.localize.
  • ActionController::HttpAuthentication::Basic::ControllerMethods (or Digest or Token): Support for basic, digest or token HTTP authentication.
  • AbstractController::Layouts: Support for layouts when rendering.
  • ActionController::MimeResponds (and ActionController::ImplicitRender for Rails 4): Support for content negotiation (respond_torespond_with).
  • ActionController::Cookies: Support for cookies, which includes support for signed and encrypted cookies. This requires the cookie middleware.

why i love ruby?!


Saturday, 14 December 2013

ruby % things

  • %r() is another way to write a regular expression.
  • %q() is another way to write a single-quoted string (and can be multi-line, which is useful)
  • %Q() gives a double-quoted string
  • %x() is a shell command
  • %i() gives an array of symbols (Ruby >= 2.0.0)

http://stackoverflow.com/questions/1274675/ruby-what-does-warray-mean

Thursday, 12 December 2013

Using a WebSocket to access your CLI


➜  temp   wget http://download.websocketd.com/releases/websocketd/0.2.7/darwin_amd64/websocketd

--2013-12-13 14:53:14--  http://download.websocketd.com/releases/websocketd/0.2.7/darwin_amd64/websocketd
Resolving download.websocketd.com... 176.32.98.233
Connecting to download.websocketd.com|176.32.98.233|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5970144 (5.7M) [application/octet-stream]
Saving to: ‘websocketd’

100%[===========================================================>] 5,970,144    962KB/s   in 11s    

2013-12-13 14:53:27 (551 KB/s) - ‘websocketd’ saved [5970144/5970144]

➜  temp  chmod +x websocketd

Test it:
➜  temp  ./websocketd --help
websocketd (0.2.7)

websocketd is a command line tool that will allow any executable program
that accepts input on stdin and produces output on stdout to be turned into
a WebSocket server....


create an app
count.sh:
#!/bin/bash

# Count from 1 to 10, pausing for a second between each iteration.
for COUNT in $(seq 1 10); do
  echo $COUNT
  sleep 1
done
Make it executable:
$ chmod +x ./count.sh

Start the server:
➜  websockets  ./websocketd --port=8080 ./count.sh
Fri, 13 Dec 2013 14:58:11 +1100 | INFO   | server     |  | Starting WebSocket server   : ws://0.0.0.0:8080/
Fri, 13 Dec 2013 14:58:11 +1100 | INFO   | server     |  | Serving using application   : ./count.sh 


In a web-page:
var ws = new WebSocket('ws://localhost:8080/');

ws.onmessage = function(event) {
  console.log('Count is: ' + event.data);
};


bam:

function (event) { console.log('Count is: ' + event.data); }
Count is: 1 VM499:5
Count is: 2 VM499:5
Count is: 3 VM499:5
Count is: 4 VM499:5
Count is: 5 VM499:5
Count is: 6 VM499:5
Count is: 7 VM499:5
Count is: 8 VM499:5
Count is: 9 VM499:5
Count is: 10 VM499:5



Server logs:
➜  websockets  ./websocketd --port=8080 ./count.sh
Fri, 13 Dec 2013 14:58:11 +1100 | INFO   | server     |  | Starting WebSocket server   : ws://0.0.0.0:8080/
Fri, 13 Dec 2013 14:58:11 +1100 | INFO   | server     |  | Serving using application   : ./count.sh 
Fri, 13 Dec 2013 14:59:38 +1100 | ACCESS | session    | url:'http://[::1]:56042/' remote:'localhost' id:'1386907178885478031' origin:'http://www.blogger.com' | CONNECT
Fri, 13 Dec 2013 14:59:48 +1100 | ACCESS | session    | url:'http://[::1]:56042/' remote:'localhost' id:'1386907178885478031' origin:'http://www.blogger.com' command:'./count.sh' pid:'46495' | DISCONNECT


test it with --devconsole
./websocketd --port=8080 --devconsole ./count.sh

and open http://localhost:8080/


connect with an javascript WebSocket
create a file count.html:
<!DOCTYPE html>
<html>
  <head>
    <title>websocketd count example</title>
    <style>
      #count {
        font: bold 150px arial;
        margin: auto;
        padding: 10px;
        text-align: center;
      }
    </style>
  </head>
  <body>

    <div id="count"></div>

    <script>
      var ws = new WebSocket('ws://localhost:8080/');
      ws.onopen = function() {
        document.body.style.backgroundColor = '#cfc';
      };
      ws.onclose = function() {
        document.body.style.backgroundColor = null;
      };
      ws.onmessage = function(event) {
        document.getElementById('count').innerText = event.data;
      };
    </script>

  </body>
</html>
Open this page in your web-browser. It will even work if you open it directly from disk using afile:// URL.



Test it with greeter.sh


make a file greeter.sh


while read LINE
do
        echo "Hello $LINE!"
done


and run it

➜  temp  ./websocketd --port=8080 --devconsole ./greeter.sh
Fri, 13 Dec 2013 15:30:02 +1100 | INFO   | server     |  | Starting WebSocket server   : ws://0.0.0.0:8080/
Fri, 13 Dec 2013 15:30:02 +1100 | INFO   | server     |  | Developer console enable  d : http://0.0.0.0:8080/
Fri, 13 Dec 2013 15:30:02 +1100 | INFO   | server     |  | Serving using application   : ./greeter.sh 


open console

http://localhost:8080/
connect and type your name

send>> "Yannis" 
onmessage: Hello "Yannis"! 




UPDATE:
use this small example to run remote terminal commands
https://github.com/msroot/SockeTerm

read more:
https://github.com/joewalnes/websocketd/wiki/Ten-second-tutorial

Friday, 29 November 2013

The Art of Innovation

["reward success", "celebrate failure", "punish inaction"]



http://www.youtube.com/watch?v=P1RUWa8pC0k

Monday, 28 October 2013

brew ungrade pg to 9.1


➜  local git:(master) sudo brew install https://raw.github.com/mxcl/homebrew/1c8c93633f446ef0ddff553d5081cd0548c91687/Library/Formula/postgresql.rb

Saturday, 26 October 2013

The journey is the reward

The journey is the reward — there is no destination.

Let go of the “there.” Your focus on the future is keeping you out of the moment, and you're not really living your life. The journey is where the magic happens. The destination is right here, right now.

Sunday, 11 August 2013

better git log in ~/.gitconfig

[alias]
l = log --date-order --date=iso --graph --full-history --all --pretty=format:'%x08%x09%C(red)%h %C(cyan)%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08 %C(bold blue)%aN%C(reset)%C(bold yellow)%d %C(reset)%s'
view raw gitconfig hosted with ❤ by GitHub

Tuesday, 6 August 2013

Load jquery dynamicly

if (typeof jQuery == 'undefined') {
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
// callback function provided as param
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
};
};
head.appendChild(script);
};
getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js', function() {
console.log("done")
});
} else {
alert("Could not load jQuery!")
};

Monday, 5 August 2013

remove all .DS_Store from git

find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch

Rails console tips

app.project_path(Project.first)
=> "/projects/130349783-with-attachments"
>> app.class
=> ActionDispatch::Integration::Session
>> app.get "/735644780/projects/605816632-bcx.atom"
=> 200
>> app.response.body
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed xml:lang=\"en-US\" ...
>> Project.instance_method(:trash).source_location
=> ["/Users/qrush/37s/apps/bcx/app/models/project.rb", 90]
>> app.method(:get).source_location
=> ["/Users/qrush/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-7d95b814583b/actionpack/lib/action_dispatch/testing/integration.rb", 32]
#http://37signals.com/svn/posts/3176-three-quick-rails-console-tips

Sunday, 4 August 2013

rails require local

gem "mygem", :path => "/Users/ioannis/Development/mygem/pkg/"

javascript objects keys and values

data = {one:1, two:2, three:3};
for(var key in data) {
console.log(data[key])
console.log(key)
}

Friday, 2 August 2013

device redirect back when user login

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def after_sign_in_path_for(resource)
sign_in_url = url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
if request.referer == sign_in_url
super
else
stored_location_for(resource) || request.referer || root_path
end
end
end
view raw gistfile1.rb hosted with ❤ by GitHub

rails and unicorn on localhost

#-------------------------------------------------
#Gem file
#-------------------------------------------------
gem 'unicorn'
#-------------------------------------------------
#Procfile in root directory (for heroku):
#-------------------------------------------------
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
#-------------------------------------------------
#./config/unicorn.rb file
#-------------------------------------------------
worker_processes 1
timeout 30
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
#make alias in ~/.profile start the server
# alias rails_u="unicorn_rails --config-file config/unicorn.rb -p 3000"
#I, [2013-08-02T21:54:02.553577 #57526] INFO -- : Refreshing Gem list
#I, [2013-08-02T21:54:10.570714 #57526] INFO -- : listening on addr=0.0.0.0:3000 fd=9
#I, [2013-08-02T21:54:10.617927 #57526] INFO -- : master process ready
#I, [2013-08-02T21:54:10.627250 #57538] INFO -- : worker=0 ready
view raw gistfile1.rb hosted with ❤ by GitHub

The UNIX Philosophy Mike Gancarz:

The UNIX Philosophy Mike Gancarz:
In 1994 Mike Gancarz (a member of the team that designed the X Window System), drew on his own experience with Unix, as well as discussions with fellow programmers and people in other fields who depended on Unix, to produce The UNIX Philosophy which sums it up in 9 paramount precepts:
Small is beautiful.
Make each program do one thing well.
Build a prototype as soon as possible.
Choose portability over efficiency.
Store data in flat text files.
Use software leverage to your advantage.
Use shell scripts to increase leverage and portability.
Avoid captive user interfaces.
Make every program a filter.
view raw gistfile1.txt hosted with ❤ by GitHub

Thursday, 1 August 2013

skip_before_filter :verify_authenticity_token

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
module Api
module V1
class AppsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:update_attr]
respond_to :json

Wednesday, 31 July 2013

ruby_metaprogramming

# class.instance_methods(false)
class Rubyist
# the code in the following method definition is executed later,
# when you eventually call the method
def what_does_he_do
@person = 'A Rubyist'
'Ruby programming'
end
end
an_object = Rubyist.new
puts an_object.class # => Rubyist
puts an_object.class.instance_methods(false) # => what_does_he_do
an_object.what_does_he_do
puts an_object.instance_variables # => @person
#respond_to
obj = Object.new
if obj.respond_to?(:program)
obj.program
else
puts "Sorry, the object doesn't understand the 'program' message."
end
#send
class Rubyist
def welcome(*args)
"Welcome " + args.join(' ')
end
end
obj = Rubyist.new
puts(obj.send(:welcome, "famous", "Rubyists")) # => Welcome famous Rubyists
#:method_missing
class Rubyist
def method_missing(m, *args, &block)
str = "Called #{m} with #{args.inspect}"
if block_given?
puts str + " and also a block: #{block}"
else
puts str
end
end
end
# => Called anything with []
Rubyist.new.anything
# => Called anything with [3, 4] and also a block: #<Proc:0xa63878@tmp.rb:12>
Rubyist.new.anything(3, 4) { something }
#http://ruby-metaprogramming.rubylearning.com/html/ruby_metaprogramming_2.html

ECMAScript 5: Tamper proofing objects

var o = {
foo: "bar"
};
// adding a new property normally:
o.hey = "guys";
// preventing further extensions:
Object.preventExtensions(o);
// silent error, or TypeError under strict mode:
o.anotherProp = "This will fail!";
// existing properties can still be changed:
o.hey = "gals";
var o = {
foo: "bar"
};
// adding a new property normally:
o.hey = "guys";
// deleting a property normally:
delete o.hey;
// sealing the object:
Object.seal(o);
// silent failure, or TypeError under strict mode:
o.anotherProp = "This will fail!";
// existing properties can still be changed if they were writable:
o.foo = "baz";
// silent failure, or TypeError under strict mode:
delete o.foo;
//We can do everything Object.seal does, but also protect data properties
//from being overwritten by using the Object.freeze method.
var o = {
foo: "bar"
};
// adding a new property normally:
o.hey = "guys";
// deleting a property normally:
delete o.hey;
// sealing the object:
Object.freeze(o);
// silent failures, or TypeErrors under strict mode:
o.anotherProp = "This will fail!";
o.foo = "baz";
delete o.foo;
var o = { foo: "bar" };
Object.preventExtensions(o);
Object.defineProperty(o, "foo", {
writable: false,
configurable: false
});
// Object.isFrozen(o) === true
//http://www.jimmycuadra.com/posts/ecmascript-5-tamper-proofing-objects
view raw gistfile1.js hosted with ❤ by GitHub

instance_values

:instance_variables
class Gift
def initialize
@name = "book"
@price = 15.95
end
end
gift = Gift.new
hash = {}
gift.instance_variables.each {|var| hash[var.to_s.delete("@")] = gift.instance_variable_get(var) }
p hash # => {"name"=>"book", "price"=>15.95}
:attributes.to_options
App.first.attributes.to_options
:instance_variable_get
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_get(:@a) #=> "cat"
fred.instance_variable_get("@b") #=> 99
:instance_values
Gift.new.instance_values # => {"name"=>"book", "price"=>15.95}
:attributes
App.first.attributes
view raw instance_values hosted with ❤ by GitHub

Active Record loves blocks

#http://blog.plataformatec.com.br/page/3/
#Active Record associations also love blocks
#We talked about using blocks when building an Active Record object using new or create, but associations like belongs_to or #has_many also work with that, when calling build or create on them:
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :user
end
# has_many
user = User.first
user.posts.build do |post|
post.title = "Active Record <3 Blocks"
post.body = "I can give tap a break! <3 <3 <3"
end
# belongs_to
post = Post.first
post.build_user do |user|
user.name = "John Doe <3 blocks"
user.username = "john.doe"
user.password = "john123"
end

instance_eval && class_eval

class Person
end
Person.class_eval do
def say
"malakias"
end
end
me = Person.new
me.say
class Person
end
Person.instance_eval do
def go_for_cofe?
true
end
end
Person.go_for_cofe?

Keyboard Shortcuts for Bash


Ctrl + AGo to the beginning of the line you are currently typing on
Ctrl + EGo to the end of the line you are currently typing on
Ctrl + L              Clears the Screen, similar to the clear command
Ctrl + UClears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + HSame as backspace
Ctrl + RLet’s you search through previously used commands
Ctrl + CKill whatever you are running
Ctrl + DExit the current shell
Ctrl + ZPuts whatever you are running into a suspended background process. fg restores it.
Ctrl + WDelete the word before the cursor
Ctrl + KClear the line after the cursor
Ctrl + TSwap the last two characters before the cursor
Esc + TSwap the last two words before the cursor
Alt + FMove cursor forward one word on the current line
Alt + BMove cursor backward one word on the current line
TabAuto-complete files and folder names
http://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/

wget links

array=(
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
"http://something.come/videos/somevideo.mp4"
)
for i in "${array[@]}"
do
wget $i
done
view raw gistfile1.txt hosted with ❤ by GitHub

seed

sed 's/FindThisWord/ReplaceWithThisWord/g' file.txt
sed 's/Apple/MacLife/g' sample.txt
#http://www.maclife.com/article/columns/terminal_101_find_and_replace_using_sed
sed -n 's/Apple/MacLife/gpw output.txt' sample.txt
view raw gistfile1.txt hosted with ❤ by GitHub


via Instagram http://instagram.com/p/ca9hzKr5da/

Monday, 29 July 2013

jQuery clone one element

<div id="contition_container">
<div class="contition-group contition-group-style form-group">
<select class="keys form-control" style="width: 30%; margin-right: 10px; float:left">
<option value="">Keys</option>
<% @category.app.data_to_json.map { |o| o.keys}.flatten.uniq.each do |k|%>
<option value="<%= k %>"><%= k %></option>
<% end %>
</select>
<select class="operators form-control" style="width: 10%; margin-right: 10px; float:left">
<option value=">">Operators</option>
<option value=">">></option>
<option value=">">=></option>
<option value=">"><</option>
<option value=">"><=</option>
<option value=">">==</option>
<option value=">">!=</option>
</select>
<input type="text" class="form-control contitions" placeholder="value" style="float:left">
<select class="logical form-control" style="width: 10%; margin-right: 10px; float:left">
<option value=">">Logical</option>
<option value=">">and</option>
<option value=">">not</option>
</select>
<a class="clone btn btn-primary" style="float:left">more</a>
</div> </div>
<script type="text/javascript" charset="utf-8">
$(".clone").click(function(){
$(".contition-group").clone().prependTo("#contition_container")
$(".contition-group").last().removeClass("contition-group")
$(".clone").first().fadeOut("slow")
});
</script>

Pry within rails4 console

#config/application.rb
module YourApp
class Application < Rails::Application
console do
require "pry"
config.console = Pry
end
end
end
#add to the gemfile
group :development, :test do
gem 'pry'
end
#rails console
rails c
cd YourModel
#read more
#https://github.com/pry/pry
view raw gistfile1.rb hosted with ❤ by GitHub

Saturday, 27 July 2013

Upgrading to Bootstrap 3 RC1 with Rails 4.0.0.rc1

#Add in application helper for bootstrap_flash
module ApplicationHelper
ALERT_TYPES = [:error, :info, :success, :warning]
def bootstrap_flash
flash_messages = []
flash.each do |type, message|
next if message.blank?
type = :success if type == :notice
type = :error if type == :alert
next unless ALERT_TYPES.include?(type)
Array(message).each do |msg|
text = content_tag(:div,
content_tag(:button, raw("&times;"), :class => "close", "data-dismiss" => "alert") +
msg.html_safe, :class => "alert fade in alert-#{type}")
flash_messages << text if msg
end
end
flash_messages.join("\n").html_safe
end
end
#Add to Gem file
gem "sass-rails", "~> 4.0.0"
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails',
:branch => '3.0.0'
rake assets:precompile

javascript Module Pattern example

http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
var MODULE = (function (my) {
my.myMethod = function () {
console.log("myMethod");
};
return my;
}(MODULE || {}));

Overwrite models attributes at Serializer with rails 4

class AppSerializer < ActiveModel::Serializer
attributes :hashid, :updated_at
def updated_at
object.updated_at.to_time.to_i
end
def attributes
data = super
data[:attribute] = edit_app_url(object)
data
end
end
view raw gistfile1.rb hosted with ❤ by GitHub

Friday, 26 July 2013

rails generate uniqie hash

class App < ActiveRecord::Base
before_create :generate_hash_id
private
def generate_hash_id
begin
self.hash_id = SecureRandom.hex(30)
end while self.class.exists?(hash_id: hash_id)
end
end

Sunday, 21 July 2013

Greeks.in the app that locates Greeks near you!






rails annotate gem

#use annotate gem to annotate your models
#add gem 'annotate' and annotate from app dir it will generate this in all models
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# uid :text
# name :string(255)
# link :string(255)
# username :string(255)
# hometown :string(255)
# location :string(255)
# quotes :text
# gender :string(255)
# created_at :datetime
# updated_at :datetime
# email :string(255) default(""), not null
# encrypted_password :string(128) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0)
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# token :text
# provider :string(255)
# image :string(255)
# latitude :float
# longitude :float
# token_local :text
#

Tuesday, 16 July 2013

newrelic_rpm with Rails 4 on heroku

There is a bug in newrelics config file

The solution:



1. in config/newrelic.yml

line 46  replace

app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>

view is var in defined in heroku

blah:(master) ✗ heroku config
DATABASE_URL                 =>
HEROKU_POSTGRESQL_COBALT_URL =>
NEW_RELIC_LICENSE_KEY        =>
NEW_RELIC_LOG                =>
PAPERTRAIL_API_TOKEN         =>

set the var

heroku config:set NEW_RELIC_APP_NAME=new_app

also in ~/.profile

export NEW_RELIC_APP_NAME=my_app

Sunday, 14 July 2013

Ιθάκη

Σα βγεις στον πηγαιμό για την Ιθάκη,
να εύχεσαι να’ναι μακρύς ο δρόμος,
γεμάτος περιπέτειες, γεμάτος γνώσεις.
Τους Λαιστρυγόνας και τους Κύκλωπας,
τον θυμωμένο Ποσειδώνα μη φοβάσαι,
τέτοια στον δρόμο σου ποτέ σου δεν θα βρεις,
αν μέν' η σκέψις σου υψηλή, αν εκλεκτή
συγκίνησις το πνεύμα και το σώμα σου αγγίζει.
Τους Λαιστρυγόνας και τους Κύκλωπας,
τον άγριο Ποσειδώνα δεν θα συναντήσεις,
αν δεν τους κουβανείς μες στην ψυχή σου,
αν η ψυχή σου δεν τους στήνει εμπρός σου.
Να εύχεσαι να’ναι μακρύς ο δρόμος.
Πολλά τα καλοκαιρινά πρωιά να είναι
που με τι ευχαρίστηση, με τι χαρά
θα μπαίνεις σε λιμένας πρωτοειδωμένους·
να σταματήσεις σ' εμπορεία Φοινικικά,
και τες καλές πραγμάτειες ν' αποκτήσεις,
σεντέφια και κοράλλια, κεχριμπάρια κ' έβενους,
και ηδονικά μυρωδικά κάθε λογής,
όσο μπορείς πιο άφθονα ηδονικά μυρωδικά·
σε πόλεις Aιγυπτιακές πολλές να πας,
να μάθεις και να μάθεις απ' τους σπουδασμένους.
Πάντα στον νου σου να’χεις την Ιθάκη.
Το φθάσιμον εκεί είν ο προορισμός σου.
Aλλά μη βιάζεις το ταξίδι διόλου.
Καλλίτερα χρόνια πολλά να διαρκέσει·
και γέρος πια ν' αράξεις στο νησί,
πλούσιος με όσα κέρδισες στον δρόμο,
μη προσδοκώντας πλούτη να σε δώσει η Ιθάκη.
Η Ιθάκη σ' έδωσε τ' ωραίο ταξίδι.
Χωρίς αυτήν δεν θα βγαινες στον δρόμο.
Άλλα δεν έχει να σε δώσει πια.
Κι αν πτωχική την βρεις, η Ιθάκη δεν σε γέλασε.
Έτσι σοφός που έγινες, με τόση πείρα,
ήδη θα το κατάλαβες η Ιθάκες τι σημαίνουν.
view raw gistfile1.txt hosted with ❤ by GitHub

Δεν το γράφουν τα λεξικά, αλλά μου το είπαν ψιθυριστά οι σειρήνες της ζωής

ΥΓ. Δεν το γράφουν τα λεξικά, αλλά μου το είπαν ψιθυριστά οι σειρήνες της ζωής,
η λέξη Κρίση σημαίνει επίσης, ευκαιρία για νέες ευκαιρίες και απελευθέρωση δημιουργικότητας.
ΥΓ. Και ποτέ δεν ξεχνώ: …Πάντα στο νου σου νάχεις την Ιθάκη…Το φθάσιμον εκεί είναι ο
προορισμός σου…Aλλά μη βιάζεις το ταξίδι διόλου…
http://www.godimitris.gr/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1909&cntnt01origid=15&cntnt01lang=el_GR&cntnt01returnid=72&hl=greek
view raw gistfile1.txt hosted with ❤ by GitHub

Friday, 12 July 2013

jquery's mouse over rotate

.cross-browser .feature-box-image{
background: url('i/feature-sprites.png') -278px 0px no-repeat;
-webkit-transition: all 0.4s;
transition: all 0.4s;
position: relative;
z-index: 10;
}
.cross-browser .feature-box-image:hover {
-webkit-transition: all 0.7s linear;
-webkit-transform: rotate(6.28rad);
transition: all 0.7s;
transform: rotate(6.28rad);
}

Tuesday, 2 July 2013

Adapt.js responsive without bootstrap

What is this?


 Adapt.js is a lightweight (848 bytes minified) JavaScript file that determines which CSS file to load before the browser renders a page. If the browser tilts or resizes, Adapt.js simply checks its width, and serves only the CSS that is needed, when it is needed.



 http://adapt.960.gs/


// Edit to suit your needs.
var ADAPT_CONFIG = {
  // Where is your CSS?
  path: 'assets/css/',

  // false = Only run once, when page first loads.
  // true = Change on window resize and page tilt.
  dynamic: true,

  // Optional callback... myCallback(i, width)
  callback: myCallback,

  // First range entry is the minimum.
  // Last range entry is the maximum.
  // Separate ranges by "to" keyword.
  range: [
    '0px    to 760px  = mobile.css',
    '760px  to 980px  = 720.css',
    '980px  to 1280px = 960.css',
    '1280px to 1600px = 1200.css',
    '1600px to 1920px = 1560.css',
    '1940px to 2540px = 1920.css',
    '2540px           = 2520.css'
  ]
};

Wednesday, 26 June 2013

reset

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
body {
line-height: 1;
color: black;
background: white;
}
ol, ul {
list-style: none;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: separate;
border-spacing: 0;
}
caption, th, td {
text-align: left;
font-weight: normal;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: "";
}
blockquote, q {
quotes: "" "";
}
view raw a.rb hosted with ❤ by GitHub

Tuesday, 25 June 2013

Single Table Inheritance in Rails


I couldn’t find too much information on Rails awesome built in Single Table Inheritance so I thought I’d write this up for anyone who is interested.
What is Single Table Inheritance?
In a nutshell, STI allows you to create subclasses of a particular database table. Using a single table, you can cast rows to specific objects that extend the base model.
How to create STI relationships in Rails
Lets say we have a model Computer
class Computer < ActiveRecord:Base
  # in app/models
  # Fields:
  #   String name
  #   String owner
  #   String manafacturer
  #   String color

  def default_browser
    "unknown!"
  end 
end
Now, we want to differentiate between Macs and PCs. It doesn’t really make sense to make a different table for each, since they both have pretty much the same columns. Instead we can create a new column, type, which tells Rails to use STI on Computer. Lets look at what the models might look like.
class Computer < ActiveRecord:Base
  # in app/models
  # Fields:
  #   String name
  #   String owner
  #   String manafacturer
  #   String color
  #   String type

  def default_browser
    "unknown!"
  end 
end

class Mac < Computer
  # in app/models
  # this is for Computers with type="Mac"
  before_save :set_color

  # Lets say all macs are silver, no point setting these ourselves
  def set_color
    self.color = "silver"
    self.manafacturer = "apple"
  end

  # Lets overwrite the default_browser method
  def default_browser
    "safari"
  end
end

class PC < Computer
  # in app/models  

  # Lets overwrite the default_browser method
  def default_browser
    "ie =("
  end
end
Anytime Rails opens up the computer object, it looks for the subclass corresponding to type. For instance,type="CoolComputer" corresponds to model CoolComputer < Computer.
How to use STI Models
To create a new mac, you can do:
m = Mac.new
m.name = "kunal's mac"
m.owner = "kunal"
m.save
m # => #<Mac id: 1, name: "kunal's mac", owner: "kunal", manafacturer: "apple", color: "silver", type: "Mac", ...>
Whats even cooler is ActiveRecord queries. Lets say we want all the computers
Computer.all # => [#<Mac id: 1, name: "kunal's mac", owner: "kunal", manafacturer: "apple", color: "silver", type: "Mac", ...>, #<Mac id: 2, name: "anuj's mac", owner: "anuj", manafacturer: "apple", color: "silver", type: "Mac", ...>, #<PC id: 3, name: "bob's pc", owner: "bob", manafacturer: "toshiba", color: "blue", type: "PC", ...>]
Yup, it automatically gives you the correct objects! You can find out the type of a particular object by calling.typeis_a? or .class
Computer.first.type == Mac # true
Computer.first.is_a? Mac # true
Computer.first.class == Mac # true
If we only want Macs, we can do
Mac.all
Custom Inheritance Column
If you want to use another column instead of type to use for STI, you can simply add this to the top of your model:
set_inheritance_column 'whatever_you want'
Note: If you have a database column named type, you can turn off Single Table Inheritance by changing the inheritance column to something other than type.
Organizing This in Rails
After using STI, I ended up with a bloated models folder because all of the many custom sub models I created were in the models folder. To solve this, I created a folder in models to store all of my computer specific models
* app
*   models
*     computer.rb
*     computers
*       pc.rb
*       mac.rb
Rails doesn’t automatically open subfolders in the models folder, so I added in config/application.rb:
# Load Subfolder Models
config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**}')]
Cheers,
Kunal


http://blog.thirst.co/post/14885390861/rails-single-table-inheritance

Wednesday, 19 June 2013

def Κοτόπουλο

# encoding: UTF-8
def παρακαλώ
"please"
end
def Κοτόπουλο
"chicken"
end
def ∑(iterable)
iterable.reduce(&:+)
end
puts [ ∑([1, 2]), Κοτόπουλο, παρακαλώ].join(' ')

Saturday, 15 June 2013

Friday, 14 June 2013

Open a new Mac OS X terminal window or tab in the current dir

#!/bin/sh
#
# Open a new Mac OS X terminal window or tab in the current or another
# directory and optionally run a command in the new window or tab.
#
# - Without any arguments, the new terminal window opens in
# the current directory, i.e. the executed command is "cd $PWD".
# - If the first argument is a directory, the new terminal will "cd" into
# that directory before executing the remaining arguments as command.
# - The optional "-t" flag executes the command in a new tab
# instead of a new window.
# - The optional "-x" flag closes the new window or tab
# after the executed command finishes.
# - The optional "-p" flag takes an argument of the form x,y (e.g. 40,50) and
# positions the terminal window to the indicated location on the screen
# - The optional "-s" flag takes an argument of the form w,h (e.g. 800,400) and
# resizes the terminal window to the indicated width and height in pixels.
#
# Written by Marc Liyanage <http://www.entropy.ch>
#
# Version 2.1
#
set -e
while getopts xtp:s: OPTION; do
[ $OPTION = "x" ] && { EXIT='; exit'; }
[ $OPTION = "t" ] && { TAB=1; }
[ $OPTION = "p" ] && { POSITION="set position of window 1 to {$OPTARG}"; }
[ $OPTION = "s" ] && { SIZE="set size of window 1 to {$OPTARG}"; }
done
for (( $OPTIND; $OPTIND-1; OPTIND=$OPTIND-1 )); do shift; done
view raw gistfile1.txt hosted with ❤ by GitHub
in ~/.profile

Thursday, 13 June 2013

Avoid `console` errors in browsers that lack a console.

// Avoid `console` errors in browsers that lack a console.
if (!(window.console && console.log)) {
(function() {
var noop = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = window.console = {};
while (length--) {
console[methods[length]] = noop;
}
}());
}

AngularJS_generator




##Install yo npm install -g yo grunt-cli bower

##AngularJS generator npm install -g generator-angular

##Make a new directory, and cd into it: mkdir AngularJS_generator && cd $_

##Run yo angular, optionally passing an app name: yo angular AngularJS_generator

Route

Generates a controller and view, and configures a route in app/scripts/app.js connecting them.

Example:

yo angular:route myroute

Produces app/scripts/controllers/myroute.js:

angular.module('myMod').controller('MyrouteCtrl', function ($scope) {
  // ...
});

Produces app/views/myroute.html:

<p>This is the myroute view</p>

Controller

Generates a controller in app/scripts/controllers.

Example:

yo angular:controller user

Produces app/scripts/controllers/user.js:

angular.module('myMod').controller('UserCtrl', function ($scope) {
  // ...
});

Directive

Generates a directive in app/scripts/directives.

Example:

yo angular:directive myDirective

Produces app/scripts/directives/myDirective.js:

angular.module('myMod').directive('myDirective', function () {
  return {
    template: '<div></div>',
    restrict: 'E',
    link: function postLink(scope, element, attrs) {
      element.text('this is the myDirective directive');
    }
  };
});

Filter

Generates a filter in app/scripts/filters.

Example:

yo angular:filter myFilter

Produces app/scripts/filters/myFilter.js:

angular.module('myMod').filter('myFilter', function () {
  return function (input) {
    return 'myFilter filter:' + input;
  };
});

View

Generates an HTML view file in app/views.

Example:

yo angular:view user

Produces app/views/user.html:

<p>This is the user view</p>

Service

Generates an AngularJS service.

Example:

yo angular:service myService

Produces app/scripts/services/myService.js:

angular.module('myMod').factory('myService', function () {
  // ...
});

Options

There are options for each of the methods for registering services. For more on using these services, see the module API AngularJS documentation.

Factory

Invoked with --factory

This is the default method when creating a service. Running yo angular:service myService --factory is the same as running yo angular:service myService

Service

Invoked with --service

Value

Invoked with --value

Constant

Invoked with --constant

Options

In general, these options can be applied to any generator, though they only affect generators that produce scripts.

CoffeeScript

For generators that output scripts, the --coffee option will output CoffeeScript instead of JavaScript.

For example:

yo angular:controller user --coffee

Produces app/scripts/controller/user.coffee:

angular.module('myMod')
  .controller 'UserCtrl', ($scope) ->

A project can mix CoffeScript and JavaScript files.

Minification Safe

By default, generators produce unannotated code. Without annotations, AngularJS's DI system will break when minified. Typically, these annotations the make minification safe are added automatically at build-time, after application files are concatenated, but before they are minified. By providing the --minsafe option, the code generated will out-of-the-box be ready for minification. The trade-off is between amount of boilerplate, and build process complexity.

Example

yo angular:controller user --minsafe

Produces app/controller/user.js:

angular.module('myMod').controller('UserCtrl', ['$scope', function ($scope) {
  // ...
}]);

Background

Unannotated:

angular.module('myMod').controller('MyCtrl', function ($scope, $http, myService) {
  // ...
});

Annotated:

angular.module('myMod').controller('MyCtrl',
  ['$scope', '$http', 'myService', function ($scope, $http, myService) {

    // ...
  }]);

The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.

The recommended build process uses ngmin, a tool that automatically adds these annotations. However, if you'd rather not use ngmin, you have to add these annotations manually yourself.

Bower Components

The following packages are always installed by the app generator:

  • angular
  • angular-mocks
  • angular-scenario

The following additional modules are available as components on bower, and installable via bower install:

  • angular-cookies
  • angular-loader
  • angular-resource
  • angular-sanitize

All of these can be updated with bower update as new versions of AngularJS are released.

Configuration

Yeoman generated projects can be further tweaked according to your needs by modifying project files appropriately.

Output

You can change the app directory by adding a appPath property to bower.json. For instance, if you wanted to easily integrate with Express.js, you could add the following:

{
  "name": "yo-test",
  "version": "0.0.0",
  ...
  "appPath": "public"
}

This will cause Yeoman-generated client-side files to be placed in public.

Testing

For tests to work properly, karma needs the angular-mocks bower package. This script is included in the bower.json in the devDependencies section, which will be available very soon, probably with the next minor release of bower.

While bower devDependencies are not yet implemented, you can fix it by running:

bower install angular-mocks

By running grunt test you should now be able to run your unit tests with karma.

Contribute

See the contributing docs

When submitting an issue, please follow the guidelines. Especially important is to make sure Yeoman is up-to-date, and providing the command or commands that cause the issue.

When submitting a PR, make sure that the commit messages match the AngularJS conventions.

When submitting a bugfix, write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix.

When submitting a new feature, add tests that cover the feature.

Folked: https://github.com/yeoman/generator-angular

License

BSD license

view raw README.md hosted with ❤ by GitHub
DOWNLOAD repo

 https://github.com/msroot/AngularJS_generator/

TESTING

sudo npm install -g karma


Start the server (it runs on node.js)
karma start
Another tab
karma run


➜  AngularJS_generator git:(master) karma run
Chrome 27.0 (Mac): Executed 6 of 6 SUCCESS (0.155 secs / 0.038 secs)
➜  AngularJS_generator git:(master) 

Tuesday, 11 June 2013

Fixing recruitment

The recruitment industry is hilariously broken. It's hard enough for me, a full-time developer, to determine if someone else is a good programmer, so how could I expect a recruiter who has no skills in programming to do it? I'm paying for someone to perform what is essentially keyword matching heuristics between my job description and a candidate’s resume. This process is poor at best with the opportunity to go stupidly wrong (like when I get sent Java developers for a JavaScript position).
You can make the argument that recruiters are there as a first pass filter, to strip out all the people that apply for jobs regardless of whether their skills match. At around 20% of what I'm going to pay for someone's salary, that's an expensive filter.
On top of that, don't forget about the incentive structure where recruiters are encouraged to place as many people as possible, as quickly as possible – the recruitment "numbers game".
In their defence, recruiters make the argument that their profession is one of human relations. Please. If that was really true, why are they almost universally despised? Why are so many “recruitment professionals” failing at the one skill they really need to have?
It comes down to one problem: transparency. A lack of transparency about who you'll be working for. A lack of transparency on how much the recruiter is being paid. Recruiters control information. Try submitting your CV to them as a PDF and watch them bounce it back wanting a Word version so they can remove your details from it before sending it off to a client.
Fixing recruitment requires introducing transparency. If you want to differentiate from all the other people in recruitment, then make your dealings transparent and provide value in other areas – such as actually determining if someone is good! With Dragonfly we're trying
change happen for full-time recruitment.
SAMUEL RICHARDSON

Socket.io-example repo

https://github.com/msroot/Socket.io-example

Tuesday, 4 June 2013

Ember.JS Resources

https://gist.github.com/harisadam/5046520/raw/2558636546bc0cd52314a73e6d62a786e402bd32/Ember.js+resources.md



# Ember.js #
[Follow Me on twitter](http://twitter.com/harisadam)

##Deprecated, I recommend emberwatch.com, you will find very usefull stuff

##Videos:##

* Architecture overview (old) - http://www.mochaleaf.com/blog/ember-js-revised-architecture-overview/
* Intro to ember.js and the new router api - http://toranbillups.com/blog/archive/2013/01/03/Intro-to-ember-js-and-the-new-router-api/
* Peepcode Fire Up Ember.js - https://peepcode.com/products/emberjs
* Seattle Ember.js Meetup Part 1 (Tom Dale - Ember Data) - http://www.youtube.com/watch?v=_6yMxU-_ARs
* Seattle Ember.js Meetup Part 2 (Tom Dale - Ember Data Q&A) - http://www.youtube.com/watch?v=TTy1pbXdKJg
* Seattle Ember.js Meetup Part 3 (Yehuda Katz - Ember Router) - http://www.youtube.com/watch?v=4Ed_o3_59ME
* Seattle Ember.js Meetup Part 4 (Yehuda & Tom - Q&A) - http://www.youtube.com/watch?v=aBvOXnTG5Ag
* Ember.js Code-Walkthrough - http://lukaszielinski.de/blog/posts/2013/02/23/ember-dot-js-code-walkthrough-video/
* Getting Started with Ember.js - http://andymatthews.net/read/2012/06/19/Getting-Started-with-Ember.js-slides-and-video-now-available
* EmberCamp video channel - https://addepar.com/ember
* Ember-EasyForm & Ember-Validations - https://www.youtube.com/watch?v=ZWUjlbN8fvA&feature=player_embedded
* RailsCast Emberjs episode 1 - http://railscasts.com/episodes/408-ember-part-1
* RailsCast Emberjs episode 2 - http://railscasts.com/episodes/410-ember-part-2
* Ember Inspector: Live Controllers - https://www.youtube.com/watch?v=18OSYuhk0Yo&hd=1


##Posts:##

* Ember guides - http://emberjs.com/guides/
* Ember blog - http://emberjs.com/blog/
* Ember API - http://emberjs.com/api/
* Ember Data Architecture - https://github.com/emberjs/data/blob/master/ARCHITECTURE.md
* Breaking Changes - https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md
* Handlebars documentation - http://handlebarsjs.com/
* Understanding Ember.Object - http://www.cerebris.com/blog/2012/03/06/understanding-ember-object/
* Introducing Ember-EasyForm - http://reefpoints.dockyard.com/ember/2013/02/21/ember-easy-form.html
* Speaking With the Ember.js Core Team - http://net.tutsplus.com/articles/interviews/ember-js-core-team-interview/
* Building an Ember app with RailsAPI - Part 1 (coffeesript + rails) - http://reefpoints.dockyard.com/ember/2013/01/07/building-an-ember-app-with-rails-api-part-1.html
* Building an Ember app with RailsAPI - Part 2 (coffeesript + rails) - http://reefpoints.dockyard.com/ember/2013/01/09/building-an-ember-app-with-rails-api-part-2.html
* Building an Ember app with RailsAPI - Part 3 (coffeesript + rails) - http://reefpoints.dockyard.com/ember/2013/01/10/building-an-ember-app-with-rails-api-part-3.html
* Using Rails & Devise with Ember.js - http://say26.com/using-rails-devise-with-ember-js
* Documenting our understanding of EmberJS Data - https://gist.github.com/BernardNotarianni/4283607
* Introduction to Ember - http://www.embertraining.com/
* Getting Started With Ember.js - http://twbrandt.github.com/
* Why Discourse uses Ember.js - http://eviltrout.com/2013/02/10/why-discourse-uses-emberjs.html
* EMBER.JS DASHBOARD - http://code418.com/ember.js-dashboard/
* Ember Wrap-up - http://bradleypriest.com/tags.html#ember-wrapup-ref
* darthdeus vs Ember.js - http://darthdeus.github.com/
* Advice on & Instruction in the Use Of Ember.js - http://trek.github.com/
* Game On: Backbone and Ember - http://net.tutsplus.com/tutorials/javascript-ajax/game-on-backbone-and-ember/
* Use Ember.js as a cross plaform javascript library part 1 - http://cgcardona.github.com/2013/02/18/use-emberjs-as-a-cross-plaform-javascript-library/
* Use Ember.js as a cross plaform javascript library part 2 - http://cgcardona.github.com/2013/02/18/use-emberjs-as-a-cross-plaform-javascript-library-pt2/
* 5 Useful Tips for Ember.js Developers - http://say26.com/five-useful-tips-for-ember-js-developers
* Ember.js and Rails Authentication Gotchas - http://blog.waymondo.com/2012-12-18-ember-dot-js-and-rails-authentication-gotchas/
* Getters and Setters in Ember.js - http://emberashes.com/blog/2012/12/23/getters-and-setters-in-ember-dot-js/
* Ember.js Routing - the Director's Cut - http://www.thesoftwaresimpleton.com/blog/2012/08/20/routing_update/
* Ember.js forms made easy with EasyForm - http://thechangelog.com/emberjs-forms-made-easy-with-easyform/
* Rails + Ember.js http://www.devmynd.com/blog/2013-3-rails-ember-js
* Debugging Emberjs And Ember data - http://www.akshay.cc/blog/2013-02-22-debugging-ember-js-and-ember-data.html
* EmberJS Confuses Me - http://wekeroad.com/2013/03/06/ember-confuses-me
* 33 Great Resources to Get Started with Ember.js - http://accidentaltechnologist.com/javascript/33-great-resources-get-started-emberjs/
* Adding Splash Screen to an Ember.js App - http://www.harimenon.com/blog/2013/03/13/adding-splash-screen-to-an-ember-dot-js-app/
* EmberPress - A Letterpress clone in EmberJS - http://emberpress.eviltrout.com/
* Debugging EmberJS and Ember Data - http://www.akshay.cc/blog/2013-02-22-debugging-ember-js-and-ember-data.html

##Presentations:##

* Writing Big (ambitious) Apps Using - http://www.rvl.io/shex/ember/
* EMBER.JS & CLIENT SIDE VALIDATIONS - http://www.rvl.io/bcardarella/ember-js-and-clientsidevalidations
* Why Ember? - http://mutewinter.github.com/why_ember/#/slides
* Optimizing an API for Ember Data - https://speakerdeck.com/dgeb/optimizing-an-api-for-ember-data

##Interesting repositories: ##

* Ember auth - https://github.com/heartsentwined/ember-auth
* Ember-inspector - https://github.com/stefanpenner/ember-inspector
* Query string support for the Ember.js router - https://github.com/alexspeller/ember-query
* Ember.js Contacts List example - https://github.com/ivanvanderbyl/contacts
* Ember TODO example - https://github.com/Skalar/ember_todo
* Internationalization for Emberjs - https://github.com/jamesarosen/ember-i18n
* Experiment building Ember.js apps using RailsAPI - https://github.com/bcardarella/ember-railsapi
* A simple Rails app for testing CRUD with ember.js and ember-data.js - https://github.com/dgeb/ember_data_example
* EmberJS example App with a common CRUD interface - https://github.com/GerritWanderer/ember_data-crud_example
* Modal CRUD example - http://jsbin.com/ixigez/2/edit

How to try out the Ember Inspector in Google Chrome


by Kasper Tidemann

Yehuda Katz has been working on Ember Inspector, an extension for Google Chrome that exposes what happens with views, controllers, objects etc. when running an Ember.js application.
There’s already a few videos demonstrating the inspector, including Ember Inspector: Live Controllers. It will be officially available with the release of Ember.js version 1.0, but you can go ahead and try it out now. Here’s a quick guide:
  • Go to github.com/tildeio/ember-extension and download the ZIP file
  • Unzip the file and fire up Google Chrome
  • Visit chrome://flags and enable “Experimental Extension APIs” in the list
  • Restart Google Chrome
  • Go to the Extensions page and ensure that the “Developer Mode” checkbox is checked
  • Click “Load unpacked extension…” and select theember-extension-master folder
  • Restart Google Chrome and bring up the Developer Tools
  • Click “Ember” at the far right of the tab menu
That’s it. If all went okay, you should be seeing something like this in your Developer Tools menu. Happy inspecting!
(As a side note, in Google Chrome 24.x, it even had a nice, little icon.)