Skip to content

Instantly share code, notes, and snippets.

View voltechs's full-sized avatar

Dale voltechs

  • Notion, Twilight Coders
  • Denver
View GitHub Profile
@voltechs
voltechs / Calendar.gs
Last active January 4, 2021 18:10
Block time off from your personal calendar on your work calendar.
function getPrimaryCalendar() {
return CalendarApp.getDefaultCalendar();
}
function getSecondaryCalendar() {
debug(JSON.stringify(PropertiesService.getUserProperties()));
debug(JSON.stringify(PropertiesService.getScriptProperties()));
return CalendarApp.getCalendarById(calendarID());
}
@valyala
valyala / README.md
Last active April 19, 2024 13:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@tokland
tokland / ar_arel_wrapper.rb
Last active March 5, 2024 06:22
Simple wrapper over arel
require 'active_record'
require 'arel'
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0).
#
# What you would usually write like this:
#
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"])
#
# can now be written like this (note those parentheses required by the operators precedences):