Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
j-mcnally / Gemfile
Last active December 18, 2015 16:19
Live reload
group :development do
gem 'rack-livereload'
gem 'guard-livereload'
gem 'guard'
end

This is just a jotting of notes on how to embed Faye into a single Rails process. Makes it nice to do simple real time things without the need for a separate Faye server/process.

Also uses Faye Redis to work across load balanced Rails apps.

You also need to copy the compiled javascript into vendor/assets/javascripts and include into application.js manifest.

Ignore the numbers in the file names... just used to add order to the Gist.

This uses the faye/faye Github repo at edc5b42f6560d31eae61caf00f6765a90e1818d1 since I wanted to use with the Puma rack server and that is only available in the master branch (until Faye 1.0)

@j-mcnally
j-mcnally / gist:6084073
Created July 25, 2013 21:47
Change scss to sass
for F in $(find ./app/assets -name '*.scss'); do export FILENAME=${F##*/} && sass-convert $F ${F%$FILENAME}`basename "${F}" ".scss"`.sass && rm $F; done
@j-mcnally
j-mcnally / gist:6206935
Last active December 20, 2015 22:39
Compile assets locally when working in low-memory environments
namespace :assets do
desc "compile assets locally and upload before finalize_update"
task :deploy do
%x[RAILS_ENV=production bundle exec rake assets:clean && RAILS_ENV=production bundle exec rake assets:precompile]
run "sudo rm -rf #{release_path}/public/assets"
ENV['COMMAND'] = " mkdir '#{release_path}/public/assets'"
invoke
path = File.expand_path("../../public/assets", __FILE__)
puts path
upload path, "#{release_path}/public/assets", {:recursive => true}
@j-mcnally
j-mcnally / SomeStomplet.rb
Last active November 7, 2022 17:37
Simple stomp authentication over websockets
require 'torquebox-stomp'
class SomeStomplet
def initialize()
@pending_subscribers = {}
@subscribers = {}
end
@j-mcnally
j-mcnally / config.ru
Created August 12, 2013 21:32
Stomp js config.ru
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'torquebox-stomp'
use TorqueBox::Stomp::StompJavascriptClientProvider
run Rails.application
@j-mcnally
j-mcnally / gist:6871312
Created October 7, 2013 17:01
Rspec Sublime Build System
{
"cmd": ["/bin/bash", "-l", "-c", "echo 'Running RSPEC for $file'; source .rvmrc && bundle exec rspec $file"],
"working_dir": "${project_path:${folder:${file_path}}}",
"selector": "source.ruby",
"variants": [
{ "cmd": ["/bin/bash", "-l", "-c", "echo 'Running entire RSPEC Suite'; source .rvmrc && bundle exec rspec"],
"name": "Run",
"working_dir": "${project_path:${folder:${file_path}}}"
}
]
@j-mcnally
j-mcnally / UINavigationBar+DarkTint.h
Created October 15, 2013 06:19
Swizzle Color Transparent
//
// UINavigationBar+DarkTint.h
//
// Created by Justin McNally on 10/15/13.
//
//
#import <UIKit/UIKit.h>
@interface UINavigationBar (DarkTint)
@j-mcnally
j-mcnally / cringe.coffee
Created November 9, 2013 00:50
I bet things like this make eric bryn cringe
channelCallback: (msg) ->
msgs = jQuery.parseJSON(msg.payload)
newMessages = new Ember.RecordArray()
newMessages.set('modelClass', App.Message)
newMessages.load(App.Message, msgs)
newMessages.set('isLoaded', true)
@set('messages', newMessages)
@j-mcnally
j-mcnally / Loadmoreable.rb
Last active December 30, 2015 18:19
Loadmoreable
module ProMotion
module Table
module LoadmoreClassMethods
def load_moreable=(val)
@load_moreable = val
end
def load_moreable
@load_moreable || false
end
def load_more_options=(val)