Skip to content

Instantly share code, notes, and snippets.

@kevinxw
kevinxw / state_based_entity_control.yaml
Last active Aug 4, 2021
State based Entity Control
View state_based_entity_control.yaml
blueprint:
name: State Based Entity Control
description: Change the target entity to desired entity state base on the trigger entity's state, illuminance sensor's state, Sun elevation and so on.
domain: automation
input:
trigger_entity:
name: Trigger Entity
description: This entity will trigger the automation.
selector:
entity:
@kevinxw
kevinxw / migrate.sh
Created Jun 25, 2019
seafile-sqlite to mysql
View migrate.sh
echo "Dropping database.."
mysql -e 'drop database if exists `seafile-ccnet`;'
mysql -e 'drop database if exists `seafile-main`;'
mysql -e 'drop database if exists `seafile-seahub`;'
echo 'Recreating ccnet database..'
mysql -e 'create database `seafile-ccnet` character set = "utf8";'
mysql 'seafile-ccnet' < seafile-server-latest/sql/mysql/ccnet.sql
echo 'Recreating seafile database..'
View adblock-generator.sh
#!bin/bash
SUBSCRIPTION_LIST=(
https://easylist-downloads.adblockplus.org/easyprivacy.txt
https://easylist-downloads.adblockplus.org/easylistchina.txt
https://easylist-downloads.adblockplus.org/easylist.txt
https://easylist-downloads.adblockplus.org/malwaredomains_full.txt
https://easylist-downloads.adblockplus.org/exceptionrules.txt
)
@kevinxw
kevinxw / ReactorDependenciesResolverMojoTest.java
Created Nov 9, 2017 — forked from vincent-zurczak/ ReactorDependenciesResolverMojoTest.java
A Maven mojo that shows how to resolve dependencies locations, be it in remote or in the local repository, or even in the reactor.
View ReactorDependenciesResolverMojoTest.java
package whatever;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
@kevinxw
kevinxw / The Technical Interview Cheat Sheet.md
Created May 24, 2017 — forked from TSiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@kevinxw
kevinxw / ddns-start
Last active Jun 28, 2021
Asus-Merlin-DuckDNS
View ddns-start
#!/bin/sh
# register a subdomain at https://www.duckdns.org/ to get your token
# put 'hostname|token' in the 'Host Name' field under DDNS
# e.g. myhost|abcdefgh-1234-5678-9876-f71b0ed7a7fe
DDNS_HOSTNAME_FIELD=$(nvram get ddns_hostname_x)
SUBDOMAIN=$(echo "$DDNS_HOSTNAME_FIELD" | awk -F'|' '{print $1}')
TOKEN=$(echo "$DDNS_HOSTNAME_FIELD" | awk -F'|' '{print $2}')
IPV4=$(nvram get wan0_ipaddr)
@kevinxw
kevinxw / _README.md
Created Aug 30, 2016 — forked from the-darkvoid/_README.md
AsusWRT Merlin: Isolate Guest WiFi
View _README.md
@kevinxw
kevinxw / .gitconfig
Last active Sep 12, 2016
ODL environment setup
View .gitconfig
[push]
default = simple
[alias]
ci = commit
co = checkout
cp = cherry-pick
st = status
ps = push
pl = pull
br = branch
View karabiner-private.xml
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>CM_Storm</vendorname>
<vendorid>0x2516</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>QuickFire_TK</productname>
<productid>0x0011</productid>
</deviceproductdef>
@kevinxw
kevinxw / BOOTP.java
Created Mar 3, 2015
OpenDaylight DHCP and DNS packet parser
View BOOTP.java
package com.kevinxw.net.packet;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.sal.packet.BitBufferHelper;
import org.opendaylight.controller.sal.packet.BufferException;
import org.opendaylight.controller.sal.packet.Packet;
import org.opendaylight.controller.sal.packet.PacketException;
import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.NetUtils;