Skip to content

Instantly share code, notes, and snippets.

View yorch's full-sized avatar

Jorge Barnaby yorch

  • SentinelOne
  • Miami, FL
View GitHub Profile
@dmann
dmann / vpn_fix.sh
Last active August 29, 2015 14:21
#!/usr/bin/env bash
if [ -z $1 ]; then
docker_machine_count=`docker-machine ls -q | wc -l | sed 's/ //g'`
if [ $docker_machine_count == "1" ]; then
machine=`docker-machine ls -q`
elif [ $docker_machine_count == "0" ]; then
echo 'No docker machines were found with the following command:'
echo ' docker-machine ls -q'
exit
else
@roryf
roryf / Flash.cs
Created July 27, 2011 15:19
Flash message implementation for ASP.NET MVC
public class Flash : DynamicObject
{
private readonly TempDataDictionary _store;
private const string KeyPrefix = "Flash";
public Flash(TempDataDictionary store)
{
_store = store;
}
@rogercampos
rogercampos / example.rb
Created November 23, 2011 16:06
Retrying Hominid api calls due to EOFError
# Example of a DelayedJob that syncs info with mailchimp
class SyncMailchimp < Struct.new(:opts)
include Dobexer::ExceptionNotifier
def run_hominid(attempts = 0, &block)
attempts += 1
block.call
rescue EOFError => e
@joequery
joequery / nginx.conf
Created January 13, 2012 14:51
Nginx server configuration for use with Unicorn
worker_processes 1;
user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
http {
default_type application/octet-stream;
@betamatt
betamatt / Procfile
Created January 26, 2012 23:29
Running delayed_job with foreman
queue: ./queue.sh
@silasmontgomery
silasmontgomery / jquery.DyanmicElements.js
Created February 10, 2012 15:37
jQuery Plugin to Dyanmically Show/Hide, Enable/Disable, and Require/Not Elements based on Class names
/* Dynamic Elements v1.0
Show/hide, require/not require, and enable/disable fields based on checkboxes and select fields.
Class names: "lock" will disable an element, "hide" will hide an element, "need" will require an element.
Adding the ID of a checkbox as a class to an element will make it show/enabled/required:
i.e. <input type="checkbox" name="getName" id="getName" /> <input type="text" name="yourName" class="getName lock hide require" />
Adding the ID and value of a select field as a class to an element will make it show/enabled/required (format is 'ID-Value'):
i.e. <select name="getTitle" id="getTitle"><option>Mr</option><option>Mrs</option><option>Other</option> <input type="text" name="yourTitle" class="getTitle-Other lock hide require" />
@dmoulton
dmoulton / HstoreModel.rb
Created June 12, 2012 19:39 — forked from kfatehi/HstoreModel.rb
Hstore ActiveRecord::Base method_missing
## Hstore Method Missing Extension
module HstoreModel
def method_missing(method, *args, &block)
key = method.to_s.gsub('=','').to_sym
sym_options = options.symbolize_keys
if !self.class.attribute_methods_generated?
self.class.define_attribute_methods
if respond_to_without_attributes?(method)
send(method, *args, &block)
@yorch
yorch / .gitignore
Created July 17, 2012 16:09
.gitignore for ASP.Net MVC
###################
# http://stackoverflow.com/questions/639647/git-and-asp-mvc
###################
#
###################
# compiled source #
###################
*.com
*.class
*.dll
@KieranP
KieranP / orphaned_check.rake
Last active October 11, 2015 11:08
Rake task that scans all Rails models for orphaned belong_to associations (Rails 3.2 or higher)
task :orphaned_check => :environment do
Dir[Rails.root.join('app/models/*.rb').to_s].each do |filename|
klass = File.basename(filename, '.rb').camelize.constantize
next unless klass.ancestors.include?(ActiveRecord::Base)
orphanes = Hash.new
klass.reflect_on_all_associations(:belongs_to).each do |belongs_to|
assoc_name, field_name = belongs_to.name.to_s, belongs_to.foreign_key.to_s
@bripkens
bripkens / gist:3986755
Created October 31, 2012 12:22
Mercurial changeset summary as JSON file
#!/bin/bash
OUT="changesets.json"
echo "[" > $OUT
hg log | grep "^changeset:" | sed 's/changeset.*:/ "/g' | sed 's/$/",/g' | sed '$s/,$//' >> $OUT
echo ']' >> $OUT