Skip to content

Instantly share code, notes, and snippets.

@yujp
yujp / webapi_test.ts
Created September 6, 2026 07:12
webapi_test.ts
// run: bun test
// app.ts
export const handler = {
async fetch(request: Request): Promise<Response> {
const url = new URL(request.url);
if (url.pathname === "/api/user" && request.method === "POST") {
const body = await request.json();
return Response.json({ success: true, user: body.name }, { status: 201 });
@yujp
yujp / flag_const.js
Created August 23, 2026 03:10
flag_const.js
const FLAGS = {
READ: 1, // 2^0
WRITE: 2, // 2^1
EXEC: 4, // 2^2
DELETE: 8, // 2^3
SHARE: 16 // 2^4
};
const flagEntries = Object.entries(FLAGS);
const totalCombinations = 2 ** flagEntries.length;
<?php
// App\Providers\AppServiceProvider
class AppServiceProvider
{
public function boot(): void
{
Json::encodeUsing(fn ($value) => json_encode($value, JSON_UNESCAPED_UNICODE));
}
}
@yujp
yujp / js_basics.js
Created August 16, 2026 09:09
js_basics.js
const num = 123_456_789;
const obj = {
member: 123,
method() {
return 456;
},
address: {
pref: "abc",
city: "def"
@yujp
yujp / project_user_search_form_example.html
Last active August 23, 2026 09:03
project_user_search_form_example.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>React jsx-esm-standalone</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<style type="text/tailwindcss">@import "tailwindcss" prefix(tw);</style>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
@yujp
yujp / backlog_members.go
Last active July 7, 2026 12:49
backlog_members.go
package main
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
$result = curl_exec($ch);
$code = $result ? curl_getinfo($ch, CURLINFO_RESPONSE_CODE): null;
curl_close($ch);
$ok = is_int($code) && 200 <= $code && $code < 300;
package main
import (
//"crypto/ed25519"
"golang.org/x/crypto/ed25519"
"log"
"time"
"github.com/o1egl/paseto"
Add-Type -AssemblyName System.Net.Http
# proxy
$bypassOnLocal = $TRUE
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
#$proxy = New-Object System.Net.WebProxy("http://localhost:8888", $bypassOnLocal)
#$proxy.Credentials = [System.Net.CredentialCache].DefaultNetworkCredentials
#$proxy.Credentials = New-Object System.Net.NetworkCredential("username", "password")
$password = ConvertTo-SecureString "password" -asplaintext -force
$cred = New-Object System.Management.Automation.PsCredential "username",$password

Installing Golang on Windows10

Open PowerShell and execute the code below:

cd C:\data\tools
Remove-Item go.bk -Recurse
Rename-Item go go.bk
curl "https://golang.org/dl/go1.16.6.windows-amd64.zip" -o go.zip -L
Expand-Archive -Path go.zip -DestinationPath .