Skip to content

Instantly share code, notes, and snippets.

@qfox
qfox / log.txt
Created July 7, 2014 07:48
proposed junglingdb test for model field names in db
DROP TABLE IF EXISTS "forum_topic" 1404719138606
DROP TABLE IF EXISTS "forum_comment" 1404719138610
CREATE TABLE "forum_topic" (
"id" SERIAL PRIMARY KEY,
"status" boolean ,
"createdAt" timestamp with time zone ,
"updatedAt" timestamp with time zone ,
"title" varchar
) 1404719138624
CREATE TABLE "forum_comment" (
@qfox
qfox / sequelize-log
Last active August 29, 2015 14:03
problems in fieldName redefine
Executing (default): SELECT "forum_topic".*, "Comments"."id" AS "Comments.id", "Comments"."status" AS "Comments.status", "Comments"."title" AS "Comments.title", "Comments"."topicId" AS "Comments.topicId", "Comments"."sys_created" AS "Comments.sys_created", "Comments"."sys_modified" AS "Comments.sys_modified", "Comments"."parent" AS "Comments.parent" FROM "forum_topic" LEFT OUTER JOIN "forum_comment" AS "Comments" ON "forum_topic"."id" = "Comments"."parent";
events.js:72
throw er; // Unhandled 'error' event
^
error: relation "forum_topic" does not exist
at Connection.parseE (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:558:11)
at Connection.parseMessage (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:387:17)
at null.<anonymous> (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:92:20)
at Socket.EventEmitter.emit (events.js:95:17)
@qfox
qfox / sequalize-promises-log
Last active August 29, 2015 14:03
sequelize-promises
Executing (default): INSERT INTO "forum_topic" ("title","id","createdAt","updatedAt") VALUES ('a',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('b',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('c',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('d',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00') RETURNING *;
Executing (default): SELECT * FROM "forum_topic";
[ '{"id":1,"title":"a","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}',
'{"id":2,"title":"b","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}',
'{"id":3,"title":"c","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}',
'{"id":4,"title":"d","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}' ]
Executing (default): SELECT * FROM "forum_topic" WHERE title <> 'a';
[ '{"id":2,"title":"b","createdAt":"2014-07-11T08:06:10.130Z",
@qfox
qfox / conf-d_rewrite_bem
Last active August 29, 2015 14:03
bem nginx conf
if ($postfix) {
set $postfix "-$postfix";
}
if ($pages_path = "") {
set $pages_path "desktop.bundles";
}
set $pages_path "$pages_path$postfix";
@qfox
qfox / sed-js2php.sh
Created November 22, 2014 03:02
sed-js2php
sed -r -e 's/module.exports.*$/<?php\nreturn function ($bh) {/' \
-e 's/bh\.match/\$bh->match/' \
-e 's/function\(ctx\)/function($ctx)/' \
-e 's/function\(ctx, json\)/function($ctx, $json)/' \
-e 's/ctx\./$ctx->/g' \
-e 's/(\s*)ctx$/\1$ctx/' \
-e 's/json\./$json->/g' \
-e 's/attrs\./$attrs->/g' \
-e 's/\.(\w+)/->\1/g' \
-e 's/(\w+) : /'\''\1'\'' => /g'
@qfox
qfox / bem-dynjson.js
Created December 23, 2014 11:10
merged-express-bem-engine
var U = require('express-bem/lib/util');
var dropRequireCache = require('enb/lib/fs/drop-require-cache');
module.exports = dynjson;
dynjson.extension = '.dynjson.js';
/**
* dynjson engine for express-bem
* @param {string} name - bundle name
@qfox
qfox / bem-entity.js
Last active August 29, 2015 14:12
bem-entity.js
/**
* Scope creator
* @return {}
*/
function create () {
var undef;
/**
* BEM entity object
* @constructor
@qfox
qfox / elem-inst-test.bemjson.js
Last active August 29, 2015 14:12
elem-inst-test
({
block : 'page',
title : 'elem-inst-test',
styles : [{ elem : 'css', url : 'elem-inst-test.min.css' }],
scripts : [{ elem : 'js', url : 'elem-inst-test.min.js' }],
content : [
{
block : 'elem-inst-test',
js : true,
mods : { mod : true },
@qfox
qfox / gist:4688012
Created February 1, 2013 00:19
Variable naming style converters via camelCase one
String.prototype.toCamelCase = function() {
return this.substr(0, 1).toLowerCase() + this.substr(1).replace(/[\-_][a-z]/g, function($0){return $0.toUpperCase().replace(/[\_\-]/,'');});
};
String.prototype.toPascalCase = function() {
return this.substr(0, 1).toUpperCase() + this.substr(1).toCamelCase();
};
String.prototype.toUnderscore = function() {
return this.toCamelCase().replace(/[A-Z]/g, function($0){return "_"+$0.toLowerCase();}).replace(/^_/,'');
};
String.prototype.toDash = function() {
@qfox
qfox / make.js
Last active February 3, 2016 13:23
nodeConfig.addTechs([
[require('enb-define'), {
target: '?.fullofconsoles.js',
sources: ['?.js'],
variables: {
ISLDEBUG: '*/!/*'
},
sourcemap: true
}]
]);