Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan García juanvgarcia

View GitHub Profile
@juanvgarcia
juanvgarcia / install_ruby.sh
Created Apr 23, 2014
Shell script to install Ruby from a newly installed Vagrant VM.
View install_ruby.sh
#!/bin/sh
sudo apt-get update
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install ruby 2.1.0
@juanvgarcia
juanvgarcia / require js snippet
Created Mar 5, 2014
Snippet for require function calls
View require js snippet
<snippet>
<content><![CDATA[require('$1')]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>req</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<!-- Optional: Description to show in the menu -->
<description>Require JS</description>
</snippet>
@juanvgarcia
juanvgarcia / Polyglot HTML Gist
Created Mar 3, 2014
Snippet so we don't go crazy adding the polyglot <%t %> everywhere! Provided by @lustercr
View Polyglot HTML Gist
<snippet>
<content><![CDATA[<%t '$1' %>]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>ts</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<!-- Optional: Description to show in the menu -->
<description>Polyglot HTML</description>
</snippet>
@juanvgarcia
juanvgarcia / Polyglot JS Snippet
Created Mar 3, 2014
Snippet so we don't go crazy adding polyglot.t everywhere
View Polyglot JS Snippet
<snippet>
<content><![CDATA[polyglot.t('$1')]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>ps</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<!-- Optional: Description to show in the menu -->
<description>Polyglot JS</description>
</snippet>
@juanvgarcia
juanvgarcia / PhoneNumberEditor.js
Last active Jan 2, 2016
This code will add a "PhoneNumber" custom editor for Backbone Forms. The formatting function was taken from: https://github.com/groupme/jquery-format-phone/blob/master/src/format_phone_input.js, and you could replace it as needed.
View PhoneNumberEditor.js
Backbone.Form.editors.PhoneNumber = Backbone.Form.editors.Text.extend({
initialize: function(options) {
Backbone.Form.editors.Text.prototype.initialize.call(this, options);
this.$el.on('keyup', function(e){
var input = $(e.currentTarget);
input.val(input.val().replace(/[^\d]/g, ''));
var digits = input.val();
if (e.which == 8 && digits.length <= 3) {
return;
@juanvgarcia
juanvgarcia / change_interfaces.sh
Created Nov 13, 2013
Script I use to change the static network configuration for a VM (I have different network configs for home/work). This script will expect comments of the form #work config start or #home config start to mark each configuration section. I complement it with two alias that include sudo on ~/.bash_profile.
View change_interfaces.sh
#!/bin/sh
if [ "$1" != "work" ] && [ "$1" != "home" ];
then
echo "Wrong arguments Usage: $0 home|work"
exit $E_BADARGS
fi
interface_file='/etc/network/interfaces'
work_config_start=`grep -n "#work config start" $interface_file | awk -F':' '{print $1}'`
@juanvgarcia
juanvgarcia / change_hosts.sh
Created Oct 30, 2013
This a very simple script that will comment host names depending on their initial numbering. My home network setup is different than my home's, and therefore I use this script to change the hostnames I use for development testing purposes.
View change_hosts.sh
#!/bin/sh
if [ "$1" != "work" ] && [ "$1" != "home" ];
then
echo "Wrong arguments Usage: $0 home|work"
exit 65
fi
work_test_regex="^10"
home_test_regex="^192"