Skip to content

Instantly share code, notes, and snippets.

View mcantelon's full-sized avatar

Mike Cantelon mcantelon

View GitHub Profile
function fresh_media_preprocess_views_views_json_style_simple(&$vars) {
global $pager_total, $pager_page_array;
$element = $vars['view']->pager['element'];
$vars['rows']['pager'] = array(
'total' => $pager_total[$element],
'current' => $pager_page_array[$element]
);
}
# configure npm
touch ~/.npmrc
echo root=$HOME/root >> ~/.npmrc
echo binroot=$HOME/bin >> ~/.npmrc
echo manroot=$HOME/man >> ~/.npmrc
mkdir $HOME/root
mkdir $HOME/bin
mkdir $HOME/man
# install npm
var sys = require('sys'),
rest = require('restler-aaronblohowiak'),
item,
node
rest.get('http://mikecantelon.com/jsontest/News')
.addListener('complete', function(data) {
for(item in data.nodes) {
node = data.nodes[item].node
# Rate limiting for SSH requests -A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 22 -m recent --set -A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 22 -m recent --update --seconds 60 --hitcount 4 -j DROP
/**
* Module dependencies.
*/
var mongoose = require('mongoose')
, Schema = mongoose.Schema
mongoose.connect('mongodb://localhost/BB')
/**
@mcantelon
mcantelon / test.yml
Created March 11, 2011 16:46
Test case for YAML literal
jim: Hey there.
bob: |
I am the law!
You will kneel!
rick: Sure
@mcantelon
mcantelon / yaml_test.js
Created March 11, 2011 16:47
Test logic for YAML literal
var yaml = require('yaml')
, fs = require('fs')
, should = require('should')
var ideal = {
jim: 'Hey there.',
bob: 'I am the law!\nYou will kneel!',
rick: 'Sure'
}
@mcantelon
mcantelon / Node monit
Created March 22, 2011 00:18
roughed out monit conf for node
check process node with pidfile /var/run/node.pid
start program = "start/node/app"
stop program = "stop/noe/app"
if failed host www.myappcom port 80 protocol http
with timeout 25 seconds
then restart
group server
@mcantelon
mcantelon / connect-form example
Created March 26, 2011 07:05
connect-form example
var connect = require('connect'),
form = require('connect-form');
var server = connect.createServer(
form({ keepExtensions: true }),
function(req, res, next){
// Form was submitted
if (req.form) {
// Do something when parsing is finished
// and respond, or respond immediately
@mcantelon
mcantelon / Mongoose example
Created April 1, 2011 05:15
Mongoose example
// from Horofox in #node.js
var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/mydb');
function allowPosts(mongoose) {
var Schema = mongoose.Schema;
var Posts = new Schema({
name : String,
subject: String,
comment : String,