Skip to content

Instantly share code, notes, and snippets.

View umardx's full-sized avatar
🏠
Working from home

Umar Nawawi umardx

🏠
Working from home
View GitHub Profile

Installing OpenCV-3.2.0 on Ubuntu 16.04

The following steps have been tested for Ubuntu 16.04 but should work with other distros as well.

Required Packages

  • GCC 4.4.x or later
  • CMake 2.8.7 or higher
  • Git
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkg-config
@umardx
umardx / consul.service
Last active June 8, 2017 07:04
Systemd for consul: /etc/systemd/system/consul.service
[Unit]
Description=Consul Agent
Requires=network-online.target
After=network-online.target
[Service]
Restart=on-failure
PIDFile=/run/consul.pid
ExecStartPre=[ -f "/run/consul.pid" ] && /usr/bin/rm -f /run/consul.pid
ExecStartPre=/usr/local/bin/consul configtest -config-dir=/etc/consul.d/server
@umardx
umardx / DHCP Failover: Primary
Created June 14, 2017 04:58
DHCP Failover Config File
DHCP Configuration
======================================================================
Primary Server
======================================================================
#dhcpd.conf
authoritative;
option domain-name "localdomain.dx";
option domain-name-servers 192.168.10.11, 192.168.10.12;
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
@umardx
umardx / golang-nuts.go
Last active June 20, 2017 12:15 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@umardx
umardx / Pi3_as_WiFi_AP_Bridge.md
Last active June 29, 2024 14:29
Using a Raspberry Pi 3 as a Wifi access point and bridge

The specificity of my setup, is that the Raspberry won’t be a router but a bridge. DHCP is thus delegated to the main ADSL router and all devices connected to the AP will appear on the same network than other devices. The instructions below are based on a fresh Raspbian lite install so that it can be reproduced easily.

Install the required packages :

$ sudo apt-get install -y bridge-utils hostapd

To create a bridge, we need to enable ip_forward in the kernel, for that, edit /etc/sysctl.conf and remove comment (#) from the following line :

@umardx
umardx / Shrink.md
Last active February 23, 2021 09:02
How to Shrink the Cloned Raspberry Pi Image (Linux-only)

How to Shrink the Cloned Raspberry Pi Image (Linux-only)

These methods create an image file that is equal to the total capacity of the SD card. For example, cloning an SD card with a capacity of 32GB will create an image file of 32 GB, even if only 5 GB is actually in use on the card. This is fine if you only have one or two such images, but any more than that (especially if you use an SSD) will cause you to run out of space. Unfortunately, this tool is only available on Linux. If you do not have Linux installed, you can install the latest version of Ubuntu or Linux Mint in a virtual machine, and run this script there:

shrink.sh

#!/bin/bash
@umardx
umardx / consul.init
Last active August 7, 2017 12:24
consul service init and systemd script for debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Consul service discovery framework
# Description: Healthchecks local services and registers
# them in a central consul database.
@umardx
umardx / autologin_gmail.py
Created August 8, 2017 15:52
Auto login bot gmail
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'putYourUsernameHere'
passwordStr = 'putYourPasswordHere'
browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/ServiceLogin?'
@umardx
umardx / openvpn_docker.md
Last active July 1, 2018 05:49
Setup own VPN server in 15 minutes with Docker

It’s VERY easy to setup your own VPN with docker. This guide assumes you’re ok with operating a linux box but know nothing about docker. I’ll break it down into easy steps:

Setup a docker host

Install docker on the host:

$ curl -sSL https://get.docker.com/ | sh

Run the docker image

Make directory for docker volume:

$ mkdir $HOME/openvpn-data