Skip to content

Instantly share code, notes, and snippets.

View franccesco's full-sized avatar
🧑‍🍳
Cooking Code

Franccesco Orozco franccesco

🧑‍🍳
Cooking Code
View GitHub Profile
@franccesco
franccesco / another_example.sql
Last active March 9, 2022 20:23
JSON example for PSQL
-- JSON Table
WITH json_table AS (
SELECT '{"action": "remove_newsletter_cta_session", "controller": "pages"}'::json AS json_field
)
-- Return values from JSON column
SELECT
json_field->>'action' AS action,
json_field->>'controller' AS controller
FROM json_table
@franccesco
franccesco / snippet.html
Last active May 24, 2020 20:43
Insert WebM video in HTML with controls, preloading and autoplay
<video src="https://source.here/path/to/video.webm" preload autoplay loop controls></video>
@franccesco
franccesco / async_http_requests.py
Created September 19, 2019 21:31
Asynchronous example on how to perform multiple requests using AioHTTP and Asyncio
import asyncio
import aiohttp
from bs4 import BeautifulSoup
async def get_title(session, url):
async with session.get(url) as response:
html_source = await response.text()
soup = BeautifulSoup(html_source, "html.parser")
@franccesco
franccesco / pickle_me.py
Created June 26, 2019 23:28
Saving a dictionary with Pickle
import pickle
dictionary_a = {'string_1': 1, 'string_2': 2.2, 'string_3': True}
# Pickling (serializing) dictionary A into a file
with open('saved_object.pickle', 'wb') as filename:
pickle.dump(dictionary_a, filename)
# Unpickling (de-serializing) dictionary A into B
with open('saved_object.pickle', 'rb') as filename:
@franccesco
franccesco / progressbars.py
Created June 16, 2019 02:21
Testing some of the progressbar libraries that I found interesting
# To test these progress bars you will have to
# install the following packages
# pipenv install click progress progressbar2 tqdm clint
import string
# progress bars
import time
import click
from tqdm import tqdm
@franccesco
franccesco / rdice.rb
Created September 7, 2018 23:42
rdice.rb
#!/usr/bin/env ruby
require 'colorize'
# if ARGV is zero (or no argument given) then default to 6. Else, keep ARGV.
length = ARGV[0].to_i.zero? ? 6 : ARGV[0].to_i
colors = String.colors
colors.delete(:black)
def scramble_pass(length)
@franccesco
franccesco / module.py
Created April 17, 2018 17:01
Just a list.
a_list = ['item1', 'item2', 'item3']