Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@nakosung
nakosung / trap.sh
Created November 27, 2013 02:15
trap!
#!/bin/bash
function clean_up {
# Perform program exit housekeeping
rm $TEMP_FILE
exit
}
trap clean_up SIGHUP SIGINT SIGTERM
@notro
notro / fbtft.conf
Created February 11, 2015 18:33
xorg configuration for use with FBTFT on Raspian: /etc/X11/xorg.conf.d/fbtft.conf
# FBTFT xorg config file
#
# startx -- -layout TFT
# startx -- -layout HDMI
#
# startx
# When -layout is not set, the first is used: TFT
#
Section "ServerLayout"
@mazgi
mazgi / NEW QGROUP!.md
Last active December 23, 2017 05:09
Btrfs subvolume quota
[root@btrfs-testdrive] # btrfs qgroup create 1/100 /mnt/btrfs
[root@btrfs-testdrive] # btrfs qgroup assign 0/276 1/100 /mnt/btrfs
[root@btrfs-testdrive] # btrfs qgroup show /mnt/btrfs
qgroupid rfer       excl       
-------- ----       ----       
0/5      16384      16384      
0/256    2864136192 2864136192 
0/258    833703936  833703936  
0/259    52510720   52510720   
@lexszero
lexszero / bfx-calc.hs
Last active August 8, 2018 16:33
Bitfinex margin trading calculator
import Control.Monad.State
import Text.Printf
initiallyRequired = 0.3
maintenanceRequired = 0.15
takerFee = 0.002
type Amount = Double
type Price = Double
@maximilize
maximilize / idlemon.py
Created September 13, 2018 03:01
Script to detect and shutdown not needed qubes VM's
#!/usr/bin/env python
import subprocess
import re
from collections import namedtuple
import binascii
import time
import json
IGNORE = """
nm-applet
@mapio
mapio / Setup an USB raw device
Created January 17, 2014 09:31
To boot Virtualbox from a USB pendrive you must first create a virtual disk to access to it and then add it as storage.
#!/bin/bash
if [ -r USB.vmdk ]; then
VBoxManage storageattach "BootFromUSB" --storagectl "SATA" --port 0 --device 0 --medium none
VBoxManage closemedium disk USB.vmdk --delete
fi
sudo chown $USER /dev/disk1*
VBoxManage internalcommands createrawvmdk -filename USB.vmdk -rawdisk /dev/disk1 -partitions 1,2
@dannguyen
dannguyen / csvkit-sql-cli-readme.md
Last active May 8, 2020 04:32
Using bash, csvkit, and SQLite to analyze San Francisco restaurant health inspection data

How to download, import, and analyze San Francisco restaurant inspection data using SQLite3 and csvkit from the command-line.

A quick example of doing data wrangling from the command-line, as well as getting to know one of San Francisco's data sets: the San Francisco restaurant inspections, courtesy of the SF Department of Public Health. I don't normally do database work from the command-line, but importing bulk data into SQLite is pretty frustrating using the available GUIs or just the shell.

So thank goodness for Christopher Groskopf's csvkit, a suite of Unix-like tools that use Python to robustly handle CSV files. There's a lot of great tools in csvkit, but for this gist, I just use csvsql, which can parse a CSV and turn it into properly-flavored SQL to pass directly into your database app of choice.

@viluon
viluon / Dockerfile
Created October 15, 2020 14:40
Dockerfile for building GHC
FROM archlinux:20200205 AS arch-ghc-build-env
RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm git base-devel go python python-sphinx libedit numactl exa
# use all possible cores for subsequent package builds
RUN sed -i 's,#MAKEFLAGS="-j2",MAKEFLAGS="-j$(nproc)",g' /etc/makepkg.conf
# don't compress the packages built here
RUN sed -i "s,PKGEXT='.pkg.tar.xz',PKGEXT='.pkg.tar',g" /etc/makepkg.conf
# set up the packager user
@ruyjfs
ruyjfs / culturagovbr-docker-run.bash
Last active April 7, 2021 15:54
Comandos de inicialização dos containers do Ministério da Cultura do Brasil. Startup commands of the containers of the Ministry of Culture of Brazil.
# Run container Nginx | Debian
docker run -it -v /var/www/:/var/www/ --name webserver-nginx-debian -p 80:80 culturagovbr/web-nginx-debian:0.1
# Run container Nginx | PHP 5 | Debian
docker run -it -v /var/www/:/var/www/ --name webserver-nginx-debian -p 80:80 --add-host local.salic:127.0.0.1 culturagovbr/web-nginx-php5-debian
# Run container Nginx | PHP 7 | Debian
docker run -it -v /var/www/:/var/www/ --name webserver-nginx-debian -p 80:80 culturagovbr/web-nginx-php7-debian:0.1
# Run container Apache | Debian
use std::io::stdin;
use std::io::prelude::*;
use std::iter::*;
use std::str::SplitWhitespace;
fn main() {
let mut inp = InRead::new();
let t = inp.int();
for _ in 0..t {
let n = inp.int();