Skip to content

Instantly share code, notes, and snippets.

View felladrin's full-sized avatar

Victor Nogueira felladrin

View GitHub Profile
@felladrin
felladrin / declarations.d.ts
Created August 16, 2020 16:26
Typescript declaration file (.d.ts) declaring one module equal another
// Whenever we use `import { GameObject } from "kontra/kontra.mjs";`
// TS compiler will resolve the typings from "kontra".
declare module "kontra/kontra.mjs" {
import kontra from "kontra";
export = kontra;
}
@felladrin
felladrin / ssh-agent-bridge-mac-example.sh
Created April 17, 2020 01:53
Example of SSH Agent Bridge working on Mac (Tested on Docker v19.03.8)
docker run -it -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" --rm alpine /bin/sh -c "apk update && apk add openssh-client && mkdir ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts && ssh -T git@github.com"
@felladrin
felladrin / theia-alias.sh
Created April 12, 2020 22:56
Alias to run, in current directory, TheiaIDE (https://theia-ide.org), with Node.js installed. Node-Modules folder is mounted as a volume for performance reasons.
alias theia='docker run --rm -it --init -u root -p 3000:3000 -v "$(pwd)":/home/project -v theia-node-modules:/home/project/node_modules theiaide/theia;'
@felladrin
felladrin / node-alias.sh
Last active April 12, 2020 22:53
Use Node.js on Mac and Linux via Docker by using an Alias
alias node='docker run --rm -it -v "$(pwd)":/workspace -w /workspace -u node node:lts-alpine node'
@felladrin
felladrin / recommended-articles.md
Created February 9, 2020 15:36
List of interesting articles I'd recommend you to read.
@felladrin
felladrin / .env
Last active January 29, 2020 22:11
Docker Compose configuration for running a Node app in a container
PORT=5000
@felladrin
felladrin / xtermjs-chalk.html
Created July 14, 2019 14:43
Xterm.js + Chalkie (Chalk for web)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Testing xTerm.js</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.4/xterm.css"
/>
<link
rel="stylesheet"
@felladrin
felladrin / add-swap-space-on-digital-ocean-ubuntu.sh
Created November 13, 2018 14:14
Summarized commands from 'How To Add Swap Space on Ubuntu 18.04' Digital Ocean Tutorial (https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04)
free -h && \
sudo fallocate -l 1G /swapfile && \
sudo chmod 600 /swapfile && \
sudo mkswap /swapfile && \
sudo swapon /swapfile && \
sudo cp /etc/fstab /etc/fstab.bak && \
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab && \
sudo sysctl vm.swappiness=10 && \
echo 'vm.swappiness = 10' | sudo tee -a /etc/sysctl.conf && \
sudo sysctl vm.vfs_cache_pressure=50 && \
<?php
class Bcrypt
{
private static $cost = 10;
public static function encode($string)
{
$salt = substr(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36), 0, 22);
$param = sprintf('$2a$%02d$%s$', self::$cost, $salt);
return crypt($string, $param);
@felladrin
felladrin / Base64UrlSafe.php
Created October 30, 2018 17:25
Encodes/decodes a string or an array with MIME base64 safely for URLs.
<?php
class Base64UrlSafe
{
/**
* Encodes a string or an array with MIME base64 safely for URLs.
* @param string|mixed $var
* @return string
*/
public static function encode($var)