Skip to content

Instantly share code, notes, and snippets.

@battlejj
battlejj / app.js
Last active June 3, 2018 06:40
express-force-ssl config with Express4 generator app
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var forceSSL = require('express-force-ssl');
var routes = require('./routes/index');
var users = require('./routes/users');
var concatAttribute = function(selector, attr){
var returnString = '';
$(selector).each(function(index){
returnString += $(this).attr(attr);
})
return returnString;
}
fs = require 'fs'
hogan = require 'hogan.js'
routes = {}
templates = {}
templates =
playout: hogan.compile(fs.readFileSync('./views/partial_layout.hjs').toString())
pindex: hogan.compile(fs.readFileSync('./views/partial_index.hjs').toString())
ptweet: hogan.compile(fs.readFileSync('./views/partial_tweet.hjs').toString())
fs = require 'fs'
hogan = require 'hogan.js'
routes = {}
templates = {}
templates =
layout: hogan.compile(fs.readFileSync('./views/layout.hjs').toString())
index: hogan.compile(fs.readFileSync('./views/index.hjs').toString())
routes.index = (req, res) ->
private string function amazonDateFormat(required date dateToFormat) hint="Follows the ISO 8601 standard" {
var formattedDate = dateAdd("s", getTimeZoneInfo().utcTotalOffset, arguments.dateToFormat);
return "#dateFormat(formattedDate,"yyyy-mm-dd")#T#timeFormat(formattedDate,'HH:mm:ss')#Z";
}
@battlejj
battlejj / psuedo-js-interfaces.js
Created July 8, 2013 19:38
A buddy of mine coming from the Java world wondered if JS had any implementation of interfaces. I told him no but tried to come up with a way to make it work. Removing any required method from the prototypes of either object that inherits from UserDAO will throw an error, but you can still verify the instance of each Object.
var inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
@battlejj
battlejj / index.html
Created July 16, 2012 14:44
Uploadify and S3
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="js/uploadify/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#uploadify').uploadify({
uploader: 'js/uploadify/uploadify.swf',
folder: '/uploads',
multi: true,
@battlejj
battlejj / maps.cfm
Created May 31, 2012 20:05
Larger Static Google Maps
<cftry>
<cfscript>
//calculate the width and height of our little maps that will be combined to make our big map
miniMapWidth = calculateDimension(form.width,500);
miniMapHeight = calculateDimension(form.height,500);
//how many columns and rows of maps will we need to create our big map?
columns = form.width/miniMapWidth;
@battlejj
battlejj / fizzbuzz.js
Created May 15, 2012 00:40
Fizz Buzz
for(x = 1; x <= 100; x++){
var temp = [x, 'fizz', 'buzz', 'fizzbuzz'];
var pos = 0;
if(x%3 == 0){
pos += 1;
}
if(x%5 == 0){
pos += 2;
}
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
}