Skip to content

Instantly share code, notes, and snippets.

@hogashi
hogashi / hellopiyo.c
Created August 1, 2015 18:12
hellopiyo.c
/* hellopiyo.c */
#include <stdio.h>
int main(void){
printf("hellopiyo\n");
return 0;
}
@hogashi
hogashi / revpol.c
Last active August 29, 2015 14:27
逆ポーランド記法四則計算(入力:0,自然数)
/* revpol.c */
#include <stdio.h>
#include <stdlib.h>
int main(void){
int countNum = 0, didMean = 0;
double num[100] = {0.0};
char c;
while(1){
@hogashi
hogashi / oauthsinatra.rb
Created September 16, 2015 15:25
Twitter OAuth in sinatra
require 'sinatra'
require 'twitter_oauth'
enable :sessions
before do
key = '**app**consumer**key**'
secret = '**app**consumer**secret**'
@twitter = TwitterOAuth::Client.new(
:consumer_key => key,
@hogashi
hogashi / TOOIbookmarklet.js
Created December 29, 2015 06:51
The bookmarklet of TwitterOpenOriginalImage
javascript:(function(){if(m=document.querySelector('.permalink-tweet-container'))for(i=((m=m.getElementsByClassName('AdaptiveMedia-photoContainer')).length-1);i>=0;i--)if(u=m[i].getElementsByTagName('img')[0].src)window.open(u+':orig')})();
/*
javascript:(
function() {
if(m = document.querySelector('.permalink-tweet-container'))
for(i = ((m = m.getElementsByClassName('AdaptiveMedia-photoContainer')).length - 1); i>=0; i--)
if(u = m[i].getElementsByTagName('img')[0].src)
window.open(u + ':orig')
}
)();
@hogashi
hogashi / ws.php
Last active August 4, 2016 17:42
<?php
$word = '+' . $_GET['query'];
$page = shell_exec ( 'curl -o- http://ejje.weblio.jp/small/content/' . urlencode($word) . ' | tr "\n" "\000" | sed "s/<\/\(\|no\)script>/\n/g" | sed "s/<\(\|no\)script.*$//" | sed "s/<meta[^>]*>//" | sed "s/\"http\:\/\/ejje\.weblio\.jp\/small\/content\/\([^\"]*\)\"/\"\.\/ws\.php\?query=\1\"/g" | sed "s/\"http\:\/\/ejje\.weblio\.jp[^\"]*\"/\"\.\/ws\.php\"/g" | tr "\000" "\n"' );
print $page;
print "It works.<br>"; # 動作確認用文字列
?>
@hogashi
hogashi / showgyazo_td.js
Last active August 18, 2016 17:15
show gyazo image on timeline in TweetDeck
Array.from(document.getElementsByClassName('url-ext')).map(
(v, i) => {
if(v.href.match(/https\:\/\/gyazo\.com/)) {
divtag1 = document.createElement('div');
divtag1.className = 'js-media media-preview position-rel';
v.parentNode.parentNode.insertBefore(divtag1, v.parentNode.nextSibling);
divtag2 = document.createElement('div');
divtag2.className = 'js-media-preview-container position-rel margin-vm';
divtag1.appendChild(divtag2);
atag = document.createElement('a');
setInterval(() => {
document.getElementsByTagName('frame')[0].contentWindow
.document.getElementsByTagName('input')[4].click();
console.log('clicked')
}, 60000);
@hogashi
hogashi / pdf-unlock-minimize.sh
Created November 9, 2016 17:05
minimize PDF with JPG compressing
#!/bin/bash
# pdf-unlock-minimize.sh <- base dir is where this script is, you must run this from here
# |- pdf/
# | \- 01.pdf, 02.pdf,... <- put PDFs you want to minimize, then run this script
# |- dec/ <- decrypted PDFs
# |- jpgs/
# | \- 01/ <- compressed JPGs from raw/
# | \- raw/ <- displayed raw JPGs
# | \- 02/

多段ssh

  1. ローカルで鍵を生成 ssh-keygen -t rsa -b 4096
  2. ~/.ssh/config に設定を書く
  3. ローカルの鍵を踏み台に登録
  • ssh-copy-id fumidai
  • cat ~/.ssh/id_rsa.pub | ssh fumidai 'cat >> ~/.ssh/authorized_keys'と等価
  1. ローカルの鍵を目的に登録
  • ssh-copy-id mokuteki
  • cat ~/.ssh/id_rsa.pub | ssh mokuteki 'cat &gt;&gt; ~/.ssh/authorized_keys'と等価
// pixivnovel.js
// // ページ全体でDOMの変更を検知し都度ボタン設置
// var target = document.querySelector('html')
// var observer = new MutationObserver(main)
// var config = {childList: true, subtree: true}
// observer.observe(target, config)
var gebi = id => document.getElementById(id),
gebc = className => document.getElementsByClassName(className),