Skip to content

Instantly share code, notes, and snippets.

@nissuk
nissuk / gist:1285035
Created October 13, 2011 18:26
C#: XML属性値を取得する単純な例(Linq, XPath)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Xml;
namespace Example
{
@nissuk
nissuk / gist:1284692
Created October 13, 2011 16:25
C#: インターネット上のファイルをダウンロードして保存する単純な例(WebClient, WebRequest)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace Example
{
public static class WebRequestExtensions
@nissuk
nissuk / gist:1270494
Created October 7, 2011 15:16
C#: HTTP POSTする単純な例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace Example
{
class Program
@nissuk
nissuk / ExampleDbTest.php
Created September 4, 2011 12:28
PHPUnit 3.5.15: データベースのテストをする単純な例
<?php
class ExampleDbTest extends PHPUnit_Extensions_Database_TestCase {
protected $conn = null;
/**
* (non-PHPdoc)
* @see PHPUnit_Extensions_Database_TestCase::setUp()
*/
public function setUp() {
@nissuk
nissuk / gist:1164402
Created August 23, 2011 05:22
C#: 基数変換(2~36)の単純な例
using System;
namespace Example
{
public class Convert
{
/// <summary>
/// 値を指定した基数で等価の String 形式に変換します。
/// 負数の場合はSystem.Convert.ToString(x, Int32)とは違い正数として変換したのち、頭に"-"を付けます。
/// </summary>
@rem このバッチファイルはtest.batなどの名前をつけてplatform-toolsフォルダ内に置いて下さい
@rem また、起動するときは http://androidsdk.web.fc2.com/ を参考にA22という名前のAVDを先に作成して下さい
..\tools\emulator -avd A22 -partition-size 1000
@echo エミュレータが立ち上がるまで待ったのち、
@pause
adb -s emulator-5554 shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
adb -s emulator-5554 shell chmod 777 /system/app
@nissuk
nissuk / kion.wsf
Created July 9, 2011 17:40
WSH: jQuery 1.6.2を使用する例 (WSF)
<job>
<!--
WSHでjQuery 1.6.2を使用する例 (Shift_JISで保存してください…)
# 元プログラム
http://d.hatena.ne.jp/hirataka522/20080806/1218031483
# 使用例(コマンドプロンプト)
cscript kion.wsf 大垣
-->
@nissuk
nissuk / gist:1062463
Created July 3, 2011 18:42
jQuery: 分割されたテキストボックスをグループとして扱うプラグイン(実験的)
/**
* jQuery input group plugin (実験的)
* public domain
*
* 郵便番号、電話番号、シリアル番号などの分割されたテキストボックスを
* 1つのグループ化されたテキストボックスとして扱います。
* 具体的には下記の挙動を取ります。
*
* 1. 要素内にある入力項目にユーザーが文字を入力しており、その入力文字数が
* a. 指定文字数(maxlength)に達した場合、次の入力項目に移動します。
@nissuk
nissuk / gist:1053862
Created June 29, 2011 13:45
PHP: 変数展開時に定数を展開する単純な例
<?php
define('FOO', 1);
define('BAR', 2);
// 変数展開が「{$」で始まっている場合、関数の実行等が可能です。
$c = 'constant';
echo "FOO: {$c('FOO')}, BAR: {$c('BAR')}" . PHP_EOL; // => FOO: 1, BAR: 2
@nissuk
nissuk / .htaccess
Created June 29, 2011 08:39
Apache: localhost内ではBASIC認証制限をかけない(.htaccess)
Order Deny,Allow
Satisfy Any
# localhost
Allow from localhost
# other
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic