Skip to content

Instantly share code, notes, and snippets.

@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@jeroenvandijk
jeroenvandijk / rails_test_box_prepackaged.sh
Created May 4, 2010 16:32
Instructions for setting up the prepackaged Rails test environment
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
@tmilewski
tmilewski / railscasts.rb
Created January 2, 2011 09:37
Download all Railscasts Episodes
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = open('http://railscasts.com/') { |f| Hpricot(f) }
total_episodes = (doc/'div.number').first.inner_html[1,3].to_i
total_pages = (total_episodes / 10).ceil
(1..total_pages).each do |i|
puts "PAGE #{i} ================================"
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@mikehaertl
mikehaertl / vimrc.local
Last active February 18, 2021 14:44
A global vim configuration on Ubuntu that uses Vundle. Just put it in /etc/vim/vimrc.local and follow the instructions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" /etc/vim/vimrc.local V1.1.12 2019-07-30 https://gist.github.com/mikehaertl/1612035
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" A Vundle based Vim configuration with globally shared plugins on Ubuntu.
"
" This is a Vundle based Vim setup that keeps all plugins in a global
" directory, namely /etc/vim/bundle. It's trimmed towards PHP development
" with Yii.
"
@madeye
madeye / ProxySettings.java
Created April 4, 2012 01:53
Set proxy for Android Webview
package me.madeye;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.http.HttpHost;
import android.content.Context;
@D3xx73r
D3xx73r / deploy.rb
Created April 30, 2012 20:48
Capistrano deploy file
require "bundler/capistrano"
# Define your server here
server "<server>", :web, :app, :db, primary: true
# Set application settings
set :application, "<app_name>"
set :user, "<deployment_user>" # As defined on your server
set :deploy_to, "/home/#{user}/apps/#{application}" # Directory in which the deployment will take place
set :deploy_via, :remote_cache
@romannurik
romannurik / SwipeDismissListViewTouchListener.java
Last active May 1, 2021 10:16
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
Moved to
https://github.com/romannurik/android-swipetodismiss
@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@janih
janih / gist:4536956
Created January 15, 2013 07:37
A Java class to determine image width, height and color depth for a number of image file formats. Written by Marco Schmidt
/*
* ImageInfo.java
*
* Version 1.9
*
* A Java class to determine image width, height and color depth for
* a number of image file formats.
*
* Written by Marco Schmidt
*