Skip to content

Instantly share code, notes, and snippets.

@abicky
abicky / bigquery_benchmark.rb
Last active Sep 9, 2019
Extract data from JSON using keys in the first level
View bigquery_benchmark.rb
require 'csv'
require 'faker'
require 'google/cloud/bigquery'
PROJECT_ID = ENV['PROJECT_ID']
DATASET_ID = ENV['DATASET_ID']
TABLE_ID = 'json_extract_benchmark'
bigquery = Google::Cloud::Bigquery.new(project_id: PROJECT_ID)
View test_unit_profiler.rb
require 'test/unit/ui/console/testrunner'
class TestUnitProfiler
Record = Struct.new(:test_name, :test_class, :start_time, :self_time, :total_time, :children, keyword_init: true) do
def to_h
{
name: test_name,
class: test_class,
self: self_time,
total: total_time,
View remove-docker-image
#!/bin/bash
set -eo pipefail
image_id=$1
if [ -z "$image_id" ]; then
echo "Usage: $(basename $0) IMAGE_ID"
exit 1
fi
View tmux-multi-ssh
#!/bin/bash
set -eu
PANE_MINIMUM=2
usage() {
cat <<USAGE
Usage: $(basename $0) [-c COL] [-r ROW] [--ssh-option SSH_OPTIONS] HOST [HOST2 ...]
View bitfield_bindable.rb
# @example
# class Setting
# include BitfieldBindable
# bind_bitfield :feature_bits, :features, 0 => "foo", 1 => "bar"
#
# attr_accessor :feature_bits
# def initialize
# @feature_bits = 0
# end
# end
View has_setting.rb
# @example
# class User < ApplicationRecord
# include HasSetting
# has_setting :setting, :user_setting_item
# end
#
# # == Schema Information
# #
# # Table name: user_settings
# #
View access_logs.R
# Copyright 2015- Takeshi Arabiki
# License: MIT License (http://opensource.org/licenses/MIT)
library(data.table)
access_logs <- (function() {
set.seed(0)
USER_COUNT <- 10000
PAGES <- c("page1", "page2", "page3")
@abicky
abicky / export.i.patch
Last active Aug 29, 2015
Files for CRFsuite
View export.i.patch
--- export.i.orig 2011-07-05 11:23:42.000000000 +0900
+++ export.i 2015-04-11 19:19:39.000000000 +0900
@@ -8,12 +8,13 @@
%include "std_vector.i"
%include "exception.i"
+%feature("director") Trainer;
+%include "crfsuite_api.hpp"
+
%template(Item) std::vector<CRFSuite::Attribute>;
View regex.R
# Copyright 2015- Takeshi Arabiki
# License: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
library(Rcpp)
Sys.setenv(PKG_LIBS = "-lpcrecpp")
sourceCpp(code = '
#include <Rcpp.h> // Rcpp 0.11.3
#include <pcrecpp.h> // pcrecpp 8.36
// [[Rcpp::export]]
View demo.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=320,user-scalable=no">
<style>
body {
margin: 0;
padding: 0;
height: 3000px;