Skip to content

Instantly share code, notes, and snippets.

@gotomypc
gotomypc / reverse-ip-lookup.js
Created Oct 27, 2012 — forked from eugenehp/reverse-ip-lookup.js
node.js IP reverse lookup
View reverse-ip-lookup.js
var dns = require('dns');
function reverseLookup(ip) {
dns.reverse(ip,function(err,domains){
if(err!=null) callback(err);
domains.forEach(function(domain){
dns.lookup(domain,function(err, address, family){
console.log(domain,'[',address,']');
console.log('reverse:',ip==address);
@gotomypc
gotomypc / image2base64.js
Created Oct 31, 2012 — forked from jfsiii/image2base64.js
Convert a remote image to Base64-encoded string
View image2base64.js
// Uses [request](https://github.com/mikeal/request)
// /?url=http://nodejs.org/logo.png
// /?uri=http://nodejs.org/logo.png
// /?url=http://nodejs.org/logo.png&cb=cbName
// /?url=http://nodejs.org/logo.png&callback=cbName
var fs = require('fs');
var url = require('url');
var http = require('http');
var request = require('request');
@gotomypc
gotomypc / load-generator.js
Created Nov 4, 2012 — forked from tkrueger/load-generator.js
generate and measure CPU load with node.js
View load-generator.js
#!/usr/bin/env node
require(__dirname+"/processor-usage.js").startWatching();
var shouldRun = true;
var desiredLoadFactor = .5;
function blockCpuFor(ms) {
var now = new Date().getTime();
var result = 0
@gotomypc
gotomypc / __request
Created Nov 5, 2012 — forked from natos/__request
Multiple Requests with Request (Node.js)
View __request
var request = require('request')
/**
* Handle multiple requests at once
* @param urls [array]
* @param callback [function]
* @requires request module for node ( https://github.com/mikeal/request )
*/
var __request = function (urls, callback) {
@gotomypc
gotomypc / gps.java
Created Dec 1, 2012 — forked from javisantana/gps.java
real/fake gps
View gps.java
package hardware;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
View redis_mysql_dump.js
// modules
var redis = require('redis');
var Step = require('step');
// config file
var config = require('config');
// mysql client connect
var mysql = require('mysql');
var connection = mysql.createConnection({
@gotomypc
gotomypc / Websocket-speed-test.js
Created Nov 4, 2012 — forked from NHQ/Websocket-speed-test.js
Test how fast your browser handles websockets with Node.js.
View Websocket-speed-test.js
var server = require( 'http' ).createServer();
// our html template
var script = function( f ) {
// get just the content of this script
var s = /^[^\{]+\{\n?([\s\S]+)\}/.exec( f )[1];
return [
'<!DOCTYPE html><html>',
'<head>',
'<script type="text/javascript">',s,'</script>',
View javascript-prototyping-best-practices.js
'use strict';
/*
# Javascript Prototyping Best Practices
* To create a class, create a constructor function with a `Name` and assign
it to a variable of the same `Name`.
* In this constructor only define properties using `this.prop` notation
@gotomypc
gotomypc / GoDaddySSLHAProxy.md
Created Oct 7, 2016 — forked from sethwebster/GoDaddySSLHAProxy.md
Creating a PEM for HaProxy from GoDaddy SSL Certificate
View GoDaddySSLHAProxy.md

GoDaddy SSL Certificates PEM Creation for HaProxy (Ubuntu 14.04)

1 Acquire your SSL Certificate

Generate your CSR This generates a unique private key, skip this if you already have one.

sudo openssl genrsa -out  etc/ssl/yourdomain.com/yourdomain.com.key 1024

Next generate your CSR (Certificate Signing Request), required by GoDaddy:

View Twelve_Go_Best_Practices.md