Skip to content

Instantly share code, notes, and snippets.

View KOBA789's full-sized avatar
🚀

KOBA789 KOBA789

🚀
View GitHub Profile
@KOBA789
KOBA789 / fix_snr.patch
Created March 15, 2018 12:24
recdvb-1.3.1 の SNR 表示をいい感じにするパッチ
diff --git a/recpt1core.c b/recpt1core.c
index 168a023..36dd1fd 100644
--- a/recpt1core.c
+++ b/recpt1core.c
@@ -39,11 +39,50 @@ close_tuner(thread_data *tdata)
}
void
+print_stat(struct dtv_stats stat)
+{
@KOBA789
KOBA789 / type_safe_url_template.ts
Created July 20, 2017 14:36
Type-safe URL Template
class PathTemplate<N extends string> {
constructor(public fragments: string[], public paramNames: N[]) {}
render(params: {[_ in N]: string}) {
const buf = [this.fragments[0]];
for (let i = 0; i < this.paramNames.length; ++i) {
buf.push(params[this.paramNames[i]]);
buf.push(this.fragments[i + 1]);
}
return buf.join('');
function dig<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
const s: string = dig({ a: 'hoge', b: 1 }, 'a');
const t: number = dig({ a: 'hoge', b: 1 }, 'b');
@KOBA789
KOBA789 / async_await.js
Created February 22, 2017 02:37
Node.js v7.6.0 記念
'use strict';
function wait (ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function mainLoop() {
while(true) {
console.log('tick!');
await wait(1000);
@KOBA789
KOBA789 / tsconfig.json
Last active January 28, 2017 11:25
よさそう.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"preserveConstEnums": true,
"target": "es2015",
"moduleResolution": "node",
"strictNullChecks": true,
"types": [
"node"
@KOBA789
KOBA789 / build.sh
Created March 14, 2016 12:45
もう Grunt やら Gulp やらで消耗したくない
#!/bin/bash
set -ue
#-------------------------------------------------------------------------------
SOURCE_DIR="."
DESTINATION_DIR="public/assets"
JAVASCRIPTS_DIR="javascripts"
STYLESHEETS_DIR="stylesheets"
function Parent () {
this._state = [];
}
Parent.prototype.foo = function (v) {
this._state.push(v);
};
Parent.prototype.bar = function () {
return this._state.join(',');
[/* item */].map(function (item) {
return function () {
return new Promise(function (resolve, reject) {
/* procedure */
});
};
}).reduce(function (a, b) {
return function () {
return a().then(b);
};
@KOBA789
KOBA789 / qs.js
Created July 22, 2015 17:04
QueryString Parser/Stringifier
// THIS CODE IS LICENCED UNDER WTFPL
var qs = {
get: function () {
return qs.parse(window.location.search.substring(1));
},
parse: function (str) {
return str.split('&').map(function (value) { return value.split('='); })
.reduce(function (obj, pair) {
obj[pair[0]] = decodeURIComponent(pair[1]);
var A = /* put your answer here */,
B = /* put your answer here */;
if (B/A !== A/B && A === B && 1/A > 2/B) console.log('congrats!');