Skip to content

Instantly share code, notes, and snippets.

@zaeleus
zaeleus / shirt_big_18.rb
Created May 6, 2011 04:01
Ole Miss ACM t-shirt design in Ruby
#!/usr/bin/env ruby
def a(m );print (m); end;
require 'zlib' ;eval(%w(c ='#'; s=32.
chr;f="\n"; j=4;i= [25, 20,14,8,3,3,j,j,5
,5,6];a (s*3 0+c*4+ s*11+c*4+f);p=-1
;[28 ,38, 50 ,62 ,72].each{|n|a(s *i[
p+=1 ]+c *n +f) ;}; w=['c 1bxji 7',' 9ixq z9b'
,'7k 1eptf', '76 zemy2' ,'qoi m0x'] .map {|g| g.to_ i(36)
.to_ s(2) };[2,3 ]. eac h{|h |w[h ]='0 '+w[ h]};w[ 4]=('0
diff --git a/kernel/bootstrap/string.rb b/kernel/bootstrap/string.rb
index a6f066f..d26370c 100644
--- a/kernel/bootstrap/string.rb
+++ b/kernel/bootstrap/string.rb
@@ -1,5 +1,14 @@
# -*- encoding: us-ascii -*-
+module Rubinius
+ module String
+ def self.to_dbl(str, strict)
def self.coerce_to_float(obj, strict=false)
case obj
when Numeric
coerce_to obj, Float, :to_f
when Float
return obj
when String
result = Rubinius.invoke_primitive :string_to_f, obj, strict
raise ArgumentError, "invalid value for Float" if result.nil?
result
n = 5_000_000
puts Benchmark.measure { n.times { Float("9.0") } }
puts Benchmark.measure { n.times { "9.0".to_f } }
@zaeleus
zaeleus / gitlab_centos6.txt
Created December 23, 2012 08:04
Gitlab install on CentOS 6.3 (2012-09-13)
-- install packages
# yum update
# yum groupinstall "Development Tools" "Additional Development"
-- epel for redis, libyaml, pip, qtwebkit-devel
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
# yum install libicu-devel libyaml-devel redis wget python-pip qt-devel qtwebkit-devel
-- install ruby
From 2587a13c97b654175d7cf68f2b969d37d42c5fea Mon Sep 17 00:00:00 2001
From: Michael Macias <[email protected]>
Date: Wed, 13 Mar 2013 15:42:34 -0500
Subject: [PATCH] Add NArray#map alias for NArray#collect
---
narray.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/narray.c b/narray.c
@zaeleus
zaeleus / rps.rb
Last active December 24, 2015 00:49
Rock-paper-scissors code golf solution to <https://icpcarchive.ecs.baylor.edu/external/40/4065.pdf>. 168 characters.
M=%w[R S P];S=STDIN;S.gets.to_i.times{t=0;S.gets.to_i.times{i,j=S.gets.split.map{|a|M.index(a)};M[i-2]==M[j]?t+=1:M[i]!=M[j]&&t-=1};puts t==0?"TIE":"Player #{t>0?1:2}"}
source 'https://rubygems.org'
gem 'sinatra', '~> 1.4.5'
gem 'ffi-gphoto2', '~> 0.5.0'
@zaeleus
zaeleus / acmhash.rs
Last active August 29, 2015 14:07
Rust solution to the fall 2014 University of Mississippi ACM hashing competition
// Michael Macias <[email protected]>
// created 2014-10-02, updated 2014-10-13
// rust 0.12.0
// MIT license (http://opensource.org/licenses/MIT)
//
// acmhash.rs is a Rust solution to the fall 2014 University of Mississippi
// ACM hashing competition (http://micha.elwillia.ms/). The goal is to find
// an input so that the SHA-256 cryptographic hash function produces a digest
// with the most leading zeros. For example, the word "mismatchment" has 4
// leading zeros.
require 'shrine'
require 'shrine/storage/memory'
Shrine.storages = {
cache: Shrine::Storage::Memory.new,
store: Shrine::Storage::Memory.new
}
class DocumentUploader < Shrine
plugin :determine_mime_type