Skip to content

Instantly share code, notes, and snippets.

@epequeno
epequeno / Blue.elm
Last active April 6, 2023 21:02
example of multiple elm apps on a single page
-- Elm 0.19.0
module Blue exposing (main)
import Html exposing (..)
main =
div [] [ text "Hello from Blue!" ]
@peterc
peterc / methods_returning.rb
Last active October 29, 2023 03:10
Object#methods_returning - to work out which method on an object returns what we want
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
@jamonholmgren
jamonholmgren / NSObject.rb
Last active December 16, 2015 18:00
RubyMotion - using method_missing to automatically snake_case Obj-C methods.
class NSObject
def method_missing(meth, *args)
obj_c_meth = meth.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
if respond_to?(obj_c_meth)
send obj_c_meth, *args
else
raise NoMethodError.new(meth.to_s)
end
end
end
@svs
svs / QuotationsIndexParams.rb
Created December 16, 2012 20:54
QuotationsIndexParams
class QuotationsIndexParams
include Virtus
include DataMapper::Validations
attribute :scope, String, :default => 'pending'
attribute :sort, String, :default => 'poolability'
attribute :quotation, Hash, :default => {}
attribute :date, Date
validates_within :scope, :set => [nil,'all','pending','to_call','to_pool', 'cabbed']
@seanlilmateus
seanlilmateus / gist:4134454
Last active January 12, 2018 16:11
Rubymotion GCD Future; with lazy evaluation
#!/usr/bin/env macruby -wKU
framework 'Foundation'
module Dispatch
module Futuristic
def proxy
Class.new(BasicObject) do
def initialize(obj)
@obj = obj
end
differ = RSpec::Expectations::Differ.new
puts differ.diff_as_object "Lorem Ipsum is simply dummy text of the printing\n and typeseting industry",
"Lorem Ipsum is simply dummy text of the printing\n and typesetting industry"
Lorem Ipsum is simply dummy text of the printing
- and typesetting industry
+ and typeseting industry
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
  • NBC
@bjeanes
bjeanes / README.md
Created November 23, 2011 22:24
Easily fold everything not relevant to your current spec

Easily fold everything not relevant to your current spec

Usage / Example

Just hit <Leader>rf (rspec focus) to fold all example groups in the entire file except the full hierarchy to your spec that your cursor is inside. The current example is automatically centered on your screen, when possible.

This lets you easily see all the context/describe blocks that apply just to the current spec. See:

example

@haschek
haschek / _contrast.scss
Last active August 14, 2019 14:20
SCSS/SASS Accessibility Color Methods
/*
SCSS Color Methods for Accessibility
================================================================================
Adjust given colors to ensure that those color combination provide sufficient
contrast.
@version 0.1
@link http://eye48.com/go/scsscontrast