Skip to content

Instantly share code, notes, and snippets.

View cristiangrojas's full-sized avatar

Cristian Rojas cristiangrojas

View GitHub Profile
@cristiangrojas
cristiangrojas / go24.bash
Created December 7, 2018 15:48
iTerm2 command to open required tabs for my project
function go24 () {
osascript &>/dev/null <<EOF
set commands to {"cd /Users/cristianrojas/www/24mm_react; npm start", "cd /Users/cristianrojas/www/24mm_react; npm test", "cd /Users/cristianrojas/www/24mm_react; git status"}
set commands to commands & {"workon api_24mm; sh run.sh", "workon api_24mm; sh celery.sh", "workon api_24mm; sh beat.sh", "workon api_24mm; git status"}
tell application "iTerm2"
repeat with command in commands
tell current window to create tab with default profile
tell current session of current window to write text command
end repeat
end tell
@cristiangrojas
cristiangrojas / server.js
Created August 3, 2018 16:22
Simple server in Express.js for create-react-app build copy
const express = require('express');
const bodyParser = require('body-parser')
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build-copy', 'index.html'));
});
# Tavtrac API Docs
## Login
Post user credentials in to Login endpoint to get `auth_token` data. the user is required to be `School Admin`.
With the auth_token data, you must send that token in the [HTTP Authorization request header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) with this sintax
**Example**
```Javascript
"Authorization": "Token {auth_token}"
@cristiangrojas
cristiangrojas / gist:dd983d833cf35199c59355c3a229a1f3
Last active August 30, 2017 20:17
Generate .pem file to authenticate to a virtual private server
# We're going to setup a new ssh-key on our server in order to login into it with a .pem file.
ssh-keygen -b 1024 -f [key-name] -t rsa
# If you don't have an .ssh folder, create it, then add your public key to the list of authorized_keys
cat totto.pub >> .ssh/authorized_keys
# Then copy the contents of the private file (not .pub) into a .pem file in your computer
@cristiangrojas
cristiangrojas / ckeditor with django-flatpages
Created April 12, 2014 15:35
Using ckeditor with django-flatpages
#-*- coding: utf-8 -*-
from django import forms
from django.contrib import admin
from django.contrib.flatpages.admin import FlatpageForm, FlatPageAdmin
from django.contrib.flatpages.models import FlatPage
from ckeditor.widgets import CKEditorWidget
class CkeditorFlatpageForm(FlatpageForm):
content = forms.CharField(widget=CKEditorWidget())
@cristiangrojas
cristiangrojas / Don't prompt user for password whit sudo
Last active August 29, 2015 13:56
Don't require password for X user in Ubuntu
# Type in the console:
sudo visudo
# Then add the following line to the document and save it
# Replace [username] with your username
[username] ALL=(ALL) NOPASSWD: ALL
@cristiangrojas
cristiangrojas / Reload Grunt.js
Last active December 24, 2015 18:09
Reload grunt when Gruntfile.js or package.json changed
Meanwhile, a workaround is to restart watch when Gruntfile.js is modified. Here is a quick hack to do it.
Set the "nospawn" option of watch to true.
Add the following task in your Gruntfile.js:
grunt.registerTask('exit', 'Just exits.', function() {
process.exit(0);
});
Put this as a target of your watch:
@cristiangrojas
cristiangrojas / gist:6529477
Created September 11, 2013 20:40
grunt restart watch
Meanwhile, a workaround is to restart watch when Gruntfile.js is modified. Here is a quick hack to do it.
Set the "nospawn" option of watch to true.
Add the following task in your Gruntfile.js:
grunt.registerTask('exit', 'Just exits.', function() {
process.exit(0);
});
Put this as a target of your watch:
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
@cristiangrojas
cristiangrojas / to add the postgis template:
Created June 2, 2013 00:30
to add the postgis template:
to add the postgis template:
cd /usr/local/Cellar/postgis/2.0.0/share/postgis/
createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsql
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
psql -d template_postgis -f postgis.sql
psql -d template_postgis -f spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"