Skip to content

Instantly share code, notes, and snippets.

View codewithtyler's full-sized avatar

Tyler Hughes codewithtyler

  • Alabama, United States
View GitHub Profile
@codewithtyler
codewithtyler / index.html
Last active August 29, 2015 14:14
Spiceworks App Example - Hello World
<!DOCTYPE html>
<html>
<head>
<script src="https://www.dropbox.com/s/l6hgjq7mh52o6od/spiceworks-sdk.js?dl=1&raw=1" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var card = new SW.Card();
var inventory = card.services('inventory');
@codewithtyler
codewithtyler / GoogleAnalyticsWizard.cs
Last active August 29, 2015 14:26
Implementing a wizard for use with Google Analytics
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LigerShark.Templates
{
@codewithtyler
codewithtyler / GoogleAnalyticsApi.cs
Last active April 17, 2019 12:56 — forked from 0liver/GoogleAnalyticsApi.cs
C# wrapper around the Google Analytics Measurement Protocol API
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace ConsoleApplication4
{
@codewithtyler
codewithtyler / index.js
Last active December 29, 2015 21:25
Random Number Generator Algorithms for JavaScript
// Generate a random decimal number between 0 and 1
var random = Math.random();
// Generate a whole number between 0 and the max number;
var maxNumber = 10;
var random = Math.floor(Math.random() * maxNumber); // Will generate a whole number between 0 and 9
// Generate random whole numbers within a given range
var min = 25;
var max = 38;
@codewithtyler
codewithtyler / bouncer.js
Last active December 30, 2015 06:13
Beginner Algorithm Challenges - All Done in JavaScript
/*
* Instructions:
* Remove all falsy values from an array.
* Falsy values in javascript are false, null, 0, "", undefined, and NaN.
*/
function bouncer(arr) {
arr = arr.filter(function(val) {
return Boolean(val);
});
@codewithtyler
codewithtyler / weatherjs-usage.js
Created January 25, 2016 03:39
How can I use weather.js?
Weather.getCurrent("Kansas City", function(current) {
console.log(
["currently:",current.temperature(),"and",current.conditions()].join(" ")
);
});
Weather.getForecast("Kansas City", function(forecast) {
console.log("Forecast High in Kelvin: " + forecast.high());
console.log("Forecast High in Fahrenheit" + Weather.kelvinToFahrenheit( forecast.high() );
console.log("Forecast High in Celsius" + Weather.kelvinToCelsius( forecast.high() );
@codewithtyler
codewithtyler / OpenPowerShellHere.reg
Last active August 31, 2016 07:38
Creates a context menu item allowing you to open a PowerShell window in whatever directory you have clicked.
Windows Registry Editor Version 5.00
;
; Add context menu entry to Windows Explorer background
;
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell]
@="Open PowerShell window here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell\command]
map = L.map("transitmap", {
center: [ 34.730225, -86.585944 ], // Huntsville, AL
zoom: 15
});
L.tileLayer("http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}", {
attribution: "&copy; <a href='http://giscience.uni-hd.de/'>GIScience Research Group @ University of Heidelberg</a> © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>",
maxZoom: 20
}).addTo( map );
@codewithtyler
codewithtyler / array.js
Created July 2, 2016 22:30
JavaScript Extension Methods
Array.prototype.contains = function( value ) {
return this.indexOf( value ) > -1;
}
@codewithtyler
codewithtyler / ADUserCount.ps1
Created August 2, 2016 21:10
Counts the number of users for a given Active Directory domain
Import-Module ActiveDirectory
$domain = Get-ADOrganizationalUnit -searchbase "DC=contoso, DC=com" -filter * -searchscope 1
$total = 0
foreach ($ou in $domain)
{
$count = @(Get-ADUser -searchbase $ou -filter * |Where-Object {$_.enabled -eq "true"}).count
$total += $count
}