Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
@kivanio
kivanio / a4-css-page-template.markdown
Created March 20, 2019 13:36
A4 CSS page template

Building a Facebook application with Rails and hosting it in Heroku

Introduction

Facebook has given a big step in simplicity with its Graph API and the creation of the Open Graph protocol, now more than ever it's easier to read and write data from and to the socalled social graph.

You could turn your webpage into a fully-featured Facebook-like page, just like if you were inside Facebook, you can give your users the ability to sign in with their Facebook credentials, customize your users' experience with parameters taken from their Facebook profiles, you could add a Like button to every object in your page as images, songs, articles, etc., tell your users which friends of theirs have liked your content, and a lot of things more, oh, I forgot to mention something, all of this with total ease. Yes, I know you could do it with Facebook Connect, but I said "with ease".

import UploadAdapter from './upload_adapter';
function CustomUploadAdapterPlugin( editor ) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
// Configure the URL to the upload script in your back-end here!
return new UploadAdapter( loader, editor );
};
}
import { Controller } from "stimulus"
@kivanio
kivanio / token.rb
Created December 22, 2016 17:53 — forked from GregBaugues/token.rb
Google API OAuth 2.0 refresh token (Ruby on Rails)
# The OAuth access token provided by the Google API expires in 60 minutes. After expiration,
# you must exchange a refresh token for a new access token. Unfortunately, the the Google API
# ruby gem does not include a method for refreshing access tokens.
# You can read up on how to refresh an access token here:
# https://developers.google.com/accounts/docs/OAuth2WebServer#refresh
# This Token model implements that process. It's based off of a Token model that can be created
# by running:
# rails g model Token token:text refresh_token:string expires_at:datetime
@kivanio
kivanio / audit_table.sql
Created October 19, 2022 19:59 — forked from djheru/audit_table.sql
Example audit table and trigger function for Postgresql
CREATE TABLE audit_log (
username text, -- who did the change
event_time_utc timestamp, -- when the event was recorded
table_name text, -- contains schema-qualified table name
operation text, -- INSERT, UPDATE, DELETE or TRUNCATE
before_value json, -- the OLD tuple value
after_value json -- the NEW tuple value
);
CREATE OR REPLACE FUNCTION audit_trigger()

Integers

1 + 1
2 * 2
5 / 3
5 % 3
5 ** 2
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@kivanio
kivanio / unused_routes.rb
Created May 23, 2022 12:24 — forked from strzibny/unused_routes.rb
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
@kivanio
kivanio / README.md
Created April 4, 2022 12:45 — forked from NikiforovAll/README.md
Postgres + RabbitMQ + Seq

Developer Setup

This repository is intended for bootstrapping developer environment.

@kivanio
kivanio / alert-manager.md
Created April 4, 2022 12:43 — forked from nicosingh/alert-manager.md
A small and local configuration for Prometheus + AlertManager + Slack notifications + Unsee

TL;DR

Clone this repo:

git clone https://gist.github.com/08be6d6e7605a43fe52d1f201c2b47d8.git
cd 08be6d6e7605a43fe52d1f201c2b47d8

Start the docker stack: