Skip to content

Instantly share code, notes, and snippets.

View shinecita's full-sized avatar

Carolina Urquhart shinecita

View GitHub Profile
@shinecita
shinecita / gist:3dbffaf861ab9306d5caab543521ea43
Created February 20, 2024 20:10
Authorization middleware
function isAuthorized(req, res, next) {
if (req.headers.authorization) {
// compare access token with db
if (everythingok)
RETURN next()
}
ngOnChanges(changes: SimpleChanges) {
if (this.currentSlide !== undefined && !changes.currentSlide.firstChange) {
this.move();
this.renderer.setElementClass(this.carouselItems[(this.currentSlide + this.center) % this.carouselItems.length ], 'faded', true);
this.renderer.setElementClass(this.carouselItems[(this.currentSlide + this.center + 1) % this.carouselItems.length], 'faded', true);
this.setFade();
this.setFade();
}
}
module.exports = function ($scope, $state, Search) {
$scope.searchString = function() {
$scope.questions = Search.query({queryString : $scope.queryString})
$state.go('search');
// $state.go('search', {questions: [{body : "asd"}]});
}
};
Model.resizeAvatar = function (user, done) {
var src = user.facebook.avatar
, filename = user._id.toString()
, url = '/avatars/' + filename;
if(src.indexOf('http') == -1 || src.indexOf('https') == -1) {
src = 'http:'+src;
};
debug("avatar :", user.facebook.avatar)
debug("avatar src:", src)
Thu, 14 Mar 2013 15:42:54 GMT app:models:user facebook login { token: 'AAAGInZCOGfQYBACDR8LeX493NPFGeJI6NYEKS6jKR8stj6ZAxaVuXOI1qZCWz0A8M7S0ZCC90XBZADwRQESccTAmxnhlah3vYAlFl4qWpsAZDZD',
id: '765178541',
data:
{ id: '765178541',
name: 'Carolina Urquhart',
first_name: 'Carolina',
last_name: 'Urquhart',
link: 'http://www.facebook.com/carolina.urquhart',
username: 'carolina.urquhart',
gender: 'female',
User.getUntrackedSimilar = function(user, done) {
var excludeIds = user.similarTracked || [];
excludeIds.push(user._id);
User
.find({
_id: {$nin : excludeIds},
tags: {$in: user.tags},
name : {$exists : true, $ne : null, $ne : ""}
}, {limit: 5}, function(err, users) {
User.similar = function(user, done) {
User
.find({
_id: {$ne: user._id},
tags: {$in: user.tags},
name : {$exists : true, $ne : null, $ne : ""}
}, {limit: 5}, function(err, users) {
// Temporary fix for avoiding users with name :""
if (users) {
console.log("users", users.map(function(user){return user.name}));
@shinecita
shinecita / backend
Last active March 9, 2017 12:52
not sure how to handle the redirect response in the resource
// Gets user avatar url
router.get('/:userId/avatar', function(req, res) {
console.log("User", req.user.pictureUrl);
if (req.user.pictureUrl) {
console.log("redirecting avatar")
res.redirect(req.user.pictureUrl)
} else {
console.log("redirecting default")
res.redirect('/img/userProfileAvatar.png')
}
// Gets user avatar url
router.get('/:userId/avatar', function(req, res) {
User.findOne({}, function(err, user) {
res.redirect(user.pictureUrl);
});
})
{
"author": "",
"name": "starscape-app",
"version": "0.0.2",
"private": true,
"dependencies": {
"express": "~3.0.0",
"monk": "~0.5.0",
"starscape-auth": "git+ssh://git@github.com:Igniter/starscape-auth.git#master",
"starscape-models": "git+ssh://git@github.com:Igniter/starscape-models.git#master",