Skip to content

Instantly share code, notes, and snippets.

View larruda's full-sized avatar

Lucas Arruda larruda

View GitHub Profile
@larruda
larruda / settings.php
Created July 25, 2013 01:53
Drupal database settings for using on Amazon Web Services (AWS) environment with Amazon RDS and Amazon EC2.
<?php
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => $_SERVER['RDS_DB_NAME'],
'username' => $_SERVER['RDS_USERNAME'],
'password' => $_SERVER['RDS_PASSWORD'],
@larruda
larruda / organizeFiles.sh
Created July 25, 2013 19:22
Shell script used to organize files by date in a directory tree. Tested and used on Mac OS X.
#!/bin/bash
function navigateRecursively {
currentDirectory=$1
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
BASEPATH=$2
i=0
#echo $currentDirectory
#!/bin/bash
#
# Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/
# release 1 PHP5.4 to 5.3 by Emil Terziev ( foxy ) Bulgaria
# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories:
echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
@larruda
larruda / jenkins
Created October 9, 2013 12:39
Jenkins standalone (Winstone) init script.
#!/bin/sh
DESC="Jenkins CI Server"
NAME=jenkins
RUN_AS=jenkins
HTTP_PORT=8281
LOGFILE=/var/log/jenkins.log
COMMAND="nohup /usr/bin/java -Dsvnkit.http.sslProtocols=\"SSLv3\" -jar /home/jenkins/jenkins.war --httpPort=$HTTP_PORT > $LOGFILE 2>&1 &"
d_start() {
@larruda
larruda / subversion_installer_1.8.sh
Created December 16, 2013 10:53
Install Subversion 1.8.5 on Ubuntu 13.x (from WANDisco)
#!/bin/bash
#
# WANdisco Subversion install script.
# Copyright (C) 2013 WANdisco plc
#
# Please contact opensource@wandisco.com if you have any problems with this
# script.
set -e
@larruda
larruda / .htaccess
Created December 31, 2013 15:42
10 .htaccess code snippets you must have in hand.
# Accompanies this blog post:
# http://www.seomoz.org/blog/htaccess-file-snippets-for-seos
# NOTE: This file isn't designed to be used all together, some of the rules will conflict,
# it is meant more as a copy and paste board.
# IMPORTANT: Make sure you test .htaccess changes thoroughly, as it can be easy to make mistakes
# and then you end up in a bad place!
RewriteEngine On
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "your@email.to.match" ]
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
catch(e){
t = 0;
@larruda
larruda / forksync.sh
Last active August 29, 2015 14:03
Syncs a forked repository against its upstream.
#!/bin/sh
git_repo=$1
[ -z "$git_repo" ] && git_repo="."
cd $git_repo > /dev/null 2>&1
if [ $? -ne 0 ]; then
printf "Invalid directory path.\n"
exit 1
fi
@larruda
larruda / unquoted_json_fix.js
Last active November 22, 2022 09:49
REGEX to add quotes to JSON unquoted keys (turns an invalid JSON into a valid one).
json_string.replace(/(\s*?{\s*?|\s*?,\s*?)(['"])?([a-zA-Z0-9]+)(['"])?:/g, '$1"$3":');
eval('var json = new Object(' + json_string + ')');