Skip to content

Instantly share code, notes, and snippets.

@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;
@kinncj
kinncj / sorting.php
Created August 30, 2016 00:24
Sorting in PHP
<?php
function bubble(array $array)
{
$n = count($array);
for($counter = 1; $counter < $n; $counter++) {
for ($current = $n -1; $current >= $counter; $current--) {
$next = $current - 1;
@kinncj
kinncj / message.js
Created August 22, 2016 23:03
console log message
(function() {
var m = 'font-family:monospace;color:#';
if(window.console) {
console.log('%cyour %cmessage %chere! %chttp://www.site.com', m+'1EFF00',m+'FF0000',m+'668CFF', m+'C6F612');
}
}())
@kinncj
kinncj / String.prototype.js
Last active August 12, 2016 14:44
String.replaceMap(parameterList);
String.prototype.replaceMap = function(parameters) {
var string = this.toString();
Object.keys(parameters).forEach(function(key){
string = string.replace(new RegExp(key, 'g'), parameters[key]);
});
return string;
}