Skip to content

Instantly share code, notes, and snippets.

View espresso3389's full-sized avatar

Takashi Kawasaki espresso3389

View GitHub Profile
@espresso3389
espresso3389 / apkuploader.cs
Created June 24, 2017 19:43
Automatic APK Uploader
// This code is based on the following article but updated for the latest system (June 2017):
// Automatic apk upload to Google Play (part 1)
// http://petr.logdown.com/posts/255755-automatic-apk-upload-1
using System;
using System.Collections.Generic;
using System.IO;
// Google.Apis.AndroidPublisher.v2
using Google.Apis.AndroidPublisher.v2;
using Google.Apis.AndroidPublisher.v2.Data;
@espresso3389
espresso3389 / kiosk.bat
Last active January 26, 2018 03:51
Autologon and Insomnia for Kiosk
@echo off
set USERNAME=xxxxxxxxxxxx
set PASSWORD=yyyyyyyyyyyy
whoami /PRIV | find "SeLoadDriverPrivilege" > NUL
if not errorlevel 1 goto :main
powershell.exe -Command Start-Process """%0""" -Verb Runas
exit /b 0
@espresso3389
espresso3389 / wslenv.bat
Last active December 20, 2018 13:46
Get WSL's rootfs directory and home directory of the default user
@echo off
rem Get the default distribution
for /f "tokens=3" %%d in ('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss /v DefaultDistribution') do set DIST=%%d
rem Get distribution name, rootfs directory, and uid
for /f "tokens=3" %%n in ('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\%DIST% /v DistributionName') do set DIST_NAME=%%n
for /f "tokens=3" %%p in ('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\%DIST% /v BasePath') do set ROOTFS=%%p\rootfs
for /f "tokens=3" %%u in ('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\%DIST% /v DefaultUid') do set /a UID=%%u
@espresso3389
espresso3389 / coroutine_test.cpp
Created December 16, 2017 15:02
Evaluating coroutine performance on Visual C++
#include <cstdio>
#include <random>
#include <experimental/generator>
auto random()
{
std::mt19937 r;
for (;;)
co_yield r();
}
@espresso3389
espresso3389 / normal_loop.cpp
Created December 16, 2017 15:04
Random number sequence
int main()
{
std::mt19937 r;
for (;;)
std::printf("%d\n", r());
}
@espresso3389
espresso3389 / guimode.sh
Created January 10, 2018 15:56
Preparing for using framebuffer directly on Raspbian
#!/bin/sh
# The script requires root permission or sudo.
# Switch to GUI mode (Alt-7)
chvt 7
# Disable screen blank (screen saver)
setvesablank off
# Disable cursor blinking on the screen top
echo 0 > /sys/class/graphics/fbcon/cursor_blink
@espresso3389
espresso3389 / admin_powershell.reg
Created January 26, 2018 03:52
Registry patch to enable powershell with administrative privilege
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="PowerShell ウィンドウをここに開く(管理者)"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
@espresso3389
espresso3389 / keyboard_en_us.reg
Created January 26, 2018 03:54
Registry patch to change keyboard layout to 101-en-us
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters]
"LayerDriver JPN"="kbd101.dll"
"OverrideKeyboardIdentifier"="PCAT_101KEY"
"OverrideKeyboardType"=dword:00000007
"OverrideKeyboardSubtype"=dword:00000000
@espresso3389
espresso3389 / keyboard-ja-jp.reg
Created January 26, 2018 03:54
Registry patch to change keyboard layout to 109-ja-jp
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters]
"LayerDriver JPN"="kbd106.dll"
"OverrideKeyboardIdentifier"="PCAT_106KEY"
"OverrideKeyboardType"=dword:00000007
"OverrideKeyboardSubtype"=dword:00000002
@espresso3389
espresso3389 / abortcopytest.mjs
Created March 3, 2018 09:19
Aborting file copy on node.js
'use strict';
import fs from 'fs-extra';
try {
const srcfn = 'sorucefile';
const dstfn = 'tmp.bin';
const src = fs.createReadStream(srcfn);
const dst = fs.createWriteStream(dstfn);