Skip to content

Instantly share code, notes, and snippets.

View JustinK's full-sized avatar

Justin Kelly JustinK

View GitHub Profile
var mapComponents = (function(){
var markers = [];
var circles = [];
var crimes = [];
return {
markers: markers,
circles: circles,
crimes: crimes,
google.maps.event.addDomListener(window, 'load', initializeMap);
function initializeMap() {
initializeDatePicker();
var mapOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
@JustinK
JustinK / ocp.cs
Last active August 29, 2015 14:08
SOLID - Open Closed Principle
//NOT SO GOOD
public class Car
{
public bool IsBus {get; set;}
public bool HasTurbo {get; set;}
public int NumberOfPistons {get; set;}
public double TotalWeight {get; set;}
abstract public double GetHorsePower(){
@JustinK
JustinK / index.html
Last active June 14, 2024 15:16
MapMyRun API Demo
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12">
<!-- This is where we are going to put the graph -->
var imageFile = hiddenFile.Value;
String img = imageFile.Replace("data:image/jpeg;base64,", "").Replace(" ", "+");
byte[] b = Convert.FromBase64String(img);
var timestamp = DateTime.Now.ToString("yyyy_MM_dd_HHmmssfff");
var virtualDirectoryPath = "~/Receipts/" + year + "/";
var fileName = Path.Combine(page.Server.MapPath(virtualDirectoryPath),
timestamp + ".jpg");
System.IO.File.WriteAllBytes(fileName, bytes);
function OnClientFileSelected(sender, args) {
var fileInput = sender;
//get the file from the input field
var file = args.get_fileInputField().files[0];
var imageType = /image.*/;
//stop the image from uploading to the temp storage on the server
if (file.type === 'image/jpeg') {
sender.pauseUpload();
$('.ruUploadProgress').addClass('ruUploadSuccess');
<telerik:RadAsyncUpload ID="asyncUpload" runat="server" AllowedFileExtensions="pdf,jpg,jpeg,png" OnClientFileSelected="OnClientFileSelected"></telerik:RadAsyncUpload>
<asp:HiddenField runat="server" ID="hiddenFile"/>
@JustinK
JustinK / demo.cs
Last active August 29, 2015 14:08
[WebMethod]
public static List<Type> GetTypeList(string categoryId)
{
var types = new List&ltType&gt
{
new Type(){ Name = "Red", Id=1, CategoryId=5 },
new Type(){ Name = "Blue", Id=2, CategoryId=5 },
new Type(){ Name = "Green", Id=3, CategoryId=3 }
};
var catId = Convert.ToInt32(categoryId);
@JustinK
JustinK / demo.js
Last active August 29, 2015 14:08
$('#cboCategory').change(function () {
var categoryId = $(this).val();
loadTypeList(categoryId);
});
function loadTypeList(categoryId) {
$.ajax({
type: 'POST',
url: 'Example.aspx/GetTypeList',
data: '{categoryId: "' + categoryId + '" }',
<asp:DropDownList ID="cboCategory" runat="server"></asp:DropDownList>
<select id="cboType"></select>