Skip to content

Instantly share code, notes, and snippets.

Avatar

Pedro Henriques dos Santos Teixeira pedroteixeira

View GitHub Profile
View redis-info-to-json.sh
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 Nov 10, 2019
Export Google Chrome passwords to Firefox
View upload_passwords_to_firefox_sync_account.py
#
# 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.
View readme.md

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 Sep 26, 2018
Itau Guardiao Ubuntu 18
View bash
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 Aug 29, 2015
web-mode is not indenting correctly javascript (web-mode in jsx files)
View prelude-js.el
(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 Dec 27, 2015
onbeforeunload support for js navigation (via hashchange, such as backbone.history, etc)
View onbeforeunload.js
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;
View robot.js
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 Sep 24, 2012
gaussian process regression
View gp.clj
(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 Sep 2, 2012
tip to test rails helper in console
View console.rb
class H; include MyHelper; end; h = H.new
@pedroteixeira
pedroteixeira / controller.rb
Created Aug 29, 2012
dynamic date+time acessors a datetime attribute in rails model
View controller.rb
# 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
You can’t perform that action at this time.