Skip to content

Instantly share code, notes, and snippets.

View jmahc's full-sized avatar
🏠
Working from home

Jordan McArdle jmahc

🏠
Working from home
View GitHub Profile
@jmahc
jmahc / Query Parameters
Created May 29, 2015 13:06
This javascript function grabs any query parameters and stores them in an array
var getQueryParams = function () {
var params = [];
var query = window.location.search;
query = query.slice(1, query.length);
var nv = query.split('&');
for (var i = 0; i < nv.length; i++) {
var q = nv[i].split('=');
params[q[0]] = q[1];
}
return params;
@jmahc
jmahc / contact-form.html
Last active August 29, 2015 14:22
JavaScript modules that can be loaded site-wide or on a per-page basis
<html>
<head>
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
<header></header>
<div class="container">
<div class="spinner-overlay">
<i class="fa fa-cog fa-spin"></i>
@jmahc
jmahc / site.js
Created July 13, 2015 15:54
Preload images
$.fn.preload = function () {
this.each(function () {
$('<img/>')[0].src = this;
});
}
Site.home = {}
Site.home.init = function () {
var t = this;
@jmahc
jmahc / CSGO autoexec
Created July 16, 2015 04:24
CSGO autoexec.cfg
alias "vh_y2" "viewmodel_offset_y 2; echo_y_2; alias toggle_down vh_y1; Notice1"
alias "vh_y1" "viewmodel_offset_y 1; echo_y_1; alias toggle_down vh_y0; alias toggle_up vh_y2"
alias "vh_y0" "viewmodel_offset_y 0; echo_y_0; alias toggle_down vh_y-1;alias toggle_up vh_y1"
alias "vh_y-1" "viewmodel_offset_y -1; echo_y_-1; alias toggle_down vh_y-2;alias toggle_up vh_y0"
alias "vh_y-2" "viewmodel_offset_y -2; echo_y_-2; Notice2 ;alias toggle_up vh_y-1"
vh_y0
Bind "downarrow" "toggle_down"
Bind "uparrow" "toggle_up"
@jmahc
jmahc / similarParams.js
Last active September 16, 2015 21:53
Takes a query string with multiple parameters of the same name ("word1", "word2", etc.) and inserts these values into a textbox.
var getQueryParams = function () {
var params = [];
var query = window.location.search;
query = query.slice(1, query.length);
var nv = query.split('&');
for (var i = 0; i < nv.length; i++) {
var q = nv[i].split('=');
params[q[0]] = q[1];
}
return params;
@jmahc
jmahc / striped_background.css
Created September 23, 2015 14:28
Zebra stripe background
.body {
background: repeating-linear-gradient(
45deg,
#1d1d1d,
#1d1d1d 60px,
#111111 60px,
#111111 120px
);
background-color: #1f1f1f;
}
@jmahc
jmahc / AccountController.cs
Last active February 4, 2016 18:26
Redirect a user to the page they were previously on after they login (.NET, C#)
private ActionResult RedirectToLocal(string returnUrl)
{
string hostUrl = Request.Url.Scheme + "://" + Request.UrlReferrer.Authority;
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(hostUrl + returnUrl);
}
return RedirectToAction("Index", "Home");
}
@jmahc
jmahc / ProductsDataProvider.cs
Created April 27, 2016 17:27
Gets product information from a json file, taking into account the host (serves multiple domains to get different content based on the path)
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Helpers;
using System.Web.Hosting;
using comSite.Models.Products;
namespace comSite.DataProviders
{
@jmahc
jmahc / main.js
Created May 13, 2016 19:38
Bootstrap v4.0.0-alpha.2, window.Tether, tooltip error, Tether error, bootstrap, tether, requirejs, require.js
document.addEventListener("DOMContentLoaded", function() {
/*
==========================================
May 13, 2016
github.com/jmahc
---
require.js with Bootstrap v4.0.0-alpha.2
Even if you aren't using the tooltips...
Get rid of the console error using this! :)
---
@jmahc
jmahc / Extensions.cs
Last active May 20, 2016 18:47
Pass a color to a Razor HtmlExtensions Helper that returns HtmlString that appends the color passed to the helper to the containing element's class. This is for when a structure is reused but its colors may vary.
namespace ProjectName.Helpers
{
public static class HtmlExtensions
{
public static HtmlString DividerHelper(this HtmlHelper helper, string color)
{
var builder = new StringBuilder()
.Append(
helper.Partial(
"~/Views/Shared/_Divider.cshtml", // Location of partial view file