Skip to content

Instantly share code, notes, and snippets.

View zeppelin's full-sized avatar
🐹

Gabor Babicz zeppelin

🐹
View GitHub Profile
@zeppelin
zeppelin / component-lookup.js
Created September 23, 2014 20:02
Ember Directives component-lookup override
import Ember from 'ember';
export default Ember.Object.extend({
lookupFactory: function(name, container) {
container = container || this.container;
var fullName = 'component:' + name,
templateFullName = 'template:components/' + name,
templateRegistered = container && container.has(templateFullName);
App.IndexView = Ember.View.extend({
bindCopyButton: function() {
var self = this;
var controller = this.get('controller');
var copyButton = this.$('.copy-button');
var clip = new ZeroClipboard(copyButton);
clip.on('dataRequested', function (client, args) {
client.setText(document.location.href);
controller.set('justCopied', true);
setTimeout(function() {
@zeppelin
zeppelin / app.js
Created December 17, 2013 13:44
Reopening core views in Ember App Kit
// app/app.js
import Resolver from 'resolver';
// ...
import extendLinkView from 'appkit/core_ext/link_view';
extendLinkView();
// ...
MyRoute = Ember.Route.extend({
events: {
doSomething: function() {
console.log('Yes sir!');
}
}
});
// If your controller already has a method named `doSomething`,
// it'll take precedence over the router's event, as the controller
foo = 10
bar = ->
((foo)->
foo = 20
console.log foo # => 20
)()
console.log foo # => 10
foo = 30
@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! *"
@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 / 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 / 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 / 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)