Skip to content

Instantly share code, notes, and snippets.

View chadhietala's full-sized avatar
🎯
Focusing

Chad Hietala chadhietala

🎯
Focusing
View GitHub Profile
@krisselden
krisselden / trace-to-mp4.js
Last active July 4, 2022 23:26
Make an mp4 out of a Chrome DevTools trace with screenshots.
const fs = require('fs');
const path = require('path');
const spawn = require('child_process').spawn;
const FPS = 60;
const MICROSEC_PER_FRAME = Math.round(1000000 / FPS);
if (process.argv.length < 3) {
console.log(`node ${path.relative('.', process.argv[1])} [DevToolsProfile]`);
process.exit(1);
}
let traceFile = path.resolve(process.argv[2]);
@ef4
ef4 / app_components_my-button.js
Last active April 7, 2017 01:35
Yielding Actions
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
click: function() {
// In Ember 2.0, actions are just regular functions passed as
// parameters to components. You will be able to invoke them
// by just calling them, like this:
var action = this.get('action');
if (action) {
@britishtea
britishtea / fish_right_prompt.fish
Last active February 17, 2024 22:20
My right prompt for the fish shell.
function fish_right_prompt -d "Write out the right prompt"
set -l exit_code $status
set -l is_git_repository (git rev-parse --is-inside-work-tree 2> /dev/null)
set -l max_shlvl 1; and test "$TERM" = "screen"; and set -l max_shlvl 2
# Print a fork symbol when in a subshell
if test $SHLVL -gt $max_shlvl
set_color yellow
echo -n "⑂ "
set_color normal
@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.
var BVT = function(width, depth, init, elems) {
this._width = width;
this._depth = depth;
this._leaf = depth === 1;
this._shift = (this._depth - 1) * Math.round(Math.log(width) / Math.log(2));
this._himask = this._width - 1;
this._lomask = Math.pow(2, this._shift) - 1;
this._elems = elems;

A future version of Ember will come with a new templating engine known as HTMLBars.

The original motivation for HTMLBars was to allow helpers and properties to have better contextual information about what they were bound to.

So for example, consider a template like this:

<a href="{{url}}">{{link}}</a>
@jlongster
jlongster / csp.js
Last active January 9, 2021 16:09
very basic CSP in JavaScript
var fs = require('fs');
// machine
function go_(machine, step) {
while(!step.done) {
var arr = step.value();
var state = arr[0];
var value = arr[1];
@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;