Skip to content

Instantly share code, notes, and snippets.

View freshlogic's full-sized avatar

Shawn Miller freshlogic

View GitHub Profile
@freshlogic
freshlogic / cache.js
Created January 15, 2014 21:53
Returns data from cache if available; otherwise executes the specified function and places the results in cache before returning the data.
var redis = require('redis');
function Cache(port, host, options) {
this.client = redis.createClient(port, host, options);
};
// Returns data from cache if available;
// otherwise executes the specified function and places the results in cache before returning the data.
Cache.prototype.fetch = function(key, func, options, callback) {
// Options are optional
var request = require('request');
var sendgrid = require('sendgrid')('YOUR sendgrid.com USERNAME', 'password');
var areaCode = 972;
var headers = { Cookie: 'YOUR www.google.com COOKIE HERE' };
var url = 'https://www.google.com/voice/setup/searchnew/?ac=' + areaCode + '&start=0&country=US';
request.get({ url: url, headers: headers }, function(error, response, body) {
var json = JSON.parse(body);
var message = 'Google Voice: There are ' + json.JSON.num_matches + ' numbers in area code ' + areaCode + ' available at this time.';
@freshlogic
freshlogic / gist:8de3afd667fc7c306e77
Created March 16, 2015 14:35
Coders Bracket 2015
function(game, team1, team2) {
var percentages = {
round5: { 1: 100, 2: 94, 3: 85, 4: 78, 5: 68, 6: 66, 7: 60, 8: 48, 9: 52, 10: 40, 11: 34, 12: 35, 13: 22, 14: 15, 15: 6, 16: 0 },
round4: { 1: 87, 2: 69, 3: 61, 4: 56, 5: 52, 6: 51, 7: 27, 8: 18, 9: 8, 10: 46, 11: 38, 12: 49, 13: 24, 14: 12, 15: 14, 16: 0 },
round3: { 1: 79, 2: 72, 3: 50, 4: 35, 5: 21, 6: 33, 7: 37, 8: 70, 9: 40, 10: 33, 11: 33, 12: 5, 13: 0, 14: 0, 15: 0, 16: 0 },
round2: { 1: 59, 2: 46, 3: 47, 4: 72, 5: 75, 6: 23, 7: 0, 8: 57, 9: 50, 10: 0, 11: 60, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0 },
round1: { 1: 57, 2: 48, 3: 64, 4: 23, 5: 50, 6: 67, 7: 0, 8: 50, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0 },
round0: { 1: 67, 2: 33, 3: 44, 4: 33, 5: 0, 6: 50, 7: 0, 8: 50, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0 }
};
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
If (Test-Path "cloud_package.cspkg") {
Remove-Item "cloud_package.cspkg" -Force
}
cd "WebRole"
iex "git reset --hard origin/master"
iex "git pull"
cmd /C "rmdir /S /Q node_modules"
%windir%\system32\inetsrv\AppCmd.exe set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00
%windir%\system32\inetsrv\AppCmd.exe set config -section:applicationPools -applicationPoolDefaults.startMode:AlwaysRunning
@freshlogic
freshlogic / gist:962da8adcedfb6b759ec
Created July 26, 2014 02:50
web-ip-security.ps1
Import-Module ServerManager
Add-WindowsFeature Web-Ip-Security
@freshlogic
freshlogic / gist:6cf0c2a01e587ce95551
Created July 26, 2014 02:47
web-ip-security.cmd
powershell .\web-ip-security.ps1
%windir%\system32\inetsrv\AppCmd.exe unlock config /section:system.webServer/security/ipSecurity
@freshlogic
freshlogic / gist:c2b3de000229a1b05221
Last active August 29, 2015 14:04
ServiceDefinition.csdef
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="example-com" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole" vmsize="Small">
<Certificates>
<Certificate name="example-com" storeLocation="LocalMachine" storeName="CA" />
</Certificates>
<Imports />
<Startup>
<Task commandLine="setup_web.cmd &gt; log.txt" executionContext="elevated">
<Environment>
@freshlogic
freshlogic / gist:fb9f912b030e0b8307b0
Last active August 29, 2015 14:04
ServiceConfiguration.Cloud.cscfg
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serviceName="serviceName" osFamily="4" osVersion="*" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="WebRole">
<ConfigurationSettings />
<Instances count="2" />
</Role>
<NetworkConfiguration>
<VirtualNetworkSite name="VirtualNetwork" />
<AddressAssignments>
<InstanceAddress roleName="WebRole">