Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View huafu's full-sized avatar
🏠
Writing code poems from home

Huafu Gandon huafu

🏠
Writing code poems from home
View GitHub Profile
@huafu
huafu / .syslog-ng.md
Created February 26, 2022 08:59 — forked from arvati/.syslog-ng.md
Publish openwrt log contents to MQTT

Router logging to MQTT

This configuration sends all (or part of) your OpenWRT logs to a MQTT broker. I'm writing it up here for future reference.

I made this so I can keep track of wireless clients as they associate and disassociate with my home network. This way, my home automation setup can make decisions based on that information. :)

Installation

@huafu
huafu / README.md
Created February 26, 2022 08:59 — forked from mbernson/README.md
Publish openwrt log contents to MQTT

Router logging to MQTT

This configuration sends all (or part of) your OpenWRT logs to a MQTT broker. I'm writing it up here for future reference.

I made this so I can keep track of wireless clients as they associate and disassociate with my home network. This way, my home automation setup can make decisions based on that information. :)

Installation

@huafu
huafu / main.dart
Created May 28, 2020 09:12
inheritance issues
abstract class IQuery {}
abstract class IDocument {}
abstract class IModel {
IQuery buildQuery({
IDocument from, // putting dynamic here doesn't fix the issue
int Function(IDocument, IDocument) clientSort,
// ...
});
@huafu
huafu / clone.ts
Created July 18, 2018 12:23
JavaScript real object clone
export default function clone<T>(base: T): T {
const res = Object.create(base.constructor.prototype)
Object.defineProperties(res, Object.getOwnPropertyDescriptors(base))
return res
}
@huafu
huafu / a.ts
Last active June 15, 2018 06:10
Issue with firebase typings when sharing code between frontend and backend
// INFO: this has been simplified a maximum just to show the underlying issue
import { database as rtdbClient } from 'firebase'
import { database as rtdbServer } from 'firebase-admin'
type Database = rtdbClient.Database | rtdbServer.Database
type DataSnapshot = rtdbClient.DataSnapshot | rtdbServer.DataSnapshot
interface User {
id: string
@huafu
huafu / lvimg.sh
Created December 15, 2015 18:46
Backup of LVM logical volume by creating a gzip compressed image of temporary snapshot
#!/bin/bash
# usage:
# lvimg lv_dev [backup_path]
#
# lv_dev: path to the logical volume to backup
# backup_path: optional, base path of backups (default to /mnt/backups)
# config
DEFAULT_BACKUP_PATH="/mnt/backups"
@huafu
huafu / gist:b34ad7062dc7f09cd80b
Created June 16, 2015 01:32
Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter not recognized as a wifi card in OpenWrt 15.05-r2 on a RaspBerry B+

I have a fresh install of OpenWrt 15.05-rc2 on a RaspBerry B+

root@bnh-traveller:~# uname -a
Linux bnh-traveller 3.18.11 #1 Mon May 18 21:56:20 CEST 2015 armv6l GNU/Linux

I have already installed required packages with success

root@bnh-traveller:~# opkg install kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb  
Package kmod-rt2800-lib (3.18.14+2015-03-09-3) installed in root is up to date.
@huafu
huafu / app_initializers_session-service.js
Last active August 29, 2015 14:13
Basic session handling
export function initialize(container, application) {
application.inject('service:session', 'store', 'store:main');
application.inject('route', 'session', 'service:session');
application.inject('controller', 'session', 'service:session');
application.inject('model', 'session', 'service:session');
application.inject('component', 'session', 'service:session');
application.deferReadiness();
// load the current session
container.lookup('service:session').load().then(function () {
application.advanceReadiness();
@huafu
huafu / search-icon.html
Created December 24, 2014 02:22
HTML search icon (magnifier)
<span style="display: inline-block;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);">
&#9906;
</span>
@huafu
huafu / index.html
Last active August 29, 2015 14:08
Ember Starter Kit// source http://emberjs.jsbin.com/yebaca
<script type="text/x-handlebars" data-template-name="index">
{{each itemView='dummy'}}
</script>
<script type="text/x-handlebars" data-template-name="dummy">
IN DUMMY TEMPLATE
{{view.val}} {{t}}
</script>