Skip to content

Instantly share code, notes, and snippets.

View sjdonado's full-sized avatar
:atom:
The enemy of the art is the absence of limitations - Orson Welles

Juan Rodriguez sjdonado

:atom:
The enemy of the art is the absence of limitations - Orson Welles
View GitHub Profile
@sjdonado
sjdonado / settings.json
Created May 14, 2021 13:52
Custom vscodevim config
{
"vim.leader": "<Space>",
"vim.visualModeKeyBindings": [
{
"before": [
">"
],
"commands": [
"editor.action.indentLines"
]
@sjdonado
sjdonado / info.md
Last active May 15, 2021 19:23
Download large file from Google Drive

You can try generating an OAuth token

  • Go to OAuth 2.0 Playground https://developers.google.com/oauthplayground/
  • In the Select the Scope box, paste https://www.googleapis.com/auth/drive.readonly
  • Click Authorize APIs and then Exchange authorization code for tokens
  • Copy the Access token
  • Run in terminal
curl -H "Authorization: Bearer ACCESS_TOKEN" https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media -o FILE_NAME 
@sjdonado
sjdonado / 08.05.23-1.js
Created May 8, 2023 18:55
Tower of Hanoi in P5.js + WASM - Dev.to
if (isMovingHorizontallly) {
if (animation.currentMove.start < animation.currentMove.end) {
refreshCanvas(p5);
drawDiskByCoordinates(
p5,
animation.currentDisk,
animation.currentMove.start,
draw.topMargin,
);
@sjdonado
sjdonado / 08.05.23-2.js
Created May 8, 2023 18:56
Tower of Hanoi in P5.js + WASM - Dev.to
function recursiveHanoi(A, C, B, n){
if (n == 1) {
moves.push(A + ":" + C);
} else {
recursiveHanoi(A, B, C, n - 1);
moves.push(A + ":" + C);
recursiveHanoi(B, C, A, n - 1);
}
}
function generateHanoiArray(disksNumber) {
@sjdonado
sjdonado / 08.05.23-3.toml
Created May 8, 2023 18:57
Tower of Hanoi in P5.js + WASM - Dev.to
...
[lib]
path = "logic/lib.rs"
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2"
getrandom = { version = "0.2.8", features = ["js"] }
gloo-utils = { version = "0.1", features = ["serde"] }
@sjdonado
sjdonado / 08.05.23-4.diff
Last active May 8, 2023 19:03
Tower of Hanoi in P5.js + WASM - Dev.to
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
+ import wasm from 'vite-plugin-wasm';
+ import topLevelAwait from 'vite-plugin-top-level-await';
import path from 'path';
export default defineConfig({
plugins: [
@sjdonado
sjdonado / 08.05.23-5.js
Created May 8, 2023 18:59
Tower of Hanoi in P5.js + WASM - Dev.to
import { get_moves } from '@wasm/games';
@sjdonado
sjdonado / 08.05.23-6.rs
Created May 8, 2023 19:00
Tower of Hanoi in P5.js + WASM - Dev.to
use gloo_utils::format::JsValueSerdeExt;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn get_moves(n: i32) -> JsValue {
fn move_tower(n: i32, from: i32, to: i32, aux: i32, moves: &mut Vec<String>) {
if n == 1 {
moves.push(format!("{}:{}", from, to));
} else {
move_tower(n - 1, from, aux, to, moves);
@sjdonado
sjdonado / 08.05.23-7.js
Created May 8, 2023 19:00
Tower of Hanoi in P5.js + WASM - Dev.to
import { get_moves } from '@wasm/games';
onmessage = (event) => {
const moves = get_moves(event.data.n);
postMessage(moves);
};
@sjdonado
sjdonado / 08.05.23-8.js
Created May 8, 2023 19:01
Tower of Hanoi in P5.js + WASM - Dev.to
const wasmWorker = new Worker(new URL('../workers/hanoi.js', import.meta.url), {
type: 'module',
});