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
| rd, wr = IO.pipe | |
| if fork | |
| wr.close | |
| puts "Parent got: <#{rd.read}>" | |
| rd.close | |
| Process.wait | |
| else | |
| rd.close | |
| puts "Sending message to parent" |
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
| # How to build dynamic instance methods for classes. | |
| # First define a method creator (i.e. attribute_accessor below) that | |
| # loops through your params to create new methods. | |
| # Via: http://codeshooter.wordpress.com/2009/06/04/understanding-class_eval-module_eval-and-instance_eval/ | |
| Object.class_eval do | |
| class < < self | |
| def attribute_accessor( *attribute_names ) | |
| attribute_names.each do |attribute_name| | |
| class_eval %Q? |
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
| ffmpeg -i in.dts -ac 6 -ab 640000 -ar 48000 out.ac3 |
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
| # Doing this will likely kill your machine | |
| very_large_array.each do |array_item| | |
| fork do | |
| cpu_intensive_task(array_item) | |
| end | |
| end | |
| # This however will lower the changes of that happening. | |
| CPU_CORE_COUNT = 4 | |
| very_large_array.each_slice(CPU_CORE_COUNT).each do |smaller_array| |
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
| # Initial Rev | |
| # machine.rb | |
| class Machine | |
| def initialize(name) | |
| @name = name | |
| end | |
| def device | |
| Lot.find_by_tester(@name).device | |
| 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
| # Use this to look for broken links in your app. | |
| # crawls the development server http://localhost:3000 | |
| # Suggestion: Also check to make sure that intentional 404s | |
| # are handled gracefully by app. | |
| task :crawl => :environment do | |
| require 'anemone' | |
| root = 'http://localhost:3000' | |
| options = {:discard_page_bodies => true, :verbose => true} |
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
| # here lies some notes to help me with define_method | |
| class MetaTest | |
| define_method(:meta_1) do | |
| puts 'm.meta_1' | |
| end | |
| def initialize | |
| @a_var = 'iable' | |
| 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
| <!-- Class / Concept --> | |
| <owl:Class rdf:ID="a_subclass"> | |
| <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Subsclass of a class</rdfs:label> | |
| <rdfs:subClassOf> | |
| <owl:Class rdf:ID="a_class"/> | |
| </rdfs:subClassOf> | |
| </owl:Class> | |
| <!-- Simple Instance --> | |
| <Route rdf:ID="Route_1"> |
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
| # joins with time range | |
| time_range = (Time.now.midnight - 1.day)..Time.now.midnight | |
| Client.joins(:orders).where(orders: { created_at: time_range }) |
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
| --type-add | |
| html=.haml | |
| --type-add | |
| css=.sass,.scss,.less | |
| --type-add | |
| js=.coffee |