Skip to content

Instantly share code, notes, and snippets.

View cubicdaiya's full-sized avatar

Tatsuhiko Kubo cubicdaiya

View GitHub Profile
@cubicdaiya
cubicdaiya / hoge.c
Last active August 15, 2021 14:04
mruby example
#include <stdio.h>
#include <mruby.h>
#include <mruby/proc.h>
#include <mruby/data.h>
#include <mruby/compile.h>
#include <mruby/string.h>
#include <mruby/hash.h>
#include <mruby/variable.h>
static struct RProc *compile(mrb_state *mrb, const char *path)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdbool.h>
bool is_dir(const char *path)
{
struct stat s;
if (lstat(path, &s) == -1) {
return false;
@cubicdaiya
cubicdaiya / print_args.c
Created June 18, 2013 11:52
print args with mruby.
#include <stdlib.h>
#include <stdio.h>
#include <mruby.h>
#include <mruby/proc.h>
#include <mruby/array.h>
#include <mruby/data.h>
#include <mruby/compile.h>
int main(int argc, char **argv)
@cubicdaiya
cubicdaiya / worker.go
Created November 2, 2013 02:45
job worker by goroutine
package main
import (
"runtime"
)
func worker(done chan bool) {
// do something
@cubicdaiya
cubicdaiya / nginx.conf
Created October 13, 2013 04:07
Regexp in mruby_nginx_module
location /mruby_regexp {
mruby_content_handler_code '
re = Regexp.compile("(.)(.)")
re.match("ab")
result = Regexp.last_match.class == MatchData and
Regexp.last_match[0] == "ab" and
Regexp.last_match[1] == "a" and

Untitled Slide

Welcome to Glide.

Glide is the easiest way to create useful slide for all of your Gists.

  • input key <- to go backward.
  • input key -> to go forward.

Publishing

@cubicdaiya
cubicdaiya / bench.php
Created September 15, 2013 14:58
benchmark APC & PECL::Memcached
<?php
$id = 'testtest';
$test_data = array();
$mem = new Memcached;
$mem->addServer('/var/run/memcached.sock', 0);
if (count($argv) < 2) {
echo "few argument" . PHP_EOL;
@cubicdaiya
cubicdaiya / bench.php
Last active December 23, 2015 03:09
benchmark APC & PECL::Memcache
<?php
$id = 'testtest';
$test_data = array();
$mem = new Memcache;
$mem->connect('unix:///var/run/memcached.sock', 0, 10);
if (count($argv) < 2) {
echo "few argument" . PHP_EOL;
@cubicdaiya
cubicdaiya / nginx.conf
Last active December 21, 2015 23:09
Modify the header "Host" to proxied server.
location /modify_proxy_host {
# Hostヘッダが書き換わらない
# mruby_rewrite_handler_code '
# hin = Nginx::Headers_in.new
# hin["Host"] = "localhost:8001"
# ';
# これなら書き換わる
mruby_set_code $proxy_host "'localhost:8001'";
$ go run rand.go
5
$ go run rand.go
12
$ go run rand.go
0
$