Skip to content

Instantly share code, notes, and snippets.

View gregwym's full-sized avatar
😁
Whow, status!

Greg Wang gregwym

😁
Whow, status!
View GitHub Profile
@gregwym
gregwym / Trie.ts
Last active May 3, 2021 23:12 — forked from tpae/Trie.js
Trie.ts - super simple JavaScript implementation
// Trie.ts - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
class TrieNode<V> {
// we keep a reference to parent
public parent = null;
@gregwym
gregwym / ingress-aliyun-sls-logtail.conf.json
Last active August 13, 2019 02:06
Aliyun logtail config for both stdout and stderr K8s Ingress Logs
{
"inputs": [
{
"detail": {
"IncludeLabel": {
"io.kubernetes.container.name": "nginx-ingress-controller"
},
"Stderr": true,
"Stdout": true
},
@gregwym
gregwym / wav-mp3
Created May 19, 2018 07:46 — forked from championofblocks/wav-mp3
Command line bash to convert all wav to mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done
@gregwym
gregwym / blocklists.synology.sh
Created July 28, 2017 06:18
Enable and update blocklists for Synology Download Station
#!/bin/sh
# Script for blocking IP's
# Set path
cd /var/packages/DownloadStation/etc/download/blocklists
# Permissions
chmod 777 ../settings.json
# Edit config file (block)
@gregwym
gregwym / init.d.homebridge.sh
Last active January 29, 2021 23:20
Homebridge init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: homebridge
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Description: HomeKit support for the impatient
### END INIT INFO
# -*- coding: utf-8 -*-
@gregwym
gregwym / gist:ee098d0bb37df7eb5ffc
Created August 13, 2014 22:00
Moment.js Angular filter
angular.module('myApp', [])
.filter('moment', [
function () {
return function (date, method) {
var momented = moment(date);
return momented[method].apply(momented, Array.prototype.slice.call(arguments, 2));
};
}
]);
@gregwym
gregwym / wd.element.isShown.js
Last active August 29, 2015 14:02
Add element.isShown method to admc/wd Node.js webdriver.
wd.addElementAsyncMethod('isShown', function isShown () {
var cb = wd.findCallback(arguments);
var el = this;
return el.getComputedCss('display', function(err, display) {
if (err) cb(err);
return el.getComputedCss('visibility', function(err, visibility) {
if (err) cb(err);
cb(null, display !== 'none' && visibility !== 'hidden');
});
});
@gregwym
gregwym / FindTopViewController.m
Last active January 6, 2016 02:47 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@gregwym
gregwym / CocoaPodsSetup.md
Last active December 22, 2015 21:19 — forked from andrewsardone/gist:3889904
A quick cheat sheet for using CocoaPods

CocoaPods project setup

Create a Podfile at the root of your project

platform :ios, '5.0'

pod 'AFNetworking'
pod 'OHAttributedLabel'
@gregwym
gregwym / gfm.py
Created February 24, 2013 04:10 — forked from Wilfred/gfm.py
"""GitHub flavoured markdown: because normal markdown has some vicious
gotchas.
Further reading on the gotchas:
http://blog.stackoverflow.com/2009/10/markdown-one-year-later/
This is a Python port of GitHub code, taken from
https://gist.github.com/901706
To run the tests, install nose ($ easy_install nose) then: