Skip to content

Instantly share code, notes, and snippets.

View renatoargh's full-sized avatar
🚀

Renato Gama renatoargh

🚀
View GitHub Profile
@renatoargh
renatoargh / initial-implementation.js
Last active July 5, 2019 13:48
Refactor Session #1
asd.js
@renatoargh
renatoargh / small-query-builder.js
Last active June 7, 2019 09:20
A small query builder to help not writing SQL insert by hand
const withQuotes = (value, quote = '\'') => {
if (typeof value === 'undefined') {
return 'null'
}
if (value === null) {
return 'null'
}
return `${quote}${value}${quote}`
// CREATE TABLE realtime_table (id serial primary key, title varchar, year varchar, producer varchar);
// CREATE FUNCTION notify_trigger() RETURNS trigger AS $$
// DECLARE
// BEGIN
// PERFORM pg_notify('watch_realtime_table', row_to_json(NEW)::text);
// RETURN new;
// END;
// $$ LANGUAGE plpgsql;
// CREATE TRIGGER watch_realtime_table_trigger AFTER INSERT ON realtime_table
@renatoargh
renatoargh / prefixed-sum.js
Created October 28, 2018 18:24
sum: O(n), get sum of segment: O(1)
function prefixedSum(array) {
const sum = new Array(array.length + 1)
sum[0] = 0
for(let k = 1; k < sum.length; k++) {
sum[k] = (sum[k - 1] || 0) + array[k - 1]
}
return sum
}
https://www.npmjs.com/package/tls-keygen
@renatoargh
renatoargh / new-mac.md
Last active April 29, 2022 05:34
New Mac Installation Checklist

General

  • chrome
  • 1pass
  • intelliJ COMMUNITY (ou Ultimate)
  • vscode
    • enable settings sync with github
  • dropbox
  • spectable
  • skype
  • teamviewer
import logging
logging.basicConfig(filename='output.log', filemode='w', level=logging.WARNING)
logging.warning('poor man\'s debugging')
@renatoargh
renatoargh / redis-compare.sh
Last active March 14, 2018 21:36
Huge file comparision with redis (you better use linux `diff` instead)
#! /bin/bash
set -e
set -u
# redis-cli --raw FLUSHALL >/dev/null 2>%1; # uncomment to clear the database
function hash () {
printf %s "$1" | md5sum | cut -f1 -d' '
}
sudo sh -c "echo -n 'sammy:' >> /etc/nginx/.htpasswd"
sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
@renatoargh
renatoargh / look-ahead.js
Created February 14, 2018 03:42
look ahead
var regexp = /^\[(.*?(?=\]))\]/;