This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$output-media-width: true !default; // true = all, otherwise use a list of numeric values (eg. 320px 23em) | |
@mixin media-min-width($bp) { | |
@if type-of($output-media-width) != list { | |
@media (min-width: $bp) { | |
@content; | |
} | |
} @else { | |
$output-bp: find-comparable($bp, $output-media-width); | |
@if not comparable($output-bp, $bp) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = new WebPage(), | |
url = 'http://localhost/a-search-form', | |
stepIndex = 0; | |
/** | |
* From PhantomJS documentation: | |
* This callback is invoked when there is a JavaScript console. The callback may accept up to three arguments: | |
* the string for the message, the line number, and the source identifier. | |
*/ | |
page.onConsoleMessage = function (msg, line, source) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page = require('webpage').create() | |
system = require 'system' | |
if system.args.length is 1 | |
console.log 'Usage: capture-element.coffee <URL> (filename) (#selector)' | |
phantom.exit 1 | |
else | |
address = system.args[1] | |
filename = system.args[2] || 'capture.png' | |
selector = system.args[3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# contains email address | |
where("column_name REGEXP '[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}'").count | |
# contains url | |
where("column_name REGEXP ?", "(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}").count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
# Use like User.sample or User.pluck(:id).sample | |
def self.sample | |
order('RAND()').first rescue nil | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ $ ruby -rox -ropen-uri -e 'Ox.sax_parse(Ox::Sax.new, open("http://go.alphashare.com/external/external.php?__method=external_xmlfeed&__feed=kyr&__company_serial=376"))' | |
*** glibc detected *** ruby: double free or corruption (!prev): 0x00000000018f0530 *** | |
======= Backtrace: ========= | |
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f15e8cc4b96] | |
/home/paul/.rvm/gems/ruby-2.0.0-p0/gems/ox-2.0.0/ext/ox/ox.so(ox_sax_drive_cleanup+0x21)[0x7f15e73ebaa1] | |
/home/paul/.rvm/gems/ruby-2.0.0-p0/gems/ox-2.0.0/ext/ox/ox.so(ox_sax_parse+0x640)[0x7f15e73ee1c0] | |
/home/paul/.rvm/gems/ruby-2.0.0-p0/gems/ox-2.0.0/ext/ox/ox.so(+0x12c5d)[0x7f15e73f0c5d] | |
/home/paul/.rvm/rubies/ruby-2.0.0-p0/lib/libruby.so.2.0(+0x1996ff)[0x7f15e919e6ff] | |
/home/paul/.rvm/rubies/ruby-2.0.0-p0/lib/libruby.so.2.0(+0x1a6e4d)[0x7f15e91abe4d] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RailsAdmin.config do |config| | |
config.included_models = RailsAdmin::Config.models_pool << 'Delayed::Job' | |
config.model Delayed::Job do | |
label 'Task' | |
navigation_label 'Background Processing' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def require(file) | |
puts `pmap #{Process.pid} | grep 'total'` | |
puts Benchmark.measure('') { super }.format("%t require #{file}") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Image.where.not(photo: nil).each do |image| | |
image_path = URI.parse(image.photo_url).path | |
image.update_attribute("remote_photo_url", "http://localhost:3000#{image_path}") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :domains, %w[host1 host2 host3] | |
desc "Deploy to all servers" | |
task :deploy_all do | |
isolate do | |
domains.each do |domain| | |
set :domain, domain | |
invoke :deploy | |
run! | |
end |
OlderNewer