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 / main.js
Last active April 9, 2019 13:16
Node requests - Simulating Browsers Fetch API and Angular HttpClient on Node
/* jshint esnext: true */
const { fetch, HttpClient } from './request.js';
const { map } = require('rxjs/operators');
const url = 'http://jsonplaceholder.typicode.com/users/1';
fetch(url)
.then(JSON.parse)
.then(r => r.address)
.then(console.log);
@javascripto
javascripto / List.ts
Last active October 21, 2019 01:21
Extending javascript Array class
export class List<T> extends Array<T> {
constructor(...args: T[]) {
super(...args);
Object.setPrototypeOf(this, List.prototype);
}
private get self() {
return Object.getPrototypeOf(this).constructor;
const obj = {
nome: 'fulano',
idade: 20
};
const generateIterator = obj => obj[Symbol.iterator] = () => {
const keys = Object.keys(obj)
let i = 0;
return ({
next() {
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Vanilla JS Masks</title>
<style>
label, input {
// Atribuição básica
const company = { name: 'Google', country: 'USA' };
const { name } = company;
// Desestruturação em parâmetros de funções
function messageSender({ from }) {
console.log('From:', from)
}
# @mgechev
# A bash function I use constantly on airports:
# Unlimited WiFi ✨
changeMac() {
local mac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig en0 ether $mac
sudo ifconfig en0 down
sudo ifconfig en0 up
echo "Your new physical address is $mac"
}
#!/usr/bin/env python3
from requests import get
from datetime import datetime, timedelta
import json
class PacktPub:
@classmethod
def get_packtpub_offers(cls, date: datetime = datetime.today()) -> dict:
#!/bin/bash
clear
# GET
curl -s -X GET http://localhost:8080/endpoint?nome=fulano&idade=22 | jq
# form-urlencoded
curl -s -X POST http://localhost:8080/endpoint -H "Content-Type: application/x-www-form-urlencoded" --data "name=fulano&idade=20" | jq
# json
#!/usr/bin/env bash
wget "https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz"
tar xfz linux-amd64-1.1.0.tar.gz
chmod +x ./linux-amd64-1.1.0/ccat
mv ./linux-amd64-1.1.0/ccat /usr/local/bin/
rm -rf linux-amd64-1.1.0.tar.gz ./linux-amd64-1.1.0
#!/usr/bin/env python3
# https://youtu.be/UV8EBsnU-GQ
import os, sqlite3, getpass
MASTER_PASSWORD = '123'
def clear_console():
os.system('cls' if os.name=='nt' else 'clear')