Skip to content

Instantly share code, notes, and snippets.

View juggy's full-sized avatar
🎯
Focusing

Julien Guimont juggy

🎯
Focusing
View GitHub Profile
//
// The logic here is the transitionend event fires instantly
// after the transition is done (1ms here). I have seen timeouts
// taking up to 300ms to fire (!) so the main avantage is responsiveness.
//
window.requestTimeout = (function(){
var vendors = 'Webkit Moz O ms Khtml'.split(' '),
supports = (function() {
var div = document.createElement('div'),
len = vendors.length;
@juggy
juggy / active_state.coffee
Created May 14, 2012 18:42
Link state with view, controller, model
Ember.ActiveState = Ember.LayoutState.extend
isActive: false
enter: (manager, transition)->
@_super(manager, transition)
@set("isActive", true)
exit: (manager, transition)->
@_super(manager, transition)
@set("isActive", false)
- content_for :scripts do
= javascript_include_tag "app/application"
= javascript_include_tag "app/templates/all"
:javascript
S.set("quote", S.store.find(S.models.Quote, S.store.load(S.models.Quote, #{QuoteSerializer.new(Quote.find(params[:id])).to_json}.quote).id));
console.log("data loaded")
- content_for :sidebar do
%script{type:"text/x-handlebars"}
{{view S.views.SidebarView}}
I have:
Skepic.DashPlot = Backbone.View.extend
...
But want (dash_plot is a precreated object):
((dash_plot)->
dash_plot.extend Backbone.View,
...
@juggy
juggy / gist:1156873
Created August 19, 2011 14:06
Patched Ruby 1.9.2 for faster load and GC
cd /tmp
# Faster require:
# https://gist.github.com/1008945
curl -O https://raw.github.com/gist/1008945/4edd1e1dcc1f0db52d4816843a9d1e6b60661122/ruby-1.9.2p290.patch
# GC-tuning:
# https://gist.github.com/856296
curl -O https://raw.github.com/gist/856296/a19ac26fe7412ef398bd9f57e61f06fef1f186fe/patch-1.9.2-gc.patch
@juggy
juggy / gist:1023110
Created June 13, 2011 16:25
Revert to last saved version using Backbone.js
Skepic.EventedModel = Backbone.Model.extend
initialize: ->
Backbone.Model.prototype.initialize.apply(@, arguments)
_.bindAll(@, "mark_to_revert", "revert")
@mark_to_revert()
save : (attrs, options)->
self = this
options || (options = {})
@juggy
juggy / call_template.rb
Created May 17, 2011 19:25
Render a complete page in rails 3 without controller
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
@juggy
juggy / gist:797100
Created January 26, 2011 17:49
Html5 parse error
<div class='template' id='expense_line_template'>
<form accept-charset="UTF-8" action="" class="formtastic expense_line" id="new_expense_line" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="Oebai47Bo8n5KjXRi37Z+nK9vJkWI3bxtwgIpc5Hjqg=" /></div>
<fieldset class="inputs"><ol><li class="numeric required material" id="expense_line_material_id_input"><label for="expense_line_material_id">Material<abbr title="required">*</abbr></label><input id="expense_line_material_id" name="expense_line[material_id]" type="text" /></li>
<li class="select required expense_category" id="expense_line_expense_category_input"><label for="expense_line_expense_category_id">Category<abbr title="required">*</abbr></label><select id="expense_line_expense_category_id" name="expense_line[expense_category_id]"><option value="1">Material</option>
<option value="2">Subcontractor</opt
ActionController::Base.asset_host = Proc.new { |source, request|
if request.env["REQUEST_PATH"].include? ".pdf"
"file://#{Rails.root.join('public')}"
else
"#{request.protocol}#{request.host_with_port}"
end
}
@juggy
juggy / Country and States.js
Created November 10, 2010 03:21
Collect country codes, names and states from yahoo geolocation service with underscore.js and jquery
window.Countries = {};
$.ajax({
url: "http://where.yahooapis.com/v1/countries",
data: {appid: "5mCqm._V34HyJ7CniyiCQq.oi8LjlbUnJ1ge4X36P9bpyyao2ey7xvS.mBb1jcAf69AzoQ--", format: "json"},
dataType: "json",
success: function(data){
var countries = _.map(data.places.place, function(country){
return {"name": country.name, "url": country.uri};
})