Skip to content

Instantly share code, notes, and snippets.

@hyrmn
hyrmn / .gitconfig
Last active December 21, 2015 05:49
my .gitconfig
[user]
name = Ben Hyrman
email = ben.hyrman@gmail.com
[core]
autocrlf = true
editor = vim
excludesfile = C:\\Users\\Ben\\Documents\\gitignore_global.txt
[credential]
helper = !~/AppData/Roaming/GitCredStore/git-credential-winstore
[merge]
@cowboyd
cowboyd / gist:6299096
Created August 21, 2013 19:33
I did not know that.
[1] pry(main)> Class.new.respond_to?(:define_method)
=> false
[2] pry(main)> Module.new.respond_to?(:define_method)
=> false
[3] pry(main)> Class.new.send(:define_method, :yup) {}
=> #<Proc:0x00000100a08cb8@(pry):3 (lambda)>
[4] pry(main)> Module.new.send(:define_method, :yup) {}
=> #<Proc:0x00000100d8f468@(pry):4 (lambda)>
@passcod
passcod / extend.coffee
Last active December 21, 2015 17:29
This is really normal prototypal inheritance, and the #extend and #create methods are just there for convenience, not to hide away the magic.
Namespace.extend = (src, obj = {}) ->
if typeof obj.init is 'function'
newObj = obj.init
delete obj.init
else
newObj = ->
newObj.prototype = Object.create src.prototype
newObj.prototype.constructor = newObj
for prop of obj
<div id="alert">
<div id="flash">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<strong>Warning!</strong>
<span></span>
</div>
</div>
@ryanflorence
ryanflorence / angular.js
Last active October 30, 2019 01:42
Comparing an avatar implementation with angular and ember. http://www.angularails.com/articles/creating_simple_directive_in_angular
// Because people can't seem to find the gist description, here is the source
// of this code, a post found in last weeks JS Weekly, it is not my code
// http://www.angularails.com/articles/creating_simple_directive_in_angular
angular.module('ui-multi-gravatar', [])
.directive('multiAvatar', ['md5', function (md5) {
return {
restrict: 'E',
link:function(scope, element, attrs) {

Guide to loading/error events and substates

In addition to the techniques described in the Asynchronous Routing Guide, the Ember Router provides powerful yet overridable conventions for customizing asynchronous transitions between routes by making use of error and loading substates.

loading substates

@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@untergeek
untergeek / kibana.json
Last active March 27, 2019 01:09
Simple Kibana dashboard for collectd stats
{
"title": "Collectd: Blackbox",
"services": {
"query": {
"list": {
"0": {
"query": "plugin:\"load\"",
"alias": "Load",
"color": "#7EB26D",
"id": 0,
# Using these pry gems -- copy to your Gemfile
# group :development, :test do
# gem 'awesome_print' # pretty print ruby objects
# gem 'pry' # Console with powerful introspection capabilities
# gem 'pry-byebug' # Integrates pry with byebug
# gem 'pry-doc' # Provide MRI Core documentation
# gem 'pry-rails' # Causes rails console to open pry. `DISABLE_PRY_RAILS=1 rails c` can still open with IRB
# gem 'pry-rescue' # Start a pry session whenever something goes wrong.
# gem 'pry-theme' # An easy way to customize Pry colors via theme files
# end
@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.