Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
@sharshenov
sharshenov / gist:33c0dd55c838ecd5762c
Created November 16, 2015 11:16
Rails middleware for health check endpoint
class HealthCheckResponder
def initialize(app, options = {})
@app = app
end
def call(env)
if env["REQUEST_PATH"] == "/health_check"
return [200, {}, [""]]
else
@wayspurrchen
wayspurrchen / git patterns.md
Last active January 18, 2023 21:38
Useful Git Techniques

History

Show file at certain commit

git show <hash>:<file>

Show history of a file

git log -p <filename>

@djonsson
djonsson / install_elasticsearch_osx.md
Last active November 11, 2022 21:10
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@fiftin
fiftin / Convert PostgreSQL to SQLite
Created October 5, 2015 07:04
Convert PostgreSQL to SQLite
1. Dump the data only sql to file
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql
2. scp to local
3. Remove the SET statements at the top
such as:
SET statement_timeout = 0;
SET client_encoding = 'SQL_ASCII';
4. Remove the setval sequence queries
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@tlrobinson
tlrobinson / redux-devtools-separate-window.js
Last active August 20, 2019 23:54
Put the awesome redux-devtools in it's own window so it doesn't obscure or be obscured by your application
// give it a name so it reuses the same window
var win = window.open(null, "redux-devtools", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no");
// reload in case it's reusing the same window with the old content
win.location.reload();
// wait a little bit for it to reload, then render
setTimeout(function() {
React.render(
<DebugPanel top right bottom left >
@sax
sax / databases.rake
Last active March 5, 2022 17:27
Overwrite Rails 3 databases rake task to remove method pollution on Object
# The built-in Rails database rake task is completely crazy, and defines methods on Object. This causes
# problems with Makara, which uses a delegator pattern along with method_missing.
require 'active_support/core_ext/object/inclusion'
require 'active_record'
class Object
remove_method :configs_for_environment
remove_method :create_database
remove_method :current_config
@stephen-puiszis
stephen-puiszis / elasticsearch-cheatsheet.txt
Last active March 14, 2024 10:32
Elasticsearch Cheatsheet - An Overview of Commonly Used Elasticsearch API Endpoints and What They Do
# Elasticsearch Cheatsheet - an overview of commonly used Elasticsearch API commands
# cat paths
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
@bryanrsmith
bryanrsmith / fetch-client.js
Last active April 12, 2020 16:21
A thin wrapper library around the fetch API to provide application-wide HTTP client configuration
export class HttpClient {
constructor(defaults) {
this.defaults = defaults;
this.interceptors = [];
this.activeRequestCount = 0;
this.isRequesting = false;
}
addInterceptor(interceptor) {
this.interceptors.push(interceptor);
@fphilipe
fphilipe / exclude.sql
Last active April 25, 2024 23:17
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)