Skip to content

Instantly share code, notes, and snippets.

@lavn0
lavn0 / .vscode_tasks.json
Created April 15, 2025 16:22
vscodeで現在日時でメモを作成する
{
"version": "2.0.0",
"tasks": [
{
"label": "createMeetingNote",
"type": "shell",
"command": ".vscode/createNote.sh",
"args": [
"_メモ",
"${input:name}"
require 'minitest/autorun'
require 'yaml'
require_relative "../lib/ypath.rb"
class TestYPath < Minitest::Test
def setup
end
def test_ypath
@lavn0
lavn0 / run_fxcop.bat
Created October 23, 2018 15:46
ソリューションファイルを指定してコード分析結果を出力する方法。FxCopCmd.exeではDLLすべてのパスを渡す必要がある。
@SET DT=%TIME: =0%
@SET DT=%DT::=%
@SET DT=%DATE:/=-%-%DT:~0,6%
@SET MSBUILD=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
@SET SOLUTION=SampleSolution.sln
@SET LOGDIR=LOG
@MKDIR "%LOGDIR%" >nul 2>&1
"%MSBUILD%" "%SOLUTION%" /t:ReBuild /verbosity:q /p:Configuration=Release;RunCodeAnalysis=true;CodeAnalysisOutputToConsole=true > %DT%_out.log
[TestClass]
public class UnitTest1
{
[DataTestMethod]
[DataRow(1, "001")]
[DataRow(2, "002")]
[DataRow(3, "003")]
public void Test1(int num, string str)
{
Assert.AreEqual(str, num.ToString("D3"));
@lavn0
lavn0 / SetUtil.cs
Created January 29, 2018 16:12
組み合わせとか順列とか
public static class SetUtil
{
/// <summary>組み合わせ</summary>
public static IEnumerable<IEnumerable<T>> Combination<T>(this IEnumerable<T> items, int r)
{
if (r == 0)
{
yield return Enumerable.Empty<T>();
yield break;
}
for /d %i in (*) do @( echo %i & dir "%i" /a-d /s /b | find /c /v "" & echo. )
@lavn0
lavn0 / Toast.cs
Created January 18, 2017 11:45
トースト通知のサンプル実装(Windows8.1以降)
using System.Diagnostics;
using Windows.UI.Notifications;
namespace ToastTest
{
public static class Toast
{
private static readonly ToastNotifier toastNotifier;
private static ToastNotification toastNotification;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace System.Xml.XPath
{
public static class XPathUtility
{
public static IEnumerable<T> XPathSelectElements<T>(this XNode xNode, string xpath)
where T : XObject
@lavn0
lavn0 / LINQX.cs
Last active March 23, 2017 12:34
using System.Collections.Generic;
using System.Diagnostics;
namespace System.Linq
{
/// <summary>LINQ Extension</summary>
[DebuggerStepThrough]
public static partial class LINQX
{
public static bool? MixedResult<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
@lavn0
lavn0 / XmlRead.targets
Created July 10, 2016 08:51
Xmlの値を読み取るMSBuildタスクを定義するコード
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="XmlRead" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<XmlFileName ParameterType="System.String" Required="true" />
<XPath ParameterType="System.String" Required="true" />
<Result ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System" />