This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@entries | |
for feed in Feed.all | |
@entries << feed.entries | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func UploadHandler(w http.ResponseWriter, r *http.Request) { | |
file, _, err := r.FormFile("file") | |
if err != nil { | |
log.Println(err) | |
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) | |
return | |
} | |
img, _, err := image.Decode(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getHexFromColor(color: NSColor) -> NSString { | |
// Get the red, green, and blue components of the color | |
var r :CGFloat = 0 | |
var g: CGFloat = 0 | |
var b: CGFloat = 0 | |
var a: CGFloat = 0 | |
var rInt, gInt, bInt, aInt: Int | |
var rHex, gHex, bHex: NSString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There seem to be problems with "climatically" and "fezzes" as passwords. | |
// When using "climatically": Program terminates with "openpgp: unsupported feature: public key version" | |
// When using "fezzes": Program terminates with "openpgp: invalid data: tag byte does not have MSB set" | |
// Expected behaviour would be a reinvokation of the prompt function in an endless loop until the right password is used. | |
package main | |
import ( | |
"bytes" | |
"errors" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
name: 'Bijan' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
OlderNewer