Skip to content

Instantly share code, notes, and snippets.

@ilude
ilude / portmap.ps1
Created December 20, 2016 14:07
Powershell script to setup localhost port fowarding for a vagrant box using the hyper-v provider
# place this script into a directory with your Vagrantfile and update the $ports hashtable below
# ./portmap up => brings portmapping up
# ./portmap down => brings portmapping down
# ./portmap list => lists portmapping
param (
[string]$command = "up"
)
@ilude
ilude / KVM Install Notes
Last active January 2, 2017 07:38
KVM Notes
# https://help.ubuntu.com/community/KVM/Installation
sudo apt-get install qemu-kvm libvirt-bin bridge-utils
sudo usermod -a -G libvirtd $USER
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
# autostart on boot
@ilude
ilude / Badblocks
Last active February 12, 2019 14:52
{{lowercase title}}
[[Category:Hardware detection and troubleshooting]]
badblocks is a program to test storage devices for bad blocks.
In case of a HDD the whole sector should get retired. A sector is a subdivision of a track on a storage device and sectors that have become bad cannot be used because they have become permanently damaged (a bad sector can have adverse effects ranging from changing a letter in a text file to causing a binary program to have a segmentation fault).
[[S.M.A.R.T.]] (Self-Monitoring, Analysis, and Reporting Technology) is Hardware-featured in almost every HDD still in use nowadays and in some cases it can automatically retire defect HDD Sectors. Anyhow it only passively waits for errors while badblocks writes simple patterns to every block of a device and then reads and checks them searching for damaged areas. (Just like memtest86* does with RAM.)
This can be done in a destructive write-mode that effectively [[Securely_wipe_disk|wipes]] the device (do Backup!) or in non-destructi
@ilude
ilude / Create ZFS Swap
Last active June 18, 2019 17:36
ZFS Notes
sudo zfs create -V 64G -b $(getconf PAGESIZE) -o compression=zle \
-o logbias=throughput -o sync=always \
-o primarycache=metadata -o secondarycache=none \
-o com.sun:auto-snapshot=false pool/swap
sudo mkswap -f /dev/zvol/pool/swap
sudo bash -c "echo /dev/zvol/pool/swap none swap defaults 0 0 >> /etc/fstab"
sudo swapon -av
$ sudo zpool get all
NAME PROPERTY VALUE SOURCE
pool size 14.5T -
pool capacity 3% -
pool altroot - default
pool health ONLINE -
pool guid 5835119220217184389 default
pool version - default
pool bootfs - default
pool delegation on default
@ilude
ilude / KVM Attempt 1
Last active June 12, 2023 18:58
KVM virt-install command
qemu-img create -f qcow2 /pool/vms/xp.qcow2 50G
sudo virt-install --connect qemu:///system -n xp -r 512 --disk path=/pool/vms/xp.qcow2,size=50 \
-c /pool/iso/windows/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso \
--graphics vnc,listen=0.0.0.0,port=65322 --noautoconsole \
--os-type windows --os-variant winxp
@ilude
ilude / .bash_profile
Last active January 2, 2017 07:42
ubuntu 16.04 setup
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 "\[\033[0;33m\][\[\033[1;36m\]%s\[\033[0;33m\]]")\[\e[0m\]$ '
curl -XDELETE 'localhost:9200/test-index/'
curl -XPUT 'localhost:9200/test-index/'
curl -XPOST 'localhost:9200/test-index/_close'
curl -XPUT 'localhost:9200/test-index/_settings' -d '
{
"settings": {
"analysis": {
"tokenizer":{
"part_tokenizer":{
"type":"pattern",
@ilude
ilude / environment.rb
Created August 7, 2013 22:40
ActiveRecord Composite Key Migrations with Rails 3.2.13
# add the following to the end of your environment.rb file
# monkey patching for the win!
ActiveRecord::ConnectionAdapters::ColumnDefinition.class_eval <<-'EOF'
def to_sql
if name.is_a? Array
column_sql = "PRIMARY KEY (#{name.join(',')})"
else
column_sql = "#{base.quote_column_name(name)} #{sql_type}"
column_options = {}
column_options[:null] = null unless null.nil?
@ilude
ilude / MinGW64.md
Last active December 20, 2015 03:49
Go Environment Script

download and compile GLEW in msys shell of DevKit

gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c

gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

# Create glew32.dll
ar cr lib/libglew32.a src/glew.o

Copy bin/, lib/ and include to mingw\x86_64-w64-mingw32 directory of devkit