Skip to content

Instantly share code, notes, and snippets.

View gobijan's full-sized avatar
🏝️
Deep in the Caribbean...

Bijan Rahnema gobijan

🏝️
Deep in the Caribbean...
View GitHub Profile
@gobijan
gobijan / gist:10749875
Created April 15, 2014 17:24
ng-really? An AngularJS directive that creates a confirmation dialog for an action. (props to asafge)
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure?" ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function(e) {
e.stopPropagation(); // In case you cancel and don't want events to be propagated.
@gobijan
gobijan / init.js
Last active December 30, 2015 16:39
chocolat autopep8 mixin
var execFile = require('child_process').execFile;
Hooks.addMenuItem("Actions/Python/autopep8", "cmd-alt-l", function() {
var type = Document.current().rootScope();
if ('python.source'.indexOf(type) !== -1) {
execFile("/usr/local/bin/autopep8", ["--aggressive", Document.current().path()], function(error, stdout, stderr) {
Recipe.run(function(recipe) {
recipe.text = stdout;
});
@gobijan
gobijan / gist:2106782
Created March 19, 2012 10:27
Referencing the same Model type under another name...
Post
has_many :upvotes <= Model: Vote
has_many :downvotes <= Model: Vote
Vote
Fields: user_id, comment
belongs_to :post <= as an upvote or downvote..
What I want to achieve:
i need to save distances between two sites => a Directions-Model should have something like
id
origin_id
destination_id
distance
How do I set this up via active record because origin and destination are both from the type site?
@entries
for feed in Feed.all
@entries << feed.entries
end