Skip to content

Instantly share code, notes, and snippets.

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

Marco Rojo mrmarcondes

🏠
Working from home
View GitHub Profile
@mrmarcondes
mrmarcondes / homework5.js
Created November 30, 2012 19:48
10gen: M101 MongoDB for Developers - Homework 5.1 - 5.4
// homework 5.1
db.posts.aggregate([
{$project: {"_id": 0,
"comments.author": 1
}},
{$unwind: "$comments"},
{$group: {"_id": "$comments.author",
sum: {"$sum": 1}
}},
{$sort: {"sum": -1}},
@mrmarcondes
mrmarcondes / question2.js
Created December 11, 2012 21:05
10gen: M101 MongoDB for Developers - Final - question 2
db.messages.aggregate([
{$project: {"_id": 0,
"headers.From": 1,
"headers.To": 1
}},
{$unwind: "$headers.To"},
{$group: {
"_id": {from: "$headers.From",
to: "$headers.To"},
sum: {"$sum": 1}
require 'aws-sdk'
# Copy an AWS S3 object from one bucket to another
class CopyObjectFromOneBucketToAnotherService
attr_reader :logger, :object_name, :object_to_copy, :destination_bucket
attr_accessor :debug
def initialize(options = {})
create_logger(STDOUT)
Aws.config.update(
@mrmarcondes
mrmarcondes / gist:21a790e1505f607ac34d
Created February 26, 2016 18:52
Certificado A3 + El Captain + Firefox
Safenet Driver: https://site.solutinet.com.br/2015/manuais/instaladores/
Instruções: http://drivers.certisign.com.br/midias/tokens/safenet/Macintosh/utilizacao_do_certificado_tipo_A3_com_SafeNet.pdf
storage = Google::Cloud::Storage.new(
project_id: ENV['GOOGLE_STORAGE_BUCKET'],
credentials: JSON.parse(ENV['GOOGLE_CREDENTIALS_FILE']),
timeout: 1_000_000
)
bucket = storage.bucket ENV['BUCKET']
files = bucket.files prefix: ENV['INTERVAL']
files.each do |file|
downloaded = file.download
@mrmarcondes
mrmarcondes / README.md
Created April 9, 2021 15:31 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using: