Skip to content

Instantly share code, notes, and snippets.

View paulofreitas's full-sized avatar

Paulo Freitas paulofreitas

View GitHub Profile
@paulofreitas
paulofreitas / tipcc-api.json
Last active April 2, 2024 21:49
tip.cc API v0.1.1 proposal: `/api/v0/currencies/fiats` should use `def-1` schema for `code`and `/api/v0/currencies/rates` should use an `oneOf` struct with `def-0` and `def-1` schemas for `code`
{
"openapi": "3.0.0",
"info": {
"title": "tip.cc API",
"description": "API for tip.cc",
"version": "0.1.1"
},
"components": {
"securitySchemes": {
"apiKey": {
@paulofreitas
paulofreitas / trivia-db.yaml
Last active November 15, 2023 11:48
Open Trivia DB cloning
This file has been truncated, but you can view the full file.
- category: general
type: boolean
difficulty: easy
question: '"27 Club" is a term used to refer to a list of famous actors, musicians, and artists who died at the age of 27.'
correct_answer: 'True'
incorrect_answers:
- 'False'
- category: music
type: multiple
difficulty: hard

Keybase proof

I hereby claim:

  • I am paulofreitas on github.
  • I am paulofreitass (https://keybase.io/paulofreitass) on keybase.
  • I have a public key ASB7AILhT0J-sojxvGL7WGx81WH-wBn9xCWDeA3Euy5e-Qo

To claim this, I am signing this object:

class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
key = (cls, args, str(kwargs))
if key not in cls._instances:
cls._instances[key] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[key]
@paulofreitas
paulofreitas / totp.py
Last active September 25, 2018 18:22
#!/usr/bin/env python3
import argparse
from pyotp import totp # pip3 install pytotp
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('key')
args = parser.parse_args()
print(totp.TOTP(args.key).now())
server {
listen 80;
server_name domain.com www.domain.com;
root /home/username/domain.com/public;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
@paulofreitas
paulofreitas / chroot-jail.md
Created October 15, 2017 02:26
Chroot Jail 101

Instructions

Install SSH server

sudo apt-get install openssh-server

Create SFTP group

groupadd sftp
<?php
class TimeoutException extends RuntimeException
{
//
}
function wait_until(callable $callback, $seconds)
{
declare(ticks = 1);
<?php
function namespace_path($namespace)
{
try {
return (new ReflectionClass($namespace))->getFileName();
} catch (ReflectionException $e) {
$autoloader = require base_path('vendor/autoload.php');
$namespaceParts = array_filter(explode('\\', $namespace));
$namespacePrefix = array_shift($namespaceParts) . '\\';
@extends('errors::layout')
@section('title', __('Unauthorized'))
@section('message', __($exception->getMessage()))