Skip to content

Instantly share code, notes, and snippets.

@c18t
c18t / install-ansible-ubuntu.sh
Last active January 19, 2020 20:45
サーバー初期設定時にansibleをインストールする
#!/usr/bin/env bash
# log file
exec 2>&1
exec 1>~/startup.log
# install ansible
sudo apt update -y \
&& sudo apt upgrade -y \
&& sudo apt install -y software-properties-common \
@c18t
c18t / save_moment_01.js
Created December 4, 2019 14:36
Twitter momentの画像を大サイズPNGのリンクにしてクリックで保存するやつ
// ログイン中
function $a(e){return e.tagName=='A'?e:$a(e.parentNode)}document.querySelectorAll('[data-testid~="tweet"] div+div a img').forEach(i=>{a=$a(i);a.href=i.src.replace(/(?:\?.+)?$/,'?format=png&name=large');a.style.zIndex=1;a.replaceWith(a.cloneNode(true))})
@c18t
c18t / 00_DynamicSubClass.cs
Last active December 16, 2019 18:24
サブクラスを実行時に生成してプロパティに属性を付与するテスト
namespace DynamicSubClass
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public class ParentClass
@c18t
c18t / nicovideo2tumblr_nicovideo.user.js
Last active March 20, 2019 15:48
show `Share Tumblr` button on nicovideo.jp
// ==UserScript==
// @name NicoVideo to Tumblr (nicovideo)
// @namespace https://u.chimata.org/
// @version 0.1
// @description show `Share Tumblr` button on nicovideo.jp
// @author You
// @match https://*.nicovideo.jp/watch/*
// @grant none
// ==/UserScript==
@c18t
c18t / dep.fish
Last active September 30, 2018 05:27
function dep --description 'run golang-dep at symlink path instead of origin'
set -l current (pwd)
set -l work $current
set -l phome /mnt/d/Users/Private
set -l ghqroot (git config -l | sed -n /^ghq.root/s/~/$phome/p | awk -F= '{print $2}')
for x in $ghqroot;
set work (string replace -r "^$x" $GOPATH/src $work);
end
sh -c "cd $work && dep $argv"
end
@c18t
c18t / LICENSE.MIT
Last active November 15, 2018 11:41
README.md (template)
MIT License
Copyright (c) 2018 Uchi (/ɯ̹t͡ɕʲi/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@c18t
c18t / dep.fish
Created May 8, 2018 20:29
run golang-dep at symlink path instead of origin
function dep --description 'run golang-dep at symlink path instead of origin'
set -l current (pwd)
set -l work $current
set -l ghqroot (git config -l | sed -n /^ghq.root/s/~/(string replace -a / \\/ $HOME)/p | awk -F= '{print $2}')
for x in $ghqroot;
set work (string replace -r "^$x" $GOPATH/src $work);
end
sh -c "cd $work && dep $argv"
end
@c18t
c18t / factor.js
Last active August 29, 2015 13:56
できるだけ短いコードですばやく素因数分解してみる
l=console.log;o=414209763;r=Math.sqrt(o);for(i=2;i<=r&&i<=o;){o%i==0?(o/=i,l(i)):i++}if(o!=1)l(o)
// 0.042s
@c18t
c18t / chperl
Created January 29, 2014 16:10
"plenv local <version> && plenv rehash"するやつ。.bash_aliasesに追加して下さい
# chperl - plenv local <version> && plenv rehash
chperl() {
# usage: chperl <perl_version>
_VERSION=$1
plenv local $_VERSION && plenv rehash
}
@c18t
c18t / capture_website.js
Created December 5, 2013 20:15
phantomjs でスクリーンショットとってみた $ phantomjs capture_website.js http://google.com/
var system = require('system');
var page = require('webpage').create();
var timezone = +9 * 60 * 60 * 1000;
if (system.args.length === 1) {
console.log('Try to pass one url that you want to capture!');
phantom.exit();
} else {
console.log('start capturing: ' + system.args[1]);