Skip to content

Instantly share code, notes, and snippets.

@cpinto
cpinto / gist:2833617e2e34bbcd84a9487840c60d0c
Created May 24, 2018 19:59
RoR freelancer requirements
Backend dev
AWS infrastruture
* bonus: terraform scripting
Ruby on Rails
* bonus: experience with v5.2
* bonus: experience with:
* rspec
* code quality tools like rubocop
* webpack, vue.js, ES6 and standard Rails asset pipeline
@cpinto
cpinto / intl_contacts
Created May 25, 2017 12:13
This here script fixes phone numbers in Mac contacts to include international prefixes. Good when you move elsewhere.
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText
@cpinto
cpinto / intl_contacts
Created May 25, 2017 12:13
This here script fixes phone numbers in Mac contacts to include international prefixes. Good when you move elsewhere.
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText
@cpinto
cpinto / django_decorators.py
Created February 19, 2011 14:58
a collection of django decorators
from django.contrib import admin
def AutoManaged(clazz):
""" The AutoManaged decorator can be used on model classes which you want to have available
on the administration site with the stock admin forms.
Example usage:
@AutoManaged
class MyModel(models.Model):
@cpinto
cpinto / mysql_drop_all_tables
Created February 16, 2011 00:28
drop all tables from a specific mysql database
mysql --silent --skip-column-names -u <username> -p<password> <database> -e "show tables" | awk '{ print "drop table " $1 ";"}' | mysql -u <username> -p<password> <password>
@cpinto
cpinto / nginx_macosx_installer.sh
Created January 6, 2011 00:01
A script that installs nginx on a MacOS X system
#!/bin/bash
SCRIPT_DIR="`cd $(dirname $0);pwd`"
NGINX_VERSION="0.8.54"
PCRE_VERSION="8.01"
INSTALL_PREFIX="$SCRIPT_DIR/binaries"
DOWNLOAD_DIR="/tmp/src"
LD_LIBRARY_PATH="$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH"
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- This software application is Twitter-Ware. If you like it,
use it, or have something to say, follow and tell me on Twitter
at @codemonkeyism
http://twitter.com/codemonkeyism
Blog at http://www.codemonkeyism.com
Webssite http://www.simple-kanban.com
See MIT license at bottom.
@cpinto
cpinto / mustache_xpath_partials.js
Created October 4, 2010 18:21
Read the top comments
/*
* Q: What is this?
* A: A sample file that uses mustache to render a single html tmeplate (including partials) on the serverside but keeps those partials intact so that they can be used by the client-side as well (ie. browser)
*
* Q: How is this useful?
* A: To you, I have little idea. I'm doing this because I want to be able to fully render a page on the server and then refresh parts of it on the client, while reusing the widget presentation code. As the widget code is in the file, I just have to bring in mustache.js, fetch new data, and have it render the parts I need to update. And I'd like to keep it all in a single file also.
*
* Q: Isn't that template code broken?
* A: Yes. I'll come back to it as I plan to patch Mu to support xpath partials natively.
* */
<html>
<head><title>wonderstache</title></head>
<body>
<script type="text/x-mustache-yadayada" name="widgetTemplate1">
<div id="notComplicatedWidget">
{{ name }}
</div>
</script>
<div id="widgetContainer">
{{>//script[name=widgetTemplate1]}}
#!/bin/bash
SVN_USERNAME=$1
GIT_REPO=$2
SVN_TRUNK_REPO=$3
if [ -z $1 ]; then
echo "Usage: $0 SVN_USERNAME GIT_REPO SVN_TRUNK_REPO"
exit 1
fi
git svn clone --username $SVN_USERNAME $SVN_TRUNK_REPO