Skip to content

Instantly share code, notes, and snippets.

View unarist's full-sized avatar

unarist unarist

View GitHub Profile
@unarist
unarist / index.html
Last active April 16, 2016 15:22
マウスカーソルが乗っている文字をハイライト
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.mask-elem { position: absolute; opacity: 0.1; z-index: -1; background: blue; }
.mask-node { position: absolute; opacity: 0.3; z-index: -1; background: green; }
.mask-char { position: absolute; opacity: 0.5; z-index: -1; background: red; }
</style>
<body>
<p>
Lorem ipsum dolor sit amet, <b>consectetur</b> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <i>Ut</i> enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
div{ width: 100px; font-family: Verdana; }
</style>
<body>
<div>
wbr:aaaaaaaa<wbr>aaaaaaaaa<br><br>
zwsp:aaaaaaaa&#8203;aaaaaaaaa<br><br>
zwnj:aaaaaaaa&zwnj;aaaaaaaaa<br><br>
@unarist
unarist / .user.js
Created May 14, 2016 15:58
画面上のツイートをテキストでコピー
// ==UserScript==
// @name 画面上のツイートをテキストでコピー
// @namespace https://github.com/unarist/
// @version 0.1
// @author unarist
// @match https://twitter.com/*
// @exclude https://twitter.com/i/*
// @grant GM_registerMenuCommand
// ==/UserScript==
@unarist
unarist / .cs
Created July 3, 2016 16:32
Mono.Cecilで配列を埋め込む
// 参考: http://lifeinhex.com/how-to-inject-byte-array-using-dnlib/
var asm = AssemblyDefinition.ReadAssembly("target.exe");
var data = File.ReadAllBytes("in.dat");
// 適当な型に、(ここではコンパイラと同じ名前を使うので競合に注意)
var cls = new TypeDefinition("", "<PrivateImplementationDetails>", Mono.Cecil.TypeAttributes.Sealed, asm.MainModule.TypeSystem.Object);
asm.MainModule.Types.Add(cls);
// a. 目的のサイズの構造体(メンバはなくてよい)
@unarist
unarist / merge.cs
Last active July 5, 2016 11:55
Mono.Cecilだけでアセンブリをマージする
Action<T> GetAssignMethod<T>(string field, object value)
{
var arg = Expression.Parameter(typeof(T));
var body = Expression.Assign(Expression.Field(arg, field), Expression.Constant(value));
return (Action<T>)Expression.Lambda(typeof(Action<T>), body, arg).Compile();
}
void MoveItems<T>(ICollection<T> src, ICollection<T> dest, Func<T,bool> filter = null)
{
var items = filter != null ? src.Where(filter).ToList() : src.ToList();
items.ForEach(x => { src.Remove(x); dest.Add(x); });
@unarist
unarist / gist:2924d5929a2e6a68d753eaec94ca39e5
Last active September 8, 2016 16:28
指定した型のシグネチャをVisual F# Power Toolsで取得する
// #r "FSharp.Compiler.Services.dll"
// #r "FSharpVSPowerTools.Core.dll"
open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharpVSPowerTools.CodeGeneration.SignatureGenerator
System.Diagnostics.Trace.Listeners.Clear()
let checker = FSharpChecker.Create()
let tempfile = Path.ChangeExtension(Path.GetTempFileName(), "fs")
// ==UserScript==
// @name MDNで翻訳するときの自動処理
// @namespace https://github.com/unarist/
// @downloadURL https://gist.github.com/unarist/641014d0836cea842690b8f3a20b44f9/raw
// @version 0.1
// @author unarist
// @match https://developer.mozilla.org/*/docs/*
// ==/UserScript==
(function() {
@unarist
unarist / MyExtensions.cs
Created January 30, 2017 06:25
今のMyExtensions
void Main()
{
// Write code to test your extensions here. Press F5 to compile and run.
}
public static class Ex
{
public static string CallerMemberName([CallerMemberName]string member = "") => member;
public static Func<TR> F<TR>(Func<TR> f) { return f; }
public static Func<T, TR> F<T, TR>(Func<T, TR> f) { return f; }
@unarist
unarist / let-diff.user.js
Last active June 18, 2023 08:12
Hatena::Let - Show diff with linked (e.g. forked) Let
// ==UserScript==
// @name Hatena::Let - Show diff for forking
// @namespace https://github.com/unarist/
// @version 0.4.1
// @author unarist
// @downloadURL https://gist.github.com/unarist/e7ee9237764cc5cd2a3b4a531db8b5ee/raw/let-diff.user.js
// @match https://let.hatelabo.jp/*/let/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jsdiff/3.4.0/diff.min.js#sha256=mXHDe/99FPqL1QnYUVFKhAAl45/l91tGCpRNkr4s9Mg=
// @grant none
// ==/UserScript==
@unarist
unarist / mastodon-preview-local-tl.user.js
Last active June 27, 2017 05:22
Mastodon - Preview Local TL
// ==UserScript==
// @name Mastodon - Preview local TL
// @description Add "Preview local TL" to bottom of signup form.
// @namespace https://github.com/unarist/
// @version 0.10
// @author unarist
// @license MIT license
// @match https://*/about
// @require https://cdnjs.cloudflare.com/ajax/libs/jade/1.11.0/jade.min.js
// @downloadURL https://gist.github.com/unarist/6d06ad73945b5a369f6d593b1a2cfba8/raw/mastodon-preview-local-tl.user.js