Skip to content

Instantly share code, notes, and snippets.

@nissuk
nissuk / gist:1388443
Created November 23, 2011 11:07
JSP: 単純なカレンダーを出力する(タグファイル)
<%@tag pageEncoding="UTF-8" body-content="empty"%>
<%@tag import="java.util.Calendar"%>
<%@attribute name="year" type="Integer" required="true" rtexprvalue="true" %>
<%@attribute name="month" type="Integer" required="true" rtexprvalue="true" %>
<%
Calendar cal = Calendar.getInstance();
cal.set(year, month - 1, 1);
int firstDayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
@nissuk
nissuk / get-exif.ps1
Created November 12, 2011 14:33
PowerShell: PowerShell Image module Get-Exifの改変
<#
PowerShell Image module(http://archive.msdn.microsoft.com/PSImage/)のget-exif.ps1を改変して下記のプロパティを追加します。
- Latitude (緯度。度表記)
- Longitude (経度。度表記)
- Name (ファイル名)
使用例
dir "*.jpg" | get-exif | select name, latitude, longitude | export-csv out.csv
ライセンス
@nissuk
nissuk / w.rb
Created November 11, 2011 17:00
HAML, SCSS, CoffeeScriptの自動コンパイル実験(watchr)
# based on http://www.223soft.net/35
class W
def initialize(opts)
@dest_dir = opts[:dest_dir]
end
def exec(cmd, md)
p = Pathname.new(@dest_dir + "/" + File.dirname(md[0]))
p.mkdir if not p.exist?
@nissuk
nissuk / convert_haml_to_html.rb
Created November 11, 2011 10:35
Aptana Studio 3.0.6: メニューのCommands > HAML にHAML形式をHTML形式に変換するメニューを追加する
=begin
適用方法
1. Commands > HAML > Edit this bundle を開く
2. 出てきたプロジェクトのbundle.rbに main_menu.command 'Convert HAML to HTML' を追加する
3. このコードを commands/convert_haml_to_html.rb に保存する
4. Aptanaを再起動する
=end
require 'ruble'
@nissuk
nissuk / gist:1325688
Created October 30, 2011 08:00
jQuery: smoothScroll
/**
* jQuery smoothScroll
* ページ内リンクをブラウザの挙動に近い形でスムーズにスクロールします。
*
* # 使用例
* $("a").smoothScroll();
* $("a").smoothScroll({ duration: "fast", easing: "swing" });
*
* # TODO
* - vertical-alignがtopでないimgを持つaに移動する際上部の位置がずれる点の修正
@nissuk
nissuk / gist:1325516
Created October 30, 2011 04:54
jQuery: hoverOpacity
/**
* jQuery hoverOpacity
* hoverしたときにopacityを指定値まで段階的に変化させ、カーソルが離れたら1まで戻します。
*
* # 使用例
* $("a:has(img)").hoverOpacity(0.5);
*/
(function($) {
var pluginName = "hoverOpacity";
var plugin = function(value, options) {
@nissuk
nissuk / gist:1315140
Created October 26, 2011 01:29
Java: static importの例
// Mathのstaticメンバを修飾なしで書けるようにします。
import static java.lang.Math.*;
// System.outを修飾なしで書けるようにします。
// outはPrintStreamのインスタンスなので
// import static java.lang.System.out.*;
// とはできないそうです。
import static java.lang.System.out;
public class StaticImportExample {
public static void main(String[] args) {
@nissuk
nissuk / gist:1309544
Created October 24, 2011 17:13
PHP: HTTPストリームコンテキスト+POSTの例
<?php
$url = 'http://localhost/example/test.php'; // <?php var_dump($_POST)
$params = array('foo' => 'bar');
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($params, '', '&')
)
@nissuk
nissuk / gist:1307206
Created October 23, 2011 10:12
C#: Bloggerに新しいエントリを投稿する例
using System;
using System.Text;
using System.Linq;
// C:\Program Files (x86)\Google\Google Data API SDK\Redist から参照します
using Google.GData.Client;
namespace Example
{
static class BloggerPost
{
@nissuk
nissuk / Example.java
Created October 19, 2011 18:26
Java: 匿名クラス+インスタンス初期化子の例
import java.util.List;
import java.util.ArrayList;
// http://d.hatena.ne.jp/t_yano/20080622/1214087678
public class Example {
public static void main(String[] args) {
List<Person> list = new ArrayList<Person>() {{
add(new Person(){{ name = "foo"; age = 20; }});
}};