Skip to content

Instantly share code, notes, and snippets.

View sheepla's full-sized avatar
🐑
メェ〜

sheepla sheepla

🐑
メェ〜
View GitHub Profile

Goコマンドを強化して使いやすくする

環境

  • Arch Linux
  • go1.22.3 linux/amd64

事前準備

$GOPATH/binにPATHを通しておくこと。

@sheepla
sheepla / Cargo.toml
Last active April 21, 2024 08:17
Search Arch Linux pacakges via official Web interface in Rust
[package]
name = "pacsearch-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
derive_builder = "0.20.0"
reqwest = { version = "0.12.4", features = ["json"] }
import { TextLineStream } from "https://deno.land/std@0.223.0/streams/text_line_stream.ts";
import * as bufio from "https://deno.land/std@0.101.0/io/bufio.ts";
type AiModel = "gpt-3.5-turbo-0125" | "claude-instant-1.2";
export async function isStatusOK(): Promise<boolean> {
return await fetch("https://duckduckgo.com/duckchat/v1/status")
.then((response) => response.json()).then((data) =>
parseInt(data["status"]) === 0
);
@sheepla
sheepla / bufwrite.ts
Last active April 20, 2024 07:09
Write text to stdout with BufWriter in Deno
import * as bufio from "https://deno.land/std@0.101.0/io/bufio.ts";
const buf = bufio.BufWriter.create(Deno.stdout);
const encoder = new TextEncoder()
buf.write(encoder.encode("The "))
buf.write(encoder.encode("quick "))
buf.write(encoder.encode("brown "))
buf.write(encoder.encode("fox "))
@sheepla
sheepla / mojisuu.ts
Last active April 20, 2024 07:16
日本語の文字数をカウントする.ts
// https://zenn.dev/pandanoir/articles/how-to-count-strings
function countStringLength(text:string) : number {
const segmenter = new Intl.Segmenter("ja-JP", { granularity: "grapheme" })
const segments = [...segmenter.segment(text)]
console.log(segments)
return segments.length
}
@sheepla
sheepla / BuildURL.fs
Created March 24, 2024 06:24
BuildURL.fs
let url =
let builder = new UriBuilder("https://www.example.com")
// let values = HttpUtility.ParseQueryString(builder.Query)
builder.Query <-
set [("key1", "value1"); ("key2", "value2")]
|> Set.map (fun (k, v) -> sprintf "%s=%s" <| Uri.EscapeDataString(k) <| Uri.EscapeDataString(v))
|> String.concat "&"
builder.ToString()
// Build URL safely in TypeScript (Deno)
//
// See:
// https://developer.mozilla.org/ja/docs/Web/API/URL
// https://developer.mozilla.org/ja/docs/Web/API/URLSearchParams
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
export function buildURL(
base: string,
import { passwordGenerator } from "https://deno.land/x/password_generator/mod.ts";
const usage = `
About:
Issue abema.tv onetime password
Usage:
deno run --allow-net main.ts <user> <token>
See:
@sheepla
sheepla / ILSpyをLinuxで使う.md
Last active March 17, 2024 07:40
ILSpyをLinuxで使う.md

🕶️ .NETの逆コンパイラ「ILSpy」をLinuxで使う

ILSpyとは

ILSpyは.NETのアセンブリブラウザおよび逆コンパイラ。 C#やF#などの言語で書かれたアプリケーションのDLLを解析してIL (.NETの中間表現)やC#のコードに逆コンパイルすることができる。開発時のデバッグやリバースエンジニアリングなどに使われる。

icsharpcode/ILSpy