Skip to content

Instantly share code, notes, and snippets.

View arbarlow's full-sized avatar

Alex Barlow arbarlow

  • UK
  • 23:35 (UTC +01:00)
View GitHub Profile
module ActsAsPublic
extend ActiveSupport::Concern
# This modules assumes you have a column
# called 'public' that is by default true
included do
default_scope where(public: true)
end
@arbarlow
arbarlow / song.rb
Last active December 11, 2015 02:58
song.rb model
class Song < ActiveRecord::Base
# Not controlled by user
# but used for hiding objects to the public
include ActsAsPublic
attr_accessible :name
def name
self[:name] || 'Untitled'
# For rails > 3
ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::YAML)
ActiveSupport::XmlMini::PARSING.delete("symbol")
ActiveSupport::XmlMini::PARSING.delete("yaml")
# Rails 2.x
# For 2.x apps, check whether your app sets
# `ActionController::Base.param_parsers[Mime::YAML] = :yaml` and snip that out if it does.
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING.delete('symbol')
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING.delete('yaml')
exports.create = function(req, res){
var product = Models.Product.build(req.body);
var errors = product.validate();
if (!errors) {
var image = req.files.image;
product.image = image.name;
console.log(image);
fs.rename(image.path, './public/images/1.jpg', function(err){
Process: Carousel [705]
Path: /Applications/Carousel.app/Contents/MacOS/Carousel
Identifier: com.mobelux.Carousel
Version: 1.2 (1.2)
App Item ID: 437548184
App External ID: 5564767
Code Type: X86-64 (Native)
Parent Process: launchd [195]
Date/Time: 2011-12-29 17:16:51.136 +0000
@arbarlow
arbarlow / controller.coffee
Created October 17, 2011 19:19
index.coffee
module.exports = class Controller
@relationships = []
constructor: (req, res) ->
# nothing to do here..
@belongs_to: (klass) ->
@relationships.push klass
class Animal
constructor: (@name, @age) ->
before_filters: []
@(contacts:Seq[models.Contact])
@main(title = "All contacts", current = "list") {
<table id="list">
<thead>
<tr>
<th class="name">Name</th>
<th class="firstname">First name</th>
<th class="birthdate">Birth date</th>
<th class="email">Email</th>
<ul id="products">
{% for product in products %}
<li>
<h2>{{ product.title }}</h2>
Only {{ product.price | format_as_money }}
<p>{{ product.description | prettyprint | truncate: 200 }}</p>
</li>
{% endfor %}
<table>
{foreach $names as $name}
{strip}
<tr bgcolor="{cycle values="#eeeeee,#dddddd"}">
<td>{$name}</td>
</tr>
{/strip}
{/foreach}
</table>