Skip to content

Instantly share code, notes, and snippets.

View marcelblijleven's full-sized avatar
:octocat:
Loading...

Marcel Blijleven marcelblijleven

:octocat:
Loading...
View GitHub Profile
@marcelblijleven
marcelblijleven / strawberry_django_get_node_from_global_id.py
Created April 25, 2023 08:15
Strawberry Django get node from global id
from base64 import b64encode as _b64encode, b64decode as _b64decode
from typing import Type
from django.db.models import Model
from django.shortcuts import get_object_or_404
_encoding = "utf-8"
def decode_base64(value: str) -> str:
import { useCallback, useEffect, useState } from 'react';
const Imanok = ({ callback }) => {
const expected = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
const [keys, setKeys] = useState([]);
const onKeyDown = useCallback(
event => {
const newKeys = [...keys];
newKeys.push(event.keyCode);
@marcelblijleven
marcelblijleven / text-selection.js
Created January 31, 2020 08:31
Text selections through JS
// Url to test on: https://the-internet.herokuapp.com/tinymce
function selectorTest() {
const iframeDocument = document.querySelector('iframe').contentDocument
const textNode = iframeDocument.querySelector('#tinymce p')
const text = textNode.firstChild
let selection = iframeDocument.getSelection()
// Remove all existing ranges first
selection.removeAllRanges()
@marcelblijleven
marcelblijleven / setup_hour_registration.sh
Last active December 24, 2019 10:56
re-uploaded my script to set up hour registration directory
#!/bin/bash
declare -a months=(
"01_Januari"
"02_Februari"
"03_Maart"
"04_April"
"05_Mei"
"06_Juni"
"07_Juli"
"08_Augustus"
@marcelblijleven
marcelblijleven / git diff comma separated files.sh
Created December 9, 2019 09:23
Comma separated files with git diff
git --no-pager diff --name-only develop | tr '\n' ',' | sed 's/\(.*\),/\1 /'
@marcelblijleven
marcelblijleven / delete_boot_entry.sh
Last active November 13, 2019 08:50
Delete boot entries from EFI
# Find the partition called EFI
diskutil list | grep 'EFI' | awk '{print $(NF)}' | sed 's/s[0-9]/s1/'
sudo mkdir /Volumes/EFI
sudo mount -t msdos /dev/disk0s1 /Volumes/EFI # Replace disk0s1 with actual EFI partition
# Delete boot entries
cd /Volumes/EFI/EFI
@marcelblijleven
marcelblijleven / nginx_subdomain_to_port
Created November 7, 2019 16:27
forward subdomain to port with nginx
server {
listen 80;
server_name sub.marcelblijleven.com;
location / {
proxy_pass http://localhost:3000/;
}
}
@marcelblijleven
marcelblijleven / wpa_supplicant.conf
Last active October 22, 2019 20:19
WPA Supplicant file for headless raspberry pi setup
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=NL
network={
ssid="SSID"
psk="PASSWORD"
key_mgmt=WPA-PSK
}
@marcelblijleven
marcelblijleven / user2.ts
Last active October 11, 2019 11:11
Users
class User {
email:string
password:string
hasLoyaltyCard: boolean
constructor(email:string, password:string, hasLoyaltyCard?:boolean) {
this.email = email
this.password = password
this.hasLoyaltyCard = !!hasLoyaltyCard
}
@marcelblijleven
marcelblijleven / user.ts
Created October 11, 2019 10:46
User class
class User {
email:string
password:string
hasLoyaltyCard: boolean
constructor(email:string, password:string, hasLoyaltyCard?:boolean) {
this.email = email
this.password = password
this.hasLoyaltyCard = !!hasLoyaltyCard
}