Skip to content

Instantly share code, notes, and snippets.

View zeppelin's full-sized avatar
🐹

Gabor Babicz zeppelin

🐹
View GitHub Profile
@zeppelin
zeppelin / router.js
Created October 4, 2014 17:44
Including locale in the URL in Ember.js
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('select-country');
this.resource('root', { path: config.locale }, function() {
@zeppelin
zeppelin / index-route.js
Created December 16, 2014 10:29
Replace root URL with the localized root
import Ember from 'ember';
var Route = Ember.Route;
export default Route.extend({
redirect() {
this.replaceWith('root'); // Replace URL: / -> /en-US
}
});
@zeppelin
zeppelin / 1-readme.md
Last active August 29, 2015 14:17
Ember ES2015 Modules

Ember ES2015 Modules

The purpose of this document is to demonstrate how methods and classes could be imported inside an Ember CLI project, instead of accessing them on the Ember namespace.

For example, instead of doing this:

import Ember from 'ember';

export default Ember.Component.extend({
new MutationObserver(function() {
var slotA = {
count: 0,
color: null,
element: null
};
var slotB = {
count: 0,
color: null,
@zeppelin
zeppelin / hashes2ostruct.rb
Created November 29, 2010 11:21
Ruby Hash to OpenStruct converter function
# Found at http://www.dribin.org/dave/blog/archives/2006/11/17/hashes_to_ostruct/
require 'ostruct'
def hashes2ostruct(object)
return case object
when Hash
object = object.clone
object.each do |key, value|
object[key] = hashes2ostruct(value)
@zeppelin
zeppelin / sc_perform_key_eq_method.js
Created May 9, 2011 18:50
SproutCore `performKeyEquivalent` method
performKeyEquivalent: function(keystring, evt) {
if ( keystring == "escape" ) {
// Do something funny...
return YES;
}
return sc_super();
}
@zeppelin
zeppelin / sc_recordattributes.js
Created May 22, 2011 21:55
SproutCore: Monkey-patched SC.Record to get SC.Record.attr keys as an Array via class method
SC.Record.mixin({
recordAttributes: function() {
var obj = this.prototype;
var ret = [];
for(var key in obj) {
if ( SC.kindOf(obj[key], SC.RecordAttribute) )
ret.push(key);
}
return ret;
}
@zeppelin
zeppelin / sqlite3_ruby19_osx.sh
Created June 21, 2011 19:13
SQLite3 Ruby 1.9.2, OS X 10.6
gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib
@zeppelin
zeppelin / upload_ssh_key.sh
Created July 29, 2011 10:33
Upload id_dsa.pub to host
#!/bin/sh
# from: http://hints.macworld.com/article.php?story=2007091814022049
KEY="$HOME/.ssh/id_dsa.pub"
if [ ! -f ~/.ssh/id_dsa.pub ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t dsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
foo = 10
bar = ->
((foo)->
foo = 20
console.log foo # => 20
)()
console.log foo # => 10
foo = 30