Skip to content

Instantly share code, notes, and snippets.

View flybayer's full-sized avatar
🤓
CEO Flightcontrol + Pilot

Brandon Bayer flybayer

🤓
CEO Flightcontrol + Pilot
View GitHub Profile
@firedev
firedev / readmarkable.rb
Created June 7, 2014 05:04
ReadMarkable
module ReadMarkable
extend ActiveSupport::Concern
included do
has_many :read_marks
def touch_read_at
update_column(:read_at, Time.now)
end
vundle_outdated() {
local -a outdated
for plugin in `find ~/.vim/bundle -maxdepth 1 -d 1`;
do
cd $plugin;
current=`git status | grep -c "Your branch is up-to-date with"`;
if [[ current -eq 0 ]] {
outdated+=$plugin;
}
cd ..;
@yock
yock / controller-params.sh
Created March 11, 2015 19:04
One-liner for finding what parameters are sent to a particular Rails controller action.
grep -A 1 FoosController#create log/development.log
@toddgeist
toddgeist / start.js
Created June 7, 2016 17:14
Using dotenv to load vars when dploying to now. But still keep it out of your repo.
// load as early as possible
if(process.env.NOW){
require('dotenv').config({path:'./.envnow', silent:true});
}else{
require('dotenv').config({silent:true});
}
// now you can deploy with:
//$cp .env .envnow && now && rm -r .envnow
@captainsafia
captainsafia / deploy.js
Last active September 16, 2017 11:06
A quick Node script to allow multi-environment deploys with now
#! /usr/bin/env node
'use strict';
const program = require('commander');
const fs = require('fs');
const { spawn } = require('child_process');
program
.version('1.0.0')
.option('-e, --environment <environment>', 'Environment to deploy to')
@mutewinter
mutewinter / README.md
Last active February 8, 2018 21:16
Magic Import for Vim UltiSnips

Magic Import for Vim UltiSnips

GIF of magic import in action

  1. Be a Vim user.
  2. Install UltiSnips.
  3. Add the code below to $YOUR_VIM_FOLDER/UltiSnips/javascript.snippets.
snippet ii "magic import" b
import `!p
// A Unit test template for Tape
// See 5 Questions every unit test must answer:
// https://medium.com/javascript-scene/what-every-unit-test-needs-f6cd34d9836d
import test from 'tape';
test('What are you testing?', assert => {
const msg = 'what should it do?'
const actual = 'what was the output?';
@aortbals
aortbals / Moment.js React Component.md
Last active April 11, 2019 02:21
React <Moment /> Component

Basic Format API

Since the usage of format is so common, there is an easy API:

<Moment date={publishedAt} format="MMMM D, YYYY" />

Advanced API

@vincentriemer
vincentriemer / PixelRatio.js
Created June 13, 2019 07:27
React PixelRatio Context & Hook
// @flow
import * as React from "react";
const DEFAULT_PIXEL_RATIO = 1;
function processPixelRatio(input: ?number): number {
return input ?? DEFAULT_PIXEL_RATIO;
}
// matchMedia feature detection
import { SessionContext } from "blitz"
import db from "db"
import { authenticateUser, hashPassword } from "app/auth/auth-utils"
import * as z from "zod"
// --------------------------------------------
// PROTECT UTIL
type Ctx = { session: SessionContext }
type ProtectArgs<T> = { schema: T; authorize?: boolean }