Skip to content

Instantly share code, notes, and snippets.

@clyfe
clyfe / ACL.rb
Created February 3, 2012 13:06
Short slides for a short talk at wurbe
#===================================================================
0. ACL - lists, individuals
- query DB conforming to ACL
@posts = Post.where( rules as per ACL ) # +joins
- authorize individuals already in memory
@post = Post.find(params[:id])
@clyfe
clyfe / overrides.css.scss
Created March 5, 2012 23:37
AS and TB play nice
/* use with AS 3.2 */
.active-scaffold-header div.actions {
top: 0;
}
.active-scaffold {
input[type="submit"], input[type="reset"], button {
@extend .btn;
@extend .btn-primary;
@clyfe
clyfe / behaviors.coffee
Created March 19, 2012 12:14
Reusable action components
$ ->
$('[data-remove-parent]').bind 'ajax:success', ->
el = $(this)
console.log el
console.log el.data('remove-parent')
console.log el.closest(el.data('remove-parent'))
el.closest(el.data('remove-parent')).fadeOut()
$('[data-live-input]').change ->
@clyfe
clyfe / meal.rb
Created March 21, 2012 14:31
Simple search with Squeel DSL
class Meal < ActiveRecord::Base
belongs_to :chef
has_many :meal_translations, inverse_of: :meal, dependent: :destroy
scope :simple_search, ->(terms) {
joins{meal_translations}.
joins{chef.locations.outer}.
where{
{ meal_translations => sift(:simple_search, terms) } |
{ chef.locations.zip_code.eq_any => terms }
require "active_support"
module M1
def m; 1 end
end
module M2
def m; super + 1 end
end
diff --git a/.gitignore b/.gitignore
index dfd12ee..bda50fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,4 @@ test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
-/nbproject/private/
\ No newline at end of file
@clyfe
clyfe / bf.ro
Last active October 13, 2015 03:47
black friday
# sudo apt-get install vlc vlc-plugin-pulse
require 'open-uri'
song = "Music/Creedence\\ Clearwater\\ Revival\\ -\\ Hey\\ Tonight.mp3"
loop do
begin
sleep 1
open("http://www.emag.ro/")
@clyfe
clyfe / navigasmic.rb
Last active December 12, 2015 04:28
Navigasmic 0.5.6 monkeypatch initializer to allow block syntax and TB compatibility
Navigasmic.setup do |config|
config.highlighted_class = 'active'
config.with_group_class = 'dropdown-menu'
end
module Navigasmic
# lazy monkey patch, makes it work with twitter bootstrap
class HtmlNavigationBuilder
def item(label = '', options = {}, &proc)
@clyfe
clyfe / simple_form.rb
Created August 22, 2013 08:20
Bootstrap3 compatible simple_form initializer
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
@clyfe
clyfe / Vagrantfile
Last active December 22, 2015 04:18
Simple Vagrat for Rails stuff on Ubuntu - simple shell based provisioning - uses ruby-2.0.0-p247 via rbenv - uses mysql (tweak it for posgresql yourself)
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 8443
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'script/provision.sh'