Skip to content

Instantly share code, notes, and snippets.

Working from home

Rodolfo Silva RodolfoSilva

Working from home
View GitHub Profile
RodolfoSilva / snowflake-id.sql
Created Jan 9, 2021 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
View snowflake-id.sql
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
our_epoch bigint := 1314220021721;
seq_id bigint;
RodolfoSilva /
Created May 4, 2020 — forked from subfuzion/
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

View CurrencyPtBrInputFormatter.dart
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
class CurrencyPtBrInputFormatter extends TextInputFormatter {
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if(newValue.selection.baseOffset == 0){
return newValue;
RodolfoSilva / django_field_update_checker.txt
Created Nov 20, 2019 — forked from alican/django_field_update_checker.txt
check if django model fields changed after save
View django_field_update_checker.txt
def DjangoModel(models.Model):
def from_db(cls, db, field_names, values):
instance = super().from_db(db, field_names, values)
instance._state.adding = False
instance._state.db = db
instance._old_values = dict(zip(field_names, values))
return instance
View react-file-upload.js
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
this.state ={
View mask.ts
import {Directive, Attribute} from '@angular/core';
import {NgModel} from '@angular/common';
selector: '[mask]',
host: {
'(keyup)': 'onInputChange()'
export class Mask {
maskPattern: string;
RodolfoSilva / spotify_keybindings
Created Nov 16, 2016 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key.
View spotify_keybindings
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
RodolfoSilva / .gitignore
Created Jun 6, 2016 — forked from bergie/.gitignore
Node.js email handling examples
View .gitignore
RodolfoSilva / object_create.js
Created Apr 29, 2016 — forked from badsyntax/object_create.js
Simple prototypal inheritance in node.js
View object_create.js
/* This shows how to use Object.create */
/** BASE MODEL **********************************/
function BaseModel(collection) {
this.collection = collection;
BaseModel.prototype.getCollection = function() {
return this.collection;
RodolfoSilva / custom-error.js
Created Apr 28, 2016 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
View custom-error.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor); =;
this.message = message;
this.extra = extra;
require('util').inherits(module.exports, Error);