Skip to content

Instantly share code, notes, and snippets.

View cdparra's full-sized avatar
🤔
Calculating next move...

Cristhian Parra cdparra

🤔
Calculating next move...
  • University of California, Berkeley
  • Berkeley, California
View GitHub Profile
@cdparra
cdparra / Google spreadsheet custom formula for formatting example
Created August 24, 2017 13:47
Snippet on how to use custom formula INDIRECT in spreadsheets for conditional formatting
=INDIRECT("SheetName!"&ADDRESS(row();column()))="VALUE"
@cdparra
cdparra / railsapp
Created December 3, 2016 05:29
RAILS init script sample
#!/bin/sh
CMD="/usr/local/bin/rails"
CMD_ARGS='server -p 5000'
APP_DIR='/path/to/railsapp/home';
PID_FILE=$APP_DIR/app.pid
LOG_FILE=$APP_DIR/app.log
set -e
@cdparra
cdparra / gruntapp
Created December 3, 2016 05:25
Init script for grunt apps
#!/bin/sh
APP_DIR='/path/to/gruntapp/home';
CMD="/usr/local/bin/grunt"
CMD_ARGS="server --base $APP_DIR --gruntfile $APP_DIR/Gruntfile.js"
PID_FILE=$APP_DIR/app.pid
LOG_FILE=$APP_DIR/app.log
USER="appuser"
GROUP="appgroup"
set -e
@cdparra
cdparra / filter-rename-delete.sh
Last active October 19, 2015 22:05
Filter files in a directory, list other with similar name but slight pattern change and then remove them
# Filter files that contains (1) in their names (copies). Remove this from the name and then use this delete the original files
ls *.jpg | cut -d. -f1 | cut -d"(" -f1 | awk '{print $1".JPG"}' | xargs rm
#!/bin/sh
### BEGIN INIT INFO
# Provides: appname
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts appname server
# Description: starts appname server using start-stop-daemon
@cdparra
cdparra / gist:9076350
Created February 18, 2014 18:08
Command for compress pdfs with ghostscript
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=foo-compressed.pdf foo.pdf
@cdparra
cdparra / rename.sh
Last active January 2, 2016 16:39
Simple shell command to rename a batch of files (i.e., *.JPG to *.jpg)
for i in *.JPG; do mv "$i" `basename "$i" .JPG`.jpg; done
@cdparra
cdparra / person.json
Created November 22, 2013 14:33
Simple Person model for assignment 2 in IntroSDE 2013
{
"firstname" : "Pinco",
"lastname" : "Pallino",
"birthdate" : "1984-06-21"
"healthProfile" : {
"weight" : 78.9,
"height" : 172
}
}
@cdparra
cdparra / jQueryCustomHeader
Created August 8, 2013 15:23
jQuery add custom header requests (to be used on $(document).ready)
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader("PLAY_SESSION", sessionKey);
}
});
@cdparra
cdparra / gist:6111666
Created July 30, 2013 09:49
Example of Javascript code for LOGIN with a hashed password, using our an authentication service based on email/password
var sessionData = new Object;
sessionData.email = $("#email").val();
sessionData.password = $.sha1($("#password").val();
$.ajax({
type: "POST",
url: "/login",
data: JSON.stringify(sessionData),
async: false,
success: function (data) {
alert("ok");