Skip to content

Instantly share code, notes, and snippets.

View okiwan's full-sized avatar

Sergio Ocaña Gálvez okiwan

View GitHub Profile
@okiwan
okiwan / motor.c
Created June 4, 2023 16:23
Small refactor on motor method
// Podemos separar la definición de las constantes
// en un archivo .H a parte e incluir después
#define MODE_SHIT 0
#define MODE_STORAGE 1
#define KEYDOWN_THRESHOLD 1500
#define LCD_DISPLAY_DELAY 1000
void display(int x, int y, char *string) {
#!/usr/bin/env python
import re
import os
handler = open("index.html", "r")
data = handler.readlines()
expression = re.compile(r'".*/(pc-engine-fan-.*)/.*"')
#!/usr/bin/env python
import os
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
detected_season = None
detected_chapter = None
current_season = None
@okiwan
okiwan / postgres_queries_and_commands.sql
Last active April 6, 2022 07:03 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@okiwan
okiwan / remove_pritunl_osx.sh
Created August 23, 2020 17:42 — forked from opragel/remove_pritunl_osx.sh
remove_pritunl_osx.sh
#!/bin/bash
# Disclaimer: it's your funeral
APP_PROCESS_NAME="Pritunl"
DAEMON_PATHS=( "/Library/LaunchAgents/com.pritunl.client.plist" \
"/Library/LaunchDaemons/com.pritunl.service.plist" \
"/Library/LaunchDaemons/net.sf.tuntaposx.tap.plist" \
"/Library/LaunchDaemons/net.sf.tuntaposx.tun.plist" )
import boto3
import requests
from requests_aws4auth import AWS4Auth
# Origin: host = 'https://my-elasticsearch-endpoint.com/'
# Destination:
host = 'https://my-elasticsearch-enpoint-destination.com/'
region = 'eu-west-1' # For example, us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
@okiwan
okiwan / mousetrail.js
Last active April 19, 2019 17:14
Draw a trail following mouse move
/**
* This is just the JavaScript side, so an HTML must be created with a canvas element.
* Originally published by @NoahYamamoto
*/
function StartMouseTrail() {
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
// Get proper height and width for canvas, then set resize handler.
canvas.width = window.innerWidth;
@okiwan
okiwan / equalizer.js
Last active April 19, 2019 17:09
Use audio analyzer to create an equalizer on your browser
/**
* Originally created by @jake_albaugh (Twitter)
* UTF8 characters starting from "\u2581"
*/
const l = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
const x = new AudioContext();
const a = x.createAnalyser();
a.fftSize = 32;
const d = new Uint8Array(16);
@okiwan
okiwan / demo.py
Last active April 18, 2019 22:52
Asyncio simple demonstration
"""
The idea of this piece of code is to demonstrate how asyncio
works so you can understand the benefits of using it in your
IO-demansind apps.
The application creates a defined number of workers that will
generate a request to a website for a randomly-generated numbers
and will return the sum.
Note that when running the code workers will be created immediately,
@okiwan
okiwan / userChrome.css
Created March 17, 2019 17:23
Configure visibility of bookmark toolbar when fullscreen is active on Mozilla Firefox
/* Place this file in ~/.mozilla/firefox/<profile folder>/chrome/userChrome.css */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#navigator-toolbox[inFullscreen] toolbar:not([collapsed="true"]) {
visibility:visible!important;
}