Skip to content

Instantly share code, notes, and snippets.

View Teino1978-Corp's full-sized avatar

Teino Boswell Teino1978-Corp

  • Ocho Rios, Jamaica
View GitHub Profile
@Teino1978-Corp
Teino1978-Corp / console.sh
Created November 21, 2015 09:17
rvm list # status!=1 ; match=/ruby/
=====cmd:start="rvm list"=
rvm rubies
goruby(B [ x86_64 ]
rbx-head-default_1.9(B [ x86_64 ]
ruby-1.8.6-p420(B [ x86_64 ]
ruby-1.8.7-p352(B [ x86_64 ]
maglev-26852(B [ x86_64 ]
ruby-1.9.2-p290-named(B [ x86_64 ]
@Teino1978-Corp
Teino1978-Corp / rvm.sh
Created November 21, 2015 08:49
RVM - Ruby Version Manager - https://rvm.io/rvm/autolibs
# Note:
# RVM does not control the system Ruby or its gems. Only Rubies and gems installed by RVM are under it's control!
# Install RVM
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
$ source /home/ubuntu/.rvm/scripts/rvm
# Install a Ruby version
$ rvm install ruby-1.9.3
Host *
CheckHostIP yes
Compression yes
IdentityFile ~/.ssh/id_rsa
Protocol 2
AddressFamily inet
IdentitiesOnly yes
KexAlgorithms [email protected]
PasswordAuthentication no
ChallengeResponseAuthentication no
ROUTES = {
"GET /" => ["RootController", :show],
"GET /home" => ["HomeController", :index],
"GET /posts/:slug/comments/:id/edit" => ["CommentsController", :edit],
"POST /posts/:slug/comments" => ["CommentsController", :create],
"PUT /posts/:slug" => ["PostsController", :update]
}
router = Router.new ROUTES
@Teino1978-Corp
Teino1978-Corp / cytoscape_decorator.py
Created November 20, 2015 08:20
Short script to generate PDF figures of a Cytoscape-generated metabolic pathway overlaid with arrows. Arrow sizes are proportional to values taken from a CSV input file. - http://www.cytoscape.org/
#!/usr/bin/env python
from __future__ import print_function
import csv
import sys
import xml.etree.ElementTree as etree
import pyx
import pyx.connector
@Teino1978-Corp
Teino1978-Corp / jquery.hasattr.js
Created November 20, 2015 07:53
jQuery hasAttr function
/* HAS ATTRIBUTE */
$.fn.hasAttr = function(attrName){
var element = this[0];
if(element.hasAttribute){
return element.hasAttribute(attrName);
@Teino1978-Corp
Teino1978-Corp / include.js
Last active November 20, 2015 07:52
include() - load scripts asynchronously w/375 bytes of code - e.g. `include(src, cb)`
function include(url,success) {
var head = document.getElementsByTagName("head")[0], done = false;
var script = document.createElement("script");
script.src = url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
done = true;
if (typeof success === 'function') success();
}
@Teino1978-Corp
Teino1978-Corp / build-new-haddock.md
Created November 20, 2015 01:01
build new haddock instructions
  1. Download and build the newest haddock. The build instructions are in README.md.

    git clone https://github.com/haskell/haddock.git cd haddock

    cabal sandbox init cabal sandbox add-source haddock-library cabal sandbox add-source haddock-api cabal install --dependencies-only

@Teino1978-Corp
Teino1978-Corp / README.md
Created November 20, 2015 00:22
Benchmarking ruby

Benchmarking ruby

The problem: Create a hash from an array of objects where the key is the object's #id and the value is the #stuff method.

Known/Suspected caveats:

  • Garbage collection might be happening, making the results lie.
  • Not exhaustive of ways to create a hash from an array
  • Not exhaustive of ways to call Benchmark.ips with code to test. (no strings yet)
  • Not able to manually change the number of iterations
@Teino1978-Corp
Teino1978-Corp / README.md
Created November 20, 2015 00:11
Happy Numbers

Implementations of Happy Numbers

Haskell

Simple recursive version that stores the previous steps in the sequence in an array, and checks for duplicates to detect cycles.

Can get up to 250,000,000 numbers in ~5s, with no memoisation:

$ time ./happy_numbers 350000000