Skip to content

Instantly share code, notes, and snippets.

View carlosbaraza's full-sized avatar
🤔
Thinking

Carlos Baraza carlosbaraza

🤔
Thinking
View GitHub Profile
@carlosbaraza
carlosbaraza / node_upgrade.sh
Last active August 29, 2015 14:14
Upgrade Node.js
#!/bin/bash
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
@carlosbaraza
carlosbaraza / keybase.md
Created October 16, 2015 14:48
Keybase GitHub account ownership proof

Keybase proof

I hereby claim:

  • I am carlosbaraza on github.
  • I am carlosbaraza (https://keybase.io/carlosbaraza) on keybase.
  • I have a public key whose fingerprint is 6192 4568 011B 783B F205 6E12 C373 4787 7B7C 8F36

To claim this, I am signing this object:

@carlosbaraza
carlosbaraza / bench_rails_memory_usage.rb
Created January 8, 2016 10:31 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@carlosbaraza
carlosbaraza / hello_world.rb
Created July 17, 2018 13:55
puts 'Hello World'
puts 'Hello, world!'
def my_method(a, b, c=15, d=35, *p, e)
puts ["a: #{a}",
"b: #{b}",
"c: #{c}",
"d: #{d}",
"p: #{p.inspect}",
"e: #{e}"].join(', ')
end
status = 'reopened'
status = 'closed' if status =~ /(opened|reopened)/
deep_symbolize_keys = lambda do |hash|
return hash unless hash.is_a?(Hash)
Hash[ hash.map do |key, value|
# if value is array, loop each element and recursively symbolize keys
if value.is_a? Array
value = value.map { |element| symbolize_keys.call(element) }
# if value is hash, recursively symbolize keys
elsif value.is_a? Hash
value = symbolize_keys.call(value)
@carlosbaraza
carlosbaraza / index.html
Last active April 29, 2019 16:01
Hopefully simple WebAssembly starting guide - index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
html,
body {
height: 100%;
margin: 0;
overflow: hidden;
@carlosbaraza
carlosbaraza / main.js
Last active April 29, 2019 16:01
Hopefully simple WebAssembly starting guide - main.js
// Set up the canvas with a 2D rendering context
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const boundingClientRect = canvas.getBoundingClientRect();
canvas.width = boundingClientRect.width | 0;
canvas.height = boundingClientRect.height | 0;
// Compute the size of the universe (here: 2px per cell)
const width = boundingClientRect.width >>> 1;
const height = boundingClientRect.height >>> 1;
@carlosbaraza
carlosbaraza / gulpfile.js
Last active April 29, 2019 15:43
Hopefully simple WebAssembly starting guide - gulpfile.js
const gulp = require('gulp');
gulp.task('build', callback => {
const asc = require('assemblyscript/bin/asc');
asc.main(
[
'main.ts',
'--baseDir',
'assembly',
'--binaryFile',