Skip to content

Instantly share code, notes, and snippets.

Yuxuan 'fishy' Wang fishy

Block or report user

Report or block fishy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fishy
fishy / switch-auto-off.groovy
Last active Oct 1, 2019
SmartThings SmartApp: auto turn off switch after N minutes
View switch-auto-off.groovy
/**
* Switch Auto Off.
*
* Copyright 2019 Yuxuan Wang
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@fishy
fishy / presence-and-garage-door.groovy
Last active Oct 10, 2018
SmartThings smartapp for garage door automation
View presence-and-garage-door.groovy
/**
* Presence and Garage Door
*
* Copyright 2016 Yuxuan Wang
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@fishy
fishy / myq.groovy
Last active Mar 3, 2019
MyQ Garage SmartThings device handler
View myq.groovy
/**
* MyQ Garage Door
*
* Copyright 2018 Yuxuan Wang
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@fishy
fishy / equal_test.go
Last active Mar 30, 2019
Go: bytes.Equal vs. reflect.DeepEqual (vs. self-implemented equal) (https://wang.yuxuan.org/blog/item/2017/02/comparing-byte-s-in-go)
View equal_test.go
package main_test
import (
"bytes"
"fmt"
"math/rand"
"os"
"reflect"
"testing"
"time"
View sections.py
import sys
last_line = ''
for line in sys.stdin.xreadlines():
length = len(last_line.rstrip())
if length != len(line.rstrip()) or length == 0:
sys.stdout.write(last_line)
last_line = line
continue
if line.count("=") == length:
View rest-api-changes.txt
Gerrit Code Review - /changes/ REST API
=======================================
This page describes the change related REST endpoints.
Please also take note of the general information on the
link:rest-api.html[REST API].
[[change-endpoints]]
Change Endpoints
----------------
@fishy
fishy / refapp.sh
Created Jun 1, 2012
If your Applications Stack is sorted by Date Added in your Dock, use this script after you dragged some new app from a DMG.
View refapp.sh
#!/bin/sh
TMPFILE=deadbeef`openssl rand -hex 14`
touch /Applications/${TMPFILE}
sleep 1
rm /Applications/${TMPFILE}
@fishy
fishy / ant-test.patch
Created Oct 20, 2011
The patch you'll need for "ant test" to run in ADT r14
View ant-test.patch
diff --git a/build.xml b/build.xml
index 9315a5e..63a0bb0 100644
--- a/tools/ant/build.xml
+++ b/tools/ant/build.xml
@@ -1043,6 +1043,10 @@
<xpath input="${tested.project.absolute.dir}/AndroidManifest.xml"
expression="/manifest/@package" output="tested.manifest.package" />
+ <!-- Name of the application package extracted from manifest file -->
+ <xpath input="AndroidManifest.xml" expression="/manifest/@package"
View apple.py
#!/usr/bin/env python
import sys
import subprocess
import re
wanted = re.compile(re.compile(r'time=\d\d(\.\d*)? ms'))
host_pattern = 'a%d.phobos.apple.com'
cmd_pattern = 'ping -c 4 %s'
result = []
View shorten_for_itsy.php
<?php
$shorten_prefix = "http://is.gd/api.php?longurl=";
$keyword = "longUrl";
echo ' { "results": {';
$params = explode('&', $_SERVER['QUERY_STRING']);
$first = true;
foreach($params as $param) {
if(preg_match("/^$keyword=(.*)/", $param, $match)) {
$url = $match[1];
You can’t perform that action at this time.