Skip to content

Instantly share code, notes, and snippets.

@misakwa
misakwa / wrk_counter.lua
Last active May 13, 2020 23:18
Lua script to count request, responses, and status codes from wrk/wrk2 tests
#!/usr/bin/env lua
local thread_id = 1
local threads = {}
setup = function(thread)
thread:set("id", thread_id)
table.insert(threads, thread)
end
@misakwa
misakwa / craftcms-v2-count-content-matrix-blocks-usage
Created September 8, 2018 16:54
CraftCMS Matrix blocks count usage on pages
SET SESSION group_concat_max_len = 1000000;
-- All matrix block types
SELECT * FROM matrixblocktypes;
-- All matrix block types and some related information
SELECT mb.id, mb.ownerId,
mb.fieldId,
mt.name,
mt.handle,

Keybase proof

I hereby claim:

  • I am misakwa on github.
  • I am misakwa (https://keybase.io/misakwa) on keybase.
  • I have a public key ASAGErWaRQRxr9drNchuOhqD66e9zA_jpty8rHnobRKKAAo

To claim this, I am signing this object:

package bench_test
import "testing"
func BenchmarkByteArray(b *testing.B) {
for n := 0; n < b.N; n++ {
GetBytes()
}
}
@misakwa
misakwa / connection.pyx
Created February 21, 2016 21:02 — forked from blackwithwhite666/connection.pyx
Cython - gevent - thrift server. Prototype.
# cython: profile=True
from gevent import socket
import logging
import struct
from libcpp.string cimport string
cimport cython
from cpython cimport bool
from gevent.hub import get_hub
from gevent.event import Event
@misakwa
misakwa / 0_reuse_code.js
Created February 17, 2016 16:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@misakwa
misakwa / gist:b51a6c466b67ee9566a8
Last active August 29, 2015 14:27 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
rds-modify-db-parameter-group {param-group-name} \
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \
--parameters="name=tmp_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=max_heap_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \
--parameters="name=query_cache_type, value=1, method=pending-reboot" \
--parameters="name=query_cache_size, value=131072, method=pending-reboot" \
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \
--parameters="name=join_buffer_size, value={DBInstanceClassMemory/64}, method=pending-reboot" \
--parameters="name=thread_cache_size, value={DBInstanceClassMemory/12582880}, method=pending-reboot" \
@misakwa
misakwa / s3.py
Last active August 29, 2015 14:13
S3 Wrapper
#!/usr/bin/env python
import threading
import contextlib as ctx
import boto.s3 as s3
storage_info = threading.local()
DEFAULT_REGION = 'us-east-1'
@ctx.contextmanager
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
mount_point=${1:-"/mnt2"}
METADATA_URL_BASE="http://169.254.169.254/latest"
require 'facter'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("ec2dtag --filter \"resource-id=#{instance_id}\" --region #{region} | cut -f 4-|awk 'BEGIN{FS=\" \";OFS=\"|\"} {$1=$1; print $0}'")
tags.scan(/(.*)\|+(.*)/) do |key, value|
fact = "ec2_tag_#{key}"
Facter.add(fact) { setcode { value } }
end