Skip to content

Instantly share code, notes, and snippets.

View danielribeiro's full-sized avatar

Daniel Ribeiro danielribeiro

View GitHub Profile
@danielribeiro
danielribeiro / Rakefile
Last active August 27, 2015 08:15 — forked from alloy/Rakefile
A Rakefile that standardises program env installation and guides the user, as opposed to crashing with Ruby exceptions such as `LoadError`. The only case where this will *never* work reliably is if you use the `rubygems-bundler` (NOEXEC) plugin, which introduces chicken-and-egg problems.
# Do *not* load any libs here that are *not* part of Ruby’s standard-lib. Ever.
desc "Install all dependencies"
task :bootstrap do
if system('which bundle')
sh "bundle install"
sh "git submodule update --init"
# etc
else
$stderr.puts "\033[0;31m[!] Please install the bundler gem manually: $ [sudo] gem install bundler\e[0m"
#!/bin/sh
#
# Adam Sharp
# Aug 21, 2013
#
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`.
#
# Does the inverse of `git submodule add`:
# 1) `deinit` the submodule
# 2) Remove the submodule from the index and working directory
@danielribeiro
danielribeiro / mynewprod.d
Created November 6, 2015 00:35
unlimited newprod.d
#!/usr/sbin/dtrace -s
/*
* newproc.d - snoop new processes as they are executed. DTrace OneLiner.
*
* This is a DTrace OneLiner from the DTraceToolkit.
*
* 15-May-2005 Brendan Gregg Created this.
*/
/*
@danielribeiro
danielribeiro / gist:f4dcaf4b56a5621450ac
Created March 21, 2016 22:43 — forked from sonsongithub/gist:2868639
Parse Xcode project file, project.pbxproj, in Ruby.
json = JSON.parse(`plutil -convert json -o - "#{filename}"`)
@danielribeiro
danielribeiro / timeout.rb
Created April 4, 2016 23:23 — forked from lpar/timeout.rb
Run a shell command in a separate thread, terminate it after a time limit, return its output
# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses Kernel.select to wait up to the tick length (in seconds) between
# checks on the command's status
#
# If you've got a cleaner way of doing this, I'd be interested to see it.
# If you think you can do it with Ruby's Timeout module, think again.
def run_with_timeout(command, timeout, tick)
output = ''
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
require 'json'
require 'ostruct'
require 'pp'
str = { woo: [ 1, 2, 3], yay: { foo: true, bar: ["42", 2, {}] } }.to_json
pp JSON.parse(str, object_class: OpenStruct).yay.bar
@danielribeiro
danielribeiro / extensing_string.go
Created October 18, 2016 18:54
extensing_string.go
package main
import (
"fmt"
)
type MyString string
func (s MyString) plusa() MyString {
return s + "a"
@danielribeiro
danielribeiro / gist:70da0d180d4b44230cde09972623ef70
Created October 27, 2016 23:01 — forked from jedi4ever/gist:7677d62f1414c28a1a8c
Some notes on travisci remote debugging via ssh or screenshot or remote desktop of Mac VM builds
Some notes on remote debugging mac builds on Travisci. It's hard to tell when something hangs what the cause it. Trial and error via commits is tedious. And on Mac , sometimes it's the gui asking for input. So I worked my around to get the access I needed for faster debugging a build.
#################################################
# Enable remote ssh access to travisci build for debugging
#################################################
# Add a key so we can login to travisci vm
- cat ssh/travisci.pub >> ~/.ssh/authorized_keys
- chmod 600 ssh/travisci
# Install netcat