Using:
Where t increases monotonically, and k can be varied with the slider below, the (x,y) co-ordinates sweep out the curve of a distressed Cardioid. When k = 0.5 the curve sweeps out a perfect Cardioid.
def pmap(enum) | |
return to_enum(:pmap, enum) unless block_given? | |
enum.map { |e| Thread.new { yield e } }.map(&:value) | |
end | |
# Returns elements in order, as expected. | |
pmap(1..10) { |e| e } #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
# Returns elements in nondeterministic order on MRI >= 1.9.3. | |
# Works as expected on JRuby, Rubinius, and earlier versions of MRI. |
Talk notes from Vim for Ruby and Rails workshop at BostonRb March 2014 meetup.
https://gist.github.com/christoomey/9357451
Rails.vim
This is a current proposal that I'd like your feedback on for how we can clean up how we write RubyMotion applications. It's purely conceptual at the moment, and there would have to be some framework development to make this work the way described here.
Please submit your feedback, as a joint effort we can clean up our RubyMotion applications and make it easier for Rails developers to expand their skills into RubyMotion development.
The main points of this are:
# From original: https://gist.github.com/baweaver/11163861 | |
# Using Pipeable for clearer code: https://github.com/baweaver/pipeable | |
# and Benchpress to measure: https://github.com/baweaver/benchpress | |
# Make Object Pipeable | |
class Object; include Pipeable end | |
# Patch numbers to have a prime? method | |
class Fixnum | |
def prime? |
Instructions for clearing expired DigiCert SSL certificate on OSX by [https://gist.github.com/agraves](agraves) | |
NOTICE: The following instructions "worked for me." Proceed at your own risk. | |
Symptoms: | |
* Visiting several sites, such as github, gravatar, twitter's CDN results in "invalid certificate" errors | |
* For example: http://i.imgur.com/8gPRfI3.png | |
Instructions |
<%= stylesheet_link_tag "application", :media => "screen,print" %> |
# Mark NoMethodError(s) coming from a call on `nil` | |
class NilClass | |
def method_missing(*) | |
super | |
rescue NoMethodError => e | |
e.instance_variable_set :@real_nil, true | |
raise e | |
end | |
end |
TEXT = <<EOF | |
See, the interesting thing about this text | |
is that while it seems like the first line defines an indent | |
it's actually the last line which has the smallest indent | |
there are also some blank lines | |
both with and without extra spaces in them | |
and it just goes on and on |
#!/bin/dash | |
for pid in `ps -Ao pid | grep -v PID`; do xargs -n 1 -0 <"/proc/$pid/environ" | grep -e '=()'; done |