Skip to content

Instantly share code, notes, and snippets.

View mattyoho's full-sized avatar

Matt Yoho mattyoho

  • San Francisco, CA, USA
View GitHub Profile
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 2955ead3bb..01467628d8 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -348,7 +348,7 @@ def reorder!(*args) # :nodoc:
self
end
- VALID_UNSCOPING_VALUES = Set.new([:where, :select, :group, :order, :lock,
+ VALID_UNSCOPING_VALUES = Set.new([:where, :select, :group, :order, :lock, :optimizer_hints,
@mattyoho
mattyoho / main.go
Created April 3, 2018 14:18 — forked from rtfb/main.go
A complete example of a custom Blackfriday v2 renderer with pygmentizing CodeBlock handler
package main
import (
"fmt"
"io"
"os/exec"
bf "gopkg.in/russross/blackfriday.v2"
)
@mattyoho
mattyoho / Email Server (Linux, Unix, Mac).md
Created March 19, 2018 20:59 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only Email Server (Linux, Unix, Mac)

Setup a Local Only Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@mattyoho
mattyoho / headless.md
Created April 20, 2017 01:01 — forked from addyosmani/headless.md
So, you want to run Chrome headless.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

You can use chrome --headless on Linux as of M57 but note you'll need to build the binaries yourself for now.

The metabug for adding headless mode to Chromium is over here.

  1. General Background and Overview
@mattyoho
mattyoho / latency.txt
Last active August 29, 2015 14:14 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@mattyoho
mattyoho / README.md
Last active August 29, 2015 14:13 — forked from majek/README.md

Passing TCP socket descriptors around

In linux, normally, it is impossible to "bind()" to the same TCP port twice. If you try to bind to the same port from second proces unix processes you'll see:

socket.error: [Errno 98] Address already in use

@mattyoho
mattyoho / output.txt
Created December 29, 2013 11:38 — forked from haileys/output.txt
Thread #0 was switched to 125044 times
Thread #1 was switched to 124994 times
Thread #2 was switched to 124994 times
Thread #3 was switched to 124993 times
Thread #4 was switched to 124993 times
Thread #5 was switched to 124994 times
Thread #6 was switched to 124994 times
Thread #7 was switched to 124993 times
1,000,000 thread switches took 2.143874 seconds
@mattyoho
mattyoho / mmap.c
Created May 23, 2013 16:13 — forked from piki/mmap.c
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#define CHECK(thing) if (!(thing)) { perror(#thing); exit(1); }
#define MAX_PAGE_IN 104857600
@mattyoho
mattyoho / ping.shar
Created January 9, 2013 20:29 — forked from qrush/ping.shar
# This is a shell archive. Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file". (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# Makefile ping.1 ping.c ping.shar newping.1 newping.c
echo x - Makefile
cat > "Makefile" << '//E*O*F Makefile//'
# Revised to compile under SunOS 4.1.x (no longer necessary to install