Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / git-mv-with-history
Created May 20, 2017 12:00 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@priyadarshan
priyadarshan / PolicyKit.conf
Last active December 28, 2021 18:00
FreeBSD 11 notebook installation cheat-sheet
# /usr/local/etc/PolicyKit/PolicyKit.conf
# Allow normal users to mount removable media automatically
<config version="0.1">
<match action="org.freedesktop.hal.storage.mount-removable">
<return result="yes"/>
</match>
<match action="org.freedesktop.hal.storage.mount-fixed">
<return result="yes"/>
</match>
@priyadarshan
priyadarshan / latency.txt
Created January 31, 2017 16:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

FreeBSD Jails with VLAN HOWTO

This article discusses how to set up jails on a FreeBSD 11-CURRENT system utilizing VIMAGE (aka VNET) to provide a virtualized independent network stack for each jail with support for VLAN tagging.

Prerequisites

  • You have a machine installed with FreeBSD 11-CURRENT on ZFS.
  • We will be building world and kernel and using that as the base for the jails. Hence basic knowledge of FreeBSD system administration is assumed. If you've never compiled and installed a FreeBSD base system and kernel, this article may be hard to follow. Refer to the FreeBSD Handbook, especially chapter 8: 'Configuring the FreeBSD Kernel' and chapter 23: 'Updating and Upgrading FreeBSD'.

Assumptions

@priyadarshan
priyadarshan / function-wrappers.lisp
Created August 28, 2016 08:42 — forked from spacebat/function-wrappers.lisp
Poor man's defadvice
;; Simple and rough substitute for defadvice :around on SBCL. Should
;; be easy to port by substituting something appropriate for
;; sb-introspect:function-lambda-list
;; Its easy to get confused with wrapped functions - if you redefine a
;; function while it is wrapped, it will still seem to be wrapped
;; (entry in the hash table for the name) but won't be.
(defvar *wrapped-functions* (make-hash-table))
@priyadarshan
priyadarshan / god-mode.lisp
Created July 23, 2016 08:50 — forked from LaloHao/god-mode.lisp
A mode-line status for stumpwm analogous to emacs' god-mode using command-mode.
;;; god-mode.lisp
(defvar *god-mode-enabled* nil)
(defvar *god-mode-enabled-text* "God")
(defvar *god-mode-disabled-text* "Default")
(defun god-mode ()
"Enables or disables `god-mode' by updating variable `god-mode-enabled'."
(if *god-mode-enabled*
(setf *god-mode-enabled* nil)
(setf *god-mode-enabled* t)))
(in-package :stumpwm)
(defun select-from-dmenu (screen table &optional prompt
(initial-selection 0))
"Prompt the user to select from a menu using dmenu on SCREEN. TABLE can be
a list of values or an alist. If it's an alist, the CAR of each
element is displayed in the menu. What is displayed as menu items
must be strings. Returns the selected element in TABLE or nil if aborted."
(let* ((menu-options (mapcar #'menu-element-name table))
@priyadarshan
priyadarshan / imenu-use-packge.el
Created April 12, 2016 16:47 — forked from jordonbiondo/imenu-use-packge.el
have imenu include use-package
;; in action: http://i.imgur.com/Tt2M0LC.gif
(add-to-list 'imenu-generic-expression
'("Used Packages"
"\\(^\\s-*(use-package +\\)\\(\\_<.+\\_>\\)" 2))
;; I also highly recommend imenu-anywhere to make developing your config even easier
@priyadarshan
priyadarshan / New-RulesFromNetstat.ps1
Last active January 9, 2018 12:55 — forked from jeffpatton1971/New-RulesFromNetstat.ps1
A script to create firewall rules based on netstat output
<#
Create FW rules for TCP and UDP Listening Ports
netstat -an -p tcp |Select-String "Listening"
netstat -an -p udp |Select-String "Listening"
for each entry in netstat create firewall rule
name = -p tcp|udp port port #
description = automatic allow rule generated by powershell on get-date
;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。