Skip to content

Instantly share code, notes, and snippets.

@hnagata
hnagata / postcanvas.js
Created March 11, 2014 11:50
Code snippet to post a HTML5 Canvas image to Facebook
/*
* Code snippet to post a HTML5 Canvas image to Facebook
* H. Nagata
*
* Variables:
* accessToken: Facebook access token
* targetID: Posting target id such as user id or album id
* canvas: HTMLCanvasElement
* base64.decode: c.f. https://github.com/hnagata/js-base64
*
Const SETTINGS_SHEET_NAME = "実行"
Const CONNECT_STRING_ADDRESS = "C5"
Const CALL_ADDRESS = "C8"
Const INPUT_SHEET_PREFIX = "入力 "
Const CHECK_SHEET_PREFIX = "出力 "
Const NULL_MARK = "$NULL"
Const EMPTY_MARK = "$EMPTY"
Const ANY_MARK = "$ANY"
## grid / ggplot ----
library(ggplot2)
library(grid)
make.grid <- function(row, col) {
grid.newpage()
l <- grid.layout(row, col)
v <- viewport(layout=l)
pushViewport(v)
}
print.at <- function(o, i, j) {
## grid / ggplot ----
library(ggplot2)
library(grid)
make.grid <- function(row, col) {
grid.newpage()
l <- grid.layout(row, col)
v <- viewport(layout=l)
pushViewport(v)
}
print.at <- function(o, i, j) {
library(ggplot2)
library(glmnet)
library(msgps)
options(scipen=1)
dat.column <- read.csv("column.csv", head=FALSE, fileEncoding="UTF-8", colClasses="character")
varnames <- dat.column[, 2]
names(varnames) <- dat.column[, 1]
dat <- read.csv("data.csv", fileEncoding="UTF-8", colClasses=dat.column[, 3])
library(ggplot2)
library(RgoogleMaps)
options(scipen=1)
dat.column <- read.csv("column.csv", head=FALSE, fileEncoding="UTF-8", colClasses="character")
dat <- read.csv("data.csv", fileEncoding="UTF-8", colClasses=dat.column[, 3])
dat <- dat[!duplicated(cbind(dat$price, dat$lat, dat$lon)), ]
dat$price[dat$id == "300056150013621013622"] <- NA # 価格の桁間違い?
dat$area[dat$id %in% c("300054130041305041305", "300105420003450004117")] <- NA # 面積の桁間違い?
dat$latitude[dat$id == "300059820006005006005"] <- NA # 緯度不正
@hnagata
hnagata / join.cc
Last active August 29, 2015 13:59
#include <sstream>
#include <string>
template<typename T, typename U, typename... R>
void Join(std::stringstream& ss, const T& sep, const U& head, const R&... follows) {
ss << head << sep;
Join(ss, sep, follows...);
}
template<typename T, typename U>
@hnagata
hnagata / functions.php
Last active August 29, 2015 13:57
excode_filter
function excode_filter($content) {
return preg_replace_callback('/(\\[?)(\\[excode ([^\\]]*?)\\])\\]?/', function($m) {
if ($m[1]) return $m[2];
$out = '[' . 'code';
$pairs = preg_split("/\s+/", $m[3]);
foreach ($pairs as $pair) {
list($key, $value) = explode('=', $pair);
if ($key == 'src') $src_url = preg_replace('/["\']/', '', $value);
elseif ($key == 'link') $link_url = preg_replace('/["\']/', '', $value);