Skip to content

Instantly share code, notes, and snippets.

View spadino's full-sized avatar
🎯
Focusing

Andrea Spada spadino

🎯
Focusing
View GitHub Profile
@spadino
spadino / configuration.nix
Created August 2, 2020 19:38 — forked from jchv/configuration.nix
Nix configuration for VGA passthrough
{ config, pkgs, lib, ... }:
{
# IOMMU configuration
boot.kernelParams = [ "amd_iommu=on" "pcie_aspm=off" ];
boot.kernelModules = [ "kvm-amd" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ];
boot.extraModprobeConfig = ''
options vfio-pci ids=10de:13c2,10de:0fbb
options kvm ignore_msrs=1
'';
@spadino
spadino / post-receive
Created March 25, 2020 01:48 — forked from lemiorhan/post-receive
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
@spadino
spadino / wsl_first_time_setup.sh
Created August 17, 2019 00:50 — forked from danwhitston/wsl_first_time_setup.sh
Setting up my WSL environment - includes git & key, rbenv, rbenv ruby-build, attis, imagemagick, ruby, bundler, mysql, mongodb, redis
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade
ln -s "/mnt/c/Users/Daniel/Documents/homeflow" ~/homeflow
ln -s "/mnt/c/Users/Daniel/Documents" ~/documents
mkdir .ssh
cp documents/id* .ssh/
sudo chmod 600 .ssh/*
cd homeflow/attis
git pull
@spadino
spadino / _service.md
Created March 14, 2019 21:10 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@spadino
spadino / gist:336eaf4d239efd8c05541045cdac467b
Created August 8, 2018 15:04 — forked from mgood/gist:3276107
Python expression evaluator
"""
An attempt to make a safe evaluator of a subset of Python expressions.
This is mostly a proof-of-concept for getting feedback, it has not been
thoroughly checked for safety, use at your own risk :)
It uses the Python ast module to parse the expression, but all evaluation is
done by walking the ast, it is not directly executed by the Python runtime.
Nosetests are provided below including coverage of supported and unsupported
$(function(){
$('#maximage').maximage({
cycleOptions: {
fx: 'fade',
speed: 1000, // Has to match the speed for CSS transitions in jQuery.maximage.css (lines 30 - 33)
timeout: 5000,
prev: '#arrow_left',
next: '#arrow_right',
pause: 0,
before: function(last,current){
@spadino
spadino / binds
Created April 9, 2016 23:11
bugged bindings for kwm
####### Keybinds #######
# Set prefix for Kwms hotkeys
kwmc config prefix-key ctrl+alt+cmd+shift-a
# Set space key
kwmc config spaces-key ctrl
# Prefix is not applied globally
kwmc config prefix-global off
@spadino
spadino / init.lua
Created March 6, 2016 16:06
Move window to space at left or right just with keyboard, using hammer spoon. Complementing setup for KWM users.
-- Switch windows to next space at left or right
function moveWindowOneSpace(direction)
_mouseOrigin = hs.mouse.getAbsolutePosition()
local win = hs.window.focusedWindow()
_clickPoint = win:zoomButtonRect()
_clickPoint.x = _clickPoint.x + _clickPoint.w + 5
_clickPoint.y = _clickPoint.y + (_clickPoint.h / 2)
local mouseClickEvent = hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftmousedown, _clickPoint)
@spadino
spadino / tab.bash
Created February 27, 2016 18:26 — forked from bobthecow/tab.bash
Open new Terminal tabs from the command line
#!/bin/bash
#
# Open new Terminal tabs from the command line
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc`
#
@spadino
spadino / .kwmrc
Created February 23, 2016 01:13
KWM Golden Section setup
##################
# Golden Section #
##################
# Set default values for screen padding
kwmc config padding top 33
kwmc config padding bottom 10
kwmc config padding left 10
kwmc config padding right 10