Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@orbitaloop
orbitaloop / executeSqlBridgeForPhonegapSQLitePlugin.js
Created March 10, 2012 01:03
executeSql Bridge For PhonegapSQLitePlugin (because there are some differences between the WebSQL API and the plugin)
/* to use WebSQL or the SQLite plugin (https://github.com/davibe/Phonegap-SQLitePlugin) with the same function) */
executeSqlBridge: function(tx, sql, params, dataHandler, errorHandler) {
var self = this;
if (typeof self.db.dbPath !== 'undefined') {
//Native SQLite DB with phonegap : https://github.com/davibe/Phonegap-SQLitePlugin/
//this is a native DB, the method signature is different:
var sqlAndParams = [sql].concat(params);
var cb = function(res) {
@mcshakes
mcshakes / Rails C error.
Created October 14, 2016 23:45
Running into RVM and readline issues
$ rails c
Running via Spring preloader in process 7916
/Users/edmac/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': dlopen(/Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Reason: image not found - /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Fixed with:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
@smukkejohan
smukkejohan / nagios
Created February 6, 2012 19:07
Nagios with Nginx configuration
server {
listen 80;
server_name nagios.example.tld;
access_log /var/log/nginx/nagios.access.log;
error_log /var/log/nginx/nagios.error.log info;
expires 31d;
root /usr/share/nagios3/htdocs;
@ileitch
ileitch / gist:1459987
Created December 11, 2011 11:08
Interruptible sleep in Ruby
module InterruptibleSleep
def interruptible_sleep(seconds)
@_sleep_check, @_sleep_interrupt = IO.pipe
IO.select([@_sleep_check], nil, nil, seconds)
end
def interrupt_sleep
@_sleep_interrupt.close if @_sleep_interrupt
end
end
@alexlee002
alexlee002 / xcplugin_update.sh
Created April 11, 2015 19:50
Auto update Xcode plugins to support new version of Xcode
#!/bin/sh
PLUGINS_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
XCODE_INFO_PATH=$(xcode-select -p)
XCODE_INFO_PATH=$(dirname "$XCODE_INFO_PATH")/Info
DVTPlugInCompatibilityUUID=$(defaults read "$XCODE_INFO_PATH" DVTPlugInCompatibilityUUID)
for plugin in "$PLUGINS_DIR"/*.xcplugin; do
plugin_info_path="$plugin/Contents/Info"
if [[ -f "$plugin_info_path.plist" ]]; then
@ged
ged / copyfrom.rb
Created September 28, 2010 15:45
Example of how to use COPY FROM from Ruby with the 'pg' library. The last two edits are demonstrating the error case and the successful case.
#!/usr/bin/env ruby
require 'pg'
require 'stringio'
$stderr.puts "Opening database connection ..."
conn = PGconn.connect( :dbname => 'test' )
conn.exec( <<END_SQL )
DROP TABLE IF EXISTS logs;
@mraaroncruz
mraaroncruz / iam_admin_policy.json
Last active September 10, 2018 13:32
S3 Policies
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
@kzkin
kzkin / phoenix-app.service
Last active October 30, 2018 19:16
systemd service for phoenix framework release (exrm)
# Phoenix Framework - A productive web framework that does not compromise speed and maintainability
[Unit]
Description=Phoenix Framework ISControl Application
After=network.target
[Service]
Type=simple
User=deployer
RemainAfterExit=yes
@mraaroncruz
mraaroncruz / ethereum.rb
Created November 8, 2018 12:24
Use your key with a contract in ruby
key = Eth::Key.new(priv: YOUR_PRIVATE_KEY)
client = Ethereum::HttpClient.new(...)
client.default_account = key.address
contract = Ethereum::Contract.create(...)
contract.key = key
@flavio
flavio / gemfile_lock2geminabox.rb
Created February 2, 2012 09:21
Parse Gemfile.lock, download all gems from rubygems and then upload them to a local instance of geminabox
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'uri'
TMP_DIR = "/tmp/gems"