Skip to content

Instantly share code, notes, and snippets.

@bcchenbc
bcchenbc / set-zen32-indicator-for-light.yaml
Last active August 11, 2022 16:28 — forked from halomakes/set-zen32-indicator-for-light.yml
Blueprint: Set Indicator on a ZEN32 Scene Controller button Based on Light Status
blueprint:
name: Set Indicator Light on Scene Controller
description: For Zooz ZEN32. Sets the indicator color when light is off or dimmed.
domain: automation
input:
zooz_switch:
name: Zooz Switch
description: List of available Zooz ZEN32 switches.
selector:
device:
@bcchenbc
bcchenbc / control-light-with-zen32.yaml
Last active August 11, 2022 16:22 — forked from halomakes/control-light-with-zen32.yml
Blueprint: Control a light with a button on a Zooz ZEN32 Scene Controller
blueprint:
name: Control Light with Scene Controller
description: For Zooz ZEN32. Toggle a light with a single press, set it to max brightness with double-tap, night-light mode with hold.
domain: automation
input:
zooz_switch:
name: Zooz Switch
description: List of available Zooz ZEN32 switches.
selector:
device:
@bcchenbc
bcchenbc / kern_log_counter.awk
Created October 3, 2018 07:13
AWK script for counting log lines that were generated in a specific time period
#!/usr/bin/awk -f
function MonInNum(in_str) {
return (index("JanFebMarAprMayJunJulAugSepOctNovDec",in_str)+2)/3
}
function TimeMaker(year, mon, day, hour, min, sec, utc) {
datestring = year" "mon" "day" "hour" "min" "sec" "utc
return mktime(datestring)
}
@bcchenbc
bcchenbc / gist:563632994cc015b61edd5d97c171fc63
Created April 24, 2018 06:53
Install CUDA 8 on Debian 9
# Credit goes to the contributors of this post:
# https://devtalk.nvidia.com/default/topic/983777/can-t-locate-installutils-pm-in-inc/
# Assuming using run file: cuda_8.0.61_375.26_linux.run
./cuda_8.0.61_375.26_linux.run --tar mxvf
sudo cp InstallUtils.pm /usr/lib/x86_64-linux-gnu/perl-base
sudo ./cuda_8.0.61_375.26_linux.run --override
@bcchenbc
bcchenbc / rmANOVA.do
Last active February 20, 2018 07:25
For Lab Meeting 20180223
/*
This script is based on the instruction provided by IDRE UCLA
https://stats.idre.ucla.edu/stata/seminars/repeated-measures-analysis-with-stata/
*/
/**** Data ****/
use https://stats.idre.ucla.edu/stat/data/repeated_measures, clear
/*
There are a total of
@bcchenbc
bcchenbc / mturk_boto_intro.py
Created November 20, 2017 20:18 — forked from ktuite/mturk_boto_intro.py
Super simple python script that uses boto to connect to amazon mturk. If you use the sandbox, you'll see a balance of $10,000! Otherwise, you'll see your normal balance.
import boto.mturk.connection
sandbox_host = 'mechanicalturk.sandbox.amazonaws.com'
real_host = 'mechanicalturk.amazonaws.com'
mturk = boto.mturk.connection.MTurkConnection(
aws_access_key_id = 'XXX',
aws_secret_access_key = 'XXX',
host = sandbox_host,
debug = 1 # debug = 2 prints out all requests. but we'll just keep it at 1
# Commands for setting up Samba 4 Domain Controller on Raspberry Pi 3.
# Only tested on "2017-08-16-raspbian-stretch-lite".
# Credit goes to:
# VirtualFrontiers.co.uk http://www.virtualfrontiers.co.uk/domain_controller.htm
# Techmint.com https://www.tecmint.com/set-add-static-ip-address-in-linux/
# Note that I have applied this fix for ethernet interface naming.
# https://raspberrypi.stackexchange.com/questions/43560/raspberry-pi-3-eth0-wrongfully-named-enx
@bcchenbc
bcchenbc / prepare_chromium.sh
Created January 12, 2017 02:29
substitute chromium of distro with the latest build
# Credit goes to saiarcot895:
# https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev
# Assuming API key has been generated,
# http://www.chromium.org/developers/how-tos/api-keys
# and (of course), chromium-browser has installed...
sudo mv $(which chromium-browser) $(which chromium-browser).backup
git clone https://github.com/scheib/chromium-latest-linux.git
sudo ln -s $(pwd)/chromium-latest-linux/latest/chrome $(which chromium-browser)
# http://tqdev.com/2016-installing-adminer-ubuntu
# http://askubuntu.com/questions/760787/php-rendered-as-text-after-ubuntu-16-04-upgrade
sudo apt install apache2 libapache2-mod-php
sudo a2enmod php7.0
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo mkdir /usr/share/adminer
sudo wget "http://www.adminer.org/latest.php" -O /usr/share/adminer/latest.php
sudo ln -s /usr/share/adminer/latest.php /usr/share/adminer/adminer.php
@bcchenbc
bcchenbc / prepare_rabbitmq.sh
Created January 2, 2017 01:16
Prepare Rabbitmq server on new system
# install current version
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install rabbitmq-server
# enable web interface
rabbitmq-plugins enable rabbitmq_management
# create admin account, guest/guest doesn't seem to work