Skip to content

Instantly share code, notes, and snippets.

@loonison123
loonison123 / oldWayLoadJsonFileMVC.cs
Created May 18, 2014 04:49
Old way of loading a menu from json file in MVC BaseController
public class BaseController : System.Web.Mvc.Controller
{
public BaseController()
{
Initialize();
}
protected void Initialize()
{
// ...
@loonison123
loonison123 / removeWebConfigKey.xml
Created May 18, 2014 04:22
Remove web.config key.
<add key="apiUrl"
xdt:Locator="Match(key)"
xdt:Transform="Remove" />
@loonison123
loonison123 / viewSessionControllerMethod.cs
Created May 15, 2014 02:06
Controller method for viewing session information
public class HomeController : Controller
{
// Other methods...
public ActionResult SessionInfo()
{
return this.View();
}
}
@loonison123
loonison123 / viewSessionInformationRazor.cshtml
Created May 15, 2014 01:52
Razor session runtime and web.config values based off of http://pardini.net/ code
@using System.Configuration
@using System.Web.Configuration;
@using System.Reflection;
@{
ViewBag.Title = "Session Info";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
@loonison123
loonison123 / raspberryPiNetConfig.sh
Created April 26, 2014 13:39
Raspberry Pi Wireless Network Configuration
# View current network configuration
cat /etc/network/interfaces
@loonison123
loonison123 / usefulDebianSnippets.sh
Last active August 29, 2015 14:00
Useful Debian Linux Snippets
# Update packages
apt-get update
apt-get dist-upgrade
sudo shutdown -h now
sudo reboot
@loonison123
loonison123 / usefulJsSnippets_1.js
Last active August 29, 2015 14:00
Useful JavaScript Snippets 1
// Find element by id with wildcard
var el = document.querySelector('[id^=side]');
// Matches --> <div id="sidebar">...</div>
// Simulate click on href tag
var el = document.querySelector('a');
window.location.href = el.href;
// Add/Update query strings, and how to call it
@loonison123
loonison123 / webFormsCodeSnippets_1.aspx
Created April 26, 2014 05:50
Useful ASP.NET Web Forms Code Snippets
// Source: http://stackoverflow.com/questions/10618196/how-to-find-a-asp-control-id-using-java-script
// Get a control by id from javascript
document.getElementById("<%= TextBox1.ClientId %>").value
@loonison123
loonison123 / usefulJqGridCodeSnippets_1.js
Last active August 29, 2015 14:00
Useful JqGrid snippets
// Before saving inline hook (needs to be before grid instantiation)
$.extend($.jgrid.inlineEdit, {
ajaxRowOptions: {
beforeSend: function (jqXHR, settings) {
alert('Before Row Send');
}
}
});
// When using the default formatter 'actions', and hooking into after deleting -OR- saving the row
@loonison123
loonison123 / usefulWindowsServerCommands_1.ps1
Created April 26, 2014 05:15
Useful Windows Server 2012 R2 commands
sconfig