Skip to content

Instantly share code, notes, and snippets.

@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@jjb3rd
jjb3rd / data.php
Created July 21, 2012 17:49
An updated server-side processing script for DataTables
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2012 - John Becker, Beckersoft, Inc.
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
class TableData {
@cowboy
cowboy / stringify.js
Created September 19, 2012 13:45
JavaScript: like JSON.stringify but handles functions, good for creating arbitrary .js objects?
var stringify = function(obj, prop) {
var placeholder = '____PLACEHOLDER____';
var fns = [];
var json = JSON.stringify(obj, function(key, value) {
if (typeof value === 'function') {
fns.push(value);
return placeholder;
}
return value;
}, 2);
anonymous
anonymous / gist:4440000
Created January 3, 2013 01:16
User impersonation HACK for Ion_Auth CodeIgniter library.
/**
* impersonate
*
* @return bool
* @author Nuri
**/
public function impersonate($identity)
{
$admin = check_admin();
@parth1020
parth1020 / Google Maps Simple Multiple Marker Example
Created January 8, 2013 07:04
Google Maps Simple Multiple Marker Example
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@mikermcneil
mikermcneil / using-raw-socket-io-in-sails.js
Created September 17, 2013 18:32
Using raw socket.io functionality in a Sails.js controller
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
@tkh44
tkh44 / FileController.js
Last active March 10, 2020 09:04
Simple file upload for sails.js
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@gabriel-dehan
gabriel-dehan / client - sign-up.html
Created February 1, 2015 19:30
Autoform for registration
<template name="signUpForm">
{{ #autoForm schema="Schemas.Form.Register" id="user-auth-form" type="method" meteormethod="user-auth:register" }}
<fieldset>
<legend>Create an account</legend>
{{> afQuickField name='username' }}
{{> afQuickField name='email' label='Email' }}
{{> afQuickField name='password' }}
{{> afQuickField name='passwordConfirmation' }}
</fieldset>
<input type="submit">
@Siphion
Siphion / validateipn.js
Created December 18, 2015 22:09
meteor iron-router validate ipn paypal
let paypalProd = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
let paypalSandbox = 'https://www.paypal.com/cgi-bin/webscr';
function validateIPN(data) {
try {
let url = (Meteor.settings.paypal.sandbox ? paypalSandbox : paypalProd) +
'?cmd=_notify-validate';
return HTTP.post(url, {params: data}) === 'VERIFIED';
} catch (err) {
log.error(err);
@openqubit
openqubit / getdates.js
Created November 4, 2016 07:59 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
var getDates = function(startDate, endDate) {
var dates = [],
currentDate = startDate,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= endDate) {