Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / locale.txt
Last active May 8, 2017 15:44
Add UTF-8 locale - FreeBSD
# In /etc/login.conf, add
$ diff -u /usr/src/etc/login.conf /etc/login.conf
--- /usr/src/etc/login.conf 2011-03-10 13:48:59.000000000 -0800
+++ /etc/login.conf 2011-05-08 16:44:01.000000000 -0700
@@ -26,7 +26,7 @@
:passwd_format=md5:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\
- :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\
@priyadarshan
priyadarshan / .xmodmap
Last active May 8, 2017 15:20
Change keyboard to have C-M-S and Hyper
! To reset:
! setxkbmap -layout us
! Alt -> Ctrl
! Win -> Meta
! Ctrl -> Super
! Caps-lock -> Hyper
clear Lock
clear Control
@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 / sockets.txt
Created February 23, 2017 12:36
Common lisp sockets
Source: http://www.huuii.com/people/juan/1301
I want to use sockets under common lisp, so I am going to create a two simple functions the first one serve-socket and the second client-socket, I am going to use usocket library.
- Load the library:
(ql:quickload "usocket")
- Change to usocket library
(in-package :usocket)
@priyadarshan
priyadarshan / sitemap.lisp
Created February 23, 2017 12:33
Generate a sitemap using cxml library
(defun generate-sitemap (urls)
"Creates the sitemap file"
(with-open-file (file "/tmp/sitemap.xml"
:direction :output
:element-type :default
:if-exists :supersede)
(cxml:with-xml-output (cxml:make-octet-stream-sink file :indentation 1 :canonical nil)
(cxml:with-element "urlset"
(cxml:attribute "xmlns" "http://www.sitemaps.org/schemas/sitemap/0.9")
;; create the tags
@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

#########################################################################
# FreeBSD - a lesson in poor defaults #
# Published on 3/18/2016 #
# Last updated 8/28/2016 #
# https://twitter.com/blakkheim #
#########################################################################
00) Intro
01) OpenSSH Modifications
02) Mailer Daemon
@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)))