Skip to content

Instantly share code, notes, and snippets.

View kobake's full-sized avatar

KOBAYASHI Keiichi kobake

View GitHub Profile
@kobake
kobake / Program.cs
Last active August 2, 2020 08:53
https://twitter.com/jmitani/status/1289780665236430849 これのゴリ押し解き。「!!!! MIN mikanPrice = 45」っていうところが解。
using System;
namespace Twitter340
{
class Program
{
static void Main(string[] args)
{
for (int mikanPrice = 1; mikanPrice <= 340; mikanPrice++)
{
@kobake
kobake / PointerSize.cpp
Last active November 5, 2018 01:59
Class method pointer size
#include <stdio.h>
#include <iostream>
#include <string>
class A {
public:
A(const char* str) { m_str = str; }
virtual ~A() {}
virtual void Foo(int n, int m) {
printf("A %d %d %hs\n", n, m, m_str.c_str());
#include <stdio.h>
#include <string.h>
// For specify int
template <int N>
class Buffer {
public:
Buffer() {
m_buf[0] = 0;
}
#include <stdio.h>
#include <vector>
class IDumpable {
public:
virtual void Dump() = 0;
};
// For inheritance
template <class T>
#include <stdio.h>
// As generics
template <class T>
class List {
public:
List() {
m_count = 0;
}
void Add(const T& t) {
@kobake
kobake / git-commit-size.sh
Created November 5, 2017 13:42
Calculate size of a git commit object.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: git-commit-size.sh <commit hash>" 1>&2
exit 1
fi
HASH=$1
ITEM_LIST="`git diff-tree -r -c -M -C --no-commit-id $HASH`"
@kobake
kobake / chrome-developer-console.js
Created September 27, 2017 13:21
255chars tweet
var s = "";
for(var i = 1; i <= 255; i++){
var c = String.fromCharCode(i);
s += c;
if(c == '@')s += '​'
}
$('#tweet-box-home-timeline').html(
"<div>255chars</div>"
+ "<div>" + s + "</div>"
+ "<div>#280characters</div>");
@kobake
kobake / github-markdown-toc.js
Created May 10, 2017 01:42
GitHub の Markdown に TOC (目次) を付けるブックマークレット(旧jQuery版。2017年5月現在以降はこのスクリプトは機能しなくなりました)
// style
var style = (function () {/*
.toc{
border: 1px solid #aaa;
padding: 4px 12px;
margin-bottom: 12px;
position: relative;
padding-top: 30px;
}
.toc-title{
@kobake
kobake / freee-auto-timecard.js
Created March 13, 2017 01:08
給与計算フリー:勤怠自動入力スクリプト
setInterval(function(){
if($('.spinner').length == 0 && $('.work-record-edit-balloon .submit-button').length > 0){
console.log("click");
$('.work-record-edit-balloon .submit-button')[0].click();
}
else{
console.log("wait");
}
}, 500);
@kobake
kobake / bitcoin-build-performance-with-ccache.sh
Last active March 7, 2017 08:31
ccache 有無による bitcoin ビルド時間の変化の計測
#!/bin/bash
#
# Ref article: http://blog.clock-up.jp/entry/2017/03/07/ccache
#
# system information
uname -a
cat /etc/system-release
cat /proc/cpuinfo