Skip to content

Instantly share code, notes, and snippets.

View dealloc's full-sized avatar

Wannes Gennar dealloc

View GitHub Profile
@dealloc
dealloc / responsive_layout.dart
Created October 26, 2023 14:48
A simple widget that selects the approperiate layout depending on the application width
import 'package:flutter/material.dart';
/// The ResponsiveLayout widget handles showing the corrct widget based on
/// screen sizes.
///
/// Similar to UI libraries like TailwindCSS it chooses the layout on width.
class ResponsiveLayout extends StatelessWidget {
/// The [Widget] shown when the screen size is mobile, this is the default child.
final Widget mobile;
@dealloc
dealloc / macro.js
Created February 23, 2023 09:35
Foundry Skill Check Macro
const skills = [
{ label: 'Perception', value: 'perception' },
{ label: 'Acrobatics', value: 'acrobatics' },
{ label: 'Deception', value: 'deception' },
{ label: 'Intimidation', value: 'intimidation' },
{ label: 'Nature', value: 'nature' },
{ label: 'Performance', value: 'performance' },
{ label: 'Society', value: 'society' },
{ label: 'Survival', value: 'survival' },
{ label: 'Arcana', value: 'arcana' },
@dealloc
dealloc / .dockerignore
Created March 15, 2021 15:27
Phoenix Dockerfile
_build/
.elixir_ls/
assets/node_modules/
deps/
priv/static
@dealloc
dealloc / echo_socket.ex
Created October 10, 2020 12:19
Echo socket demo
defmodule PooledConnWeb.Socket.EchoSocket do
@moduledoc """
Javascript code to run this (put in .html.eex file):
const id = <%= :rand.uniform(10) %>;
const websocket = new WebSocket('ws://localhost:4000/socket/websocket?id=' + id);
websocket.onopen = (args) => console.info('Open', args);
websocket.onmessage = (msg, args) => console.info('Message', msg, args);
websocket.onclose = (args) => console.warn('Close', args);
"""
@dealloc
dealloc / setup-debian.sh
Created January 1, 2020 20:41
WSL debian setup script
#!/bin/bash
# Update APT repositories
sudo apt-get update
# Now, install stuff we need.
sudo apt-get install -y vim git curl wget htop postgresql gnupg zsh
# Setup Elixir repositories
cd /tmp
@dealloc
dealloc / install.sh
Last active October 5, 2018 08:47
Small shell script that automatically installs Arch (configured to work on my Laptop)
#!/bin/bash
clear
set -e
# Set keyboard
echo "Setting keyboard layout..."
loadkeys be-latin1
# Prompting for variables as required
echo "Getting required data..."
PASSWORD=$(dialog --clear --stdout --backtitle "Arch installer" --no-shadow --title "Enter password for users" --passwordbox "Please enter a strong password for the root user.\n" 8 60 2> /dev/null)
@dealloc
dealloc / docker-compose.yml
Last active August 8, 2018 14:49
Gitlab docker
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost:9090'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
gitlab_rails['backup_path'] = '/var/opt/gitlab/backups'
ports:
@dealloc
dealloc / Dockerfile
Last active October 7, 2020 18:45
Elixir Docker makefile
FROM elixir:alpine
WORKDIR /app
ARG USER_UID
ARG UNAME
EXPOSE 4000
RUN apk add --no-cache curl bash
RUN curl --url https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh --output /wait-for-it.sh
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
@dealloc
dealloc / cryptor.js
Last active May 2, 2017 17:49
simple AES en/decryption
export default class Cryptor {
constructor() {
this.AES_ALGO = 'AES-CBC';
this.DERIVE_ALGO = 'PBKDF2';
this.HASH_ALGO = 'SHA-256';
this.KEY_BITS = 256;
this.KEY_ITERATIONS = 1000;
}
encrypt(data, password) {
@dealloc
dealloc / sudo_once.sh
Created March 25, 2016 20:02
prompt sudo once and forget about it
startsudo()
{
sudo -v
( while true; do sudo -v; sleep 50; done; ) &
SUDO_PID="$!"
trap stopsudo SIGINT SIGTERM
}
stopsudo()
{
kill "$SUDO_PID"