Skip to content

Instantly share code, notes, and snippets.

// Simple function to send Weekly Status Sheets to contacts listed on the "Contacts" sheet in the MPD.
// Load a menu item called "Project Admin" with a submenu item called "Send Status"
// Running this, sends the currently open sheet, as a PDF attachment
function onOpen() {
var submenu = [{name:"Send Status", functionName:"exportSomeSheets"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu('Project Admin', submenu);
}
function exportSomeSheets() {
@nachokb
nachokb / sendxbmc.sh
Last active August 29, 2015 14:09 — forked from dataolle/sendxbmc.sh
#!/bin/bash
#set url and port to the xbmc box webservice
XBMC_HOST="http://127.0.0.1:8080"
if [ "$1" = "" ]; then
echo -n "Insert URL: "
read url
else
url="$1"
fi

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
@nachokb
nachokb / test_ar.rb
Last active March 8, 2016 05:16 — forked from manno/test_ar.rb
issue 18061
# rails/rails#18061
# env vars: AR_VERSION (see below for default), TRY_PATCH (default false)
system 'rm Gemfile' if File.exist?('Gemfile')
$ar_version = ENV['AR_VERSION']
# $ar_version ||= '5.0.0.beta3' # succeeds, patch does not apply (lacks #where_values)
$ar_version ||= '4.2.6' # fails, patch works
# $ar_version ||= '4.1.15' # fails, patch works
# $ar_version ||= '4.0.13' # fails, patch works
@nachokb
nachokb / test_ar.rb
Last active August 29, 2015 14:11
issue 18062
system 'rm Gemfile' if File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'activerecord',
'4.2.0.rc3'
# '4.1.8'
# '4.0.12'
# '3.2.21'
gem 'sqlite3'
GEMFILE
@nachokb
nachokb / ar_merge_joins_hmt.rb
Last active February 21, 2017 20:07
ActiveRecord: #merge with joins and a has_many :through creates redundant INNER JOINs and postgresql does not like those
system 'rm Gemfile' if File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'activerecord',
'5.0.1'
# '4.2.0'
# '4.1.8'
# '4.0.12'
# '3.2.21'
gem 'sqlite3'
@nachokb
nachokb / centos-scaleway.md
Last active March 16, 2017 07:11
Instruction for running CentOS 6.7 on Scaleway's C2
  1. create a scaleway instance, let's call it centos-builder
  2. Ubuntu Trusty on a C2S is ok
  3. make sure to add an additional 50gb volume Screenshot_from_2016-03-11_02-19-22
  4. upload centos-root.fsa to centos-builder
  5. install FSArchiver
  6. apt-get install fsarchiver
  7. extract it on /dev/nbd1
  8. fsarchiver -v restfs centos-root.fsa id=0,dest=/dev/nbd1
  9. shut the machine down from Scaleway's web UI
# rubocop:disable Style/DotPosition
# rubocop:disable Style/GlobalVars
# test Rails 5's ActiveRecord OR
system 'rm Gemfile' if File.exist?('Gemfile')
$ar_version = ENV['AR_VERSION']
$ar_version ||= '5.0.0.rc1'
$try_patch = ENV['TRY_PATCH'] == 'true'
$enable_byebug = false

Keybase proof

I hereby claim:

  • I am nachokb on github.
  • I am icarrera (https://keybase.io/icarrera) on keybase.
  • I have a public key ASDkdxSLvI2S5paYWtFSnT6Z-XTZRtTKKGg0H6Lpo__E4wo

To claim this, I am signing this object: