Skip to content

Instantly share code, notes, and snippets.

View britg's full-sized avatar
🖖
Building games

Brit Gardner britg

🖖
Building games
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
anonymous
anonymous / UIColor+Helper.swift
Created September 13, 2015 14:04
UIColor from Hex String in Swift
import UIKit
extension UIColor {
convenience init(hex: String, alpha: CGFloat = 1) {
assert(hex[hex.startIndex] == "#", "Expected hex string of format #RRGGBB")
let scanner = NSScanner(string: hex)
scanner.scanLocation = 1 // skip #
var rgb: UInt32 = 0
@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.
# RSpec CanCan matcher.
#
# When testing your user must have an id otherwise a nil foreign key will
# match on new records.
#
# Examples
#
# describe User do
# subject { User.create! }
#
@zorab47
zorab47 / deploy.rb
Created October 10, 2012 18:24
Capistrano task to precomile assets locally, if necessary
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
assets_path = File.join(release_path, "public/assets")
assets_empty = capture("ls -x #{assets_path}").length == 0
has_current_release = capture("if [ -d #{current_path} ]; then echo -n \"yes\"; fi") == "yes"
compile_assets = false