Skip to content

Instantly share code, notes, and snippets.

View jyap808's full-sized avatar

Julian Y jyap808

View GitHub Profile
@jyap808
jyap808 / create_boot_usb_osx.md
Created February 19, 2014 00:04
Create a bootable USB stick on OS X

##Create a bootable USB stick on OS X

Convert the .iso file to .img using hdiutil

Note: OS X tends to put the .dmg ending on the output file automatically.

$ hdiutil convert -format UDRW -o target.img source.iso
Reading Master Boot Record (MBR : 0)…
Reading Ubuntu 13.10 i386                (Apple_ISO : 1)…
@jyap808
jyap808 / gist:8963001
Created February 12, 2014 19:40
Finding iowait culprits

As root:

/etc/init.d/syslog stop
echo 1 > /proc/sys/vm/block_dump
dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head

Sample output

@jyap808
jyap808 / People_laurenz_dislikes.md
Last active August 29, 2015 13:56
People Laurenz dislikes
  • Kanye West
  • Edward Snowden
  • Floyd Mayweather Jr.
  • Jay Z
  • Uwe Bowell
  • WS Anderson
@jyap808
jyap808 / gist:8924735
Created February 10, 2014 21:39
MySQLDump one INSERT statement for each data row
@jyap808
jyap808 / gist:8703450
Created January 30, 2014 06:13
Resume another user's screen session

The problem: Being root you would like to resume another user's screen session. Let the user be A.

You 'become' him by

su A -

or

sudo su - A
@jyap808
jyap808 / gist:8700714
Last active November 25, 2022 22:42
Rsync - via SSH with no password, utilizing SSH ForceCommand in the authorized_keys file to limit the commands that can be run with that SSH key

To make rsync both secure and automated (i.e : non-interactive), you can use SSH as the transport and set up a key pair. This is what will be discussed in this post, along with a few improvements.

Basic rsync + ssh

Let’s first ensure that rsync works correctly over ssh :

spaghetti% rsync -avz -e ssh --delete Documents prodigy:/tmp

Password:

@jyap808
jyap808 / resize_swap_lvm.md
Created January 28, 2014 21:33
Resize a swap LVM volume
swapoff /dev/vg_foo/lv_swap
lvextend -L+100M /dev/vg_foo/lv_swap
mkswap /dev/vg_foo/lv_swap
swapon /dev/vg_foo/lv_swap

That is: disable swapping on the volume, extend it, re-create the swap area and enable swapping again.

Swap will need to be recreated with mkswap to the new size to be seen.

Modified From: http://oxygene.sk/2009/12/resizing-a-lvm-swap-volume/

@jyap808
jyap808 / resize_ext4_lvm_boot_cd.md
Last active January 4, 2016 20:49
Resize an ext4 LVM volume with a boot CD

Find the name of the Volume Group (henceforth “somevg”) that contains the root Logical Volume:

sudo lvs

(If it’s not showing up, try running sudo lvmdiskscan and sudo pvscan then try again.)

If you run ls /dev/mapper/ you may see that the Logical Volumes is not showing up. If it’s not there, you need to run the following command to make the kernel aware of the logical volumes:

sudo vgchange --available y <somevg>
@jyap808
jyap808 / public_key_decrypt_gpg_base64.go
Created January 9, 2014 20:32
Decrypting a base64 GPG public key encrypted string using a passphrase protected private key in ASCII armor format
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
)
@jyap808
jyap808 / public_key_encrypt_gpg_base64.go
Last active May 21, 2021 16:39
Public key encrypting a string into GPG format and outputting it in base64 encoding
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
)