Skip to content

Instantly share code, notes, and snippets.

View radames's full-sized avatar

Radamés Ajna radames

View GitHub Profile
@radames
radames / grid.js
Created May 24, 2023 06:48
Amethyst Custom Layout Simple Square Grid
function layout() {
return {
name: "Grid",
getFrameAssignments: (windows, screenFrame) => {
const numWindows = windows.length;
const numRows = Math.floor(Math.sqrt(numWindows));
const numCols = Math.ceil(Math.sqrt(numWindows));
const cellWidth = screenFrame.width / numCols;
const cellHeight = screenFrame.height / numRows;
@radames
radames / api-inference-Stable-Diffusion.py
Created February 1, 2023 20:16
Save Image from API inference Stable Diffusion on Hugging Face in Python
import json
import requests
from PIL import Image
import io
import re
from time import time
API_TOKEN = "" # token in case you want to use private API
headers = {
# "Authorization": f"Bearer {API_TOKEN}",
@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"))

@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 / 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 / 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 / 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 / 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;

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 / 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):