Skip to content

Instantly share code, notes, and snippets.

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

Shintaro Kaneko kaneshin

🏠
Working from home
View GitHub Profile
func qsort(a []int) []int {
if len(a) < 2 { return a }
left, right := 0, len(a) - 1
// Pick a pivot
pivotIndex := rand.Int() % len(a)
// Move the pivot to the right
a[pivotIndex], a[right] = a[right], a[pivotIndex]
@kaneshin
kaneshin / geo.m
Created February 5, 2014 10:33
逆ジオ
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
[manager stopUpdatingLocation];
DLog(@"location %@", locations);
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:locations[0] completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = placemarks[0];
#include <stdio.h>
#define N 1000
void initialize(long long int *r, long long int *s, long long int *y, long long int *x);
int
main(int argc, char* argv[])
{
// z: k + 1
static inline int
ud_floor(const double x)
{
return (x > 0 ? (int)x : (int)x - 1);
}
alias blp='bl | peco | chbarg'
function chbarg()
{
target=`awk '{print $1}' | sed -e 's/^remotes\///'`
branch=`echo $target | awk '{sub("/", "-"); print $0;}'`
git checkout -b $branch $target
if [[ $? != 0 ]]; then
git checkout $branch
fi
}
cat strings.xml | awk '{sub(".*string.*\">", "");print $1}' | awk '{sub("<\/string.*","");print $1}' | awk '{sub("^<.*", ""); print $1}'
#!/bin/bash
# File: ex.sh
# Maintainer: Shintaro Kaneko <kaneshin0120@gmail.com>
# Last Change: 06-Aug-2014.
# Usage:
# bash ex.sh strings.xml strings_foo.xml strings_bar.xml strings_baz.xml strings_qux.xml > result.csv
list=$@
for var in $list
$content = '
<Font Size="0" Color="#000000"><div style="line-height:0">##########
新着情報</div></Font>
入力項目1
<Font Size="0" Color="#000000">##########</Font>
<Font Size="0" Color="#000000"><div style="line-height:0">##########
新#着情報</div></Font>
入力項目2
<Font Size="0" Color="#000000">##########</Font>
/**
* Foo
*/
public class Foo {
private static final int MIN_HEIGHT = 130;
private static final int MAX_HEIGHT = 200;
private static final int[] EXPECTED = {
130,
135,
extension SLComposeViewController {
convenience init(forServiceType type: String, initialText text: String) {
self.init(forServiceType: type)
self.setInitialText(text)
}
class func shareViewController(forServiceType type: String) -> SLComposeViewController {
let text = LocalizedString("Share body")
let viewController = SLComposeViewController(forServiceType: type, initialText: text)
viewController.completionHandler = { (result) in