Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.
This file contains hidden or 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
# This works for me in 1.9.3-p125 but not in p194. | |
# Can anyone explain why? | |
require 'net/http' | |
http = Net::HTTP.new("theclymb1.campfirenow.com", 443) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
request = Net::HTTP::Get.new("/login") | |
response = http.request(request) | |
raise response.inspect if response.code != '200' |
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
This file contains hidden or 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
# Updated for Ruby 2.3 | |
string_t = None | |
def get_rstring(addr): | |
s = addr.cast(string_t.pointer()) | |
if s['basic']['flags'] & (1 << 13): | |
return s['as']['heap']['ptr'].string() | |
else: | |
return s['as']['ary'].string() |
This file contains hidden or 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
> pp ENV.select {|x| x =~ /^RUBY/ } | |
{"RUBY_GC_HEAP_GROWTH_FACTOR"=>"1.3", | |
"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR"=>"1.3", | |
"RUBY_GC_HEAP_INIT_SLOTS"=>"600000", | |
"RUBY_GC_MALLOC_LIMIT"=>"90000000", | |
"RUBYOPT"=>"-rbundler/setup", | |
"RUBYLIB"=> | |
"/usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib"} |
This file contains hidden or 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
# This pattern avoids serializing a large object (the Task) to Redis, whilst | |
# avoiding passing a low-level data type (the id) into the constructor. | |
# You might choose to call TaskJob.new(task) directly elsewhere (e.g. tests) | |
class TaskJob | |
def self.perform(id) | |
new(Task.find(id)).perform | |
end | |
def initialize(task) |
This file contains hidden or 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
import httplib2 | |
import argparse | |
import json | |
import mysql.connector | |
import time | |
import sys | |
import itertools | |
from joblib import Parallel, delayed | |
from apiclient.discovery import build |