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 | |
| # -*- ruby -*- | |
| block = ["news.ycombinator.com", | |
| "reddit.com", | |
| "stackoverflow.com"] | |
| fblock = block.map{|e|"127.0.0.1 #{e}"}.join("\n") | |
| hosts = File.readlines("/etc/hosts").join |
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
| import Bio.Alignment.AAlign -- Align w/ Affine Gap Penalties | |
| import Bio.Alignment.AlignData | |
| import Bio.Sequence.SeqData | |
| import Control.Monad | |
| import qualified Data.ByteString.Lazy as B | |
| import Data.ByteString.Internal (c2w, w2c) | |
| import IO | |
| import Text.Regex | |
| -- | I kind of wish this was just part of IO... |
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
| CACHE SIZE: 1 | |
| BLOCK_SIZE: 1 | |
| CACHE HITS: 261 | |
| CACHE MISSES: 773 | |
| CACHE SIZE: 1 | |
| BLOCK_SIZE: 1 | |
| CACHE HITS: 261 | |
| CACHE MISSES: 773 |
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
| ;;; File: fibonacci.asm | |
| ;;; Author: Burke Libbey <[email protected]> | |
| ;;; Modified: <2009-11-29 19:26:28 CST> | |
| ;;; | |
| ;;; Generates Fibonacci numbers on hard drive | |
| MOVE R10,0 ; HD Status | |
| MOVE R11,1 ; HD Addr Reg | |
| MOVE R12,2 ; HD MAR | |
| MOVE R13,3 ; First real memory loc. |
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 HPLattice | |
| attr_reader :residues | |
| POPULATION_SIZE = 100 | |
| BUMP_PENALTY = 1000000000 | |
| H_BLANK_SCORE = 1 | |
| P_BLANK_SCORE = -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
| def mr(n) | |
| # n = (2**k)*m + 1 | m is odd | |
| m = 0 | |
| k = 0 | |
| until m.odd? do | |
| k += 1 | |
| m = (n - 1)/(2**k) | |
| end | |
| a = rand(n-2)+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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int | |
| expmod(int a, int m, int n) | |
| { // (a ** m) % n | |
| int temp = 1; | |
| while (m != 0) { | |
| temp *= a; | |
| temp %= n; |
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 'inline' | |
| class MyMath | |
| # Thanks, Bruce Schneier! | |
| inline do |builder| | |
| builder.c <<-EOS | |
| unsigned long expmod(unsigned long base, unsigned long exponent, unsigned long modulus) { | |
| unsigned long result = 1; | |
| while(exponent > 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdbool.h> | |
| unsigned long | |
| expmod(unsigned long base, unsigned long exponent, unsigned long modulus) | |
| { | |
| unsigned long result = 1; | |
| while(exponent > 0) { | |
| if ((exponent & 1) == 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
| 1.8.7: | |
| >> t=Time.now;1_000_000.times{("asdf".html_safe+"zxcv").html_safe?};puts Time.now-t | |
| 5.673326 | |
| => nil | |
| >> require 'output_safety' | |
| => true | |
| >> t=Time.now;1_000_000.times{("asdf".html_safe+"zxcv").html_safe?};puts Time.now-t | |
| 1.715778 | |
| => nil |