Skip to content

Instantly share code, notes, and snippets.

View tibbon's full-sized avatar

David Fisher tibbon

View GitHub Profile
@ppyrrhula
ppyrrhula / e1e-g7f.yaml
Last active November 20, 2023 18:18
HomeAssistant blueprint for Sengled Smart Light Switch E1E-G7F
blueprint:
name: ZHA - Sengled Smart Light Switch
description: 'Control lights with a Sengled Smart Light Switch.
The top "on" button will turn the lights on to the last set brightness
(unless the force brightness is toggled on in the blueprint).
@flanger001
flanger001 / gem_update.rb
Last active April 30, 2020 19:11
Gem update script. Put this in bin/gem_update and chmod +x bin/gem_update. Thanks to https://www.honeybadger.io/blog/capturing-stdout-stderr-from-shell-commands-via-ruby/
#!/usr/bin/env ruby
require "open3"
puts "Create new branch? (press y to continue)"
print "> "
if gets.chomp.casecmp?("y")
system("git checkout master")
system("git branch -D gems/outdated")
system("git checkout -b gems/outdated")
@fay59
fay59 / Quirks of C.md
Last active January 23, 2024 04:24
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@terabyte
terabyte / amazon.md
Created December 6, 2017 02:27
Amazon's Build System

Prologue

I wrote this answer on stackexchange, here: https://stackoverflow.com/posts/12597919/

It was wrongly deleted for containing "proprietary information" years later. I think that's bullshit so I am posting it here. Come at me.

The Question

Amazon is a SOA system with 100s of services (or so says Amazon Chief Technology Officer Werner Vogels). How do they handle build and release?

@Kovrinic
Kovrinic / .gitconfig
Last active April 11, 2024 11:50
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@valyala
valyala / README.md
Last active April 18, 2024 13:51
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:
@hfreire
hfreire / qemu_osx_rpi_raspbian_jessie.sh
Last active March 24, 2024 14:35
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location
# rubocop:disable Style/HashSyntax
# shoryuken用のタスク
namespace :queues do
desc 'Create default SNS & SQS'
task 'setup' => :environment do
# http://qiita.com/takeyuweb/items/cdc262d97c3e863c15ff
# TODO
end
desc "List all SQS queues"
@kerrizor
kerrizor / bullet_and_minitest.md
Last active January 31, 2024 00:07
Trigger MiniTest failures in Rails when Bullet detects N+1 query violations

In test/test_helper.rb...

### Bullet (N+1 queries)

if ENV['BULLET']
  Bullet.enable = true

  require 'minitest/unit'