Skip to content

Instantly share code, notes, and snippets.

View marianposaceanu's full-sized avatar

Posăceanu Marian marianposaceanu

View GitHub Profile
# we're using the TmpIO class
# -*- encoding: binary -*-
# :stopdoc:
require 'tmpdir'
# some versions of Ruby had a broken Tempfile which didn't work
# well with unlinked files. This one is much shorter, easier
# to understand, and slightly faster.
class TmpIO < File
# creates and returns a new File object. The File is unlinked
require 'json'
# r, w = IO.pipe
# w << 'secret'
# w << ' message'
# w.close_write
# r.read #=> "secret message"
# if fork
# wr.close
@marianposaceanu
marianposaceanu / ebooks.md
Created December 22, 2011 16:53 — forked from roidrage/ebooks.md
Self-published and awesome
@marianposaceanu
marianposaceanu / visualization_in_js.md
Created December 24, 2011 00:36 — forked from entaroadun/visualization_in_js.md
Visualization using Javascript on Github

Data visualization in one of three most important steps in data mining (https://github.com/entaroadun/hnpickup). Often times, it's impossible to understand data without proper visualization. I went looking for great tools to do that.

Two website list recent JS visualization frameworks:

Most of them are available on Github. My three favorite:

@marianposaceanu
marianposaceanu / useful_windows_7_tweaks.md
Last active September 29, 2015 19:08
useful_windows_7_tweaks

Windows 7 Tweaks

The analysis will take 60 seconds (which you can change with the optional - duration switch), after which powercfg will save its report as an HTML file on your desktop. Just double-click output.html to view the report.

powercfg -energy -output %userprofile%\desktop\output.html

Enabling this setting will prevent Windows from paging certain system processes to disk

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management

DisablePagingExecutive // Values: 0 = disabled (default), 1 = enabled.

class Lisp
def initialize
@env = {
:label => lambda { |(name,val), _| @env[name] = val },
:quote => lambda { |sexpr, _| sexpr[0] },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), _| l == r },
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
@marianposaceanu
marianposaceanu / for_vs_each.rb
Created February 3, 2012 16:38
let_the_benchmarks_begin.rb
# For vs. each
# Results:
#
# user system total real
# 0.340000 0.000000 0.340000 ( 0.341422)
# 0.310000 0.000000 0.310000 ( 0.326168)
require 'benchmark'
n = 500000
@marianposaceanu
marianposaceanu / rvm_lion_x_code_4_2_1.md
Created February 7, 2012 16:57
rvm_lion_x_code_4_2_1.md

Install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
function' >> ~/.bash_profile

Install GCC 4.2

Grab and unpack the tarball

$ mkdir ~/tmp && cd ~/tmp

@marianposaceanu
marianposaceanu / mac_tips.md
Created February 13, 2012 10:46
mac_tips.md

Disable dashboard (free ram and stuff)

defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock

Purge RAM (tip: install xcode 1st)

In terminal > purge # then wait

@marianposaceanu
marianposaceanu / eventmachine.rb
Created February 27, 2012 08:38 — forked from joshuasiler/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {