Skip to content

Instantly share code, notes, and snippets.

Avatar

Oozman oozman

View GitHub Profile
@oozman
oozman / restart.bash
Last active May 21, 2020
Simple script to re-deploy a container via SSH.
View restart.bash
#!/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
Get IP of docker containers.
View docker-ip.sh
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
@oozman
oozman / random-rename.sh
Created Oct 19, 2018
Random file renamer.
View random-rename.sh
#!/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"
@oozman
oozman / expose-rasberry-pi-to-web.md
Last active Jan 17, 2020
Exposing HomeAssistant to the Internet
View expose-rasberry-pi-to-web.md

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 / vue.js
Created Aug 27, 2017
on-load vue component
View vue.js
Vue.component('onload', {
props: [],
template: '<span></span>',
created: function () {
this.load();
},
methods: {
load() {
this.$emit('load')
}
@oozman
oozman / directive.js
Last active Aug 18, 2017
ng-directive
View directive.js
/**
* 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' +
@oozman
oozman / miio
Last active Sep 25, 2017
MI Home Integration #api #nodejs
View miio
* 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.
View Run Headless Nightmare.js Scripts
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 / gist:8e78d465632745fd197eebe95239f176
Created Jul 20, 2016
[js] clean msword special characters
View gist:8e78d465632745fd197eebe95239f176
/// Replaces commonly-used Windows 1252 encoded chars that do not exist in ASCII or ISO-8859-1 with ISO-8859-1 cognates.
var replaceWordChars = function(text) {
var s = text;
// smart single quotes and apostrophe
s = s.replace(/[\u2018\u2019\u201A]/g, "\'");
// smart double quotes
s = s.replace(/[\u201C\u201D\u201E]/g, "\"");
// ellipsis
s = s.replace(/\u2026/g, "...");
// dashes
View Query Log [L5]
DB::enableQueryLog();
DB::listen(
function ($sql) {
// To save the executed queries to file:
// Process the sql and the bindings:
foreach ($sql->bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else {