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 <openssl/hmac.h> | |
#include <string.h> | |
#include <stdio.h> | |
int main() | |
{ | |
unsigned char *key = (unsigned char*)"This is your secret"; | |
unsigned char *data = (unsigned char*) "hoge"; | |
unsigned char *expected = (unsigned char*) "4a7bc6c59ebc1a83dc38ec4fd537f98994a9210bf09ad9fc8c60c2ae83746d82"; | |
unsigned char *result; |
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 Data.Char (ord) | |
import Data.Bits | |
base64 :: String -> String | |
base64 "" = "" | |
base64 xs = indexToChar (concat24Bits xs) ++ padding xs | |
concat24Bits :: String -> [Int] | |
concat24Bits (x:[]) = | |
let n = shiftL (ord x::Int) 16 |
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
bswap [x] = [x] | |
bswap (x:y:zs) | |
| x < y = y : bswap (x:zs) | |
| otherwise = x : bswap (y:zs) | |
bsort :: (Ord a) => [a] -> [a] | |
bsort [] = [] | |
bsort [x] = [x] | |
bsort xs = y : bsort ys | |
where |
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
fib :: Int -> [Integer] | |
fib 0 = error "arg >= 1" | |
fib 1 = [1] | |
fib 2 = fib 1 ++ [1] | |
fib n = xs ++ [x + y] | |
where xs = fib (n - 1) | |
(x:y:_) = reverse xs |
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
#!/usr/bin/env perl \ | |
use strict; | |
my $DEBUG = 0; | |
main(); | |
sub main { | |
my $win = 0; |
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
+ (CGFloat)angleWithOrigin:(CGPoint)origin initial:(CGPoint)initial current:(CGPoint)current { | |
CGFloat initialAngle = atan2(initial.y - origin.y, initial.x - origin.x); | |
CGFloat currentAngle = atan2(current.y - origin.y, current.x - origin.x); | |
return currentAngle - initialAngle; | |
} |
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
+ (CGPoint)intersectionOfLineFrom:(CGPoint)p1 to:(CGPoint)p2 withLineFrom:(CGPoint)p3 to:(CGPoint)p4 { | |
CGFloat d = (p2.x - p1.x)*(p4.y - p3.y) - (p2.y - p1.y)*(p4.x - p3.x); | |
if (d == 0) | |
return CGPointZero; // parallel lines | |
CGFloat u = ((p3.x - p1.x)*(p4.y - p3.y) - (p3.y - p1.y)*(p4.x - p3.x))/d; | |
CGFloat v = ((p3.x - p1.x)*(p2.y - p1.y) - (p3.y - p1.y)*(p2.x - p1.x))/d; | |
if (u < 0.0 || u > 1.0) | |
return CGPointZero; // intersection point not between p1 and p2 | |
if (v < 0.0 || v > 1.0) | |
return CGPointZero; // intersection point not between p3 and p4 |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use AnyEvent::XMPP::Client; | |
use AnyEvent; | |
use Config::Pit; | |
use Encode; | |
use constant DEBUG => 0; |
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
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example.android</groupId> | |
<artifactId>my-android-library</artifactId> | |
<version>0.1</version> | |
<packaging>apklib</packaging> | |
<name>my-android-library</name> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example.android</groupId> | |
<artifactId>my-android-app</artifactId> | |
<version>0.1</version> | |
<packaging>apk</packaging> |
NewerOlder