This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# chkconfig: 35 99 99 | |
# description: Node.js /home/nodejs/sample/app.js | |
# | |
. /etc/rc.d/init.d/functions | |
USER="nodejs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The API controller | |
Exports 3 methods: | |
* post - Creates a new thread | |
* list - Returns a list of threads | |
* show - Displays a thread and its posts | |
*/ | |
var Thread = require('../models/thread.js'); | |
var Post = require('../models/post.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# node.js app under nginx | |
upstream node { | |
server 127.0.0.1:8001; | |
} | |
server { | |
listen 80; | |
server_name node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
//specify site script is hosted on | |
var site = "www.example.com"; | |
//specify page to pop-under | |
var data ="http://syndication.traffichaus.com/popserve.php?z=279&p=25"; | |
var height = 800; | |
//var height = (screen.availHeight - 122).toString(); // Fullscreen | |
var width = 510; | |
//var width = (screen.availWidth - 10).toString(); // Fullscreen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************ | |
Calculate Number of Days in Date Range | |
************************************************************************/ | |
function days_between(date1, date2) { | |
var d1 = parseDate(date1.replace(/\-/g,'.')); | |
var d2 = parseDate(date2.replace(/\-/g,'.')); | |
// The number of milliseconds in one day | |
var ONE_DAY = 1000 * 60 * 60 * 24; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*----------------------------------DEBUG ----------------------------------------*/ | |
error_reporting(E_ALL); | |
ini_set("display_errors", 1); | |
//*----------------------------------DEBUG ----------------------------------------*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************ | |
Split Data Returned From AJAX | |
************************************************************************/ | |
$.post('dir/file.php',{ params: params },function(data){ | |
// arrays for each | |
var attr = []; | |
for(var j = 0; j < data.length; j++){ | |
for(var index in data[j]){ | |
if(index == "attr"){ | |
// Add to array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
PHP: cURL Scrape page | |
*/ | |
function getData($url) { | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$contents = curl_exec ($ch); | |
curl_close ($ch); | |
return $contents; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Parse XML feed => Assocative Array | |
*/ | |
//*----------------------------------DEBUG ----------------------------------------*/ | |
error_reporting(E_ALL); | |
ini_set("display_errors", 1); | |
//*----------------------------------DEBUG ----------------------------------------*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'config.php'; | |
try { | |
# MySQL with PDO_MYSQL | |
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass); | |
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); | |
} | |
catch(PDOException $e) { | |
echo $e->getMessage(); |