Skip to content

Instantly share code, notes, and snippets.

@rikuba
rikuba / html_practice.html
Last active October 31, 2020 11:11 — forked from machida/html_practice.html
HTMLの練習(このレシピにマークアップをしてみましょう)
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>カレーのレシピ</title>
</head>
<body>
<article>
@rikuba
rikuba / actions.ts
Last active January 27, 2018 10:04
Make it possible to automatically calculate the union type of action interfaces (until `conditional types` feature is implemented)
// same as `Action = Actions['selectSubreddit'] | Actions['invalidateSubreddit'] | ...`
export type Action = Actions[keyof Actions];
// same as `ActionType = 'SELECT_SUBREDDIT' | 'INVALIDATE_SUBREDDIT' | ...`
export type ActionType = Action['type'];
interface Actions {
selectSubreddit: {
type: 'SELECT_SUBREDDIT';
@rikuba
rikuba / thunks.ts
Created January 25, 2018 18:04
Define thunk actions as classes in TypeScript (It's nonsense...)
import { ThunkAction } from "redux-thunk";
import { RequestPosts, ReceivePosts } from './creators';
import { State } from "../reducers/index";
const ThunkActionClass = class {
constructor(thunk: any) {
return thunk;
}
} as {
new<R, S, A>(thunk: ThunkAction<R, S, A>): ThunkAction<R, S, A>;
const request = require('request');
const Encoding = require('encoding-japanese');
function write(threadUrl, {
name = '',
mail = '',
message = '',
}, onsuccess, onerror) {
const thread = parseUrl(threadUrl);
const writeUrl = thread.url.replace('read.cgi', 'write.cgi');
// ==UserScript==
// @name wheel de slide
// @namespace http://rikuba.com/
// @include http://www.slideshare.net/*
// @include https://www.slideshare.net/*
// @include http://speakerdeck.com/player/*
// @include https://speakerdeck.com/player/*
// @include http://slides.com/*
// @include http://qiita.com/*
// @include http://niconare.nicovideo.jp/watch/*
// ==UserScript==
// @name VolumeWheel
// @namespace http://rikuba.com/
// @match http://*/*
// @match https://*/*
// @run-at document-end
// @version 0.1
// ==/UserScript==
(function () {
@rikuba
rikuba / patch_apply.js
Created September 28, 2013 11:51
patch Function.prototype.apply LICENSE: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
(function () {
try {
Array.apply(null, {});
return;
} catch (e) { }
var toString = Object.prototype.toString,
arrayType = '[object Array]',
_apply = Function.prototype.apply,
slice = /*@cc_on @if (@_jscript_version <= 5.8)
@rikuba
rikuba / function_new.js
Created August 29, 2013 21:39
Function.prototype.new
(function () {
var bind = Function.prototype.bind;
var slice = Array.prototype.slice;
Object.defineProperty(Function.prototype, 'new', {
value: function _new() {
return new (bind.apply(this, [null].concat(slice.call(arguments))));
},
configurable: true,
enumerable: false,
@rikuba
rikuba / function_getName.js
Last active December 21, 2015 09:29
get function name
Function.prototype.getName =
(function () { return (function foobar() { }).name === 'foobar'; })()
? (function () { return function getName() { return this.name; }; })()
: (function () {
var functionKeywordPattern = (function () {
var parts = [];
var keyword = 'function';
for (var i = 0; i < 8; ++i) {
var ch = keyword.charAt(i);
var code = keyword.charCodeAt(i);