Skip to content

Instantly share code, notes, and snippets.

@kiidax
kiidax / switch-search.js
Last active October 14, 2015 12:02
Switch Google and Bing
(function () {
var q = location.search;
if (q.startsWith('?')) {
q = q.substr(1).split('&');
var p = {};
q.forEach(function (x) { var y = x.split('='); p[y[0]] = y[1]; });
console.log(p);
var h = location.hostname;
var langmap = { en: 'en-us', ja: 'ja-jp' };
if (h.indexOf('google') >= 0) {
@kiidax
kiidax / jsobjprop.html
Created September 15, 2014 04:45
Dump Object properties of JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Katsuya Iida">
<title>JavaScript Object properties</title>
</head>
<body>
<h1>JavaScript Object properties</h1>
<table border="2" style="font: 12px monospace">
@kiidax
kiidax / keep-big-images.js
Last active October 14, 2015 12:04
This JavaScript keeps only big images in a page so that you can view them easily.
javascript:(function () {
var MAX_LINK_DEPTH = 3;
var MIN_PIXELS = 100000;
var MAX_RATIO = 3.0;
var LINK_DELAY = 3000;
var imagePat = /.*\.(png|jpg|jpeg|gif)$/;
/**
* Checks if the image is good enough to keep.
* @param {HTMLImgElement} elem The element.
@kiidax
kiidax / ctrlcaps.reg
Created June 28, 2014 01:00
Swap ctrl and caps
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,1d,00,1d,00,3a,00,\
00,00,00,00
@kiidax
kiidax / New-Password.ps1
Created June 27, 2014 13:43
Password generator by PowerShell
param([switch]$Upper, [switch]$Lower, [switch]$Number, [int]$Length = 8)
function Make-CharArray($FirstChar, $LastChar)
{
$FirstIndex = [char]::ConvertToUtf32($FirstChar, 0)
$LastIndex = [char]::ConvertToUtf32($LastChar, 0)
$Chars = $FirstIndex..$LastIndex | ForEach-Object { [char]::ConvertFromUtf32($_) }
return $Chars
}
$UpperChars = Make-CharArray 'A' 'Z'
@kiidax
kiidax / pi.html
Created June 27, 2014 13:42
Compute Pi with HTML5
<style>
* {
margin: 0px;
padding: 0px;
border: none;
}
table {
table-layout: fixed;
width: 100vw;
border-spacing: 0px 0px;
@kiidax
kiidax / generateRandomPassword.js
Last active August 29, 2015 14:03
generateRandomPassword
/// @param {number} length
/// @param {boolean} useUpper
/// @param {boolean} useLower
/// @param {boolean} useNumber
/// @return {string} Generated password.
/// Generate password
function generateRandomPassword(length, useUpper, useLower, useNumber, useSymbol, easy) {
if (typeof length === "undefined") length = 12;
if (typeof useUpper === "undefined") useUpper = true;
if (typeof useLower === "undefined") useLower = true;
@kiidax
kiidax / show-in-english.js
Last active October 14, 2015 12:04
多言語対応しているサイトでは環境によっては自動的に日本語のページが表示されることがあります。このブックマークレットで英語のページを開けます。
javascript:void(window.location=window.location.href.replace("/ja-jp/","/en-us/").replace("/ja/","/en/"))