Skip to content

Instantly share code, notes, and snippets.

@bhind
bhind / gist:b85cb780fb349647654436645f1f03af
Created May 3, 2019
convert cp932 to utf-8 for mac by iconv
View gist:b85cb780fb349647654436645f1f03af
find . -type f | grep "\.cpp$" | xargs -t -I{} sh -c "iconv -f cp932 -t utf8 {} > {}.utf8.cpp"
@bhind
bhind / Camel2SnakeAndSnake2Camel.swift
Created Nov 24, 2017
converting between Camel Case and Snake Case for Swift 4
View Camel2SnakeAndSnake2Camel.swift
extension String {
static private let SNAKECASE_PATTERN:String = "(\\w{0,1})_"
static private let CAMELCASE_PATTERN:String = "[A-Z][a-z,\\d]*"
func snake_caseToCamelCase() -> String{
let buf:NSString = self.capitalized.replacingOccurrences( of: String.SNAKECASE_PATTERN,
with: "$1",
options: .regularExpression,
range: nil) as NSString
return buf.replacingCharacters(in: NSMakeRange(0,1), with: buf.substring(to: 1).lowercased()) as String
}
@bhind
bhind / magicsquare.js
Last active May 25, 2017
パイザの
View magicsquare.js
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ!!
function createPermutation(inputArray) {
if(inputArray.length===1) return [[inputArray[0]]];
var result = [];
for(var index=0; index<inputArray.length; index++) {
let cloneArray = inputArray.concat([]);
let head = cloneArray.splice(index,1);
View opencv_colorpicker.py
# coding: utf-8
# USAGE
# opencv_colorpicker.py
# import the necessary packages
from Tkinter import Tk
from Tkinter import *
from PIL import Image
from PIL import ImageTk
import tkFileDialog
View binary_tree_iterator.py
# -*- coding:utf-8 -*-
import numpy as np
# [問題]
#
# 以下の表はそのマスとその周囲8マスに含まれている爆弾の個数を表しています。フィールドに含まれている爆弾の位置を(x,y)としたとき、
# その積k(=x*y)が小さい順にアルファベットを並べるとある単語が完成します。
field_data = np.array([
[[1, 'i'], [2, 'p'], [2, 'a'], [1, 'g'], [1, 'x'], [1, 'u']],
View matplot_test.py
# -*- coding:utf-8 -*-
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import pylab
np.random.seed(0)
View premium_friday.ics
BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:Japan
BEGIN:STANDARD
DTSTART:19390101T000000
TZOFFSETFROM:+0900
TZOFFSETTO:+0900
TZNAME:JST
END:STANDARD
END:VTIMEZONE
View update_r53_local.sh
#! /bin/bash
ZONE_NAME=XXXXXXXX.local
HOSTED_ZONE_ID=/hostedzone/XXXXXXXXXXXXXX
FILEBUF=r53_local.json
FLG=0
PRIVATE_ADDRESS_TABLE=$(aws ec2 describe-instances | jq -r '.Reservations[].Instances[]|{InstanceName: (.Tags[]|select(.Key=="Name").Value),PrivateIpAddress}|[.InstanceName, .PrivateIpAddress]|@csv')
You can’t perform that action at this time.