Skip to content

Instantly share code, notes, and snippets.

View javascripto's full-sized avatar
:octocat:
Focusing

Yuri Alves javascripto

:octocat:
Focusing
View GitHub Profile
@javascripto
javascripto / EventEmitter.ts
Last active January 8, 2019 15:16
Imitação do EventEmitter usando no Angular para estudo do padrão Observable
interface Observable {
subscribe: (fn?) => any;
}
class Subscription {
constructor(
private emitter: EventEmitter<any>,
private index: number) {}
unsubscribe() {
@javascripto
javascripto / snake.py
Created January 31, 2019 09:37
Snake básico com pygame
#!/usr/bin/python3
import pygame
from pygame.locals import *
from random import randint
def on_grid_random():
x = randint(0, 290)
y = randint(0, 290)
return (x//10 * 10, y//10 * 10)
@javascripto
javascripto / set_dot_env_value.sh
Created January 31, 2019 20:35
script to set .env values
#!/bin/bash
set_dot_env_value() {
ENV=$1
KEY=$2
VALUE=$3
PATH=$(dirname $ENV)
if [[ ${#@} -ne 3 ]]; then
echo -e "É necessário informar 3 argumentos:\n\t[1: endereço do .env],\n\t[2: variavel],\n\t[3: valor]"
exit
@javascripto
javascripto / prototypes.js
Created February 11, 2019 21:58
Some Array and Object Prototypes
const movieCategories = [
{
name: "Thrillers",
videos : [
{
"id": 70111470,
"title": "Die Hard",
"boxarts": [
{ width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/DieHard150.jpg" },
{ width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/DieHard200.jpg" }
@javascripto
javascripto / backup-vscode-extensions.sh
Last active May 8, 2019 18:11
Generates a script with backup of vscode extensions ready to installation
#!/bin/bash
loading() {
echo -n "Aguarde"
for i in {1..5}; do echo -n "." && sleep 0.5; done
}
backup_vscode() {
file="install-vscode-extensions.sh"
@javascripto
javascripto / php_swole.md
Last active September 1, 2019 18:42
php swoole extension Instalation

Dividir tela verticalmente CTRL+B SHIFT+5 (%)

Dividir Horizontalmente CTRL+B SHIFT+' (")

Navegar entre janelas CTRL+B Arrowkeys

Matar tmux

@javascripto
javascripto / install-nvm.sh
Last active September 21, 2020 15:53
Instalação do nvm, npm e node na ultima versão
#!/bin/bash
install_nvm_npm_and_node() {
which curl
if [ $? -eq 1 ]; then
echo "curl is required to install nvm"
exit 1
fi
local SHELLRC="$HOME/.${0}rc"
@javascripto
javascripto / index.html
Last active April 1, 2019 13:08
Socket.io
<h1>Socket.io</h1>
<div id="msgs"></div>
<input type="text">
<script src="/socket.io/socket.io.js"></script>
<script src="/socket.io-client.js"></script>
Array.prototype.pluck = function(...keys) {
return this.map(item => keys.reduce((acc, key) =>
(key in item) && (acc[key] = item[key]) ? acc : acc, {}));
}
Array.prototype.pluck = function(...keys) {
return this.map(item => JSON.parse(JSON.stringify(item, [...keys])));
}