Skip to content

Instantly share code, notes, and snippets.

View oppara's full-sized avatar
:octocat:
::

oppara oppara

:octocat:
::
View GitHub Profile
@oppara
oppara / run firefox
Created November 9, 2008 03:57
bash: run firefox
#!/bin/bash
FF=`ps aux | grep firefox-bin | wc -l`
if [ "$FF" == 1 ]; then
  env DISPLAY=:0. zenity --info --text "I run Firefox" && firefox
else
  env DISPLAY=:0. zenity --info --text "Firefox is running"
fi
mm hh * * * export DISPLAY=:0 && firefox-bin > /dev/null 2>&1
@oppara
oppara / is_assoc_array.php
Last active October 25, 2015 06:05
php: is assoc array
<?php
/**
* is assoc array
*
* @see http://jp.php.net/manual/ja/function.is-array.php
* @param array $a
* @access public
* @return bool
*/
@oppara
oppara / sprintf with array
Created April 26, 2009 16:23
php: sprintf use array
/**
* sprintf use array
*
* @see http://jp.php.net/manual/ja/function.printf.php
* @param string $format
* @param array $arr
* @access public
* @return string
*/
function sprintf_array( $format, $arr ) {
@oppara
oppara / htmlescape.php
Last active October 25, 2015 06:04
php: htmlescape but $tags
<?php
/**
* htmlescape but $tags
*
* @see http://jp.php.net/manual/ja/function.htmlspecialchars.php
* @param string $str
* @param string $tags delimiter "|". i.e. 'a|div|span'
* @param string $quote_style
* @param string $l_deli '##{##'
@oppara
oppara / gist:132274
Created June 18, 2009 23:13
php: mb_trim
function mb_trim( $str ) {
return mb_ereg_replace(
'^[[:space:]]*([\s\S]*?)[[:space:]]*$', '\1', $str );
}
@oppara
oppara / jQuery confirm plug-in
Created September 20, 2009 13:57
jQuery confirm plug-in
/*
* jQuery confirm plug-in
*
* @see http://blog.smartnetwork.co.jp/staff/jquery-confirm-plugin
*
* usage:
* <form id="hoge" method="post">
* <input type="submit" name="hoge" value="ダイアログなし"/>
* <input type="submit" name="hoge" title="ほんとに送信?" value="ダイアログあり"/>
* </form>
@oppara
oppara / css.vim
Created November 10, 2009 12:03 — forked from hail2u/css.vim
css_color.vim
" Language: Colored CSS Color Preview
" Maintainer: Niklas Hofer <niklas+vim@lanpartei.de>
" URL: svn://lanpartei.de/vimrc/after/syntax/css.vim
" Last Change: 2008 Feb 12
" Licence: No Warranties. Do whatever you want with this. But please tell me!
" Version: 0.6
function! s:FGforBG(bg)
" takes a 6hex color code and returns a matching color that is visible
let pure = substitute(a:bg,'^#','','')
@oppara
oppara / tap.js
Created December 17, 2009 15:12
tap.js
// @see http://search.cpan.org/~mschwern/Test-Simple/lib/Test/More.pm
function test (num) {
if ( num > 0 ) {
console.log('1..' + num);
}
}
function is (got, expected, message) {
var str = '';
if (got !== expected) {
str += 'not ';
@oppara
oppara / gist:258801
Created December 17, 2009 15:16
Vimで#RRGGBBからrgb(r,g,b)に変換
" http://hail2u.net/blog/software/convert-hex-color-to-functional-color-with-vim.html
command! -range=% HexToFunc :silent!<line1>,<line2>s/#¥([0-9A-F]¥{3,6}¥)/¥=HexToFunc(submatch(1))/gi
function! HexToFunc(hex)
if strlen( a:hex ) == 6
let color = matchlist(a:hex, '¥([0-9A-F]¥{2¥}¥)¥([0-9A-F]¥{2¥}¥)¥([0-9A-F]¥{2¥}¥)')
return s:ToRgbFunc(color[1], color[2], color[3])
endif
let color = split(a:hex, '¥zs')
return s:ToRgbFunc(repeat(color[0], 2), repeat(color[1], 2), repeat(color[2], 2))