Skip to content

Instantly share code, notes, and snippets.

View gerzhan's full-sized avatar

Nikolay Gerzhan gerzhan

View GitHub Profile

#config/mailgun.js

  module.exports.mailgun = {
    usessl: true,
    port: 465,
    to: '<youremailaddress>',
    prepend_subject: 'Happy Contact Form | ',
    user: process.env.MAILGUN_USER,
    pass: process.env.MAILGUN_PASS
// Define gulp before we start
var gulp = require('gulp');
// Define Sass and the autoprefixer
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
// This is an object which defines paths for the styles.
// Can add paths for javascript or images for example
// The folder, files to look for and destination are all required for sass
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@gerzhan
gerzhan / eservice.sh
Last active August 29, 2015 14:10 — forked from robhrt7/devshelf.sh
#!/bin/bash
#
# description: eservice service
# processname: node
# pidfile: /var/run/eservice.pid
# logfile: /var/log/eservice.log
#
# Based on https://gist.github.com/jinze/3748766
#
# To use it as service on Ubuntu:
module.exports = function(sails) {
/**
* Module dependencies.
*/
var cookie = require('express/node_modules/cookie'),
parseSignedCookie = require('express/node_modules/connect').utils.parseSignedCookie,
ConnectSession = require('express/node_modules/connect').middleware.session.Session;
@gerzhan
gerzhan / plugin_extend.js
Last active August 29, 2015 14:11
Plugin jQuery with POST data
(function($){
jQuery.fn.wipdlg=function(options){
var defaults = {position:['center','center'],
modal: false, bgiframe: true,
autoOpen: false, draggable: true,
resizable: false ,
height: 'auto', width: 'auto', autoResize:true,
show:'fade',hide:'fade'
,open:function(){
$(this).dialog('option', 'position', 'center')
/**
* HomeController
*
* @module :: Controller
* @description :: Contains logic for handling requests.
*/
module.exports = {
index: function (req,res) {
#
# blob : Object from MongoDB
#
# blob.body: Buffer
# blob.size: length of buffer, substitute for blob.body.length
# blob.type: MIME (Eg. audio/x-wav)
#
# req : Object from http
# res : Object from http
# _ : Object from underscore
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {
// ...
middleware: {
// Define a custom HTTP middleware fn with the key `foobar`:
foobar: function (req,res,next) { /*...*/ next(); },
// Define another couple of custom HTTP middleware fns with keys `passportInit` and `passportSession`
// (notice that this time we're using an existing middleware library from npm)
passportInit : require('passport').initialize(),
passportSession : require('passport').session(),