Skip to content

Instantly share code, notes, and snippets.

View htsign's full-sized avatar
🤔

htsign htsign

🤔
View GitHub Profile
@htsign
htsign / canvas-overlay.js
Last active December 16, 2015 21:59
現在 version 0.6 ってとこ。 input[type=range]で背景(div[style=background-color:#fff])の透明度を指定できると面白いかも。
//(function main(){
var mouseStatus = { down: false, grag: false };
var canvasWidth, canvasHeight;
var tmpImage, stackImage = [], current = 0; // undo, redo用
var saved = true; // 画像保存フラグ
var wrapper = document.createElement("div");
wrapper.id = "canvas-overlay-wrapper";
document.body.insertBefore(wrapper, document.body.firstChild);
@htsign
htsign / logintest.xml
Last active December 16, 2015 21:59
自動ログインというか、XMLファイルを軽くいじるとログインしてくれるように動くスクリプトのサンプル。 会社で自分用に使っていたのでIE6でしかテストできていません。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="res/loginform.xsl"?>
<request to="(input here URL to send request)">
<param name="mail" value="foo%40bar.com"/>
<param name="pass" value="this_is_password"/>
<param name="login" value="true"/>
</request>
@htsign
htsign / Custom Data Attribute for IE.js
Last active December 17, 2015 02:19
HTML5の独自データ属性について、Element.dataset.***でアクセスできて欲しいのにIEではできないので、それをできるようにしようと思って書いた。 ECMAScript5th準拠なのでIE9以降でないと動作しません。
window.DOMStringMap || Object.defineProperty(Element.prototype, "dataset", {
enumerable: false,
configurable: false,
get: function(){
var dataset = {};
Array.prototype.slice.call(this.attributes)
.filter(function(val){
return val.name.indexOf("data-") === 0;
}).forEach(function(val){
var property = val.name.slice(5);
@htsign
htsign / Config.cs
Last active August 29, 2015 14:16
MusicBeeプラグイン作成に利用しているConfigクラスとその基底クラス
using System;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
namespace MusicBeePlugin
{
public class ConfigBase
{
/// <summary>
@htsign
htsign / booklivepaid.js
Last active October 28, 2017 10:19
It calculates total paid. Run on 'https://booklive.jp/my/top'
!Number.prototype.padLeft && Object.defineProperty(Number.prototype, "padLeft", {
value(n, s = " ") {
return (Array(n).join(s) + this).slice(-n);
}
});
main();
function main() {
const now = new Date;
"use strict";
for (let i of fib(10)) {
console.log(i);
}
function* fib(num) {
let [prev, curr] = [0, 1];
for (let i = 0; i < num; ++i) {
fib = n ->
[p, c] = [0, 1]
for i in [0..(n - 1)]
[p, c] = [c, p + c]
yield c
for i of fib 10
console.log i
@htsign
htsign / AnciaScript.d.ts
Last active April 24, 2016 17:16
TypeScript Definition for AnciaScript
declare namespace Ancia {
interface App {
/**
* 現在アクティブなTabオブジェクトを返却します。
*/
activeTab: Tab;
/**
* 現在のタブの数を返却します。
*/
@htsign
htsign / Form1.cs
Last active October 26, 2016 10:45
Save/Load CookieContainer Sample
using System;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
@htsign
htsign / string_pointer_test.cs
Created September 29, 2016 01:12
文字列の 2, 7, 12, 17, 22 文字目をアンマネージメモリ上で変更して新たに文字列を作成する
using System;
using System.Runtime.InteropServices;
class Program
{
static void Main(string[] args)
{
string str = "ABCDEabcde01234ひらがなカタカナ漢字", newstr1, newstr2;
IntPtr ptr = Marshal.StringToHGlobalUni(str);