Skip to content

Instantly share code, notes, and snippets.

View ddre54's full-sized avatar

David Rodas ddre54

View GitHub Profile
@ddre54
ddre54 / Timeout Interval
Created November 3, 2013 20:57
This is the timeout code to create an interval in JavaScript, taking care that the execution of each call to the interval will take more accurate the exactly amount of time specified in the timer
(function(){
// do some stuff
setTimeout(arguments.callee, 60000);
})();
@ddre54
ddre54 / command_mac_osx.sh
Last active January 4, 2016 20:59
Mac OS: Check in which port is an running an application
# Command shows in which port is an application running
lsof -i -P | grep nginx
# Find programs running by port they are using
sudo lsof -i:80
@ddre54
ddre54 / guide.sh
Created February 4, 2014 22:14 — forked from teamon/guide.sh
Pow + nginx configuration aka give me back my 80 port! - teamon/guide.sh
# Install pow
$ curl get.pow.cx | sh
# Install powder
$ gem install powder
# See that firewall is fucked
$ sudo ipfw show
00100 0 0 fwd 127.0.0.1,20559 tcp from any to me dst-port 80 in <- THIS ONE!!!
65535 81005 28684067 allow ip from any to any
#!/usr/bin/env ruby
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
@ddre54
ddre54 / .gitconfig
Created April 13, 2014 01:09
Git: Useful commands to add to .gitconfig
[alias]
unadd = reset HEAD
log-tree = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
commit-diff-with-remote = log @{u}...HEAD --graph --decorate --left-right --boundary --pretty=format:'%Cred%h%Creset %d %s %Cgreen(%cr)%Creset %Cblue[%an]%Creset' --abbrev-commit --date=relative
@ddre54
ddre54 / Preferences.sublime-settings
Created April 13, 2014 22:07
SublimeText 2 - User Preferences
{
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".tags*",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@ddre54
ddre54 / nginx.conf
Created April 17, 2014 16:39
NGINX configuration to detect and redirect unsupported browsers
# # IE 10 +
# # Firefox 27 +
# # Safari 7 +
# # iOS Safari 5 +
# # IE mobile 10 +
# # Android 4.2 +
# # Blackberry 10 +
# # Chrome 31+
#
@ddre54
ddre54 / .bashrc
Created April 18, 2014 14:35
Git: Displays current branch in the Terminal
# Add git branch to the prompt
# http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[34m\]\h:\W \$ \[\e[m\]"
export PS1
@ddre54
ddre54 / script.sh
Created June 9, 2014 17:42
Terminal pipe process pid into top
#!/bin/sh
top -pid $(ps -A | grep -m1 'unicorn worker' | awk '{print $1}')
@ddre54
ddre54 / redis_keys_clear_pattern_matching.lua
Last active December 13, 2020 16:23
Remove all the keys from redis matching a pattern
--Starting with redis 2.6.0, you can run lua scripts
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:*
--For big number of keys
EVAL "local keys = redis.call('keys', ARGV[1]) \n for i=1,#keys,5000 do \n redis.call('del', unpack(keys, i, math.min(i+4999, #keys))) \n end \n return keys" 0 prefix:*