Skip to content

Instantly share code, notes, and snippets.

@calvintwr
calvintwr / gist:36515c9bdf68f8558a99
Created January 6, 2015 15:59
FIX: Sequelize error in model naming after moving from dev12 to rc6
fs.readdirSync(__dirname).filter(function(file) {
return (file.indexOf('.') !== 0) && (file !== 'index.js')
}).forEach(function(file) {
var model = sequelize.import(path.join(__dirname, file))
var name = capitaliseFirstLetter(model.name); //ugly hack to restore uppercase
console.log(name);
db[name] = model
@calvintwr
calvintwr / gist:0b966c1ae02cf3963801
Created January 6, 2015 15:58
Sequelize error in model naming after moving from dev12 to rc6
/Users/MacBook/hashiontag/node_modules/sequelize/lib/associations/mixin.js:101
throw new Error(this.name + "." + Utils.lowercaseFirst(Type.toString())
^
Error: comment.function (source, target, options) {
Association.call(this);
this.associationType = 'BelongsTo';
this.source = source;
this.target = target;
this.options = options;
db.User.findAll({
attributes: ['userId', 'lastStreamUpdate']
}).then(function(results){
results.forEach(function(el, i) {
el.updateAttributes({
lastStreamUpdate: Date.now()
}).catch(function(err){
console.log(fname + 'user lastStreamUpdate error userId: ' + el.userId + ' Error: ' + err);
var fname = "instagramLink.js ";
module.exports = function instagramLink(req, res, action) {
var retries = 0;
//GET USER
if(action === "getuser") {
instaNode.user_search(req.body.screenName, function(err, users, remaining, limit) {
if(err) { console.log(err); return res.json({success:false}); }
SELECT "Hashtag".*, "Post_Hashtag"."createdAt" as "Post_Hashtag.createdAt", "Post_Hashtag"."updatedAt" as "Post_Hashtag.updatedAt", "Post_Hashtag"."Post_postId" as "Post_Hashtag.Post_postId", "Post_Hashtag"."Hashtag_hashtagId" as "Post_Hashtag.Hashtag_hashtagId" FROM "Hashtag" AS "Hashtag", "Post_Hashtag" AS "Post_Hashtag" WHERE ("Post_Hashtag"."Post_postId"=245 AND "Post_Hashtag"."Hashtag_hashtagId"="Hashtag"."hashtagId");
[email protected] /Users/MacBook/hashiontag
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
}
);
$('#signupForm').validate({
rules: {
username: {
<!doctype html>
<html lang="en" class="no-js" ><!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{title}</title>
<meta name="description" content="Description.">
<meta name="keywords" content="">
<meta name="author" content="">
@calvintwr
calvintwr / gist:21f13462147509d068f6
Created October 14, 2014 04:48
iOS Safari problem: package JSON
{
"name": "hashionable",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"async": "0.9.0",
"bcrypt-nodejs": "0.0.3",
gm(rawPath).noProfile().autoOrient()
//parse the stream for async saving.
.stream(function(err, stdout, stderr) {
if(err) {
console.log('Stream error...');
console.log(err);
return res.json({success: false});
}