This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path of LibreOffice installation | |
cd /Applications/LibreOffice.app/Contents/MacOS | |
# General command | |
./soffice --headless --convert-to <extention> <path+file> | |
# Automatically convert all .odt files to pdf | |
./soffice --headless --convert-to pdf ~/Downloads/*.odt | |
# To specify an output folder you can add the --outdir option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mongoid | |
module DeepCloning | |
def deep_clone(attrs = {}, obj = nil) | |
returning obj || self.class.new do |o| | |
o.write_attributes(@attributes.merge(attrs).except("_id", "versions").except(*o.class.associations.keys)) | |
yield o if block_given? | |
o.save | |
@attributes.each_pair do |key, value| | |
next unless proxy = self.associations[key] | |
case proxy.association |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/projects/jruby ➔ gem install -v1.5.5 org.jruby.jruby-complete | |
Installing from Maven using install at /Users/headius/apache-maven-3.0/bin | |
Successfully installed org.jruby.jruby-complete-1.5.5-java | |
1 gem installed | |
Installing ri documentation for org.jruby.jruby-complete-1.5.5-java... | |
Installing RDoc documentation for org.jruby.jruby-complete-1.5.5-java... | |
~/projects/jruby ➔ gem install -v1.5.3 org.jruby.jruby-complete | |
Installing from Maven using install at /Users/headius/apache-maven-3.0/bin | |
Successfully installed org.jruby.jruby-complete-1.5.3-java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IndexUsersEmails < ActiveRecord::Migration | |
def self.up | |
execute "END" | |
add_pg_index :users, :email, :lock => false | |
execute "BEGIN" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Watchable | |
def events | |
@events ||= Hash.new { |h,k| h[k] = [] } | |
end | |
def fire event, *args | |
events[event].each { |e| e[*args] } | |
end | |
def on event, &block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultiValue < BasicObject | |
attr_reader :secondary | |
def initialize(obj, *secondary) | |
@obj, @secondary = obj, secondary | |
end | |
def method_missing(sym, *args, &block) | |
@obj.__send__(sym, *args, &block) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
java_import java.nio.channels.FileChannel | |
java_import java.nio.file.StandardOpenOption | |
java_import java.nio.file.FileSystems | |
path = FileSystems.default.get_path('/') | |
option = StandardOpenOption::READ | |
ch = FileChannel.open(path, option) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example JRuby program to display the JVM's available locales | |
# and their number, currency, and date formats. | |
# | |
# Keith R. Bennett, @keithrbennett | |
require 'java' | |
java_import 'java.util.Locale' | |
java_import 'java.text.DateFormat' | |
java_import 'java.text.NumberFormat' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# Can ruby have method names have newlines/be crazy? | |
class BadKitty | |
FACE = " | |
|\\_/| | |
/ @ @ \\ | |
( > º < ) | |
`>>x<<´ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put the file into spec/support | |
shared_examples_for "ActiveModel" do | |
include ActiveModel::Lint::Tests | |
# to_s is to support ruby-1.9 | |
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| | |
example m.gsub('_',' ') do | |
send m | |
end | |
end |
OlderNewer