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 'priority_queue' | |
| require 'set' | |
| class Node | |
| def initialize(x, y) | |
| @x = x | |
| @y = y | |
| @obstacle = false | |
| @g_score = Float::INFINITY | |
| 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 'bundler' | |
| Bundler.require | |
| url = 'http://0.0.0.0:9000/images/avatar.png' | |
| EM.run do | |
| http = EventMachine::HttpRequest.new(url).get | |
| http.stream {|chunk| print [:chunk, chunk.size] } | |
| http.headers {|h| p [:headers, h] } | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env ruby | |
| # A simply utility to show character counts for each line of input and | |
| # highlight lines longer than 80 characters. | |
| # | |
| # Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html | |
| # | |
| # Examples: | |
| # | |
| # $ hilong Gemfile | 
  
    
      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 getimage.rb -e production -c config/getimage.rb | 
  
    
      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
    
  
  
    
  | fib=->(n){_=5**0.5;(((1+_)**n-(1-_)**n)/(2**n*_)).to_i} | 
  
    
      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
    
  
  
    
  | # Square root calculation using Newton-Raphson | |
| # from Practical Programming (1968) | |
| a = 256 | |
| x = (1 + a) / 2.0 | |
| loop do | |
| ox = x | |
| x = (x + a.to_f / x) / 2.0 | 
  
    
      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
    
  
  
    
  | # Convert ssh-rsa key to pem | |
| ssh-keygen -f infile.pub -e -m PKCS8 > outfile.pem | |
| # Encrypt a file using public key pem | |
| openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file.ssl | |
| # Decrypt using private key | |
| openssl rsautl -decrypt -inkey private.pem -in file.ssl -out decrypted.txt | 
NewerOlder