Skip to content

Instantly share code, notes, and snippets.

View Pablo-Merino's full-sized avatar
🪛

Pablo Merino Pablo-Merino

🪛
View GitHub Profile
@Pablo-Merino
Pablo-Merino / config.ru
Created March 1, 2012 16:25
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
require "rails"
@Pablo-Merino
Pablo-Merino / count_lines.rb
Created March 10, 2012 12:23
Script to count the line numbers of all the files in the actual dir
total = 0
Dir["./**/*.*"].each do |f|
filenumber =%x{wc -l #{f}}.split.first
puts f+ " - "+count = filenumber
total = total + filenumber.to_i
end
puts "Total lines = #{total}"
@Pablo-Merino
Pablo-Merino / Gemfile
Created April 10, 2012 15:47
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@Pablo-Merino
Pablo-Merino / clear.rb
Created April 19, 2012 15:43
Clear screen on Ruby script
module Screen
def self.clear
print "\e[2J\e[f"
end
end
dispatch_queue_t myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(myQueue, ^{
[self performSelectorOnMainThread:@selector(someActionToUpdate:) withObject:an_object waitUntilDone:YES];
});
-(void)someActionToUpdate:(id)an_object {
// an_object can be any kind of type
}
$('.gallery_button a').click ->
console.log('y0')
def 😄(😡)
if 😡 == "😎"
puts "Yay UTF8!"
end
end
😛 = "😎"
😄 😛
# Configure touchpads to use xf86-input-synaptics X input driver
Section "InputClass"
Identifier "touchpad"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "synaptics"
Option "MinSpeed" "0.4"
Option "MaxSpeed" "1.0"
Option "AccelFactor" "0.0035"
Option "HorizScrollDelta" "6"
class Summarizer
def initialize(text)
@text = text
end
def summarize
summary = []
@Pablo-Merino
Pablo-Merino / pdf_compressor.rb
Last active August 29, 2015 14:10
Some scripts I wrote to help me in cutting and compressing a bunch of PDFs
require 'ruby-progressbar'
files = (1..10).to_a
dir = "./" # DIRECTORY WHERE THE PDFS ARE KEPT (the PDFs have to be named pdf-#.pdf)
progressbar = ProgressBar.create(:format => '%a %bᗧ%i %p%% %t', :progress_mark => ' ', :remainder_mark => '・', :starting_at => 0, :total => 21)
files.each do |i|
`pdf2ps pdf-#{i}.pdf pdf-#{i}.ps`
progressbar.increment
`ps2pdf pdf-#{i}.ps pdf-compressed-#{i}.pdf`