Skip to content

Instantly share code, notes, and snippets.

View leandroh's full-sized avatar
:shipit:
To deploy or not to deploy?

Leandro Pará leandroh

:shipit:
To deploy or not to deploy?
View GitHub Profile
full_name = "Leandro Parazito"
name_list = full_name.split()
greeting_list = "Hi, I'm x".split()
# Get last item in greeting_list
greeting_list[-1] = name_list[0]
greeting = " ".join(greeting_list)
@leandroh
leandroh / timeapi.py
Created August 18, 2014 12:14
get current date and time from a reliable external resource
import requests
url = 'http://www.timeapi.org/pdt/in+four+hours'
hours = requests.get(url)
hours.content
@leandroh
leandroh / lxml_install.sh
Last active August 29, 2015 14:05
install Python LXML on ubuntu
#/usr/bin/env /bin/sh
aptitude install libxml2-dev libxslt1-dev python-dev
aptitude install python-lxml
@leandroh
leandroh / script.js
Created August 18, 2014 17:55
The code is obfuscated and deobfuscates to: document.createElement('script')
document.createElement('s&!c&#^)r^#(!i)@p#&t&)&^'.replace(/\(|\)|&|@|\$|\^|\!|#/ig, ''));
@leandroh
leandroh / encoding.py
Created August 22, 2014 20:56
If you are from another country, and you get errors about ASCII encodings, then put this at the top of your Python scripts:
# -*- coding: utf-8 -*-
# It will fix them so that you can use Unicode UTF-8 in your scripts without a problem.
@leandroh
leandroh / ip_address.sh
Last active August 29, 2015 14:06
how to find your ip address
#/usr/bin/env /bin/sh
ifconfig eth0 | grep inet | awk '{ print $2 }'
@leandroh
leandroh / absolute_path.sh
Last active August 29, 2015 14:07
(ba)sh script absolute path
#/usr/bin/env /bin/sh
$( cd "$(dirname "$0")" ; pwd -P )
@leandroh
leandroh / post_json_with_curl.sh
Created November 6, 2014 12:28
POST JSON data with Curl
#!/bin/sh
curl -H "Content-Type: application/json" -d '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login
@leandroh
leandroh / home-ctrl.js
Created January 19, 2015 13:23
AngularJS Controller
(function() {
var Controller;
Controller = (function() {
function Controller($scope) {
$scope.hello = 'Hello!';
}
return Controller
})();
@leandroh
leandroh / pt_BR.js
Created January 27, 2015 16:24
An ISO 8601 description of a date-time combination is <date>T<time>. For example, 1985-04-12T23:20:50+02:00 is 23:20:50 on 1985-04-12 in the time zone that is 2 hours ahead of UTC.
Date.prototype.toISO8601CombinedDateTime = function() {
return this.getFullYear() +
'-' + pad(this.getMonth() + 1) +
'-' + pad(this.getDate()) +
'T' + pad(this.getHours()) +
':' + pad(this.getMinutes()) +
':' + pad(this.getSeconds()) +
'-' + ('0' + (this.getTimezoneOffset() / 60)).slice(-2) +
':00';
};