Skip to content

Instantly share code, notes, and snippets.

Using Yo Ember instead of Ember-Rails

First Generate Ember application using Yo Ember generator

  1. Install yeoman npm install -g yo grunt-cli bower
  2. Install ember-generator npm install -g generator-ember
  3. Create your project mkdir webapp && cd webapp
  4. Generate ember template yo ember
  5. Run itgrunt server
#!/usr/bin/env ruby
require 'curb'
require 'yaml'
hosts = %w(
example.com
google.com
)
@boy-jer
boy-jer / S3Upload.js
Created July 18, 2013 09:37 — forked from raytiley/S3Upload.js
This class uploads to an S3 bucket. And was adapted from this blog post: http://www.ioncannon.net/programming/1539/direct-browser-uploading-amazon-s3-cors-fileapi-xhr2-and-signed-puts/ You need to have an endpoint on your server that will sign your S3 request for you ('covered in the plog post'). To use: App.S3Upload.create({ file: file-from-fil…
App.S3Upload = Ember.Object.extend({
progress: 0,
state: "pending",
bucket: 'your-bucket'
complete: false,
s3url: null,
xhr: null,
file: null,
fileName: function() {
var file = this.get('file');
@boy-jer
boy-jer / animations-router-stuff.coffee
Created July 18, 2013 09:39 — forked from ebryn/animations-router-stuff.coffee
animations in emberjs router
App.Router.map ->
@route "a"
@route "b"
@route "ab"
@route "ba"
App.ARoute = Em.Route.extend
events:
animateToB: ->
@transitionTo('ab')
module Mongoid
module ActiveRecord
module EagerLoadable
module Criteria
extend ActiveSupport::Concern
def includes_active_record(*relations)
relations.each do |relation|
metadata = RelationMetadata.new(relation)
@boy-jer
boy-jer / multi-parameter_attributes_spec.rb
Created December 4, 2013 10:59 — forked from k-rudy/multi-parameter_attributes_spec.rb
Multiparameter Attributes support in Mongoid 4 (Rails 4.0.1) Code is taken from https://github.com/mongoid/mongoid/issues/2954 with minor amendments to work with Rails 4.0.1
# This class is needed since Mongoid doesn't support Multi-parameter
# attributes in version 4.0 before it's moved to active model in rails 4
#
# https://github.com/mongoid/mongoid/issues/2954
#
require "spec_helper"
require 'mongoid/multi_parameter_attributes'
describe Mongoid::MultiParameterAttributes do
@boy-jer
boy-jer / search.rb
Last active August 29, 2015 13:57
Simple Model Search with Rails
http://erniemiller.org/2008/02/07/simple-model-search-with-rails/
#controller
class OffenceController < ApplicationController
def index
@offenses = []
@search = Search.new(Offense,params[:search])
if @search.conditions
@offenses = Offense.search(@search)
@boy-jer
boy-jer / Gemfile
Created October 11, 2015 19:28 — forked from mchail/Gemfile
Zapier Webhooks in Rails with Resque
gem "resque", :require => 'resque/server'
gem 'resque-history'
@boy-jer
boy-jer / url_regex.rb
Last active October 24, 2015 09:47 — forked from ryana/url_regex.rb
@gruber's improved regex for matching URLs written in Ruby
# From @gruber http://daringfireball.net/2010/07/improved_regex_for_matching_urls
#http://ryanangilly.com/post/8654404046/grubers-improved-regex-for-matching-urls-written
UrlRegex = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s\`!()\[\]{};:\'\".,<>?«»“”‘’]))/i
@boy-jer
boy-jer / tic
Last active April 21, 2016 04:13
http://codereview.stackexchange.com/questions/88429/tic-tac-toe-implementation-in-ruby
**https://codequizzes.wordpress.com/2013/10/25/creating-a-tic-tac-toe-game-with-ruby/
ruby ~/dev-gt/test/ttt/lib/ttt.rb
For example, a Tic Tac Toe program requires data structures for storing
the board and conditional logic for knowing whose turn it is or if someone has won.
http://stackoverflow.com/questions/3233278/how-do-i-test-if-all-items-in-an-array-are-identical?rq=1
You can use Enumerable#all? which returns true if the given block returns true for all the elements in the collection.