Skip to content

Instantly share code, notes, and snippets.

@radames
radames / timerArduino.ino
Last active July 10, 2021 18:47
Simple Arduino Hour Minute counter
long lastTime = 0;
long minutes = 0;
long hours = 0;
void setup() {
}
void loop() {
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
// you can also call it with a different address you want
Adafruit_PWMServoDriver servo1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver servo2 = Adafruit_PWMServoDriver(0x42);
Adafruit_PWMServoDriver light1 = Adafruit_PWMServoDriver(0x43);
Adafruit_PWMServoDriver light2 = Adafruit_PWMServoDriver(0x44);
@radames
radames / python_opencv_camera_haar.py
Last active January 5, 2021 14:25
Example of Python with Opencv and camera face detection - repo complete https://github.com/radames/python_opencv_camera_haar
import cv2
cap = cv2.VideoCapture(0)
cap.set(3, 640) # WIDTH
cap.set(4, 480) # HEIGHT
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_eye.xml")
while(True):

Keybase proof

I hereby claim:

  • I am radames on github.
  • I am radames (https://keybase.io/radames) on keybase.
  • I have a public key whose fingerprint is 00F4 8FAC 27C4 481A 55AE ABFB A5A5 1E37 DF61 6F4D

To claim this, I am signing this object:

@radames
radames / acf_fields_to_rest_api.php
Created August 8, 2019 18:57
Simple Register ACF Field to Wordpress REST API / Add this code to functions.php
// add this to functions.php
//register acf fields to Wordpress API
//https://support.advancedcustomfields.com/forums/topic/json-rest-api-and-acf/
function acf_to_rest_api($response, $post, $request) {
if (!function_exists('get_fields')) return $response;
if (isset($post)) {
$acf = get_fields($post->id);
$response->data['acf'] = $acf;
@radames
radames / aggregate_world_data.sh
Last active April 7, 2020 21:12
Shell script to aggregate country level COVID-19 Mobility data from https://github.com/kylemcdonald/covid-mobility-data
#!/bin/zsh
# You can run this on base folder with all csvs
rm -f res/world.tsv;
touch res/world.tsv;
firstfile=`ls -t *.tsv | head -n 1`
col=`echo 'code\t'`
firstline=`ls -t *.tsv | head -n 1 | xargs sed -n '1,1p'`
res=`echo $firstline | sed 's/^/'$col'/'`;
echo $res >> res/world.tsv;
@radames
radames / README.md
Last active March 4, 2024 06:44
How to connect to your Google Colab Notebook via SSH!

Connect to your Google Colab Notebook via SSH

Using this amazing project tmate.io you can SSH tunnel to your colab notebook machine. You can with few lines of code download the binary, run an instance in the background and output the generated SSH address.

!wget -nc https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-i386.tar.xz &> /dev/null
!tar --skip-old-files -xvf tmate-2.4.0-static-linux-i386.tar.xz &> /dev/null
!rm -f nohup.out; bash -ic 'nohup ./tmate-2.4.0-static-linux-i386/tmate -S /tmp/tmate.sock new-session -d & disown -a' >/dev/null 2>&1
!./tmate-2.4.0-static-linux-i386/tmate -S /tmp/tmate.sock wait tmate-ready
@radames
radames / index.html
Last active December 3, 2020 01:38
test-mutable-generator.html
<div class="animation"></div>
<div class="slider"></div>
<p>
Credit:
<a
href="https://observablehq.com/@observablehq/how-to-embed-a-notebook-in-a-react-app"
>🤔 How to: Embed a Notebook in a React App by Observable</a
>
</p>
@radames
radames / umap_learn_on_apple_silicon.md
Created April 6, 2022 05:22
How to install umap-learn on Apple Silicon M1
# https://github.com/numba/llvmlite/issues/693#issuecomment-909501195
brew install llvm@11   
LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_4/bin/llvm-config" arch -arm64 pip install llvmlite

pip install umap-learn
@radames
radames / a-bookmark-stable-diffusion-ui.MD
Last active February 1, 2023 01:57
Minimal Stable Diffusion UI as a browser bookmark

Bookmark this javascript code to make the minimal Stable Diffusion UI thanks to @huggingface inference API pic.twitter.com/i1slI4ObdH

— Radamés Ajna (@radamar) February 1, 2023
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Bookmark this code

javascript:p=prompt("Enter your prompt:");fetch("https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5",{method:"POST",headers:{"content-type":"application/json","X-Wait-For-Model":"true"},body:JSON.stringify({inputs:p})}).then(e=&gt;e.blob()).then(e=&gt;window.open(URL.createObjectURL(e),"_self"))