Skip to content

Instantly share code, notes, and snippets.

View fumikito's full-sized avatar
🐕
Have 1 dog. Her name is Packing.

Takahashi Fumiki fumikito

🐕
Have 1 dog. Her name is Packing.
View GitHub Profile
@fumikito
fumikito / fluid-redmine-badge.js
Created June 2, 2011 13:38
Fluidで作成したRedmineのアプリでドックにバッジを表示するユーザースクリプト
/**
* 自分の担当しているチケットを表示する Window > User Scriptで貼りつける
*
* @return void
*/
function getTicketCount(){
new Ajax.Request("http://tech.hametuha.org/issues.xml", {
method: "get",
parameters: {
key: "Here_comes_your_api_key",
@fumikito
fumikito / nmap-port-scan.bash
Created June 14, 2011 07:26
Nmap ポートスキャン
#Macportsでnmapをインストールすること
nmap -sT 192.168.0.0-255
@fumikito
fumikito / check-deffered-mail.sh
Created June 12, 2012 14:58
Postfixで配信失敗したメールを読む
# http://hatomugi.sakura.ne.jp/forum/topic.php?id=76
#メールキュー確認
mailq
#メールキューのIDで中身を見る
sudo postcat -q [キューID] | nkf -m
@fumikito
fumikito / wp-readme
Last active October 20, 2020 14:28
Githubのreadme.mdからWordPressプラグイン用のreame.txtをに変換するコマンドラインツール
#!/opt/local/bin/php
<?php
// 1行目のシバンは環境に合わせて書き換えてください
// `which php` とターミナルで打つと、パスがわかります。
$file = './readme.md';
if( !file_exists($file) ){
die("[Error] 現在のディレクトリにreadme.mdが存在しません".PHP_EOL);
@fumikito
fumikito / wp-fulltext-search.php
Created October 19, 2013 17:38
WordPressでFULLTEXTインデックスを用いた全文検索を試す
<?php
/**
* WordPressで全文検索を試みる
*
* initフックなどでインスタンス化してください。
* あんまり遅いタイミングだとエラーを吐きます。
* Singleton実装です。
*
* <code>
* // functions.phpなどに記載
@fumikito
fumikito / insert-to-wp-editor.js
Last active December 29, 2015 19:48
WordPressのエディタに対してiframe内からテキスト要素を追加ビジュアルエディタかHTMLエディタかを判別しつつ、最後にカーソルがあった位置に挿入する。ついでにthickboxを閉じる
jQuery(document).ready(function($){
// ショートコード挿入
$('.button-shortcode').click(function(e){
e.preventDefault();
// ex. ショートコードの値
var shortcode = $(this).prev('input').val(),
mce = window.parent.tinyMCE;
if( mce.activeEditor && !(mce.activeEditor.isHidden()) ){
// TinyMCEがオープンならそれを使う
window.parent.tinyMCE.activeEditor.execCommand( 'mceInsertContent', false, shortCode )
@fumikito
fumikito / try-catch.php
Created January 19, 2014 04:33
catchブロックの中でエラーを投げてみる
<?php
/**
* catchブロックの中でエラーを投げてみる
*
* php try-catch.php 1000と入力すると、
* Uncaught exceptionが発生。したがって、こういうことをやりたい場合は
* 入れ子にしないとダメ。
* 結果的に、例外の種類が増えると入れ子がどんどん深くなっていく
* 5.5ならfinally があるので、もうちょっとすっきりできる
*/
@fumikito
fumikito / lsf-to-scss.php
Created January 23, 2014 07:28
Ligature Symbolsのフォントをfont-awesomeライクなSCSSに返還するスクリプト - HTMLのテーブルをコピーしてテキストファイルに貼付け - Excelに貼付け後、TSVに書き出し - そのtsvと同階層で実行
<?php
$file = explode("\n", file_get_contents('./lsf.txt'));
$variables = [];
$sass = [];
foreach($file as $row){
list($title, $aliases, $unicode) = array_map('trim', explode("\t", trim($row)));
$title = 'lsf-'.$title;
@fumikito
fumikito / wp-pagenavi_bootstrap.php
Last active December 12, 2015 16:34
WordPressのWP-Pagenaviが返すHTMLをTwitter Bootstrapに合ったものに変更する
<?php
/**
* Change WP-Pagenavi's output
*
* @package hametuha
* @filter wp_pagenavi
* @param string $html
* @return string
*/
@fumikito
fumikito / mecab.php
Last active May 2, 2023 22:35
PhpStormのプロジェクト内に入れておくとphp-mecabのコード補完ができる魔法のファイル
<?php
/**
* The MeCab PHP extension
*
* Copyright (c) 2006-2012 Ryusuke SEKIYAMA. All rights reserved.
*
* 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,