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
| # https://en.wikipedia.org/wiki/SHA-2 | |
| # with additional hints from: | |
| # - https://github.com/ruby/rubygems/pull/4989/files | |
| # - https://github.com/kaloos/sha256/blob/master/lib/TBAddress.rb | |
| # - https://github.com/eliblurr/sha256-algorithm | |
| # | |
| # Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 232 | |
| # Note 2: For each round, there is one round constant k[i] and one entry in the message schedule array w[i], 0 ≤ i ≤ 63 | |
| # Note 3: The compression function uses 8 working variables, a through h | |
| # Note 4: Big-endian convention is used when expressing the constants in this pseudocode, |
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
| # Stolen from Xenobrain and remixed (https://gist.github.com/xenobrain/5fa64f8a3e8f8f6f1b31eee4f870dd75) | |
| TIME_STEP = 1 / 60 # delta time isn't required in DragonRuby but it really handy for tuning and debugging physics | |
| COLLISION_BIAS = 0.05 # adds some energy into the collision to get objects to separate. tune this in steps of 0.01 | |
| COLLISION_SLOP = 0.1 # amount shapes are allowed to overlap without triggering correction. helps avoid position jitter | |
| COLLISION_ITERATIONS = 10 # how many times to run the solver. a good range is between 5 and 15 | |
| CIRCLE_RADIUS = 10 | |
| CIRCLE_RADIUS_2 = CIRCLE_RADIUS * 2 | |
| CIRCLE_RADIUS_SQ = CIRCLE_RADIUS_2**2 |
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
| LAYERS = %w[ | |
| solids | |
| sprites | |
| primitives | |
| labels | |
| lines | |
| borders | |
| ].freeze | |
| class Player |
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
| #!/bin/bash | |
| wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_armhf.deb | |
| wget http://launchpadlibrarian.net/218525709/chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb | |
| wget http://launchpadlibrarian.net/218525711/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb | |
| sudo dpkg -i libgcrypt11_1.5.0-5+deb7u3_armhf.deb | |
| sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb | |
| sudo dpkg -i chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb |
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 'httparty' | |
| require 'nokogiri' | |
| def log(name, url) | |
| time = Time.now | |
| html = HTTParty.get(url) | |
| doc = Nokogiri::HTML(html) | |
| body = (doc/"table tbody") | |
| data = body.children.map { |r| r.children.map { |c| c.text.strip }.join(" ") }.reject { |t| t.nil? || t.to_s.squeeze.strip == "" } |
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
| namespace :views do | |
| desc "Converts all .html.erb files in app/views to .html.haml files" | |
| task :hamlize do | |
| Dir.glob('app/views/**/*.erb').each do |file| | |
| begin | |
| puts "Hamlizing #{file}" | |
| `bundle exec html2haml #{file} | cat > #{file.sub(/(\.html)?\.erb$/, '.html.haml')} && rm #{file}` | |
| rescue => e | |
| puts "Error in #{file}: #{e.message}" | |
| 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
| addLoadEvent(function() { | |
| var dropdowns = form.getElementsByTagName("select"); | |
| for(var i = 0; i < dropdowns.length; ++i) { | |
| dropdowns[i].onchange = (function() { | |
| var dropdown = dropdowns[i]; | |
| return function() { | |
| if(dropdown.value != "") { | |
| if(document.getElementsByClassName(dropdown.id).length == 0) { | |
| var input = document.createElement("input"); | |
| input.type = "hidden"; |
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
| public static void CallAPI(ParamType param) | |
| { | |
| var resetServicePoint = false; | |
| var origSecurityProtocol = System.Net.ServicePointManager.SecurityProtocol; | |
| try | |
| { | |
| System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3; | |
| resetServicePoint = true; | |
| // Make your API call here | |
| } |
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
| // Simple memoization which only handles a single argument | |
| // There's lots of things wrong with this code, | |
| // like that it doesn't handle falsy values, for example. | |
| // See below for a good discussion on memoization: | |
| // http://addyosmani.com/blog/faster-javascript-memoization | |
| Function.prototype.memoize = function() { | |
| var fn = this, | |
| cache = {}; | |
| return function(arg) { | |
| if(!cache[arg]) { |
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 'rubygems' | |
| require 'httparty' | |
| class MadMimi | |
| include HTTParty | |
| base_uri 'http://api.madmimi.com/' | |
| def self.import(username, api_key, csv_data) | |
| attempts = 0 | |
| success = false |
NewerOlder