Skip to content

Instantly share code, notes, and snippets.

View hugojosefson's full-sized avatar
👍

Hugo Josefson hugojosefson

👍
View GitHub Profile
@hugojosefson
hugojosefson / debian-swap
Created December 10, 2017 22:05
Creates swap on debian, for example on a digitalocean vpc.
#!/bin/bash
set -e
touch /var/swap.img
chmod 600 /var/swap.img
dd if=/dev/zero of=/var/swap.img bs=1M count=4096
mkswap /var/swap.img
swapon /var/swap.img
@mickdekkers
mickdekkers / clean-js.sh
Last active June 27, 2020 15:19
Clean JS snippets using lebab and prettier
function clean-js () {
local transforms='arrow,for-of,for-each,arg-rest,arg-spread,obj-method,obj-shorthand,no-strict,exponent,multi-var,let,class,commonjs,template,default-param,destruct-param,includes'
lebab --transform $transforms | prettier --no-semi --single-quote
}
@jpouellet
jpouellet / qvm-terminal.pl
Last active October 31, 2020 08:01
Opens a terminal in the front-most Qubes VM.
#!/usr/bin/env perl
use strict;
use warnings;
sub dom0_term {
(exec 'xfce4-terminal') or (exec 'xterm') or die "dom0 terminal exec failed\n";
}
sub domU_term {
@SietsevanderMolen
SietsevanderMolen / qubes_domain_terminal.sh
Last active May 8, 2024 12:43
Opens a terminal in the domain belonging to the current active winow
#!/bin/bash
run_terminal='
for t in $TERMINAL urxvt rxvt terminator Eterm aterm xterm gnome-terminal roxterm xfce4-terminal; do
which $t > /dev/null 2>&1 && exec $t;
done
'
get_id() {
local id=$(xprop -root _NET_ACTIVE_WINDOW)
What is it?
  • Compiles to JavaScript
  • Haskell-inspired type system (with some improvements!)
  • No runtime (unlike Elm, GHCJS, etc)
  • A focus on readable and debuggable JavaScript
@gusennan
gusennan / crypt_unlock.sh
Created March 7, 2015 17:57
initramfs-hook for unlocking LUKS-encrypted LVM partition
#!/bin/sh
PREREQ="dropbear"
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
@wdullaer
wdullaer / docker-cleanup
Last active August 17, 2023 14:17
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@nikmartin
nikmartin / A: Secure Sessions Howto
Last active April 28, 2024 05:17
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
require 'formula'
class TmuxIterm2 < Formula
url 'http://iterm2.googlecode.com/files/iTerm2-1_0_0_20130122.zip'
sha1 'a5f55b545500ebcb97e842f65ea9c90dd457f228'
head 'git://tmux.git.sourceforge.net/gitroot/tmux/tmux'
depends_on 'pkg-config' => :build
depends_on 'libevent'
@ryanflorence
ryanflorence / static_server.js
Last active April 26, 2024 16:18
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);