Skip to content

Instantly share code, notes, and snippets.

@ylansegal
ylansegal / example.rb
Last active Apr 13, 2022
Expose difference in behaviour in MRI vs JRuby
View example.rb
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>
View consumer.rb
require "bundler/inline"
require 'yaml'
# require 'pry'
require "./person"
gemfile do
source "https://rubygems.org"
gem 'ruby-kafka'
end
View run_changed_specs
#!/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 Aug 30, 2017 — forked from gshutler/update-rbenv-rubygems.sh
Update Rubygems for all rbenv rubies
View update-rbenv-rubygems.sh
#! /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 Jan 12, 2016
Profilling Jruby 1.7.23 and JRuby 9.0.4.0
View sample_meat_of_controller_action.txt
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
View delayed_job.rb
# config/initializer/delayed_job.rb
Thread.new { Delayed::HardenedWorker.new.start }
@ylansegal
ylansegal / README.md
Created Jun 11, 2013 — forked from Dehalion/README.md
BTSync Setup
View README.md

####Go to temp dir $ cd /tmp ####Download your version of btsync i386 or x64 $ curl http://btsync.s3-website-us-east-1.amazonaws.com/btsync_i386.tar.gz -o btsync.tar.gz # i386 $ curl http://btsync.s3-website-us-east-1.amazonaws.com/btsync_x64.tar.gz -o btsync.tar.gz # x64 ####Then unpack this shit $ tar -xf btsync.tar.gz ####And move to your local bin $ sudo mv btsync /usr/local/bin/ ####Create a user and a group named btsync and give it a home folder

@ylansegal
ylansegal / gist:4272448
Created Dec 12, 2012 — forked from fantactuka/gist:1887133
Sass compilation -> Programatically
View gist:4272448
require "sass"
require "compass"
def compile_sass(sass_file)
sass_dir = File.dirname(sass_file)
compass_dir = File.join(Compass.base_directory, "frameworks/compass/stylesheets")
css_dir = File.join(File.dirname(__FILE__), 'css')
Sass.compile(File.read(sass_file), :syntax => :scss, :load_paths => [sass_dir, compass_dir, css_dir])
end
@ylansegal
ylansegal / example.rb
Created Mar 18, 2015
Use Thread.current
View example.rb
>> 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>
>>
View pie_test.csv
Country Likness
USA 50
Mexico 25
Canada 25
India 50