Skip to content

Instantly share code, notes, and snippets.

View ShogunPanda's full-sized avatar

Paolo Insogna ShogunPanda

View GitHub Profile
@ShogunPanda
ShogunPanda / authenticate.rb
Last active August 29, 2015 13:56
Google Drive
client = Google::APIClient.new(authorization: :oauth_2, application_name: NAME, application_version: VERSION)
client.client_id = CLIENT_ID
client.client_secret = CLIENT_SECRECT
client.authorization.scope = SCOPES
authorizer = Clavem::Authorizer.new do |auth, req, res|
raise RuntimeError.new if request.query["error"].present? || request.query["code"].blank?
client.authorization.code = request.query["code"].to_s
client.authorization.fetch_access_token!
client.authorization.refresh_token
@ShogunPanda
ShogunPanda / cleanup.sh
Created March 5, 2014 21:14
Clean up large files from GIT repo.
#!/bin/bash
# Copyright (C) 2014 Shogun <shogun@cowtech.it>
# Run this script with a single argument which is the threshold size. Example: sh cleanup.sh 100k
# Find the files to remove
files=$(find * -type f -size +$1)
echo "Removing $files";
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch $files" --prune-empty --tag-name-filter cat -- --all
@ShogunPanda
ShogunPanda / applause.html
Last active August 29, 2015 14:01
Bookmarklets
<!doctype html>
<html>
<head>Applause Bookmarklet</head>
<body>
<h1>Applause Bookmarklet</h1>
<h2><a href="javascript: (function(){var id=prompt('Enter the Applause bug ID'); if(id && id.length > 0) window.open('https://my.applause.com/u/a#!&view=issues&subview=issues&bugId=' + id, '_blank'); })();">Open a Bug</a></h2>
</body>
</html>
@ShogunPanda
ShogunPanda / michan-efp-bejelein.css
Created January 27, 2015 04:33
michan-efp-bejelein.css
@import url(http://fonts.googleapis.com/css?family=Alegreya|Ubuntu:300);
.michan-custom{
font-family: Alegreya;
font-size: 14pt;
line-height: 1.4em;
text-align:justify;
max-width: 21cm;
word-wrap: break-word;
margin: 0 auto;
@ShogunPanda
ShogunPanda / fb-comments-stealer.js
Created April 22, 2015 18:14
fb-comments-stealer
#!/usr/bin/env babel-node
import request from "request";
import chalkbars from "chalkbars";
process.on("uncaughtException", e =>{
console.log(e);
process.exit(2);
});
@ShogunPanda
ShogunPanda / reek.yml
Created August 21, 2013 19:14
Metrics configuration.
---
### Enabled ###
ClassVariable:
enabled: true
exclude: []
DuplicateMethodCall:
enabled: true
exclude: []
max_calls: 2
allow_calls: []
@ShogunPanda
ShogunPanda / sequence.rb
Created July 16, 2011 11:15 — forked from masatomo/sequence.rb
adds a feature to set sequence number to Mongoid::Document
# encoding: utf-8
module Mongoid
# Include this module to add automatic sequence feature (also works for _id field, so SQL-Like autoincrement primary key can easily be simulated)
# usage:
# class KlassName
# include Mongoid::Document
# include Mongoid::Sequence
# ...
# field :number, :type=>Integer
# sequence :number
@ShogunPanda
ShogunPanda / ESM in CJS.md
Created November 16, 2021 14:09
Usage of ESM modules in CommonJS world.

Import ESM module in a CommonJS module

Do not use requires or top-level imports (if you're transpiling server side code). Replace all occurrences with await import and wrap your code in a async function.

Example

If your original code was:

const { dirname, sep, join, resolve } = require('path')
const { build } = require('esbuild')
const { readFile } = require('fs/promises')
// TODO: Check how to solve when [dir] or [hash] are used
function pinoPlugin(options) {
options = { transports: [], ...options }
return {
name: 'pino',