Skip to content

Instantly share code, notes, and snippets.

View gdesatrigraha's full-sized avatar

Gde Mahardhikha Satrigraha gdesatrigraha

  • Spenmo
  • Indonesia
View GitHub Profile
@gdesatrigraha
gdesatrigraha / enabling tun tap in lxc guest
Created May 3, 2014 07:48
enabling tun/tap in LXC Guest
# in LXC Host (Container), set the following config for the guest
lxc.cgroup.devices.allow = c 10:200 rwm
# in the LXC Guest, run the following commands as root
mkdir /dev/net
mknod /dev/net/tun c 10 200
chmod 666 /dev/net/tun
@gdesatrigraha
gdesatrigraha / remove a directory or files from all git commits
Created May 8, 2014 17:32
remove a directory / files from all git commits
git filter-branch --prune-empty -d /dev/shm/scratch \
--index-filter "git rm --cached -f -r --ignore-unmatch sreader/cms/static" \
--tag-name-filter cat -- --all
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git gc --prune=now
git push -f
@gdesatrigraha
gdesatrigraha / gist:33b21b9554fc6f5c522d
Last active August 29, 2015 14:02
JPA Enhancer Prototype
public class Order {
private long id;
private Set<Product> products;
public Order(long id) {
this.id = id;
}
public long getId() {
@gdesatrigraha
gdesatrigraha / gist:701416a3e67feab36755
Last active August 29, 2015 14:08
ubuntu common setup
sudo apt-get update
sudo apt-get -y install --reinstall language-pack-en
sudo echo 'LC_ALL="en_GB.utf8"' >> /etc/environment
sudo apt-get -y install python-software-properties apt-file software-properties-common
#apt-file is useful to locate a file in apt, ex: apt-file search add-apt-repository
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@gdesatrigraha
gdesatrigraha / linux-gpu-passthrough.md
Last active December 29, 2023 07:04
personal notes on trying gpu-passthrough with ubuntu 18.04

command: apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager ovmf qemu-utils hugepages

command: for iommu_group in $(find /sys/kernel/iommu_groups/ -maxdepth 1 -mindepth 1 -type d); do echo "IOMMU group $(basename "$iommu_group")"; for device in $(ls -1 "$iommu_group"/devices/); do echo -n $'\t'; lspci -nns "$device"; done; done outputs:

IOMMU group 17
	0a:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] [10de:1c03] (rev a1)
	0a:00.1 Audio device [0403]: NVIDIA Corporation GP106 High Definition Audio Controller [10de:10f1] (rev a1)
IOMMU group 16
	09:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK208 [GeForce GT 710B] [10de:128b] (rev a1)
@gdesatrigraha
gdesatrigraha / linux-fix-monitor-resolution.md
Last active November 24, 2023 06:43
fixing monitor resolution on linux with nvidia GPU

Fix monitor resolution on linux with nvidia GPU because the monitor EDID information is unavailable.
This fix assume we are using multiple monitor setup with the same monitor, so we can grab the EDID information of the monitor, from the other monitor attached to another output port (D-SUB, DVI, HDMI, DisplayPort)

In my setup, I have 3 Dell S2415H attached to D-SUB, HDMI, and DVI port.
The monitor which was attached to the D-SUB port (VGA-0), doesn't has any EDID information available, thus I was unable to use the native 1920x1080 resolution.

Step to overcome the situation:

  • install nvidia driver
  • dump binary monitor EDID data using nvidia-settings:
  • run the nvidia-settings app
@gdesatrigraha
gdesatrigraha / iptables-enable-ip-masquerading.sh
Last active October 2, 2018 13:34
iptables enable ip masquerading
#!/bin/sh
iptables -t nat -A POSTROUTING -o <eth0 or whatever else> -j MASQUERADE
# to persist the rule, install iptables-persistent package
#!/bin/sh
# create ovs bridge named bridge0
nmcli conn add type ovs-bridge conn.interface bridge0 autoconnect yes
# add add a port to the bridge for the internal ovs interface (iface0)
nmcli conn add type ovs-port conn.interface port0 master bridge0 autoconnect yes
# add internal ovs interface to the create port0
nmcli conn add type ovs-interface conn.interface iface0 master port0 autoconnect yes ipv4.method auto
@gdesatrigraha
gdesatrigraha / redis-tcpkill.sh
Created October 21, 2020 07:52
installing tcpkill and blocking redis connection on centos 7
yum --enablerepo=extras install epel-release
yum -y install dsniff
tcpkill -i eth0 -9 port 6379
ID 46f4:0001 QEMU QEMU USB HARDDRIVE