Skip to content

Instantly share code, notes, and snippets.

@David256
David256 / self_improving_script_with_openai.py
Created April 9, 2023 22:28
This code is a proof of context for a Python script that self-improves using the OpenAI API.
#!/usr/bin/env python
"""
Run this code under the Python interpreter.
"""
import os
import random
import re
import openai
@David256
David256 / express-server.js
Created August 17, 2022 21:23
express.js launches stuffs and responses if the process is still running
const express = require('express');
const {
exec,
} = require('child_process');
const app = express();
const port = 7000;
let isRunning = false;
@David256
David256 / dynamic-hexagon-component-styles.sass
Created May 19, 2022 20:37
React.js component to create a hexagon with CSS (or SASS): So... pure CSS hexagons with box-shadow, border, and background image.
// This
// Use this for math.div(number, divider) function
@use "sass:math"
// The sqrt function, just to calc sqrt(3) ._.
// Source: https://www.antimath.info/css/sass-sqrt-function/
@function sqrt($r)
$x0: 1
$x1: $x0
@David256
David256 / colores.py
Created May 25, 2021 17:45
Script to create a GIF with colors
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from numpy import pi, array, full, uint8
import imageio
import matplotlib.pyplot as plt
theta = 0.5 # valor entre [0,1)
light = 1 # valor entre [0,1)
@David256
David256 / script.js
Created April 17, 2021 17:49
I don't know why
const L = 37, R = 39, U = 38, D = 40;
let a = [
[L, U, R, D], [L, D, R, U],
[R, U, L, D], [R, D, L, U],
[U, L, D, R], [U, R, D, L],
[D, L, U, R], [D, R, U, L]
];
let d = document;
let c = d.getElementsByTagName("canvas")[0];
let gdir = () => { return a[Math.floor(Math.random() * a.length)]; }
@David256
David256 / scrcpy.sh
Last active October 28, 2020 05:24
Bash script to config the ADB over TCP/IP and connects and starts scrcpy
#!/bin/bash
PORT="5555"
DEVICE=$(adb devices | grep "device$")
echo "Esperando por un dispositivo..."
adb wait-for-device
# Revisamos si se está conetado a DEBUG USB
if [ -z "$DEVICE" ];
@David256
David256 / AdSkipScript.js
Last active July 3, 2021 02:38
Script skips ads automatic in YouTube
/**
* Ad Skip Script - Javascript
*/
/**
* Ad Skip Script - Javascript
*/
let d = document;
let t = 1000;
let e = document.createEvent("HTMLEvents");
e.initEvent("click", true, true);
@David256
David256 / _action.py
Created August 18, 2019 18:28
Una simple clase python para administrar acciones.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import warnings
class Action(object):
"""Una acción"""
def __init__(self):
super(Action, self).__init__()
self.to_do = None
@David256
David256 / raspberrry_sensor_flask.py
Created May 20, 2019 14:27
This script defines http server with flask to read and show data from sensors of ultrasound and infrared.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# import the cool libray
import RPi.GPIO as GPIO
# others
import time
import argparse
import threading
import signal
@David256
David256 / IoTExcavator.java
Created May 20, 2019 02:02
Clase Android Java para escanear un rango de ip. Pensada para otra cosa, pero...
package ext.domain.subdomain.appname;
import java.net.Socket;
import java.io.IOException;
import java.util.ArrayList;
import android.util.Log;
/**
* Esta clase define un objeto rebuscador de direcciones IP que