Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / .brewrc
Created August 1, 2011 03:06
[mac][homebrew]install homebrew to $HOME/.brew
#[homebrew setting for installing to each user directory]
#[ENV: put them into "$HOME/.bash_profile"]
HOMEBREW=$HOME/.brew
export PATH=$HOMEBREW/bin:$PATH
export LD_LIBRARY_PATH=$HOMEBREW/lib:/usr/lib
export DYLD_FALLBACK_LIBRARY_PATH=$HOMEBREW/lib
export C_INCLUDE_PATH=$HOMEBREW/include
export CPLUS_INCLUDE_PATH=$HOMEBREW/include
@bellbind
bellbind / app.m
Created July 19, 2012 20:32
[macosx][objective-c]Make cocoa app without Xcode
// clang -framework Cocoa app.m -o app
// ./app
#import <Cocoa/Cocoa.h>
int main()
{
[NSAutoreleasePool new];
id app = [NSApplication sharedApplication];
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
@bellbind
bellbind / index.html
Last active November 23, 2023 13:54
[WebGPU] Rendering animated 3D object for Chrome-100
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"
@bellbind
bellbind / algorithms-for-jpeg.js
Last active November 17, 2023 13:03
[javascript]Algorithms for JPEG processing
/* eslint no-unused-vars: 0, no-multi-spaces: 0 */
"use strict";
// [JPEG encode process]
// 1. RGB to YUV
// 2. Padding & chunk to 8x8-blocks
// 3. DCT
// 4. Quantization
// 5. zigzag scan
// 6. Huffman coding
@bellbind
bellbind / cpuinfo.c
Created October 29, 2015 07:07
[c][intel][clang] get cpu info from CPUID intrinsic in clang/gcc
// intel CPUID opcode
// see: https://en.wikipedia.org/wiki/CPUID
// clang -Wall -Wextra -std=c11 cpuinfo.c -o cpuinfo
#include <stdint.h>
#include <stdio.h>
#include <cpuid.h> //macro __cpuid(eaxin, eaxout, ebx, ecx, edx)
int main() {
{
@bellbind
bellbind / Dockerfile
Last active November 7, 2023 19:49
[docker] ruby-1.8.7 with rails-2.3.18 image
# docker build -t ruby-1.8.7 .
# docker run -it --rm ruby-1.8.7
FROM ubuntu:16.04
WORKDIR /root
RUN apt update
RUN apt upgrade -y
RUN apt install -y ruby-build autoconf subversion bison
RUN apt install -y mecab mecab-ipadic-utf8 wget
@bellbind
bellbind / movconcat-fps60.js
Last active October 25, 2023 08:49
[deno]10M bps video files concation with x4 speed and x2 volume with ffmpeg command
#!/usr/bin/env -S deno run --allow-read --allow-run
// usage: deno run --allow-read --allow-run movconcat.js /Volumes/UNTITLED/Normal/F/ result.mp4
import * as path from "https://deno.land/std/path/mod.ts";
import * as flags from "https://deno.land/std/flags/mod.ts";
const parsed = flags.parse(Deno.args);
const sources = parsed._.at(-2);
const output = parsed._.at(-1);
const inputs = [];
for await (const {name} of Deno.readDir(sources)) inputs.push(name);
@bellbind
bellbind / index.html
Created March 3, 2015 10:01
[browser][javascript]Web Cryptography API usecase
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Web Crypto API Example</title>
<script src="script.js"></script>
</head>
<body>
open "Web Console" of this browser
</body>
@bellbind
bellbind / DisplayMode.swift
Last active October 12, 2023 17:54
[macos][swift4]Switch and Display DisplayMode command and StatusBar Menu app
#!/usr/bin/env swift -import-objc-header cg-hidden.h
// $ swiftc -import-objc-header cg-hidden.h DisplayMode.swift
import Foundation
import CoreFoundation
import CoreGraphics
let display = CGMainDisplayID()
let count = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
defer {count.deallocate()}
CGSGetNumberOfDisplayModes(display, count);
@bellbind
bellbind / index.html
Last active October 1, 2023 10:33
[WebGPU] Tiny example for WebGPU API
<!doctype html>
<html>
<head>
<!-- IMPORTANT: The current Chrome requires some origin-trial token in <meta>.
To register origins at the last "WebGPU REGISTER" in https://developer.chrome.com/origintrials/
This token is for a Web Origin "http://localhost:8000" (maybe expired at Mar 31, 2022)
-->
<meta http-equiv="origin-trial"
content="AkIL+/THBoi1QEsWbX5SOuMpL6+KGAXKrZE5Bz6yHTuijzvKz2MznuLqE+MH4YSqRi/v1fDK/6JyFzgibTTeNAsAAABJeyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViR1BVIiwiZXhwaXJ5IjoxNjUyODMxOTk5fQ==" />
<meta http-equiv="origin-trial"