Skip to content

Instantly share code, notes, and snippets.

@trapezoid
trapezoid / ignore_protobuf_clean.csproj
Last active August 17, 2023 10:22
Grpc.Toolsでのコード生成をOutputDir指定で永続的に吐き出したい場合に、dotnet cleanで生成されたコードが削除されるのを防ぐ
<Project Sdk="Microsoft.NET.Sdk">
<!-- clean時の削除タスクの実行前に生成ファイル一覧をクリアして、削除後に元に戻す -->
<Target Name="_Protobuf_CoreClean_Stash" BeforeTargets="_Protobuf_CoreClean">
<ItemGroup>
<Protobuf_ExpectedOutputsStashed Include="@(Protobuf_ExpectedOutputs)" />
<Protobuf_ExpectedOutputs Remove="@(Protobuf_ExpectedOutputsStashed)" />
</ItemGroup>
</Target>
<Target Name="_Protobuf_CoreClean_Restore" AfterTargets="_Protobuf_CoreClean">
<ItemGroup>
@trapezoid
trapezoid / main.gs
Last active January 28, 2023 05:44
GoogleSlideのスピーカーノートに書いた台本を元にタイムコードを埋め込むGAS
function onOpen() {
SlidesApp.getUi()
.createMenu("UpdateTalkTimes")
.addItem("Update TalkTime in Notes", `updateTalkTimesAction`) //タイムコードを埋め込む。繰り返し実行可
.addItem("Remove TalkTime in Notes", `removeTalkTimesAction`) //タイムコードを取り除く
.addToUi()
}
function removeTalkTimesAction() {
//一部だけリセットしたければその区間を引数に渡す。省略時は全てが対象になる
@trapezoid
trapezoid / SwitchPredictionView.ps1
Last active February 27, 2022 04:08
PSReadLine2.2のPredictionViewStyleをCtrl+rで切り替えていい感じに使う
Set-PSReadLineOption -PredictionSource History -PredictionViewStyle InlineView
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
function Switch-PredictionView()
{
if ((Get-PSReadLineOption).PredictionViewStyle -eq "InlineView")
{
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key "Ctrl+b" -Function HistorySearchBackward
@trapezoid
trapezoid / gitignore_io.ps1
Last active June 23, 2021 10:05
PowerShellでgigignore.ioから.gitignoreを作る & いい感じに補完する
function gig() {
param(
[Parameter(Mandatory=$true)]
[string[]]$list
)
$params = ($list | ForEach-Object { [uri]::EscapeDataString($_) }) -join ","
Invoke-WebRequest -Uri "https://www.toptal.com/developers/gitignore/api/$params" | select -ExpandProperty content | Out-File -FilePath $(Join-Path -path $pwd -ChildPath ".gitignore") -Encoding ascii
}
Register-ArgumentCompleter -CommandName "gig" `
-ParameterName "list" `
@trapezoid
trapezoid / GenericTest.cs
Created May 20, 2015 06:10
IL2CPP Issue
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace GenericTest
{
public interface IReadable
{
void Read();
int GetValue { get; }
@trapezoid
trapezoid / ConstructorHasEnumDefaultValue.cs
Last active August 29, 2015 14:15
constructor having Enum default value with generics, cause error
public enum SampleEnum
{
None,
Hoge,
Huga,
Hiyo
}
public class ConstructorHasEnumDefaultValue<T>
{
public SampleEnum Flag { get; private set; }
@trapezoid
trapezoid / ComparableValue.cs
Last active August 29, 2015 14:11
ComparableValue
namespace Sample.ValueObject
{
public abstract class ComparableValue<TConcrete> : IComparable<TConcrete>
where TConcrete : ComparableValue<TConcrete>
{
#region IComparable implementation
public abstract int CompareTo(TConcrete other);
#endregion
@trapezoid
trapezoid / HavingMaxByExtension.cs
Created September 9, 2014 06:39
deathly LINQ sample
using System;
using System.Collections.Generic;
namespace LinqTest
{
public static class HavingMaxByExtension
{
private static TSource HavingMaxByInternal<TSource, TValue>(IEnumerable<TSource> source, Func<TSource, TValue> maxFunc)
where TSource : class
where TValue : struct, IComparable<TValue>
@trapezoid
trapezoid / gist:5011729
Created February 22, 2013 08:24
miu packet format
[{"tag": tag, "time":time, "packet": miu_packet},...]
@trapezoid
trapezoid / irchat.nb
Created November 7, 2010 17:04
IrcJabberGateway
require 'rubygems'
require 'xmpp4r'
require "iconv"
require "nkf"
require "kconv"
require "uri"
/*
# in nadokarc (NADOKA_Config)
BotFiles = [