Skip to content

Instantly share code, notes, and snippets.

View gcollazo's full-sized avatar

Giovanni Collazo gcollazo

View GitHub Profile
@gcollazo
gcollazo / keychain.py
Created March 8, 2014 16:35
Python methods to interact with Mac OS X Keychain
import re
import os
def getpassword(service, account):
def decode_hex(s):
s = eval('"' + re.sub(r"(..)", r"\x\1", s) + '"')
if "" in s: s = s[:s.index("")]
return s
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>magicFields</title>
<style type="text/css" media="screen">
.inlineLabel{
{
"id":"6ce4a00a-677d-4265-8144-4873d3d0075d",
"url":"https://api.filepreviews.io/v2/previews/6ce4a00a-677d-4265-8144-4873d3d0075d/",
"status":"success",
"preview":{
"original_size":{
"width":"1280",
"height":"1024"
},
"page":1,
@media (max-width: 320px) {
body { background-color: red; }
}
@media (min-width: 321px ) and (max-width: 375px) {
body { background-color: blue; }
}
@media (min-width: 376px ) and (max-width: 425px) {
body { background-color: orange; }
export default class ValueObject {
private readonly value: string;
constructor(value: string) {
if (!value) {
throw new ValidationError("ValueObject value cannot be empty");
}
this.value = value;
}
@gcollazo
gcollazo / fabfile.py
Created July 28, 2010 17:16 — forked from onyxfish/fabfile.py
Sample fabfile.py
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
@gcollazo
gcollazo / components.my-component.js
Created November 28, 2018 16:33
remove-capture-attr
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
this._super(...arguments);
this.element.querySelector('input[type="file"]').removeAttribute('capture');
}
});
@gcollazo
gcollazo / 01-run.sh
Last active April 12, 2018 11:48
Testing npm5
# curl -s https://gist.githubusercontent.com/gcollazo/93853987c5e1fa362494315478cd0608/raw/01-run.sh | bash
echo ""
mkdir testnpmyanrnpm5
cd testnpmyanrnpm5
curl -s https://gist.githubusercontent.com/gcollazo/93853987c5e1fa362494315478cd0608/raw/npm-test.sh | bash
curl -s https://gist.githubusercontent.com/gcollazo/93853987c5e1fa362494315478cd0608/raw/yarn-test.sh | bash
cd ..

tmux cheat sheet

  • tmux -CC attach iTerm to tmux
  • tmux new -A -s <session-name> creates a new named session or attaches to that session if already exists
  • control + b - commands
    • creates a horizontal pane
    • % creates a vertical pane
    • q shows pane numbers, if you hit the number on the keyboard you will change to that pane
    • o moves between panes
  • x kills the current pane, exit command also works