Skip to content

Instantly share code, notes, and snippets.

View posaunehm's full-sized avatar

Hiroshi Maekawa (a.k.a. Posaune) posaunehm

View GitHub Profile
@posaunehm
posaunehm / gist:3281421
Created August 7, 2012 04:06
Small seq-like snippet
static IEnumerable<T> seq<T>(params T[] args)
{
return args;
}
var sequence = seq(1,2,3,4,5);
@posaunehm
posaunehm / gist:3312379
Created August 10, 2012 07:40
COM登録している全バッチファイルを検索するワンライナー。
ls -Recurse -Include "*.bat" | ?{(cat $_.FullName) -match "REGSVR"}
@posaunehm
posaunehm / gist:3402484
Created August 20, 2012 09:00
Rename contens of files under specified path
ls $PATH -Recurse -Include "$EXT" | %{$temp = (cat $_.FullName) -replace $OLDNAME,$NEWNAME; $temp | Out-File -Encoding default -FilePath $_.FullName}
@posaunehm
posaunehm / gist:3753744
Created September 20, 2012 03:09
save clipboad image as file
Get-Clipboard -Image | %{$_.Save((Get-Date -Format "MMddhhmmss") + ".bmp")}
@posaunehm
posaunehm / gist:3753947
Created September 20, 2012 04:12
Rename sequentially (example)
ls *.bmp | sort -Property Length -Unique | % -begin{$i = 0} -process{ren $_ ("Image" + $i.ToString() + ".bmp");$i += 1 }
@posaunehm
posaunehm / gist:3756960
Last active March 25, 2018 12:39
Convert aac to mp3, using ffmpeg on mac
for file in *.m4a; do ffmpeg -qscale 0 -i "$file" "${file%.m4a}.mp3"; done
#128kに変換するなら-abを使う
for file in *.m4a; do ffmpeg -aq 100 -i "$file" "${file%.m4a}.mp3"; done
@posaunehm
posaunehm / gist:4046798
Created November 9, 2012 16:51
ListとSortedListの挙動の違いを確認する。
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace List_SortedList_Behavior_Test
{
public class Test
{
private List<int> _randList;
@posaunehm
posaunehm / gist:4087971
Last active March 26, 2021 19:24
Why OO Sucks by Joe Armstrong
@posaunehm
posaunehm / Test.cs
Created November 29, 2012 09:31
Extention method for serialize using DataContract
using DataContractExtention
//Serialize
var x = new SomeClass();
var str = x.ToStringUsingDataContract();
//Deserialzie
SomeClass y = str.ToObjectUsingDataContract<SomeClass>();
@posaunehm
posaunehm / gist:4180255
Created December 1, 2012 02:28
extention method to create BitmapSource from hBitmap
public static class HBitmapExtention
{
/// <summary>
/// ref: http://nine-works.blog.ocn.ne.jp/blog/2011/12/post_b0e8.html
/// </summary>
/// <param name="hBitmapSource">hBitmap</param>
/// <returns>BitmapSource</returns>
public static BitmapSource ToBitmapSource(this IntPtr hBitmapSource)
{
return Imaging.CreateBitmapSourceFromHBitmap(