Skip to content

Instantly share code, notes, and snippets.

View robsalasco's full-sized avatar
🏠
Working from home

Roberto Salas robsalasco

🏠
Working from home
View GitHub Profile
@kohgpat
kohgpat / ruby_spreadsheet_example.rb
Created April 2, 2012 11:40
Ruby spreadsheet example
1 require 'spreadsheet'
# Open workbooks
current_workbook = Spreadsheet.open('jan.xls')
total_workbook = Spreadsheet.open('output.xls')
# Process xls
# Iterate through workbook spreadsheets
current_workbook.worksheets.each_with_index do |current_spreadsheet, spreadsheet_index|
@makevoid
makevoid / sinatrize.rb
Last active October 3, 2015 03:57
Sinatrize, generates a base sinatra app
# Sinatrize
# usage:
#
# mkdir -p yourapp
# cd yourapp
# wget https://gist.githubusercontent.com/makevoid/2385559/raw/1fc0355a04ed2153d74b06386048d1e1541a0706/sinatrize.rb # if you are not sure get the latest gist by clicking on [Raw]
# ruby sinatrize.rb
# rm -f sinatrize.rb
# bundle
@fujimura
fujimura / Gemfile
Created May 31, 2012 04:18
cross domain ajax sample to render html fragment
source "http://rubygems.org"
gem 'sinatra'
gem 'sinatra-jsonp'
@parkr
parkr / generator_scss.rb
Created June 5, 2012 13:19
Jekyll Plugin to output SCSS without requiring the "---" YAML Front Matter
#
# Jekyll Generator for SCSS
#
# (File paths in this description relative to jekyll project root directory)
# Place this file in ./_plugins
# Place .scss files in ./_scss
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
# Config file placed in ./_sass/config.rb
#
@joshuaflanagan
joshuaflanagan / watch_git.rb
Created June 27, 2012 01:10
See what's going on in your .git folder when you perform git commands
# I used this to monitor changes to the .git folder during
# my Austin on Rails lightning talk on Understanding Git.
#
# I ignore any changes to the .git/logs folder, because they are
# noisy and don't add a lot to understanding.
# If you want "the whole truth", remove the :ignore parameter below.
#
# ruby listen.rb <path to .git folder>
#
# gem install listen # its the foundation of Guard
@dentarg
dentarg / pdf-reader.rb
Created July 11, 2012 13:39
Convert a PDF to text, HTML and XML with various tools
#!/usr/bin/env ruby
require 'pdf-reader'
infile=ARGV[0]
outfile=ARGV[1]
reader = PDF::Reader.new(infile)
text = ""
reader.pages.each do |page|
@alexfish
alexfish / stringCleaner.rb
Created July 12, 2012 14:36
Cleans carrige returns in strings to \n characters for pasting into Xcode localizable.strings file
string = ARGV.first
string = string.gsub(/\n/,"\\n")
file = File.new("output.txt", "w")
file.write(string)
file.close
@lucascaton
lucascaton / reinstall.sh
Last active April 29, 2024 00:26 — forked from tomas-stefano/reinstall.sh
Reinstalling MySQL 5.x on macOS via Homebrew
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql
@dsparks
dsparks / Marimekko.R
Created September 23, 2012 14:34
Simplest marimekko/mosaic plot
# Simplest possible marimekko/mosaic plot
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("vcd", "ggplot2", "RColorBrewer")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
theme_set(theme_gray(base_size = 7))
# All you need to start with is individual count data, and a grouping variable
@evenchange4
evenchange4 / controller.rb
Created October 1, 2012 06:44
ROR RSS parse
# encoding: UTF-8
require 'uri'
require 'feedzirra'
require 'open-uri'
class LivefeedController < ApplicationController
def livefeed
q = '宏達電'
url = URI.escape("https://news.google.com/news/feeds?q="+q+"&output=rss&num=90")