Skip to content

Instantly share code, notes, and snippets.

View shinecita's full-sized avatar

Caro Urquhart shinecita

View GitHub Profile
@shinecita
shinecita / gist:4039978
Created November 8, 2012 16:44
./ssh/config
Host heroku.com
Hostname heroku.com
Port 22
IdentitiesOnly yes
IdentityFile ~/.ssh/heroku_rsa
TCPKeepAlive yes
User [email protected]
ForwardAgent yes
npm http GET https://registry.npmjs.org/up
npm ERR! git clone [email protected]:Igniter/starscape-auth.git Initialized empty Git repository in /tmp/build_3flfct30tzftp/tmp/npm-3420/1352223283745-0.15098921791650355/.git/
npm ERR! git clone [email protected]:Igniter/starscape-auth.git
npm ERR! git clone [email protected]:Igniter/starscape-auth.git Host key verification failed.
npm ERR! git clone [email protected]:Igniter/starscape-auth.git fatal: The remote end hung up unexpectedly
npm ERR! git clone [email protected]:Igniter/starscape-models.git Initialized empty Git repository in /tmp/build_3flfct30tzftp/tmp/npm-3420/1352223283716-0.3042264792602509/.git/
Model.addOrganization = function(model, organizationId, done) {
console.log("model:", model, "organizationId" , organizationId )
Model.save({_id:model._id, $addToSet: {organizations: toObjectId(organizationId)}}, function(err) {
console.log(err);
done(null, model);
})
}
Model.hasOrganization = function (model, organization) {
if (!model.organizations) return false;
var organizationsIds = model.organizations.map(function(o){return o._id});
console.log("CHEKCING : orgs", organizationsIds, "orgId", organization._id, organizationsIds.filter(function(id){id === organization._id}))
return organizationsIds.indexOf(organization._id) != -1
}
@shinecita
shinecita / gist:3941190
Created October 23, 2012 20:06
adding a User
Model.addUser = function(model, user, done) {
User.save({_id: toObjectId(model), $addToSet: {organizations: toObjectId(model)}}, function(err, user) {
// user.organizations || (user.organizations = []);
// user.organizations.push(toObjectId(model));
done(null, user);
});
};
@shinecita
shinecita / gist:3893047
Created October 15, 2012 15:17
forEachSeries
function checkUserTags(user) {
var tags = user.tags
var newTags = [];
console.log( "Checking user", user._id)
if (tags.length > 0) {
tags.forEach(function (tagName, i) {
console.log("user", user._id, tagName, i);
@shinecita
shinecita / gist:3706465
Created September 12, 2012 13:03
header
.navbar.navbar-fixed-top
.navbar-inner
.container-fluid.mobile
a(href='/#').brand
img(src='/img/devscapeD.png')
.dropdown.nav.pull-right
a(role="button", data-toggle="dropdown", data-target="#", href="#").dropdown-toggle#dLabel
if(user && user.name)
=user.name.toLowerCase()
else
@shinecita
shinecita / gist:3701470
Created September 11, 2012 19:42
populate self referenced
app.post('/login', function(req, res) {
User
.where('email', req.body.email)
.populate('organizations')
.findOne(function(err, user) {
if(user) {
console.log(user);
user.authenticate(req.body.password, function(err) {
if(!err) {
req.session._userId = user.get('id');
var OrganizationRouter = module.exports = Backbone.Router.extend({
routes: {
'o/:organizationName': 'show'
, 'createOrganization': 'add'
}
, show: function (orgUserName) {
$('body').removeClass();
$('body').addClass('organizations');
// var org = new Organization({id : orgUserName});
@shinecita
shinecita / gist:3660067
Created September 6, 2012 20:15
Show function that gives me the backbone object
, show: function (orgUserName) {
$('body').removeClass();
$('body').addClass('organizations');
var org = new Organization({id : orgUserName});
org.fetch();
var view = new OrganizationView({model: org});
Application.