Skip to content

Instantly share code, notes, and snippets.

View scottsappen's full-sized avatar

Scott Sappenfield scottsappen

View GitHub Profile
@scottsappen
scottsappen / restfuluploadofpngfromios
Created January 24, 2013 20:30
This is a code snippet that uploads a binary image file from an iOS device to a listening RESTful web service that answers to POST. Dispatch this method in a separate thread.
(void)uploadMyNewPictureToWeb {
//your web service that's on the lookout for the image
NSMutableString *customWebPage = [NSMutableString stringWithString:@"your web service URL would go here"];
NSURL *aUrl = [NSURL URLWithString:customWebPage];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl];
//this is your POST, PUT, whatever restful protocol you support
[request setHTTPMethod:@"POST"];
@scottsappen
scottsappen / gist:5901423
Created July 1, 2013 14:42
ASP.Net friendly uploaded POST file receiver
//ASP.Net libraries have many useful collection for you, one being files in the request object
Dim fileCollection As HttpFileCollection = Request.Files
//Code works, but is simplified here for you, meaning you'll want more robust error handling and logging
For Each uploadedFileName In fileCollection
Dim uploadedFile As HttpPostedFile = fileCollection(uploadedFileName)
If Not uploadedFile Is Nothing Then
If (uploadedFile.ContentLength > 0) Then
//Save it somewhere on the server, whatever path conventions you have
//also, this doesn't save it with a file extension, but you could that just the same
@scottsappen
scottsappen / gist:5901440
Created July 1, 2013 14:44
Wake on LAN with ASP.Net and Magic Packets
1. Add a reference in your project to System.Management.Automation in your Visual Studio project
2. Front-end code (you can take out all that Jquery stuff)
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="PowerShellApp._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script src="Scripts/jquery-1.4.1.min.js" language="javascript" type="text/javascript"></script>
@scottsappen
scottsappen / gist:5901453
Created July 1, 2013 14:45
Check out http://arshaw.com/fullcalendar for a terrific full calendar implementation.
1. Include the code
<script src="../Scripts/fullcalendar/fullcalendar.js" type="text/javascript"></script>
2. Include a div for your calendar
<div id="cal_viewcalendar"></div>
3. Setup your calendar
$("#cal_viewcalendar").fullCalendar({
theme: true,
events: "GetCalendars.aspx",
@scottsappen
scottsappen / gist:5901472
Created July 1, 2013 14:47
Formatting HTML that comes back with the return JSON feed. Full calendar implementation http://ssbits.wordpress.com/category/javascript-snippets/calendar/
1. Formatting HTML that comes back with the return JSON feed. When setting up your calendar object, you can define some methods.
eventRender: function (event, element) {
element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());
},
2. Changing the border of an event for mouse events.
eventMouseover: function (event, element, view) {
$(this).css('border', '3px dashed #c70000');
},
eventMouseout: function (event, element, view) {
@scottsappen
scottsappen / gist:5901483
Created July 1, 2013 14:48
Here’s how you could make it respond to drag and drop events using jquery. http://ssbits.wordpress.com/category/javascript-snippets/calendar/
1. Make something draggable
$("#img_myimage").draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
2. Make your calendar capable of accepting draggable objects (in the calendar setup)
droppable: true,
1. Just change the defaultView attribute for the calendar you are rendering
$(&quot;#cal_viewcalendarweekataglance&quot;).fullCalendar({
theme: true,
events: &quot;SomeWebPage.aspx&quot;,
cache: true,
height: 160,
defaultView: 'basicWeek',
eventRender: function (event, element) {
element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());
},
@scottsappen
scottsappen / gist:5901507
Created July 1, 2013 14:50
Fixed in place, but moves! Many people think that in order to create something on a page that stays in place (and appears to move) that you actually have to move it. I know that sounds weird, but you wouldn’t believe how many people think you need to use something like jquery. You know, $(“#mydiv”) x and y coordinates, screen top etc…ah, not so,…
//and here it is, moving with your mouse
<div style="position:fixed;">Move me around</div>
It doesn’t need to be much more complicated than that, unless you want to work with non-CSS compliant issues or have concerns about scrolling past other divs etc. But for something simple, this works.
@scottsappen
scottsappen / gist:5901526
Created July 1, 2013 14:52
Bootstrap’s Inverse Navbar issue with IE versions less than 10. If you used the default navbar and encountered issues in Internet Explorer (like the navbar appears to be all black in IE only), check this out. Oh and this isn’t an issue in IE10, just IE9, IE8 and lower. The problem has to do with IE’s treatment of gradients specified in the boots…
Open up /css/bootstrap.css and look for this entry: .navbar-inverse .navbar-inner
In that style, change the filter entry from this:
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515', endColorstr='#ff040404', GradientType=0);
to this:
filter: none;
That should make the navbar look as good in IE as it does already for Chrome, Safari and Firefox.
<script src="/js/vendor/raphael-min.js"></script>
<script src="/js/vendor/world.js"></script>
<script>
Raphael("forworldmap", 1000, 400, function () {
var r = this;
r.rect(0, 0, 1000, 400, 10).attr({
stroke: "none",
fill: "0-#9bb7cb-#adc8da"
});
var over = function () {