Skip to content

Instantly share code, notes, and snippets.

View hidori's full-sized avatar
🏠
Working from home

Hiroaki SHIBUKI hidori

🏠
Working from home
  • Tokyo, Japan
  • 20:12 (UTC +09:00)
View GitHub Profile
func Escape(sql string) string {
dest := make([]byte, 0, 2*len(sql))
var escape byte
for i := 0; i < len(sql); i++ {
c := sql[i]
escape = 0
switch c {
case 0: /* Must be escaped for 'mysql' */
@hidori
hidori / profile.json
Last active August 21, 2020 23:14
Windows Terminal
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"requestedTheme": "dark",
"initialCols": 192,
"initialRows": 64,
"copyOnSelect": false,
"copyFormatting": false,
"defaultProfile": "{b9aeb94f-45e4-4c38-838d-f93e33045f4e}",
"profiles": {
"defaults": {
@hidori
hidori / docker-ps
Created November 1, 2019 19:02
docker-ps
#!/bin/sh
DOCKER_PS_DOCKER_PATH=${DOCKER_PS_DOCKER_PATH:-/usr/bin/docker}
DOCKER_PS_COLUMN_ORDER=${DOCKER_PS_COLUMN_ORDER:-CONTAINER ID,IMAGE,STATUS,NAMES}
${DOCKER_PS_DOCKER_PATH} ps $@ \
| awk \
-v ORDER="${DOCKER_PS_COLUMN_ORDER}" \
-f $(dirname $0)/docker-ps.awk
@hidori
hidori / chssh
Created June 18, 2019 09:59
chssh
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: `basename ${0}` <profile>"
exit 1
fi
cp ~/.ssh/id_rsa ~/.ssh/id_rsa.bak
cp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa.pub.bak
@hidori
hidori / node-db-helper.js
Created December 24, 2018 11:41
DB Helper for testing
'use strict';
const SqlBuilder = require('json-sql-builder2');
const fs = require('fs');
const path = require('path');
module.exports = class DbHelper {
static async init(connection, name) {
await this.execute(connection, name, 'truncate');
await this.execute(connection, name, 'seed');
@hidori
hidori / sample.csv
Created May 11, 2018 09:38
sample.csv
A B C
1 2 3
4 5 6
7 8 9
@hidori
hidori / sample.json
Last active April 24, 2018 23:50
sample.json
[
{
"col1": 123,
"col2": "ABC"
},
{
"col1": 234,
"col2": "BCD"
},
{
@hidori
hidori / era-jp-2019
Created April 3, 2018 06:32
Expectation of Japanese New Era 2019
JinBun - 仁文
using System;
using System.Xml.Linq;
namespace Mjollnir.Xml.Linq
{
public static class XElementExtensions
{
public static void Walk(this XElement element, Action<XNode> action)
{
if (element == null) throw new ArgumentNullException(nameof(element));
@hidori
hidori / Echo.cs
Created April 1, 2016 08:22
Echo
class Program
{
static void Main(string[] args)
{
Server.Run().ConfigureAwait(false).GetAwaiter().GetResult();
}
}
static class Server
{