Skip to content

Instantly share code, notes, and snippets.

@kinncj
kinncj / README.md
Last active June 15, 2021 20:41
RSA

Run

curl https://gist.githubusercontent.com/kinncj/1de6b1c030f18a49531547068da7152e/raw/4725d0c9f174d022bf2dd56466b92c73e9f053b8/generate.sh | $SHELL
@kinncj
kinncj / README.md
Last active June 15, 2021 20:03
PHP JWT Encoder/Decoder

Download

$ cd ~/ && mkdir .jwt && cd .jwt && curl https://gist.githubusercontent.com/kinncj/b245cbbf17cce28e14a2c899116acb05/raw/03b714540d36cc65b0d6c356cebc009293b70919/jwt.php > jwt.php

php jwt.php encode HS256 foo "{\"name\":\"Kinn\"}" 

Usage

@kinncj
kinncj / README.md
Created February 23, 2021 18:38
Dev Ubuntu Setup
@kinncj
kinncj / elgato.py
Last active February 15, 2021 23:04
elgato linux
#!/bin/env python3
import leglight
import click
allLights = leglight.discover(2);
light = allLights[0];
__author__ = "kinncj"
@click.group()
@kinncj
kinncj / remover.js
Created April 9, 2018 16:21
JS snippet to remove all github branches from a given tab - in my case, the Stale branches tab
(function(){
// Run at console from the Stale Branches tab.
var rawForms = document.querySelectorAll('.js-branch-destroy > button'),
forms = Array.from(rawForms);
console.log(forms);
forms.forEach(function(form){
console.log(form.click());
});
})();
@kinncj
kinncj / .bash_profile
Last active August 10, 2017 14:18
few things
# ~/.bash_profile
# ...
# Docker cleanup
dcleanup(){
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
# Git cleanup
gitcleanup() {
@kinncj
kinncj / README.md
Last active January 30, 2017 16:51
Common interview questions

Those are the 3 most common interview questions...

  • Sorting:
    • Bubble, or sinking sort
      • Seeks for the lowers value, swaps in the inner level
        • Means that every iteration would swap values
    • Selection:
      • Seeks for the lowest value, swaps only when found AT the outter level
        • Means that not all iteration would swap values
@kinncj
kinncj / FileObject.php
Created January 10, 2017 17:05
SplFileObject::getMimeType()
<?php
class FileObject extends \SplFileObject
{
private $size;
public function fwrite($content, $len = null) // :int
{
$this->size = $len ?: strlen($content);
@kinncj
kinncj / SuaPlatform.php
Created December 20, 2016 18:24
questão do joubertredrat no PHPSP - Slack
<?php
SuaPlatform extends MySQLWHateverPlatform
{
/** .. **/
public function getDefaultValueDeclarationSQL($field)
{
$default = parent::getDefaultValueDeclarationSQL($field);
$this->decorateDatetime($field, $default);
@kinncj
kinncj / binaryTree.php
Created August 30, 2016 00:35
binaryTree max height PHP
<?php
class Node
{
private $left;
private $right;
public function __construct(Node $left = null, Node $right = null)
{
$this->left = $left;