Skip to content

Instantly share code, notes, and snippets.

@ChrisLusted
ChrisLusted / gist:9440912
Last active August 29, 2015 13:57
Foundation 5 block grids for bootstrap 3 sass
// Adapted from the awesome zurb foundation
// https://github.com/zurb/foundation/blob/v5.2.0/scss/foundation/components/_block-grid.scss
//
// Block Grid Mixins
//
// We use this to control the maximum number of block grid elements per row
$block-grid-elements: 12 !default;
@jacklynrose
jacklynrose / Rakefile
Last active August 29, 2015 13:57
Simple macro like functionality for RubyMotion
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require './lib/preprocessor'
begin
require 'bundler'
Bundler.require
rescue LoadError
end
@GantMan
GantMan / new.rb
Last active August 29, 2015 13:58
RMQ switching from Default to Subtitle Table Cell
def tableView(table_view, cellForRowAtIndexPath: index_path)
data_row = @data[index_path.row]
#cell = table_view.dequeueReusableCellWithIdentifier(ALERTS_CELL_ID) || begin
# rmq.create(AlertsCell, :alerts_cell, reuse_identifier: ALERTS_CELL_ID).get
#end
cell ||= AlertsCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier:ALERTS_CELL_ID).autorelease
cell = rmq.build(cell, :alerts_cell).get
@brianjlandau
brianjlandau / gist:aa33f69932a4089a4de9
Created June 17, 2014 18:07
More strict web URL regex for validations. (better then URI.regexp)
require 'uri'
hostname = "(?:(?:[\\w\\-]+\\.)+[[:alpha:]]{2,})"
host = "(?:#{hostname}|#{URI::DEFAULT_PARSER.pattern[:IPV4ADDR]}|#{URI::DEFAULT_PARSER.pattern[:IPV6ADDR]})"
server = "//(?:#{URI::DEFAULT_PARSER.pattern[:USERINFO]}@)?#{host}(?::\\d*)?"
absolute_path = "(?:#{URI::DEFAULT_PARSER.pattern[:ABS_PATH]})?"
query = URI::DEFAULT_PARSER.pattern[:QUERY]
http_uri_regex = Regexp.new("\\A(?:http|https):(?:#{server}#{absolute_path})(?:\\?(?:#{query}))?\\z", Regexp::EXTENDED, 'N')
@stve
stve / content_post.rb
Created December 31, 2010 20:08
Using Ruby to post to a Facebook Page's wall
post_data = {}
post_data[:name] = 'Title for my link'
post_data[:link] = 'http://path.to/my/link'
post_data[:caption] = 'A caption'
post_data[:description] = 'A description'
post_data[:picture] = 'http://path.to/myimage.jpg'
post_data[:actions] = { :name => 'My site name', :link => 'http://link.to/my/site'}.to_json
client.post("feed", nil, post_data)
@ccabot
ccabot / rails_admin.rb
Created January 26, 2011 19:03
patch rails_admin to use paper_trail
require "rails_admin/application_controller"
require "rails_admin/abstract_history"
module RailsAdmin
# use declarative_authorization for rails_admin's authz
class ApplicationController < ::ApplicationController
filter_access_to :all
end
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
@a-chernykh
a-chernykh / staging.rb
Created May 9, 2011 07:51
whenever + capistrano - custom log path
# Configure whenever
set :whenever_environment, rails_env
set :whenever_output, '/var/www/apps/alt12/current/log/crontab.log'
set :whenever_update_flags, "--update-crontab #{whenever_identifier} --set environment=#{whenever_environment}\\&output=#{whenever_output}" # notice the escaping \& passed to the shell
@thomasmaas
thomasmaas / gist:1013101
Created June 7, 2011 20:39 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
if Rails.env == "development"
Dir.foreach("#{Rails.root}/app/models") do |model_name|
require_dependency model_name unless model_name == "." || model_name == ".."
end
end