Skip to content

Instantly share code, notes, and snippets.

View francolaiuppa's full-sized avatar

Franco Laiuppa francolaiuppa

View GitHub Profile
@francolaiuppa
francolaiuppa / data.json
Created January 18, 2017 16:19
Sample monoline JSON data
{"web-app":{"servlet":[{"servlet-name":"cofaxCDS","servlet-class":"org.cofax.cds.CDSServlet","init-param":{"configGlossary:installationAt":"Philadelphia, PA","configGlossary:adminEmail":"ksm@pobox.com","configGlossary:poweredBy":"Cofax","configGlossary:poweredByIcon":"/images/cofax.gif","configGlossary:staticPath":"/content/static","templateProcessorClass":"org.cofax.WysiwygTemplate","templateLoaderClass":"org.cofax.FilesTemplateLoader","templatePath":"templates","templateOverridePath":"","defaultListTemplate":"listTemplate.htm","defaultFileTemplate":"articleTemplate.htm","useJSP":false,"jspListTemplate":"listTemplate.jsp","jspFileTemplate":"articleTemplate.jsp","cachePackageTagsTrack":200,"cachePackageTagsStore":200,"cachePackageTagsRefresh":60,"cacheTemplatesTrack":100,"cacheTemplatesStore":50,"cacheTemplatesRefresh":15,"cachePagesTrack":200,"cachePagesStore":100,"cachePagesRefresh":10,"cachePagesDirtyRead":10,"searchEngineListTemplate":"forSearchEnginesList.htm","searchEngineFileTemplate":"forSearchEngines
@francolaiuppa
francolaiuppa / gist:9507d003c9694c451bee
Created November 14, 2014 18:57
Example HAProxy 1.5 configuration for load-balancing Redis nodes with Sentinel (including health checks!)
backend messages
mode tcp
option tcplog
option tcp-check
#tcp-check send AUTH\ foobar\r\n
#tcp-check expect +OK
tcp-check send PING\r\n
tcp-check expect +PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:master
@francolaiuppa
francolaiuppa / data.json
Created January 19, 2017 10:06
Sample multiline JSON for demos
{
"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@pobox.com",
"configGlossary:poweredBy": "Cofax",
@francolaiuppa
francolaiuppa / sequelize-schema-file-generator.js
Last active August 5, 2020 14:25 — forked from manuelbieh/sequelize-schema-file-generator.js
Automatically generates migration files from your sequelize models
'use strict';
//////////////////////////////////
// How to use?
// 1. Create `sequelize-schema-file-generator.js` in your app root
// 2. Make sure you've ran the `sequelize init` before (It should create `config`,`seeders`,`migrations` folders).
// 3. Update `DATABASE_DSN` below to match your connection string (works with any database adapter that Sequelize supports)
// 4. Run it with `node sequelize-schema-file-generator.js`
// 5. Review the generated migrations inside of the `migrations` folder.
//////////////////////////////////
@francolaiuppa
francolaiuppa / gist:bfcc088a674e2856bd19
Created June 6, 2014 13:37
mysql - Join between two tables with LIMIT 1 on second table
SELECT c.*,
(SELECT cm.msg
FROM conversation_messages AS cm
WHERE cm.conversation_id = c.id
ORDER BY cm.created_at DESC
LIMIT 1) AS last_msg
FROM conversations c
@francolaiuppa
francolaiuppa / express-controller.js
Last active April 21, 2023 17:31
Express JS + Amazon S3 + DropzoneJS Code Snippet
// Requires https://www.npmjs.org/package/s3-policy and https://www.npmjs.org/package/node-uuid
var config = require('env/' + process.env.NODE_ENV),
policy = require('s3-policy'),
uuid = require('node-uuid');
// SETUP S3
const AWS_ACCESS_KEY = config.s3.accessKey;
const AWS_SECRET_KEY = config.s3.secret;
const S3_BUCKET = config.s3.bucket;