Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
taroyabuki / opencl-devices.c
Last active December 15, 2015 10:09
OpenCLに対応するデバイスの列挙 http://blog.unfindable.net/archives/5829
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
#define MAX_PLATFORM_IDS 8
@taroyabuki
taroyabuki / manipulate-cuda-mandelbrot.nb
Last active December 15, 2015 05:49
マンデルブロ集合をCUDAでインタラクティブに描く(Mathematica) http://blog.unfindable.net/archives/3512
buffer = CUDAMemoryAllocate["Integer32", {height, width}];
Manipulate[With[{
xMin = center[[1]] - 10^scale, xMax = center[[1]] + 10^scale,
yMin = center[[2]] - 10^scale, yMax = center[[2]] + 10^scale},
kernel[buffer, IntegerPart[10^maxSteps], width, height, xMin, xMax, yMin, yMax];
ArrayPlot[CUDAMemoryGet[buffer],
DataRange -> {{xMin, xMax}, {yMin, yMax}},
DataReversed -> True, ColorFunction -> "Rainbow"]],
{{center, {-0.5, 0}}, Locator},
@taroyabuki
taroyabuki / cuda-mandelbrot.nb
Last active December 15, 2015 05:49
マンデルブロ集合をCUDAで描く(Mathematica) http://blog.unfindable.net/archives/3512
Needs["CUDALink`"]
CUDAQ[]
kernelCode = "
__device__ int check(Real_t x, Real_t y, int maxSteps) {
Real_t re = 0, im = 0;
int i = 0;
while (i++ < maxSteps) {
Real_t newRe = re * re - im * im + x;
@taroyabuki
taroyabuki / cpu-mandelbrot.nb
Last active December 15, 2015 05:49
マンデルブロ集合(Mathematica) http://blog.unfindable.net/archives/3512
Clear@f;
f[c_] := f[c, 0., 0]
f[_, _, 100] = -1;
f[c_, z_, i_] := With[{x = z^2 + c}, If[2 < Abs@x, i, f[c, x, i + 1]]]
xMin = -2;
xMax = 1;
yMin = -3/2;
yMax = 3/2;
dx = (xMax - xMin)/300;
@taroyabuki
taroyabuki / manipulate-opencl-mandelbrot.m
Last active December 15, 2015 04:50
マンデルブロ集合をOpenCLでインタラクティブに描く(Mathematica) http://blog.unfindable.net/archives/5772
buffer = OpenCLMemoryAllocate["Integer32", {height, width}];
Manipulate[Module[{
xMin = center[[1]] - 10^scale, xMax = center[[1]] + 10^scale,
yMin = center[[2]] - 10^scale, yMax = center[[2]] + 10^scale},
kernel[buffer, IntegerPart[10^maxSteps], width, height, xMin, xMax, yMin, yMax];
ArrayPlot[OpenCLMemoryGet[buffer],
DataRange -> {{xMin, xMax}, {yMin, yMax}},
DataReversed -> True, ColorFunction -> "Rainbow"]],
{{center, {-0.5, 0}}, Locator},
@taroyabuki
taroyabuki / opencl-mandelbrot.m
Last active December 15, 2015 04:50
マンデルブロ集合をOpenCLで描く(Mathematica) http://blog.unfindable.net/archives/5772
Needs["OpenCLLink`"]
kernelCode = "
# ifdef USING_DOUBLE _PRECISIONQ
# pragma OPENCL EXTENSION cl_khr _fp64 : enable
# pragma OPENCL EXTENSION cl_amd _fp64 : enable
# endif /* USING_DOUBLE _PRECISIONQ */
int check(Real_t x, Real_t y, int maxSteps) {
Real_t re = 0, im = 0;

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for Google TV

Consumer key: iAtYJ4HpUVfIUoNnif1DA

<?php
header('Content-type:text/plain; charset=utf-8');
session_start();
$oauth = new OAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
if (substr(PHP_OS, 0, 3) == 'WIN') {
$caPath = 'C:/xampp/perl/vendor/lib/Mozilla/CA/';
$caInfo = "${caPath}cacert.pem";
<?php
session_start();
$_SESSION['consumer_key'] = 'Consumer Key';
$_SESSION['consumer_secret'] = 'Consumer Secret';
$callbackUrl = 'http://localhost/twitter/twitter-oauth-end.php';
$oauth = new OAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
if (substr(PHP_OS, 0, 3) == 'WIN') {//XAMPP(いいかげん)
$caPath = 'C:/xampp/perl/vendor/lib/Mozilla/CA/';
<?php
session_start();
session_destroy();
?>
<!doctype html>
<html>
<head>
<title>Logout</title>
</head>
<body>