Skip to content

Instantly share code, notes, and snippets.

View philsmy's full-sized avatar

Phil Smy philsmy

View GitHub Profile
#!/bin/sh
mkdir -p ~/development/src
cd ~/development/src
if [ -d ImageMagickInstall ]
then
# remove old ImageMagickInstall directory if it exists
rm -rf ImageMagickInstall
fi
mkdir ImageMagickInstall
cd ImageMagickInstall
@philsmy
philsmy / arel_or.rb
Created August 18, 2011 10:20
or scopes - add this to your model to be able to or scopes together (eg: Model.or(Model.scope1, Model.scope2). Stolen and adapted from fake_arel
__or_fn = lambda do |*scopes|
where = []
joins = []
includes = []
# for some reason, flatten is actually executing the scope
scopes = scopes[0] if scopes.size == 1
scopes.each do |s|
w = []
s.where_clauses.each do |where_clause|
@philsmy
philsmy / ability.rb
Created August 23, 2011 09:30
our ability class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user.role? :super_admin
can :manage, :all
else
@philsmy
philsmy / make.log
Created September 9, 2011 11:07
error from rvm install attempt of ruby 1.8.7
[2011-09-09 12:59:08] make
/usr/bin/gcc-4.2 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -DRUBY_EXPORT -I. -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -c array.c
/usr/bin/gcc-4.2 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -DRUBY_EXPORT -I. -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -c bignum.c
bignum.c: In function ‘rb_big_unpack’:
bignum.c:314: warning: right shift count >= width of type
/usr/bin/gcc-4.2 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -DRUBY_EXPORT -I. -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -c class.c
/usr/bin/gcc-4.2 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -DRUBY_EXPORT -I. -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -c compar.c
/usr/bin/gcc-4.2 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -DRUBY_EXPORT -I. -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -c dir.c
/usr/bin/gcc-4.2 -a
@philsmy
philsmy / gmaps4rails_compare
Created December 11, 2013 23:25
Comparison of old and new calls to gmaps4rails (Google Maps For Rails - https://github.com/apneadiving/Google-Maps-for-Rails)
## gmaps4rails v1
## controller
@json = @shops.to_gmaps4rails do |shop, marker|
marker.infowindow render_to_string(partial: "/shops/map_info_window", locals: { object: shop})
icon_name = "wl_sm_icon"
unless shop.shop_group.nil?
if (shop.shop_group.name.downcase =~ /pen/) != nil
server {
listen 80;
server_name domain1.ca;
return 301 https://www.domain1.com$request_uri;
}
server {
listen 80;
server_name domain1.com;
return 301 https://www.domain1.com$request_uri;
@philsmy
philsmy / activejob_delayedjob
Created October 15, 2017 04:55
configuring ActiveJob and DelayedJob to have priority
# app/jobs/sample_job.rb
class SampleJob < ActiveJob::Base
queue_as :maintenance
attr_accessor :options
def enqueue(options = {})
self.options = options
super
end
@philsmy
philsmy / homebrew_mysql_57.md
Created July 9, 2018 06:11
How to get homebrew to install and use mysql 5.7 instead of 8 under OSX
@philsmy
philsmy / select2_controller.js
Last active December 27, 2019 05:40
Basics of Select2 and Stimulus
import { Controller } from "stimulus"
import $ from 'jquery';
require("select2/dist/css/select2")
require("select2-bootstrap-theme/dist/select2-bootstrap")
import Select2 from "select2"
export default class extends Controller {
@philsmy
philsmy / filter_controller.js
Last active December 27, 2019 05:48
Select2 and Stimulus with events
import { Controller } from "stimulus"
import $ from 'jquery';
export default class extends Controller {
connect() {
console.log('connecting Filter controller');
$("#subscriber-tags-select").on('select2:select', function () {