Skip to content

Instantly share code, notes, and snippets.

@devfred
devfred / jquery.fk-forecast.js
Last active February 9, 2018 23:36
javascript: Weather forecast jquery plugin
/**
* Weather Forecast Plugin
* Author: Frederick King
*
**/
(function(window, document, $, undefined) {
var api = {
load: function(zip, $elem) {
var self = this;
// XDomain Request for IE8/IE9 :(
@devfred
devfred / jquery.fk-themechanger.js
Last active October 5, 2015 22:07
javascript: Load stylesheets dynamically
/**
Load stylesheets dynamically
@author: Frederick King <mcdevfred@gmail.com>
@filename: jquery.fk-themechanger.js
**/
( function( win, doc, $, undefined ){
$.fn.themeChanger = function( options ){
var defaults = { themes: [], wrapper: 'li' }, opts = defaults, elem = this[0], $elem = this, link,
methods = {
@devfred
devfred / browser-detect.js
Last active August 7, 2020 23:28
javascript: Browser Detection
(function( undefined ){
/* Apple Device Webkit Browsers */
var isIdevice = /(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent);
if (isIdevice){
document.getElementsByTagName('body')[0].className += ' iphone ipod ipad';
}
var isIphone = /(iPhone).*AppleWebKit/i.test(navigator.userAgent);
if (isIphone){
document.getElementsByTagName('body')[0].className += ' iphone';
@devfred
devfred / View.ascx
Last active October 6, 2015 06:18
csharp: Tiny boilerplate for compiled dnn controls/module
<%@ Control language="C#" Inherits="CW.Modules.ModuleName.View" Codebehind="View.ascx.cs" AutoEventWireup="true"%>
<div class="module">
<asp:BulletedList ID="list" runat="server" />
</div><!-- end .xmp-kit-installer-->
@devfred
devfred / FormValidation.html
Last active October 6, 2015 08:38
javascript: Check inputs for empty strings
<form action="#action" method="get">
<label For="FirstName">First Name*</Label>
<input id="FirstName" Type="text" Name="FirstName" class="required" data-message="Please fill in First name"/>
<label For="LastName">Last Name*</Label>
<input id="LastName" name="LastName" class="required" data-message="Please fill in Last name"/>
<input Type="submit" name="send" />
</form>
@devfred
devfred / newproject.bat
Last active June 6, 2016 18:53
Batch: Simple windows batch script example
:: New Project Batch Script
:: @author Frederick King <mcdevfred@gmail.com>
:: @date 6/21/2012
::----------------------------------------------
:: hide extra stuff
@ECHO OFF
:: clear the screen
cls
@devfred
devfred / Number.prototype.formatMoney.js
Last active April 3, 2018 17:25
javascript: Restrict all number inputs to use only digits, commas, periods
Number.prototype.formatMoney = function(c, d, t){
var
n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "," : d,
t = t == undefined ? "." : t,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
@devfred
devfred / FileGetContents.cs
Last active December 11, 2020 17:55
csharp: Function that acts like PHP's file_get_contents
protected string file_get_contents(string fileName)
{
string sContents = string.Empty;
if (fileName.ToLower().IndexOf("http:") > -1){
// URL
System.Net.WebClient wc = new System.Net.WebClient();
byte[] response = wc.DownloadData(fileName);
sContents = System.Text.Encoding.ASCII.GetString(response);
} else {
@devfred
devfred / ModuleSendMail.cs
Last active October 12, 2015 05:48
csharp: Send email through DotNetNuke Frameworkork
using DotNetNuke.Services.Mail.Mail.SendMail;
public void ModuleSendMail(string from, string to, string subject, string body){
Mail.SendMail(from, to, "", subject, body, "", "HTML", "", "", "", "" );
};
@devfred
devfred / PayPalHandler.cs
Last active October 12, 2015 05:48
csharp: Simple Handler that listens for PayPal Instant Payment Notifications
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Web;
public class PayPalIPN : IHttpHandler
{
/**