Skip to content

Instantly share code, notes, and snippets.

View nicolasdanelon's full-sized avatar
🖖
live long and prosper

Nicolas Danelon nicolasdanelon

🖖
live long and prosper
View GitHub Profile
@nicolasdanelon
nicolasdanelon / sample.csv
Created August 16, 2023 18:20
create a python dictorionary from a csv
first_name last_name email_address zipcode
John Doe john.doe@example.com 12345
Jane Smith jane.smith@example.com 67890
Alice Johnson alice.johnson@example.com 11223
Bob White bob.white@example.com 44556
@nicolasdanelon
nicolasdanelon / index.php
Last active July 14, 2023 16:14
Simple php 'server' with CORS for react/preact & vite project
<?php
// $ php -S 127.0.0.1:9001
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: http://localhost:5173'); // CORS
header('Access-Control-Allow-Methods: POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
class Humano {
constructor(n) {
this.nombre = n;
}
saludar() {
return `Hola, soy ${this.nombre}`;
}
}
const human = new Humano('Tomás');
@nicolasdanelon
nicolasdanelon / conjuntos.md
Last active March 31, 2023 23:20
Ejercicios con arrays

Ejercicios para los pibes

Suma invertida

Escribir una función que reciba dos números enteros positivos y retorne su suma invertida. Ayuda un int se puede pasar a string y viceversa

Ejemplo, si recibe (123,456) (123+456=579), Retornaría 975. OJO retorna un ENTERO

@nicolasdanelon
nicolasdanelon / borrowing.rs
Created January 2, 2023 19:36
understanding rust concepts
// Borrowing allows you to reference data without taking
// ownership of it. This can be useful when you have a large data
// structure and you don't want to copy it, or when you want to
// allow multiple parts of your code to access the same data.
fn main() {
let s1 = String::from("hello");
let len = calculate_length(&s1); // s1 is borrowed by the function
println!("The length of '{}' is {}.", s1, len);
pacman -S --needed xorg sddm i3 i3-wm i3lock i3status feh dmenu rofi firefox kitty the_silver_searcher vim htop ttf-fira-mono ttf-hack ttf-joypixels ttf-ubuntu-font-family
yay -y i3blocks i3-gaps
systemctl enable sddm
cat ~/.config/i3/config
mkdir ~/.config/i3/i3status
cp /etc/i3status.conf ~/.config/i3/i3status/default.conf
@nicolasdanelon
nicolasdanelon / kill-firebase-emu-switch.sh
Created December 5, 2022 13:30
Dead simple script for kill processes (firebase emulators) by port, blazingly fast
#!/bin/bash
for i in 9001 8086 8081
do
lsof -i tcp:$i | head -n 2 | tail -n 1 | awk '{print $2}' | xargs kill
done
@nicolasdanelon
nicolasdanelon / Cargo.toml
Created July 26, 2022 19:49
problem line 23
[package]
name = "rust-json"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
@nicolasdanelon
nicolasdanelon / docker-compose.yml
Created April 27, 2022 16:11
docker compose -> kafka - zookeeper - postgres - pgadmin
version: "2"
services:
zookeeper:
image: docker.io/bitnami/zookeeper:3.8
ports:
- "2181:2181"
volumes:
- "zookeeper_data:/bitnami"
environment:
@nicolasdanelon
nicolasdanelon / install-arch.sh
Created April 25, 2022 15:47
Quick and simple guide - ArchLinux install
timedatectl set-ntp true
fdisk /dev/sda
o
n
p
1
+300M
a
n
p