Skip to content

Instantly share code, notes, and snippets.

function checkStatus(req, res, next) {
As.findOne({ email: req.body.email }, function(err, data) {
if (err) {
return next(err);
} else if ( data === null) {
return( next() );
} else if ( data.verifyStatus === true ) {
res.send('Your account has already been activated. Just head to the login page.');
} else {
res.send('An email has been send before, please check your mail to activate your account. Note that you can only get another mail after 1.5h. Thanks!');
// Usage:
// var express = require('express')
// require('enableMultipleViewRoots')(express)
module.exports = function(express) {
var old = express.view.lookup;
function lookup(view, options) {
// If root is an array of paths, let's try each path until we find the view
if (options.root instanceof Array) {
@dasibre
dasibre / gist:8959376
Created February 12, 2014 16:43
Network I/O ruby Event handling chat server
#event loop demystified ruby
#Working with network I/O in Ruby is so easy:
#https://practicingruby.com/articles/event-loops-demystified
require 'socket'
# Start a server on port 9234
server = TCPServer.new('0.0.0.0', 9234)
# Wait for incoming connections
while io = server.accept
@dasibre
dasibre / gist:8959399
Last active August 29, 2015 13:56
Ruby I/O
class IOLoop
# List of streams that this IO loop will handle.
attr_reader :streams
def initialize
@streams = []
end
# Low-level API for adding a stream.
def <<(stream)
class Manuscript
include Mongoid::Document
embeds_many :authors
field :code, type: String
field :title, type: String
field :status, type: String
field :status_date, type: Date
end
@dasibre
dasibre / rsyslog.conf
Created March 5, 2014 17:15
Rsyslog Configuration sample file
######################
MODULES
######################
$ModLoad imuxsock
$ModLoad imklog
######################
Directives
######################
def change(str)
alphabet_count = str.downcase.scan(/[a-z]/).count
if alphabet_count > 0
ones = "1"*alphabet_count
zeroes = 26
ones_zeroes = ones.ljust(zeroes-alphabet_count,'0')
else
"0"*26
end
end
<source>
type embedded_elasticsearch
</source>
<source>
type kibana_server
bind 0.0.0.0
port 24300
mount /kibana/
access_log_path var/log/kibana/access.log
#! /bin/sh
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@dasibre
dasibre / Vagrantfile
Created July 25, 2014 17:24
Default Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5.0"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration