Skip to content

Instantly share code, notes, and snippets.

View duhruh's full-sized avatar
👽
Storming Area 51

David Rivera duhruh

👽
Storming Area 51
View GitHub Profile
@duhruh
duhruh / gist:6e61bf0f36f43a4c93c886d7ad5f7a1c
Created November 3, 2017 17:34 — forked from thomas11/gist:2909362
Log memory usage every n seconds in Go #golang
import (
"runtime"
"time"
)
...
go func() {
for {
var m runtime.MemStats
//issue a token, with an expiration date
var jwt = require('jsonwebtoken')
//issue token that expires after 10 mins AND has an issuer
var token = jwt.sign('helloworld','secret',{ expiresInMinutes : 10, issuer : 'hipster.io'});
//verify token, but don't check assertions.
authenticate : function(req,res){
var username = req.param('username')
var password = req.param('password')
if(!username || !password){
return res.json(403,{err : 'username and password required'})
}
User.findOneByUsername(username,function(err,user){
/**
* sails-jwt-auth configuration and devdocs
*
*
*/
/**
@duhruh
duhruh / HEX2BIN.js
Created August 11, 2013 14:36 — forked from ghalimi/HEX2BIN.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function HEX2BIN(number, places) {
// Return error if number is not hexadecimal or contains more than ten characters (10 digits)
if (!/^[0-9A-Fa-f]{1,10}$/.test(number)) return '#NUM!';
// Check if number is negative
var negative = (number.length === 10 && number.substring(0, 1).toLowerCase() === 'f') ? true : false;
// Convert hexadecimal number to decimal
@duhruh
duhruh / app.js
Created June 18, 2013 13:25 — forked from kanreisa/app.js
var PORT = 10443;
var SSL_KEY = '___.key';
var SSL_CERT= '___.cert';
var fs = require('fs');
var io = require('socket.io').listen(PORT, {
key : fs.readFileSync(SSL_KEY).toString(),
cert : fs.readFileSync(SSL_CERT).toString()
});
@duhruh
duhruh / app.js
Created June 11, 2013 00:55 — forked from dskanth/app.js
var app = require('express').createServer()
var io = require('socket.io').listen(app);
var fs = require('fs');
app.listen(8008);
// routing
app.get('/', function (req, res) {
res.sendfile(__dirname + '/chat.html');
});
<script>
// (c) Copyright 2011 Caroline Schnapp. All Rights Reserved. Contact: [email protected]
// See http://wiki.shopify.com/Linked_Options
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
<?php
require 'google-api/apiClient.php';
require 'google-api/contrib/apiOauth2Service.php';
require 'google-api/contrib/apiDriveService.php';
$pdfFile = 'test.pdf';
// API Console: https://code.google.com/apis/console/
// Create an API project ("web applications") and put the client id and client secret in config.ini.