Skip to content

Instantly share code, notes, and snippets.

$.post( "/endpoint/url/goes/here",
{
message: "this is an object full of data that you're POST'ing to the server",
A: 69,
S: true,
L: "your dreams"
},
function( data ) {
console.log("we're in the success callback! everything is fine!");
console.log("here's what the server returned:", data);
//the variable "oversimplifiedModule" gets assigned the return value of the anonymous and self executing function
var oversimplifiedModule = (function(){
//"private" variables are declared within the scope of the anonymous function: "counter" will not be in the global scope.
var counter = 42;
//the return value of the anonymous function can be considered the modules "public" interface
return {
incrementCounter: function(){
//because we refer to "counter", which is in the outer scope, inside this inner scope, a closure is formed, which keeps a reference to "counter"
//and prevents it from being garbage collected. closures are very neat and useful.
@benwillkommen
benwillkommen / install-commerce-server-assemblies-into-gac.ps1
Last active August 29, 2015 14:16
install Commerce Server assemblies in GAC windows server 2012
Set-location "C:\Assemblies"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$assemblyPaths = Get-ChildItem -recurse | select FullName | where { $_.FullName -like "*.dll" }
foreach ($assembly in $assemblyPaths)
{
$publish.GacInstall($assembly.FullName)
}
@benwillkommen
benwillkommen / monitoringsuppressions.psm1
Last active February 23, 2016 17:29
ServiceNow lack-of-API hack script ¯\_(ツ)_/¯
function New-LogicalisMonitoringSuppression{
[cmdletbinding()]
Param(
[String[]]
[Parameter(Mandatory=$true)]
$Server,
$ShowBrowser = $False
)
begin{}
process{
@benwillkommen
benwillkommen / tests.py
Created February 20, 2016 18:50
gross or nah?
def test_put_detail_without_pk(self):
payload = self.dailytotal_post_data.copy()
payload['carbohydrate'] = 69
# I'd like to support PUT to create on detail resources.
# If there's no pk on the payload for a PUT, tastypie will create it.
# However, there needs to be a token for the pk for the route to match the resource detail route.
# How gross is throwing in a pk that cannot exist in the url, just to get the route to match?
# I haven't had to break out the tastypie source code yet today, and I kind of want to keep it that way
resp = self.api_client.put('/api/v1/dailytotal/-1/', format='json', data=payload)
public string SessionId()
{
return Session.SessionID;
}
[cmdletbinding()]
param (
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:computername
)
begin {}
process {
foreach ($Computer in $ComputerName) {
if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
@benwillkommen
benwillkommen / get-pageloadtime.ps1
Created March 17, 2016 18:35
get-pageloadtime.ps1
$ie = new-object -com internetexplorer.application
$ie.visible = $false
$timer = [System.Diagnostics.Stopwatch]::StartNew()
$ie.navigate2("http://example.com")
while($ie.busy){
}
$time = $timer.Elapsed.ToString()
$ie.quit()
@benwillkommen
benwillkommen / Class1-disassembled.cs
Last active May 9, 2016 15:15
using statement v.s. try-catch-finally
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
namespace UsingIlTest
{
public class Class1
{
public Class1()
@benwillkommen
benwillkommen / tests.js
Created May 9, 2016 19:54
mocking w/ sinon example
//weird codewars function
function _if(bool, func1, func2) {
if(bool === true){
return func1();
} else {
return func2();
}
};
//arrange