Skip to content

Instantly share code, notes, and snippets.

@openqubit
openqubit / stringify.js
Created January 8, 2017 18:30 — forked from cowboy/stringify.js
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);
@openqubit
openqubit / letsencrypt_2016.md
Created December 20, 2016 11:44 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

@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) {
@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);
@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">
@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
}
};
@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) {
@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">
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();
@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);