Skip to content

Instantly share code, notes, and snippets.

View hirohitokato's full-sized avatar

Hirohito Kato hirohitokato

View GitHub Profile
@hirohitokato
hirohitokato / bench.cpp
Created February 21, 2010 13:26 — forked from qnighy/bench.cpp
元ネタ:C++ で気軽に時間測定がしたい http://d.hatena.ne.jp/iwiwi/20100221/1266682598 ブロック内で標準エラー出力へ出力していたり,入れ子的に使ったりすると表示がおかしなことになってしまう問題の対策コード http://twitter.com/qnighy/status/9423778596
/*
* 元ネタ:C++ で気軽に時間測定がしたい
* http://d.hatena.ne.jp/iwiwi/20100221/1266682598
*
* ブロック内で標準エラー出力へ出力していたり,入れ子的に使ったりすると,
* 表示がおかしなことになってしまうという問題への対策を施したコード
* Twitter: http://twitter.com/qnighy/status/9423778596
*/
#include <cstdio>
#include <sys/time.h>
/*
NSData+XMLParser
Simple XML Parser for iPhone
Usage:
* -I /usr/include/libxml2
* -L libxml2
- (void)removeObjectForKey:(NSString*)key {
#if !TARGET_IPHONE_SIMULATOR
@synchronized(self) {
if (!deleteQueryDictionary) {
deleteQueryDictionary = [[NSMutableDictionary alloc]initWithObjectsAndKeys:
(id)kSecClassGenericPassword, (id)kSecClass,
key, (id)kSecAttrAccount,
(id)kSecMatchLimitAll, (id)kSecMatchLimit,
(id)kCFBooleanTrue, (id)kSecReturnAttributes,
nil];
/*
* BeginEnd.h
* GLBeginEnd
*
* Created by narumij on 10/05/18.
* Copyright 2010 narumij. All rights reserved.
*
*/
// http://d.hatena.ne.jp/narumij/20100518/1274190881
#import <UIKit/UIKit.h>
@interface UIWebView (Additions)
/*!
@abstract Enable/Disable the receiver from scrolling.
*/
@property (nonatomic, assign) BOOL webViewScrollEnabled;
import os
import csv
from subprocess import Popen, PIPE
from Foundation import NSMutableDictionary
build_number = os.popen4("git rev-parse --short HEAD")[1].read()
info_plist = os.environ['BUILT_PRODUCTS_DIR'] + "/" + os.environ['WRAPPER_NAME'] + "/Info.plist"
# Open the plist and write the short commit hash as the bundle version
plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info_plist)
require 'coreaudio'
dev = CoreAudio.default_output_device
buf = dev.output_loop(44000)
line = ARGV[0]
puts line
44000.times do |t|
# buf[i] = 0x3FFF * rand()
@hirohitokato
hirohitokato / gist:4115565
Created November 20, 2012 02:36
C11の新機能によるNSNumber用マクロ
#define N(x) _Generic((x), \
int: [NSNumber numberWithInt: x], \
float: [NSNumber numberWithFloat: x], \
double: [NSNumber numberWithDouble: x])
@hirohitokato
hirohitokato / gist:4194090
Created December 3, 2012 10:26
Torch code for iOS6
@property (nonatomic,strong)AVCaptureSession *captureSession;
@property (nonatomic,strong)AVCaptureDevice *device;
@property (weak, nonatomic) IBOutlet UISlider *torchLevelSlider;
- (void)setupTorch
{
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *d in devices)
if (d.hasTorch && [d isTorchModeSupported:AVCaptureTorchModeOn]) {
self.device = d;
@hirohitokato
hirohitokato / gist:5966016
Last active December 19, 2015 13:59
error: use of undeclared identifier 'proc' ... why?? -> solved. Required to specify the rvalue of '->*'
// ref: http://okwave.jp/qa/q3884248.html
#include <iostream>
#include <stdio.h>
#include <functional>
class SuperClass {
public:
virtual ~SuperClass() {}