[Silverlight] 実行時にはエラーにならないが、VisualStudioのデザイナ上ではエラーになってしまう場合
if (!System.ComponentModel.DesignerProperties.IsInDesignTool) { // 処理 } で囲むとひとまず回避可能
[PHP] ファイル出力(テキスト追加)の例
// 出力内容 $log = 'test'. "\r\n"; // ファイル名 //$filename = 'test'. date('YmdHis') . '.log'; $filename = 'test'. date('Ymd') . '.log'; $fp = fopen($filename, 'a'); if (flock($fp, LOCK_EX)) { //ファイルロック(多重書き込みによるファイル破損回避) fwrite($fp, $log); flock($fp, LOCK_UN); } fclose($fp);
SVGオブジェクトの塗りを透明にする場合
「fill:none」を指定
↓
対象オブジェクト表示後、onclick等のイベントが有効になるまで時間がかかる。
↓
「fill:transparent」を指定することで回避可能
[PHP] 多次元配列のソート
以下のような二次元配列「$array」を「created」昇順でソートする array(2) { [0]=> array(6) { ["name"]=> string(6) "test01" ["created"]=> string(31) "Tue, 19 Jul 2011 07:28:44 +0000" ["message"]=> string(3) "aaa" } [1]=> array(6) { ["name"]=> string(6) "test02" ["created"]=> string(31) "Tue, 19 Jul 2011 07:28:00 +0000" ["message"]=> string(19) "bbb" } } ↓ foreach ($array as $key => $val) { $key_created[$key] = strtotime($val['created']); } array_multisort($key_created, SORT_ASC, $array);
Silverlight WebBrowserコントロールのUserAgent
[Windows 7 32bit]
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
[Windows XP 32bit]
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
[Mac OS X Lion]
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.48.3 (KHTML, like Gecko)
[Mac OS X Snow Leopard]
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; ja-jp) AppleWebKit/533.21.1 (KHTML, like Gecko)
[Mac OS X Leopard]
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; ja-jp) AppleWebKit/533.21.1 (KHTML, like Gecko)
Silverlightを囲む会in東京#3 セッション資料
Silverlightを囲む会in東京#3 (2011.7.9)で「Silverlightで作るSharePoint Webパーツ」をテーマに話をさせていただきました。
[Silverlight] (メモ)分離ストレージ
【Windows Vista・7】
[SYSTEMDRIVE]\Users\[ユーザー]\AppData\LocalLow\Microsoft\Silverlight\is
【Windows XP】
[SYSTEMDRIVE]\Documents and Settings\[ユーザー]\Local Settings\Application Data\Microsoft\Silverlight\is
【Mac OS X】
/Users/[ユーザー]/Library/Application Support/Microsoft/Silverlight/is
[C#] Twitter Search APIをWebClientから使用する例
private class Tweet { public string ID { get; set; } public string Title { get; set; } public string Published { get; set; } public string Source { get; set; } public Uri Image { get; set; } public string Author { get; set; } } private void GetTweets() { WebClient client = new WebClient(); client.DownloadStringCompleted += (sender, e) => { if (e.Error == null) { XDocument doc = XDocument.Parse(e.Result); // XNamespace XNamespace nsDef = "http://www.w3.org/2005/Atom"; XNamespace twitter = "http://api.twitter.com/"; var items = from item in doc.Descendants(nsDef + "entry") let author = item.Element(nsDef + "author") select new Tweet() { ID = item.Element(nsDef + "id").Value, Title = item.Element(nsDef + "title").Value, Published = item.Element(nsDef + "published").Value, Source = item.Element(twitter + "source").Value, Author = author.Element(nsDef + "name").Value, Image = new Uri((from XElement xe in item.Descendants(nsDef + "link") where xe.Attribute("type").Value == "image/png" select xe.Attribute("href").Value).First()) }; foreach (Tweet t in items) { // 取得したTweetを処理 } } else { // error } }; client.DownloadStringAsync(new Uri("http://search.twitter.com/search.atom?q=" + HttpUtility.UrlEncode("#test"))); }
[C#] 正規表現メモ
// 文字列に含まれるタグを除去 Regex r = new Regex(@"<.*?>", RegexOptions.None); string result = r.Replace("<div style='font-size:12px;'>test</div>", string.Empty); // 文字列から()で囲まれた部分を除去 Regex r = new Regex(@"\(.*?\)", RegexOptions.None); string result = r.Replace("aaa (bbb)", string.Empty);