This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rexml/parsers/pullparser' | |
require 'htmlentities' | |
class String | |
# Truncate strings containing HTML code | |
# Usage example: "string".truncate_html(50, :word_cut => false, :tail => '[+]') | |
def truncate_html(len = 30, opts = {}) | |
opts = {:word_cut => true, :tail => ' ...'}.merge(opts) | |
p = REXML::Parsers::PullParser.new(self) | |
tags = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: delayed_job | |
# Recipe:: default | |
# | |
node[:applications].each do |app_name, data| | |
user = node[:users].first | |
case node[:instance_role] | |
when "solo", "app", "app_master" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'tinder' #https://github.com/collectiveidea/tinder | |
campfire = Tinder::Campfire.new('your-subdomain', | |
:token => 'your token', | |
:ssl => true, | |
:proxy => 'http://your-proxy:1234') | |
room = campfire.rooms.first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sproutcore' | |
require 'sproutcore-statechart' | |
require 'sproutcore-routing' | |
App = SC.Application.create() | |
App.GlobalNavController = SC.Object.create( | |
home: -> App.statechart.gotoState 'home' | |
about: -> App.statechart.gotoState 'about' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
class HandlebarsFilter < Rake::Pipeline::Filter | |
def initialize(&block) | |
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') } | |
super(&block) | |
end | |
def generate_output(inputs, output) | |
inputs.each do |input| | |
output.write "return Ember.Handlebars.compile(#{input.read.to_json})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="javascripts/jquery.js" type="text/javascript" charset="utf-8"></script> | |
<script src="javascripts/ember.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> | |
App = Ember.Application.extend(); | |
App.Node = Ember.Object.extend({ | |
name: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Luh.Ui.AnimationStyle = { | |
FROM_DOWN: 0 | |
, FROM_UP: 1 | |
, FROM_LEFT: 2 | |
, FROM_RIGHT: 3 | |
, NONE: 4 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It uses the awesome code from https://github.com/digitalBush/jquery.maskedinput/blob/master/src/jquery.maskedinput.js | |
App.MaskedInput = Ember.TextField.extend({ | |
isIphone: function () { return (window.orientation != undefined) }, | |
// browsers like firefox2 and before and opera doenst have the onPaste event, but the paste feature can be done with the onInput event. | |
pasteEvent: function (){ | |
return (jQuery.browser.opera || (jQuery.browser.mozilla && parseFloat(jQuery.browser.version.substr(0,3)) < 1.9 ))? 'input': 'paste'; | |
}.property().cacheable(), | |
// these keys will be ignored by the mask. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# ... | |
unless Rails.application.config.consider_all_requests_local | |
rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
end | |
private | |
def render_error(status, exception) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake-pipeline-web-filters' | |
# package js | |
input 'packages/emberjs/dist', 'ember.js' | |
input 'packages/package_A' | |
input 'packages/package_B' | |
# project js | |
input 'lib' |
OlderNewer