Skip to content

Instantly share code, notes, and snippets.

View mileszim's full-sized avatar

Miles Zimmerman mileszim

  • San Francisco, CA
  • 01:29 (UTC -07:00)
View GitHub Profile
@mileszim
mileszim / index.d.ts
Last active October 25, 2022 03:44
@ember/utils typescript predicate guards
declare module '@ember/utils' {
import { TypeOf } from '@ember/utils/-private/types';
type EmptyType = null | undefined | '' | false | 0 | [];
type BlankType = null | undefined | '' | [] | '\n\t' | ' ';
type NoneType = null | undefined;
type TypeOfType =
| 'string'
| 'number'
| 'boolean'
@mileszim
mileszim / wait.rb
Created May 16, 2022 04:51 — forked from aks/wait.rb
Ruby Wait class for waiting for things to happen or not happen
# frozen_string_literal: true
#
# Wait.until { expr } -- waits until expr is true
# Wait.while { expr } -- waits while expr is true
#
# Each iteration contains a `sleep(sleep_time)`, where the default sleep time is
# Wait::DEFAULT_SLEEP_TIME (0.1 seconds).
#
# The sleep interval can be specified with the `sleep_time` argument:
#
@mileszim
mileszim / create_active_storage_tables.active_storage.rb
Created May 28, 2021 17:53
Rails Migration Active Storage with UUIDs
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.1]
def change
create_table :active_storage_blobs, id: :uuid do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
@mileszim
mileszim / docker-compose.yml
Last active December 14, 2020 14:05
Rails Redis+Postgres easy docker-compose.yml
# 1. Copy into the root project dir
# 2. `docker-compose start`
# 3. Add the following to `config/database.yml`:
#
# default: &default
# ...
# username: postgres
# password: postgres
# host: localhost
# port: 5432
@mileszim
mileszim / glob.rb
Created August 5, 2020 07:53
glob.rb
# OH MY GLOB
#
# DO ANYTHING. BE ANYONE.
# ALL GLORY BE TO GLOB.
#
# Glob will respond to anything with `nil`.
# You can initialize Glob. go ahead! *Grob bringeth to all*
# myglob = Glob.new("oh", { my: GLOB })
# Now call your methods. "Gob returnith to all*
# myglob.i_made_up_this_method #=> nil
@mileszim
mileszim / .profile
Created June 29, 2017 05:13
nukeit
alias nukeit="bundle exec rake db:drop && bundle exec rake db:create && bundle exec rake db:migrate && bundle exec rake db:seed"
@mileszim
mileszim / app|torii-adapters|application.js
Created June 2, 2017 00:39
Emberfire + Torii Auth load session always
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
store: Ember.inject.service('store'),
firebase: Ember.inject.service('firebase'),
raven: Ember.inject.service('raven'),
findAndSetUser(data) {
return this.get('store').findRecord('user', data.currentUser.uid).then((user) => {
@mileszim
mileszim / emberfire-relationship-service.js
Created May 18, 2017 04:21
firebase relationship magic service
import Ember from 'ember';
const { Service, get, set, A, RSVP: { Promise }, inject: { service }, assert } = Ember;
export default Service.extend({
firebaseApp: service(),
/**
* Link two records, there must be a relationship with an inverse between the two records
* @param {DS.Model} recordA
@mileszim
mileszim / controllers.application.js
Created May 7, 2017 09:58
Emberfire + Torii Auth Example
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
accessDenied() {
this.transitionTo('index');
}
}
});
@mileszim
mileszim / git-branch-in-shell.sh
Last active April 3, 2017 08:36
Display the current git branch in shell
# 1. `brew update`
# 2. `brew install bash-completion`
# 3. `curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh`
# 4. Add the following to ~/.bashrc
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true