Skip to content

Instantly share code, notes, and snippets.

@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@jeremywrowe
jeremywrowe / ember-data-1.13-cheatsheet.md
Created August 17, 2015 17:00
Ember Data v1.13.x Cheatsheet

Ember Data v1.13.x Cheatsheet

Things to remember

  • If you return a promise beforeModel, model, and afterModel in a route, it will wait to resolve the promise before transitioning into the route. This is helpful when using loading and error substate templates.

  • All ember data records go into a global cache. There is not a cache per query,

@samselikoff
samselikoff / future-proof.md
Last active April 21, 2023 17:14
Future-proofing your Ember 1.x code

This post is also on my blog, since Gist doesn't support @ notifications.


Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:

  • Use Ember CLI
  • In general, replace views + controllers with components
  • Only use controllers at the top-level for receiving data from the route, and use Ember.Controller instead of Ember.ArrayController or Ember.ObjectController
  • Fetch data in your route, and set it as normal properties on your top-level controller. Export an Ember.Controller, otherwise a proxy will be generated. You can use Ember.RSVP.hash to simulate setting normal props on your controller.
@willurd
willurd / web-servers.md
Last active May 24, 2024 13:07
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
class MyController < UIViewController
def viewDidLoad
@button = UIButton.alloc.init
@button.when_tapped do
weak_self = WeakRef.new(self) # <--- create a weak reference to self
@alert = UIAlertView.alertViewWithTitle "Alert",
message: "Message",
cancelButtonTitle: "Dismiss",
@mattetti
mattetti / app_delegate.rb
Created June 19, 2012 01:17
crashing RubyMotion with libdispatch and blocks
class Foo
def self.bar(&block)
block.call(42)
end
end
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
Dispatch::Queue.concurrent(:low).async do
Foo.bar{|res| p "the answer is #{res}"}
@tpope
tpope / why_isnt_this_the_default.rb
Created June 5, 2012 17:34
Raise an error on missing assets
Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do
class MissingAssetError < StandardError; end
def digest_for_with_presence_check(logical_path)
unless asset_environment[logical_path]
raise MissingAssetError.new("#{logical_path} doesn't exist")
end
digest_for_without_presence_check(logical_path)
end
alias_method_chain :digest_for, :presence_check
@jboner
jboner / latency.txt
Last active May 24, 2024 12:40
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@iwarshak
iwarshak / nginx
Created December 12, 2011 15:31
nginx init script
#!/bin/bash
case "${1:-''}" in
'start')
# start commands here
/opt/nginx/sbin/nginx
;;
'stop')
# stop commands here
kill `cat /opt/nginx/logs/nginx.pid`