Skip to content

Instantly share code, notes, and snippets.

# cf. https://html-preview.github.io/?url=https://github.com/hashids/hashids.github.io/blob/master/index.html
require "hashids"
puts "Default alphabet length: #{Hashids::DEFAULT_ALPHABET.length}"
hashids = Hashids.new("This is salt", 10)
puts <<MSG
Alphabet: #{hashids.alphabet}
Alphabet length: #{hashids.alphabet.length}
Seps: #{hashids.seps}
@abicky
abicky / bigquery_benchmark.rb
Last active September 9, 2019 07:30
Extract data from JSON using keys in the first level
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)
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,
#!/bin/bash
set -eo pipefail
image_id=$1
if [ -z "$image_id" ]; then
echo "Usage: $(basename $0) IMAGE_ID"
exit 1
fi
#!/bin/bash
set -eu
PANE_MINIMUM=2
usage() {
cat <<USAGE
Usage: $(basename $0) [-c COL] [-r ROW] [--ssh-option SSH_OPTIONS] HOST [HOST2 ...]
# @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
# @example
# class User < ApplicationRecord
# include HasSetting
# has_setting :setting, :user_setting_item
# end
#
# # == Schema Information
# #
# # Table name: user_settings
# #
# 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 August 29, 2015 14:18
Files for CRFsuite
--- 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>;
@abicky
abicky / regex.R
Last active August 21, 2016 14:42
# 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]]