Skip to content

Instantly share code, notes, and snippets.

@ylansegal
ylansegal / consumer.rb
Last active April 2, 2020 23:22
Kafka POC
require "bundler/inline"
require 'yaml'
# require 'pry'
require "./person"
gemfile do
source "https://rubygems.org"
gem 'ruby-kafka'
end
@ylansegal
ylansegal / run_changed_specs
Last active March 9, 2018 17:56
Ruby dev scripts
#!/usr/bin/env bash
set -e
if [ $1 ];
then
BRANCH=${1:-"develop"}
shift # Get rid of first parameters, which should not pass on to smart_rspec
else
@ylansegal
ylansegal / update-rbenv-rubygems.sh
Created August 30, 2017 17:07 — forked from gshutler/update-rbenv-rubygems.sh
Update Rubygems for all rbenv rubies
#! /usr/bin/env bash
set -e
eval "$(rbenv init -)"
for version in `rbenv whence gem`; do
rbenv shell "$version"
echo "Updating rubygems for $version"
gem update --system --no-document --quiet
@ylansegal
ylansegal / sample_meat_of_controller_action.txt
Created January 12, 2016 01:04
Profilling Jruby 1.7.23 and JRuby 9.0.4.0
This file has been truncated, but you can view the full file.
Total time: 0.62
%total %self total self children calls name
---------------------------------------------------------------------------------------------------------
100% 0% 0.62 0.00 0.62 1 (top)
0.59 0.00 0.59 1/1 UserDecorator#to_client_api_resources_hash
0.01 0.00 0.01 1/2096 Class#new
0.01 0.00 0.01 1/79 ActiveSupport::Dependencies::ModuleConstMissing.const_missing
0.00 0.00 0.00 1/2 Repo::Oauthorization::GeneratedAssociationMethods.user
---------------------------------------------------------------------------------------------------------
@ylansegal
ylansegal / example.rb
Last active November 26, 2022 05:08
Expose difference in behaviour in MRI vs JRuby
require 'nokogiri'
puts "Ruby: #{RUBY_DESCRIPTION}"
puts "Nokogiri: #{Nokogiri::VersionInfo.instance.to_hash['nokogiri']}"
puts
schema = <<-SCHEMA
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name="addresses">
<xs:complexType>
@ylansegal
ylansegal / example.rb
Created March 18, 2015 21:55
Use Thread.current
>> Thread.current[:your_variable] = 3
=> 3
>> puts Thread.current[:your_variable].to_i + 1
4
=> nil
>> Thread.new { puts Thread.current[:your_variable].to_i + 1 }.join
1
=> #<Thread:0x007fa68d94d870@(irb):18 dead>
>>
@ylansegal
ylansegal / pie_test.csv
Last active August 29, 2015 14:08
Sample CSV
Country Likness
USA 50
Mexico 25
Canada 25
India 50
@ylansegal
ylansegal / players.txt
Created June 30, 2014 15:49
World Cup 2014 Players Database
Alan PULIDO Mexico 08/03/1991 5 4
Adam TAGGART Australia 02/06/1993 4 3
Reza GHOOCHANNEJAD Iran 20/09/1987 13 9
NEYMAR Brazil 05/02/1992 48 31
Didier DROGBA Ivory Coast 11/03/1978 100 61
David VILLA Spain 03/12/1981 95 56
Abel HERNANDEZ Uruguay 08/08/1990 12 7
Javier HERNANDEZ Mexico 01/06/1988 61 35
Islam SLIMANI Algeria 18/06/1988 19 10
Shinji OKAZAKI Japan 16/04/1986 75 38
@ylansegal
ylansegal / 0_reuse_code.js
Created May 16, 2014 20:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ylansegal
ylansegal / gist:8979417
Created February 13, 2014 17:13
Gosu gem installation fails on Riby 2.0.0
➜ ~ rvm use 2.0.0
Using /Users/ylansegal/.rvm/gems/ruby-2.0.0-p353
➜ ~ gem i gosu
Building native extensions. This could take a while...
ERROR: Error installing gosu:
ERROR: Failed to build gem native extension.
/Users/ylansegal/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
The Gosu gem requires some libraries to be installed system-wide.