Skip to content

Instantly share code, notes, and snippets.

User.find({'profile.picture': /twimg.*_normal/}, function(err, users, done) {
if (err) { debug('Username err: ', err); next(err); }
for (var i = 0; i < users.length; i++) {
console.log(users[i].profile.picture);
users[i].profile.picture = users[i].profile.picture.replace('_normal', '');
users[i].save(function(err) {
if (err) { return next(err); }
done(err, user);
});
console.log(users[i].profile.picture);
db.users.find({'profile.picture': /twimg.*_normal/}).forEach( function(user) {
var picture = user.profile.picture.replace(/_normal/, '');
user.profile.picture = picture;
db.users.save( user );
print(user.profile);
});
db.users.find({email: /@twitter.com/}).forEach( function(user) {
var username = user.email.replace('@twitter.com', '');
user.profile.username = username;
/**
* In Express
*/
exports.getAccount = function(req, res) {
Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) {
if (err) {
console.error('Challenge err: ', err);
next(err);
}
res.render('account/profile', {
/**
* Angular API Call
*/
exports.getAccountAngular = function(req, res) {
Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) {
if (err) {
console.error('Challenge err: ', err);
next(err);
}
{
"name": "Palindrome Tester",
"difficulty": 1, // should be a range from 1-5
"description": [
"Your job is to determine if a provided string is a palindrome.",
"The definition of a palindrome can be found at http://en.wikipedia.org/wiki/Palindrome.",
"Strings will be passed in with varying formats, such as \"racecar\", \"RaceCar\", and \"race CAR\" among others.",
"Return true if the string is a palindrome, otherwise false"
],
"publicTests": [
/**
* Jquery related stuffs
*/
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
$('#complete-bonfire-dialog').modal('show');
// Only post to server if there is an authenticated user
if ($('.signup-btn-nav').length < 1) {
$.ajax({
type: 'POST',
data: {
@terakilobyte
terakilobyte / gulpfile.js
Last active August 29, 2015 14:16
browserify help
var paths = {
main: './client/client.js',
jsx: './common/components/**/*.jsx',
publicJs: './public/js',
server: './server/server.js',
serverIgnore: [
'gulpfile.js',
'public/',
'components/**/*.styl',
'bower_components/',
@terakilobyte
terakilobyte / gulpfile.js
Created March 4, 2015 13:01
messy gulpfile
process.env.DEBUG = process.env.DEBUG || 'freecc:*';
var _ = require('lodash'),
gulp = require('gulp'),
// ## debug
bundleLogger = require('./gulpUtils/bundleLogger'),
handleErrors = require('./gulpUtils/handleErrors'),
// ## bundle
bundleName = require('vinyl-source-stream'),
@terakilobyte
terakilobyte / LearnRX
Created April 18, 2015 18:16
FEM async
Array.prototype.concatAll = function() {
var results = [];
this.forEach(subArray => {
subArray.forEach(item => {
results.push(item);
});
// ------------ INSERT CODE HERE! ----------------------------
// Add all the items in each subArray to the results array.
// ------------ INSERT CODE HERE! ----------------------------
});
return movieLists.map(genres =>
genres.videos.map(video =>
video.boxarts.filter(boxart =>
boxart.width === 150 && boxart.height === 200
).map(boxart => {
return ({
id: video.id,
title: video.title,
boxart: boxart.url
})