Skip to content

Instantly share code, notes, and snippets.

View xtornasol512's full-sized avatar

Jesús Alvarado Garzón xtornasol512

View GitHub Profile
@xtornasol512
xtornasol512 / datetime_scripts_for_python.md
Last active July 4, 2018 15:44
Python Datetime scripts
# This give you the last day of the month given on second index
from calendar import monthrange
monthrange(2012, 2)
>>> (2, 29)
import datetime
alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@xtornasol512
xtornasol512 / VagrantFile
Created May 24, 2018 20:15
New Vagrant Project Files
# -*- mode: django -*-
# vi: set ft=python :
# Module to know the host platform
# Based on BernardoSilva's answer in http://stackoverflow.com/questions/26811089/vagrant-how-to-have-host-platform-specific-provisioning-steps
module OS
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.linux?
@xtornasol512
xtornasol512 / Console tips
Created May 7, 2018 18:30
Console tips for Bash
#!/usr/bin/env bash
if [ -d "./chuko" ]; then
echo "WOlolo"
else
echo "wtf!?"
fi

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@xtornasol512
xtornasol512 / Burn USB tools on MAc
Created January 30, 2018 20:10
Example of burn USB on mac
diskutil list
diskutil partitionDisk /dev/disk1 1 "Free Space" "unused" "100%"
sudo dd bs=1m of=/dev/rdisk1 if=manjaro-kde-17.0-stable-x86_64.iso
''' Method to connect to a database url(URI) with psycopg2 '''
import os
import psycopg2
import urlparse # import urllib.parse for python 3
result = urlparse.urlparse(os.environ["DATABASE_URL"])
username = result.username
password = result.password
database = result.path[1:]
@xtornasol512
xtornasol512 / join_csvs.py
Last active October 30, 2017 17:44
Join Csv files in the same directory
'''
Script for join CSV
author: @xtornaso5l2
'''
import os
files = os.listdir(os.curdir)
# ['.DS_Store', 'download (1).csv', 'download (2).csv', 'download.csv']
files.remove('.DS_Store') # Only for mac
# ['download (1).csv', 'download (2).csv']
@xtornasol512
xtornasol512 / scrapping_users_data.js
Last active October 30, 2017 17:39
Scrapping data users user sessions time on Google analytics
// _GAZeb Id de Cliente
// _GAvi Parent Element (days)
// _GAOyb Fecha (date)
// _GAMI Hora (hour)
// Script to retrieve data from
// Create Data Sessions for clients
console.clear();
var sessions_client = []
// Get client ID
@xtornasol512
xtornasol512 / AnyFile2base64.py
Created October 3, 2017 23:44
Convert any file to base64 using base64 python standard library
''' Convert any file to base64 using base64 python standard library '''
import base64
with open('MyFile.ext', 'rb') as f:
# read file as binary and encode to base64
encoded_string = base64.b64encode(f.read())
with open('cer.base64', 'w') as f:
# write in a new file the base64
f.write(encoded_string)