This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// toBinary | |
func toBinary<T: UnsignedIntegerType>(value: T) -> String { | |
let str = String(value, radix:2) | |
let size = sizeofValue(value) * 8 | |
let padd = String(count: (size - str.characters.count), repeatedValue: Character("0")) | |
return padd + str | |
} | |
func toBinary<T: _SignedIntegerType>(value: T) -> String { | |
let size = sizeofValue(value) * 8 | |
let signed: IntMax = value.toIntMax() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load("visualization", "1.1", {packages:["geochart"]}); | |
google.setOnLoadCallback(drawRegionsMap); | |
function drawRegionsMap() { | |
/* 0…未踏、1…通過、2…接地、3…訪問、4…宿泊、5…居住 */ | |
var data = google.visualization.arrayToDataTable([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
NSInteger i = 101; | |
NSLog(@"NSInteger %lu",sizeof(NSInteger)); | |
NSLog(@"long %lu",sizeof(long)); | |
NSLog(@"int %lu",sizeof(int)); | |
NSLog(@"%ld",(long)i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -lt 1 ]; then | |
echo "Uage: $0 ImageFileName" | |
exit 1 | |
fi | |
FILE=$1 | |
BASENAME=${FILE%.*} | |
EXT=${FILE##*.} | |
DIR=icons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
NSString *toCamelCase(NSString *s) | |
{ | |
return [[[s capitalizedString] componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"] invertedSet]] componentsJoinedByString:@""]; | |
} | |
NSString *splitOnCapital(NSString *s) { | |
NSRange upcaseRange = NSMakeRange('A', 26); | |
NSRange numberRange = NSMakeRange('0', 10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Convert2 { | |
public static void main(String args[]) { | |
if ( args.length < 2 ) { | |
throw new IllegalArgumentException("parameter : number_string radix"); | |
} | |
String s = args[0]; | |
int radix = Integer.parseInt(args[1]); | |
int decimal = Integer.parseInt(s,radix); | |
System.out.println("result = "+decimal); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Convert { | |
public static void main(String args[]) { | |
if ( args.length < 2 ) { | |
throw new IllegalArgumentException("parameter : decimal radix"); | |
} | |
int decimal = Integer.parseInt(args[0]); | |
int radix = Integer.parseInt(args[1]); | |
String s = Integer.toString(decimal,radix); | |
System.out.println("result = "+s); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Decimal { | |
public static long toLong(String bin) { | |
long decimal = 0; | |
for ( int i = 0; i < bin.length(); i++ ) { | |
if ( bin.substring(i,i+1).equals("1") ) { | |
decimal <<= 1; | |
decimal += 1; | |
} else if ( bin.substring(i,i+1).equals("0") ) { | |
decimal <<= 1; | |
} else if ( bin.substring(i,i+1).equals(" ") ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
unsigned long bin2dec(const char *binary) | |
{ | |
unsigned long decimal = 0; | |
do { | |
if ( *binary == '0' ) { | |
decimal <<= 1; | |
} else if ( *binary == '1' ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <time.h> | |
#include <mach/mach_time.h> | |
#define DEBUG 0 | |
int digit3(unsigned long n) | |
{ |