Skip to content

Instantly share code, notes, and snippets.

View gf3's full-sized avatar
🍊
workin' goodly

Gianni Chiappetta gf3

🍊
workin' goodly
View GitHub Profile
@gf3
gf3 / 81-disable-onboard-audio.rules
Created April 7, 2020 05:34
Linux on AMD TRX40 (Threadripper) and NVIDIA 2080ti RTX
# /etc/udev/rules.d/81-disable-onboard-audio.rules
#
# Disable onboard Asustek USB audio device
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="1917", ATTR{authorized}="0"
@gf3
gf3 / ago.js
Created June 2, 2011 18:43
Super small relative dates
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }
@gf3
gf3 / roundedCorners.swift
Last active August 14, 2019 14:43
NSImageView with rounded corners
// XCode 8.3
// Swift 3.1
import Cocoa
class SomeViewController: NSViewController {
@IBOutlet weak var artwork: NSImageView!
override func viewDidLoad() {
super.viewDidLoad()
@gf3
gf3 / main.rs
Created May 29, 2019 21:12
error[E0507]: cannot move out of borrowed content
extern crate unidiff;
use unidiff::PatchSet; // http://messense.github.io/unidiff-rs/unidiff/struct.PatchSet.html
pub struct Printer {
patch_set: PatchSet,
}
impl Printer {
pub fn new(source: &str) -> Self {
@gf3
gf3 / setup.sh
Last active January 22, 2019 20:20
Neovim config setup
#!/bin/sh
# Install:
# curl -fsL https://gist.githubusercontent.com/gf3/3d90fd82deaa4cab19fb8d817a370e27/raw/setup.sh | sh
# Directories
mkdir -p ~/.local/share/nvim/{backup,swap,undo}
# Config
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
@gf3
gf3 / README.md
Last active January 22, 2019 18:07
Docker: VPN + DNS Proxy + App

Docker setup

Using the docker-compose.yml below as a template, replace the webapp section with your application.

VPN setup

Follow the setup guide here: https://github.com/kylemanna/docker-openvpn

Afterwards we'll want to modify the VPN config so that it points to our local DNS proxy.

@gf3
gf3 / html5.vim
Created May 5, 2010 15:27 — forked from rcmachado/html5.vim
vim HTML5 Syntax File
" Vim syntax file
" Language: HTML (version 5)
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
" URL: http://rm.blog.br/vim/syntax/html.vim
" Last Change: 2009 Aug 19
" License: Public domain
" (but let me know if you liked it :) )
"
" Note: This file just adds the new tags from HTML 5
" and don't replace default html.vim syntax file
@gf3
gf3 / backoff-request.js
Last active April 4, 2018 02:02
Backoff AJAX requests
/**
* @flow
*/
import request from 'lib/request';
type F<T> = (response: T) => bool;
const BACKOFF_MAX = 60; // seconds
const BACKOFF_ATTEMPTS = 60;
@gf3
gf3 / uuid.ts
Created February 20, 2018 19:57
Generate a secure RFC4122-compliant v4 UUID
/**
* Convert a number or array of integers to a string of padded hex octets.
*/
function asHex(value: number[] | Uint8Array): string {
return Array.from(value).map(i => ('00' + i.toString(16)).slice(-2)).join('');
}
/**
* Attempt to securely generate random bytes/
*/
@gf3
gf3 / rename.vim
Created May 2, 2017 14:04
Vim Rename
" Rename buffer (:Rename) {{{
function! s:RenameBuffer(name)
silent! execute 'saveas! ' . a:name
let l:old_buffer = bufnr("#")
let l:old_filename = expand("#:t")
let l:new_buffer = bufnr("%")
let l:new_filename = expand("%:t")
silent! execute '!rm ' . shellescape(expand("#"), 1)
silent! execute 'bd' l:old_buffer
echom 'Renamed `' . l:old_filename . '` to `' . l:new_filename . '`'