Skip to content

Instantly share code, notes, and snippets.

View oozman's full-sized avatar

Oozman oozman

View GitHub Profile
@oozman
oozman / custom-domain-localhost-xampp
Last active September 1, 2022 06:07
How to add a custom domain name on your localhost using XAMPP. Codes are based on Windows, but Step 2 onwards are pretty much applicable on other operating system.
Step 1:
Go to: C:\Windows\System32\Drivers\etc\hosts
And add this to the bottom of the file:
=============
127.0.0.1 your.domain.com
=============
Step 2:
Go to [your XAMPP directory]/apache/conf/httpd-xampp.conf
@oozman
oozman / restart.bash
Last active May 21, 2020 00:23
Simple script to re-deploy a container via SSH.
#!/bin/bash
# Usage: ./restart.bash <container-name> <domain name>
CONTAINER_NAME=$1
CONTAINER_DOMAIN=$2
# Build
docker build -t $CONTAINER_NAME .
@oozman
oozman / docker-ip.sh
Last active May 7, 2020 18:44
Get IP of docker containers.
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
@oozman
oozman / vue.js
Created August 27, 2017 16:04
on-load vue component
Vue.component('onload', {
props: [],
template: '<span></span>',
created: function () {
this.load();
},
methods: {
load() {
this.$emit('load')
}
@oozman
oozman / expose-rasberry-pi-to-web.md
Last active January 17, 2020 14:54
Exposing HomeAssistant to the Internet

Install Dataplicity

Exposes our RaspberryPi to the web.

  • Login to RaspberryPi
  • Create account at https://www.dataplicity.com
  • Install Dataplicity daemon as per instruction.
  • Go to your Dataplicity dashboard and go to your device and enable wormhole.

Install Caddy Server

This will serve as our HTTP server.

@oozman
oozman / random-rename.sh
Created October 19, 2018 11:43
Random file renamer.
#!/bin/bash
chars=( {a..z} {A..Z} {0..9} )
function rand_string {
local c=$1 ret=
while((c--)); do
ret+=${chars[$((RANDOM%${#chars[@]}))]}
done
printf '%s\n' "$ret"
How to install and run Headless nightmare.js based scripts in Ubuntu.
Steps:
1. Spin Ubuntu 16.04 x64 server
2. Run: apt-get update
3. Run: apt-get upgrade
4. Run: apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb
5. Install Node.js 6+. See: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
You can then run your script using this command:
@oozman
oozman / LongRunningGetIO
Created March 14, 2013 07:08
Getting data from API URL using GET in Android (AsyncTask). Credits: http://goo.gl/5hgFC
private class LongRunningGetIO extends AsyncTask <Void, Void, String>{
protected String getASCIIContentFromEntity(HttpEntity entity) throws IllegalStateException, IOException{
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
int n = 1;
while (n>0) {
byte[] b = new byte[4096];
n = in.read(b);
if (n>0){
@oozman
oozman / miio
Last active September 25, 2017 12:54
MI Home Integration #api #nodejs
* Install miio library: https://github.com/aholstenson/miio
`node install -g miio`
* Get device token:
`miio --discover`
or use [python-mirobo](https://github.com/rytilahti/python-mirobo)
* See and follow miio library documentation.
@oozman
oozman / directive.js
Last active August 18, 2017 03:26
ng-directive
/**
* Toast directive. Ex: <toast msg="Some message." style="success|info|warning|danger"></toast>
*/
.directive('toast', [function () {
return {
restrict: 'E',
template: function (elem, attr) {
return '<div class="toast">\n' +
' <div class="{{ style }}" role="alert">{{msg}}</div>\n' +