Skip to content

Instantly share code, notes, and snippets.

@dankogai
dankogai / eqpath.pl
Last active December 24, 2021 06:58
check if two paths are identical
#!/usr/bin/env perl
# cf. https://twitter.com/dankogai/status/1474270327006195718
use strict;
use warnings;
use feature 'say';
sub eqpath {
my @lhs = lstat( $_[0] ) or return;
my @rhs = lstat( $_[1] ) or return;
# if device numbers and inode numbers are the same, they are identical
@dankogai
dankogai / inteldo.c
Created November 25, 2020 06:36
I came up with this before I rediscovered "arch -x86_64"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
if (argc <= 1)
{
fprintf(stdout, "usage:\n\t%s cmd [args...]\n", argv[0]);
exit(-1);
(($)=>$+JSON.stringify($)+")")("(($)=>$+JSON.stringify($)+\")\")(")
@dankogai
dankogai / gist:52cd6ef645c9fc248547b79dccd8e893
Created September 22, 2018 12:25
swift 4.2 on ubuntu 18.04 quick start
$ cd ~ # home directory で作業
$ sudo apt-get install clang libicu-dev libcurl4
$ wget https://swift.org/builds/swift-4.2-release/ubuntu1804/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ tar xvpf swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ export PATH=~/swift-4.2-RELEASE-ubuntu18.04/usr/bin:$PATH
@dankogai
dankogai / cbrttest.c
Last active June 6, 2018 03:53
cbrt() of Linux libm seems buggy
#include <dlfcn.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#define DBL_ULPOFONE 0x1p-52
void *load_cbrt(void **dlhp, char *path){
*dlhp = dlopen(path, RTLD_LAZY);
if (*dlhp == NULL) {
fprintf(stderr, "%s\n", dlerror());
@dankogai
dankogai / tanakh.swift
Created April 20, 2018 01:44
tanakh in swift
#!/usr/bin/env swift
// cf. https://twitter.com/mattn_jp/status/987128843633770496
import Foundation
while true {
"""
(´・_・`)´・_・`)
(´・_・`)_・`)
@dankogai
dankogai / digest.swift
Last active March 19, 2018 03:22
CommonCrypto in Swift
//
// digest.swift
// CryptoDigest
//
// Created by Dan Kogai on 2018/03/19.
// Copyright © 2018 Dan Kogai. All rights reserved.
//
import Foundation
import CommonCrypto
@dankogai
dankogai / newArrayInES6.js
Last active January 23, 2018 09:10
what `new Array(n)` does
let newArray = (n) => {
let o = Object.create(null);
Object.setPrototypeOf(o, Array.prototype);
Object.defineProperty(o, 'length', {value:n});
return o;
}
// let a = newArray(2);
// console.log((a).map)
// console.log((a).map($=>"hello"))
@dankogai
dankogai / mkhighsierrainstaller.sh
Last active November 13, 2017 13:45
Make High Sierra Installer
#!/bin/sh
#
# Use at your own risk
#
hdiutil create -o /tmp/macOS13.cdr -size 5130m -layout SPUD -fs HFS+J
hdiutil attach /tmp/macOS13.cdr.dmg -noverify -mountpoint /Volumes/cdrimg
sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/cdrimg
mv /tmp/macOS13.cdr.dmg ~/Desktop/macOS13.dmg
hdiutil detach /Volumes/Install\ macOS\ High\ Sierra
hdiutil convert ~/Desktop/macOS13.dmg -format UDTO -o ~/Desktop/macOS13.iso
@dankogai
dankogai / apfs.log
Created March 29, 2017 04:54
NFD Test
fn =\x{304b}\x{3070}\x{3093}.txt
fn_nfd =\x{304b}\x{306f}\x{3099}\x{3093}.txt
かばん.txt:No such file or directory at ./test.pl line 32.
.
..
\x{304b}\x{3070}\x{3093}.txt