Skip to content

Instantly share code, notes, and snippets.

View yorch's full-sized avatar

Jorge Barnaby yorch

  • SentinelOne
  • Miami, FL
View GitHub Profile
@greypants
greypants / README.markdown
Last active October 17, 2023 05:49 — forked from reagent/nav_link.rb
RAILS 3: nav_link helper for adding 'selected' class to navigation elements
@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
@i-scorpion
i-scorpion / README.txt
Created June 18, 2012 12:24
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
@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)
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@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" />
@betamatt
betamatt / Procfile
Created January 26, 2012 23:29
Running delayed_job with foreman
queue: ./queue.sh
@joequery
joequery / gist:1607063
Created January 13, 2012 15:49
Convient bash functions for managing nginx and Unicorn
# Kill and restart nginx
function restart_nginx(){
pids=$(pidof nginx)
if [[ -n $pids ]];
then
sudo kill -9 $pids
sudo service nginx restart
fi
}
@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;
@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