Skip to content

Instantly share code, notes, and snippets.

View 0xjgv's full-sized avatar
:atom:

Juan Gaitán-Villamizar 0xjgv

:atom:
View GitHub Profile
@0xjgv
0xjgv / Python Async Decorator.py
Created March 3, 2022 13:15 — forked from Integralist/Python Async Decorator.py
[Python Async Decorator] #python #asyncio #decorator
import asyncio
from functools import wraps
def dec(fn):
@wraps(fn)
async def wrapper(*args, **kwargs):
print(fn, args, kwargs) # <function foo at 0x10952d598> () {}
await asyncio.sleep(5)
@0xjgv
0xjgv / best_of_best.py
Created February 3, 2022 16:22 — forked from ourway/best_of_best.py
Best Python Snippets
## 1::calculating_with_dictionaries
# example.py
#
# Example of calculating with dictionaries
prices = {"ACME": 45.23, "AAPL": 612.78, "IBM": 205.55, "HPQ": 37.20, "FB": 10.75}
# Find min and max price
min_price = min(zip(prices.values(), prices.keys()))
max_price = max(zip(prices.values(), prices.keys()))
@0xjgv
0xjgv / pair-rotation.py
Created November 18, 2021 10:46
Round-robin scheduling algorithm
"""
Inspired from https://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm
"""
team = [
"John",
"Lee",
"Dave",
"Steve",
"Louis",
@0xjgv
0xjgv / System Design.md
Created July 6, 2020 13:41 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
Verifying my Blockstack ID is secured with the address 1MXJCnZoVyAFGDFQYHmTwP8yRsoVvg7jAg https://explorer.blockstack.org/address/1MXJCnZoVyAFGDFQYHmTwP8yRsoVvg7jAg
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+t",
"command": "workbench.action.terminal.focus"
},
{
"key": "shift+cmd+t",
"command": "workbench.action.terminal.new"
},
@0xjgv
0xjgv / images-extractor.js
Last active July 29, 2018 21:49
Extract all available images in a search result from Google Images.
const fs = require('fs');
const md5 = require('md5');
const async = require('async');
const puppeteer = require('puppeteer');
const request = require('request-promise');
async function scrollDown(page) {
try {
await page.evaluate(
async () =>
const Apify = require('apify');
const cheerio = require('cheerio');
const requestPromise = require('request-promise');
// Utils functions to simplify the code
const { log } = console;
const pretty = object => JSON.stringify(object, null, 2);
// Get code line-by-line with cheerio into an Object
const arrayToObjectInContext = $ => (array, object = {}) => (
@0xjgv
0xjgv / main.js
Last active December 23, 2017 20:20
const Apify = require('apify');
const request = require('request-promise');
Apify.main(async () => {
// Get input of your act
const input = await Apify.getValue('INPUT');
console.log('My input:');
console.dir(input);
// Do something useful here
@0xjgv
0xjgv / gitflow-breakdown.md
Created June 28, 2016 14:38 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository