Skip to content

Instantly share code, notes, and snippets.

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@alandotcom
alandotcom / logstash-mysql-query-parse.md
Created November 15, 2016 00:46 — forked from jordansissel/logstash-mysql-query-parse.md
parsing mysql's bullshit query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '

@alandotcom
alandotcom / multiple_ssh_setting.md
Created October 28, 2016 20:06 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@alandotcom
alandotcom / jq.konami.js
Created November 6, 2012 02:05 — forked from adamcbrewer/jq.konami.js
JS: Konami Code
// Konami code with jQuery.
// Source: http://paulirish.com/2009/cornify-easter-egg-with-jquery/
var kkeys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(evt) {
kkeys.push( evt.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ){
$(document).unbind('keydown',arguments.callee);
@alandotcom
alandotcom / card.rb
Created October 21, 2012 18:52 — forked from dbc-challenges/card.rb
FlashCardinator
class Card
attr_reader :term, :definition
def self.load(filename,cards = [])
File.new(filename).each do |card|
card = card.split("\t")
cards << Card.add_card(card)
end
cards
end
require './binary'
describe 'binary_search' do
let(:int_ary) { (100..200).to_a }
let(:strg_ary) { %w{ swedish\ chef miss\ piggy scooter gnu animal foo-foo }.sort }
let(:one_elemnt_ary) { [0] }
it 'returns correct index' do
binary_search(135,int_ary).should eq 35
binary_search('miss piggy',strg_ary).should eq 3
# Put your answers here!
rvm rubies
jruby-1.6.8 [ x86_64 ]
ruby-1.8.6-p420 [ i686 ]
ruby-1.8.7-p370 [ i686 ]
=* ruby-1.9.3-p194 [ x86_64 ]
@alandotcom
alandotcom / gist:3724382
Created September 14, 2012 20:06 — forked from schneems/gist:2968840
Databases and Rails Recap Quiz for Week 2
## Week 3 Quiz
## 1) What does ORM stand for?