Skip to content

Instantly share code, notes, and snippets.

View kyleondata's full-sized avatar

Kyle Jennings kyleondata

View GitHub Profile
@kyleondata
kyleondata / blog.html
Created April 10, 2012 04:09
Knockout.js Example
<html>
<head>
<style>
.post {
list-style-type: none;
}
</style>
<script src='jquery-1.7.2.min.js'></script>
<script src='knockout-2.0.0.js'></script>
@kyleondata
kyleondata / KnockoutAjaxRefresh.js
Created April 11, 2012 16:47
Knockout issue with rebinding the model based on an ajax request
$.ajax({
url: "some url",
dataType: "json",
cache: false
});
@kyleondata
kyleondata / gist:3083739
Created July 10, 2012 14:46
C# code fore returning a file from CRM 2011
var id = new Guid(Request["id"]);
Repository.DocumentRepository documents = new Repository.DocumentRepository();
var results = documents.GetDocumentItem(id);
var f = File(Convert.FromBase64String(results.DocumentBody), Request["type"], results.FileName);
return f;
@kyleondata
kyleondata / gist:3083774
Created July 10, 2012 14:50
Javascript to handle getting the file
function getDocItems(id) {
$.ajax({
url: "<URL TO GET THE DOCUMENT>?id=" + id,
dataType: "json",
cache: false
}).error(function (jqXHR, textStatus) {
}).success(function (data) {
for (var key in data) {
var html = '<p><a href="<URL TO GET FILE>/GetFile?id=' + data[key].Id + '&type=' + data[key].MimeType + '" >' + data[key].FileName + '</a></p>';
$('#YourElementId').append(html);
@kyleondata
kyleondata / gist:3145973
Created July 19, 2012 18:54
Knockout null reference example
// Makes the call
$.ajax({
url: "<SOME URL TO QUERY>",
dataType: "json",
cache: false
}).error(function (jqXHR, textStatus) {
}).success(function (data) {
// Loop through each returned result
for (var key in data) {
@kyleondata
kyleondata / ApiHandler.rb
Created August 20, 2012 14:53
Sinatra example
require 'sinatra'
require 'json'
get '/api/hello' do
# Return this message in JSON format.
content_type :json
{ :message => 'Hello World!' }.to_json
end
@kyleondata
kyleondata / gist:3440492
Last active February 1, 2023 19:23
Backbone.js and Handlebars.js example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.min.js" ></script>
<script src="handlebars-1.0.0.beta.6.js" ></script>
<script src="underscore-min.js" ></script>
<script src="backbone-min.js" ></script>
@kyleondata
kyleondata / gist:3489548
Created August 27, 2012 15:32
Backbone.js events
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.min.js" ></script>
<script src="handlebars-1.0.0.beta.6.js" ></script>
<script src="underscore-min.js" ></script>
<script src="backbone-min.js" ></script>
@kyleondata
kyleondata / gist:3789104
Created September 26, 2012 16:43
Sprite Example
.desktopIcon
{
background-position: 0 0;
height: 25px;
width: 25px;
background-repeat: no-repeat;
}
/* gets any input that is type submit */
input[type='submit']{}
/* gets the first child of an element */
table:first-child{}
/* gets the second element that comes after the first,
in this example any hr tags that follow a div tag */
div + hr{}