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
def reorder_children(ordered_ids) | |
ordered_ids = ordered_ids.map(&:to_i) | |
current_ids = children.map(&:id) | |
unless current_ids - ordered_ids == [] && ordered_ids - current_ids == [] | |
raise ArgumentError, "Not ordering the same ids that I have as children. My children: #{current_ids.join(", ")}. Your list: #{ordered_ids.join(", ")}. Difference: #{(current_ids - ordered_ids).join(', ')} / #{(ordered_ids - current_ids).join(', ')}" | |
end | |
j = 0 | |
transaction do | |
for new_id in ordered_ids | |
old_id = current_ids[j] |
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
register file:/home/hadoop/lib/pig/piggybank.jar | |
raw_logs = | |
LOAD '$INPUT' | |
USING PigStorage('\t') | |
AS ( | |
date: chararray, time: chararray, x_edge_location: chararray, sc_bytes: int, | |
c_ip: chararray, cs_method: chararray, cs_host: chararray, cs_uri_stem: chararray, | |
sc_status: chararray, cs_referer: chararray, cs_user_agent:chararray, cs_uri_query: chararray | |
); |
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
if !Exceptional::Config.api_key.nil? && Rails.env == 'production' | |
begin | |
class Delayed::Worker | |
def handle_failed_job_with_exceptional(job, error) | |
Exceptional.handle(error, "Delayed::Job #{self.name}") | |
handle_failed_job_without_exceptional(job, error) | |
Exceptional.context.clear! | |
end | |
alias_method_chain :handle_failed_job, :exceptional | |
Exceptional.logger.info "Lars Pind's custom DJ integration enabled" |
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
link_to_glyphicon(:edit, edit_admin_product_coupon_path(@product, coupon)) | |
glyphicon(:move, :class => 'drag_handle', :title => "Drag to reorder", :variant => :halfling) |
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
// Example usage: | |
// $('#entrant_1_email').linkTo('#purchase_email'); | |
// This will cause any changes to #purchase_email to be reflected in #entrant_1_email | |
// unless #entrant_1_email has been changed to be something different from #purchase_email | |
(function($){ | |
$.fn.linkTo = function(link_to, options) { | |
return this.each(function() { | |
var $link_to = $(link_to); | |
var changed_manually = false; |
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
module ActionView | |
module Helpers | |
module FormHelper | |
def form_for_with_bootstrap(record, options = {}, &proc) | |
options[:builder] = BootstrapFormBuilder | |
form_for_without_bootstrap(record, options, &proc) | |
end | |
def fields_for_with_bootstrap(record_name, record_object = nil, options = {}, &block) | |
options[:builder] = BootstrapFormBuilder |
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
@mixin gradient($first, $second) { | |
background-color: $second; | |
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');"; | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#{ie-hex-str($first)}', endColorstr='#{ie-hex-str($second)}');; | |
zoom: 1; | |
background: -webkit-gradient(linear, left top, left bottom, from($first), to($second)); | |
background: -moz-linear-gradient(top, $first, $second); | |
} |
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
source 'http://rubygems.org' | |
gem "rails", '3.2.0.rc1' | |
gem "mysql2" | |
# Assets | |
group :assets do | |
gem 'sass-rails', git: 'https://github.com/rails/sass-rails.git', branch: '3-2-stable' | |
gem "coffee-rails" |
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
task :glyphs => :environment do | |
glyphs = [] | |
glyphs_hash = {} | |
longest_name = 0 | |
Dir.glob(Rails.root.join("app", "assets", "images", "glyphicons", "*.png")) do |path| | |
width, height = `identify -format "%wx%h" #{path}`.strip.split(/x/) | |
# glyphicons_083_random.png | |
# glyphicons_083_random@2x.png | |
# glyphicons_halflings_047_bold.png |
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
#!/bin/zsh | |
file=`/Users/lars/.rvm/gems/ruby-1.9.3-p0/bin/bundle show $1` | |
if [ -x "$file" ] | |
then | |
mate $file | |
else | |
echo "No gem named $1 found" 1>&2 | |
exit -1 | |
fi |
OlderNewer