Skip to content

Instantly share code, notes, and snippets.

View pedroteixeira's full-sized avatar

Pedro Henriques dos Santos Teixeira pedroteixeira

View GitHub Profile
@pedroteixeira
pedroteixeira / redis-info-to-json.sh
Created May 6, 2020 17:58
Format Redis Info to JSON
echo "info" | redis-cli | grep -v '^#' | grep -v -e '^[[:space:]]*$' | sed 's/\r//g' | jq --raw-input 'split(":")| {(.[0]): .[1]}' | jq -s add
@pedroteixeira
pedroteixeira / upload_passwords_to_firefox_sync_account.py
Created November 10, 2019 19:30
Export Google Chrome passwords to Firefox
#
# This is a little script to populate Firefox Sync with
# password exported from Google Chrome as csv. Use it like so:
#
# $> pip install PyFxA syncclient cryptography
# $> python ./upload_passwords_to_firefox_sync_account.py
#
# It will prompt for your Firefox Account email address and
# password, csv file and upload password records, then
# sync down and print all password records stored in sync.
@pedroteixeira
pedroteixeira / readme.md
Created October 16, 2018 14:20
coding challenge

Consider a information model where each record is represented by an immutable tuple. This tuple in this context is called a fact.

Example of a fact:

('john', 'age', 18, true)

In this representation, the subject (or entity) 'john' has a value of '18' associated with the attribute 'age'.

To represent a deletion (or retraction) of information, the fourth element of the tuple can be 'false' to indicate that the corresponding entity's attribute no longer has that value.

@pedroteixeira
pedroteixeira / bash
Last active September 26, 2018 16:37
Itau Guardiao Ubuntu 18
Baixe deb em http://www.dieboldnixdorf.com.br/warsaw/
(ou em http://guardiao.itau.com.br/warsaw/warsaw_setup_64.deb)
sudo apt install python python-openssl python-six python-cryptography python-gpg
sudo dpkg --ignore-depends=libcurl3 --ignore-depends=python-gpgme -i warsaw-setup-ubuntu_64.deb
sudo vi /usr/bin/warsaw
@pedroteixeira
pedroteixeira / prelude-js.el
Last active August 29, 2015 14:14
web-mode is not indenting correctly javascript (web-mode in jsx files)
(custom-set-variables
'(web-mode-attr-indent-offset nil)
'(web-mode-code-indent-offset 2)
'(web-mode-markup-indent-offset 2)
'(web-mode-indentation-params '("lineup-calls" . nil))
)
@pedroteixeira
pedroteixeira / onbeforeunload.js
Last active December 27, 2015 17:39
onbeforeunload support for js navigation (via hashchange, such as backbone.history, etc)
var cancelNavigate;
$(window).on("hashchange", function(ev) {
if(cancelNavigate) {
cancelNavigate = false;
return false;
}
if(window.onbeforeunload) {
var ok = confirm(window.onbeforeunload());
if(ok) {
window.onbeforeunload = null;
@pedroteixeira
pedroteixeira / robot.js
Created December 6, 2012 18:50
Zolmeister
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@pedroteixeira
pedroteixeira / gp.clj
Created September 24, 2012 01:08
gaussian process regression
(ns demo.gp
(:use (incanter core stats)))
(set! *warn-on-reflection* true)
(def X (matrix [-4 -3 -1 0 2]))
(def Y (matrix [-2 0 1 2 -1]))
(def X* (matrix (range -5 5 0.2040816)))
@pedroteixeira
pedroteixeira / console.rb
Created September 2, 2012 20:55
tip to test rails helper in console
class H; include MyHelper; end; h = H.new
@pedroteixeira
pedroteixeira / controller.rb
Created August 29, 2012 17:26
dynamic date+time acessors a datetime attribute in rails model
# and you can handle formating in your controller
def action
params[:start_at] = params[:start_at_date] + ' ' + params[:start_at_time]
params.delete :start_at_date
params.delete :start_at_time
end