Skip to content

Instantly share code, notes, and snippets.

@naotokui
naotokui / google_result_count.py
Last active November 3, 2016 00:42
Google search and get the number of search result
import requests
from bs4 import BeautifulSoup
import argparse
def get_google_count(query):
parser = argparse.ArgumentParser(description='Get Google Count.')
parser.add_argument('word', help='word to count')
r = requests.get('http://www.google.com/search',
params={'q':'"'+ query +'"',
"tbs":"li:1"}
@naotokui
naotokui / ofxFmodSoundPlayer.cpp
Last active November 4, 2016 09:43
openFrameworks - get raw audio frame from audioPlayer using ofFmodSoundPlayer
#include "ofxFmodSoundPlayer.h"
FMOD_RESULT F_CALLBACK analyzerCallback(FMOD_DSP_STATE *dsp_state,
float *inbuffer, float *outbuffer,
unsigned int length, int inchannels,
int outchannels)
{
// pass the data along
memcpy(outbuffer, inbuffer, sizeof(float)* length * outchannels);
@naotokui
naotokui / ChainerPainter.ipynb
Last active October 22, 2016 06:29
Image Regression in Chainer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@naotokui
naotokui / make_universal_binary.sh
Created October 22, 2016 04:10
make command for compiling an universal binary
make CXXFLAGS="-arch i386 -arch x86_64" CFLAGS="-arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64"
@naotokui
naotokui / check_permission.sh
Created January 25, 2016 03:39
Verify/Repair Disk Permission on OS X El Capitan
# verify
sudo /usr/libexec/repair_packages --verify --standard-pkgs /
# repair
sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume /
@naotokui
naotokui / gist:ee983e0c384fa5acd49f
Created November 9, 2015 06:32
Xcode - Arguments Passed on Launch - Show UIView Alignment Rects
-UIViewShowAlignmentRects YES
@naotokui
naotokui / gist:603aa18fee584232363a
Created October 11, 2015 04:53
time elapsed time in c++
auto start = std::chrono::steady_clock::now();
// some task
auto end = std::chrono::steady_clock::now();
std::cout << "Elapsed time " << double((end-start).count())/double(std::chrono::steady_clock::period::den) << "s" << std::endl;
NSString *hexString = "01abcd";
UInt64 value = (UInt64)strtoull([hexString UTF8String], NULL, 16);
NSLog(@"value %ld", value);
@naotokui
naotokui / gist:b5637a147cb46c0ed3eb
Created September 11, 2014 04:03
MPMediaQuery - ignore songs on Cloud (i.e., iTunes Match)
[mediaQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithBool:NO] forProperty:MPMediaItemPropertyIsCloudItem]];
@naotokui
naotokui / gist:f70eddddbcb7c96f6a07
Created August 21, 2014 01:34
check if a number is 2^N
if ((num & (num - 1)) == 0){
// num is 2^N
}