Skip to content

Instantly share code, notes, and snippets.

@jg2alv
jg2alv / dict.c
Created December 14, 2023 17:28
Implementation of Dictionary<string, string> in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int __len;
char** __keys;
char** __vals;
} Dict;
@jg2alv
jg2alv / knucklebones.c
Created December 11, 2023 13:39
Implementation of a console-based Knucklebones minigame (from Cult of the Lamb)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct
{
int n;
int col;
} Choice;
@jg2alv
jg2alv / function_name_generator.py
Created December 7, 2023 19:06
Generate a random function name in Python - including a-Z, 0-9 and "_" (from [1, 15] characters long)
import random
def generate_function_name():
ALPHA = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
NUMS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
SPECIAL = ['_']
MIN_LEN = 1
MAX_LEN = 15
while True:
@jg2alv
jg2alv / flatten.py
Created December 7, 2023 19:04
Function to flatten a Python list
# Recursive function to flat the elements of a list
# Pass in the data type that the list is comprised of as `data_type` (or leave it as default - object)
def flatten(arr, data_type = object):
res = []
for el in arr:
if isinstance(el, data_type) and not isinstance(el, list):
res.append(el)
else:
res += flatten(el)
@jg2alv
jg2alv / block-quora-login-popup.md
Created December 7, 2023 19:03
Block Quora's "Login to continue" popup

No one likes that "Login to continue" popup, am I right?
I've come up with a pretty basic solution in order to block the popup and browse Quora without being logged in with no interruptions.

Just install the Stylus browser extension and add the following style to Quora website:

#root {
    filter: none !important;
}

[id*='signup_wall_wrapper']{
@jg2alv
jg2alv / nlock-imdbpro-login-popup.md
Created December 7, 2023 19:03
Block IMDbPro "Login to continue" popup

No one likes that "Login to continue" popup, am I right?
I've come up with a pretty basic solution in order to block the popup and browse IMDbPro without being logged in with no interruptions.

Just install the Stylus browser extension and add the following style to IMDbPro website:

#logged_out_upsell {
    display: none !important;
}
@jg2alv
jg2alv / event_lopp.cs
Created December 7, 2023 19:02
C# script to constantly read console for input while in an infinite loop
using System;
using System.Threading;
class Program
{
static void Main()
{
while(true)
{
if(Console.KeyAvailable)
@jg2alv
jg2alv / promise.js
Created December 7, 2023 19:02
Implementing JS's Promises
class Promise {
constructor(callback) {
const resolve = arg => {
this.status = 'fulfilled';
this.value = arg;
this.thenCallback ? this.thenCallback(arg) : null;
},
reject = reason => {
this.status = 'rejected';
if (this.catchCallback)
@jg2alv
jg2alv / extract-array-object-properties.js
Created December 7, 2023 19:01
Simple JS file to extract the properties of objects inside an array
const people = [
{
name: "John",
age: 1
},
{
name: "Mary",
age: 2
},
{
@jg2alv
jg2alv / block-instagram-login-popup.md
Created December 7, 2023 19:00
Block Instagram "Login to continue" popup

No one likes that "Login to continue" popup, am I right?
I've come up with a pretty basic solution in order to block the popup and browse Instagram without being logged in with no interruptions.

Just install the Stylus browser extension and add the following style to Instagram website:

body {
    overflow: auto !important;
}

.RnEpo,