Skip to content

Instantly share code, notes, and snippets.

@aliang
aliang / mymodel.rb
Created June 13, 2011 06:25
render from model in Rails 3
# yes, sometimes you need to do this. you get pilloried in a forum if you
# ask about it, though!
# this code taken from
# http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/
class MyModel < ActiveRecord::Base
# Use the my_models/_my_model.txt.erb view to render this object as a string
def to_s
ActionView::Base.new(Rails.configuration.paths.app.views.first).render(
@cheeaun
cheeaun / putonglasses.txt
Created September 14, 2012 08:57
put on glasses unicode
•_•)
( •_•)>⌐■-■
(⌐■_■)
@machty
machty / new-router-examples.md
Last active April 16, 2020 22:03
How to do cool stuff with the new Router API
@j-wang
j-wang / Temporarily using g++-4.2 for Ruby EventEngine
Created July 3, 2013 04:36
I was having trouble install bud (gem install bud) and eventually figured out that it was a problem with the g++ version I had installed (not the mac native 4.2). '-Wshorten-64-to-32' is native to mac only. This gist temporarily replaces g++ with g++-4.2 and then reverses the switch. Error I was getting: Jamess-MacBook-Pro:exercises Avantos$ gem…
mv /usr/local/bin/g++ /usr/local/bin/g++.bak && ln -s /usr/bin/g++-4.2 /usr/local/bin/g++
rm /usr/local/bin/g++ && mv /usr/local/bin/g++.bak /usr/local/bin/g++
@carols10cents
carols10cents / ajax_settings.coffee
Last active April 11, 2019 16:35
One way to get Rails and Backbone CSRF protection working
# In your Backbone app, wherever you want -- we put this in lib/ajax_settings.coffee
define [
'backbone',
'cookie' # This is https://github.com/js-coder/cookie.js,
# we have a bower-compatible fork at https://github.com/thinkthroughmath/cookie.js
], (Backbone, cookie) ->
init: ->
# This overrides all ajax requests sent through Backbone. We could have set this in jQuery
# since Backbone ultimately calls the jQuery ajax functions, but we decided we shouldn't be
# doing ajax requests outside of Backbone anyway.
es
version: 0.0.23
Missing template processorError: Missing template processor
at module.exports.preprocessTemplates (/Users/adolfo/code/ember-cli/lib/preprocessors.js:44:11)
at EmberApp.<anonymous> (/Users/adolfo/code/ember-cli/lib/broccoli/ember-app.js:83:25)
at EmberApp.memoized [as appAndDependencies] (/Users/adolfo/code/ember-cli/node_modules/lodash-node/modern/functions/memoize.js:65:28)
at EmberApp.<anonymous> (/Users/adolfo/code/ember-cli/lib/broccoli/ember-app.js:122:41)
at EmberApp.memoized [as javascript] (/Users/adolfo/code/ember-cli/node_modules/lodash-node/modern/functions/memoize.js:65:28)
at EmberApp.toArray (/Users/adolfo/code/ember-cli/lib/broccoli/ember-app.js:150:10)
at EmberApp.<anonymous> (/Users/adolfo/code/ember-cli/lib/broccoli/ember-app.js:157:26)

EU4 Trade

The goals of the Trade minigame are twofold:

  1. Get the most tradepower in your home tradenode
  2. Get the most tradepower in nodes that point to your trade node

The tradepower formula is fairly complex, but the important modifiers are: Local Provincial Tradepower, Mercantilism and Trade Efficiency. Any event that gives Mercantilism needs to be taken at all costs. It's amazing. Seriously. 1.00 Merchantilism can mean the difference of 3 duckets/month.

Merchants are the Envoy for trade. You start off with 2 and get one from Expansion Ideas, 2 from Trade Ideas, 1 from Merchant Republic, 1 for every major trade company, and 1 from Thalassocracy. Merchants can do two things: Collect from tradenode and transfer trade power.

@naps62
naps62 / webpack.rb
Created April 19, 2017 13:36
Run webpacker before test suite, only if a test tagged with JS is selected
# spec/support/webpack.rb
module WebpackTestBuild
TS_FILE = Rails.root.join("tmp", "webpack-spec-timestamp")
class << self
attr_accessor :already_built
end
def self.run_webpack
puts "running webpack-test"