Skip to content

Instantly share code, notes, and snippets.

public static class ExtensionMethods
{
/// <summary>
/// Creates paginated links
/// </summary>
/// <param name="helper">HtmlHelper class that can provide access to helpful functionality</param>
/// <param name="startPage">Starting page (most likely 1)</param>
/// <param name="currentPage">Number of the current page</param>
/// <param name="totalPages">Number of total pages</param>
/// <param name="pagesToShow">Number of pages to show forward and backward</param>
var endpoint = new System.ServiceModel.EndpointAddress("http://www.ecubicle.net/gsearch_rss.asmx");
var binding = new System.ServiceModel.BasicHttpBinding();
var oProxy = System.ServiceModel.ChannelFactory.CreateChannel(binding, endpoint);
/* Code specific to service */
var request = new GetSearchResultsRequest() { Body = new GetSearchResultsRequestBody() };
request.Body.searchPage = "";
request.Body.gQuery = "Test";
request.Body.numOfResults = "50";
bool successfulCall = false;
public class JavascriptHandler : IHttpHandler
{
private readonly static bool enabledAutoMinified = ConfigurationManager.AppSettings["enableAutoMinified"] == "true";
private readonly static Minifier minifier = new Minifier();
private readonly static CodeSettings minifierSettings = new CodeSettings()
{
/* Minifier code settings here */
};
bool IHttpHandler.IsReusable
<div>Hover over swatch</div>
<img src="http://markistaylor.files.wordpress.com/2012/05/swatches.jpg"
alt="Swatches" usemap="#swatchmap" />
<map name="swatchmap">
<area shape="rect" coords="0,0,20,20" alt="Graphite" />
<area shape="rect" coords="24,0,44,20" alt="Snow" />
<area shape="rect" coords="50,0,70,20" alt="Poppy" />
<area shape="rect" coords="77,0,97,20" alt="Caynene" />
<area shape="rect" coords="103,0,123,20" alt="Tan" />
var $hoveredSwatch = $("#hoveredSwatch");
var $selectedSwatch = $("#selectedSwatch");
$("area").hover(
function() {
var altText = $(this).attr("alt");
$hoveredSwatch.html(altText);
},
function() {
$hoveredSwatch.html("");
@markis
markis / deferParsing
Created January 10, 2014 21:32
wrap html that doesn't need to be loaded on initial load in <div class="deferParsing"><!-- --></div>
$(".deferParsing").each(function(idx, elem) {
var $elem = $(elem),
comments = $elem
.contents()
.filter(function(){return this.nodeType === 8;})
.get(0)
;
$elem.replaceWith(comments.nodeValue);
});
var stops=[];
$.ajax({
url:"http://webservices.nextbus.com/service/publicXMLFeed?command=predictionsForMultiStops&a=sf-muni&stops=37|4169&stops=37|3255&stops=48|3476&stops=48|4924",
success:function(xml) {
$("predictions", xml).each(function(idx, predictions) {
var stop = {times:[]};
$.each(predictions.attributes, function(idx, attribute) { stop[attribute.name] = attribute.value });
$("prediction", predictions).each(function(idx, prediction) {
var time = {};
$.each(prediction.attributes, function(idx, attribute) { time[attribute.name] = parseInt(attribute.value) ? parseInt(attribute.value) : attribute.value });
/*
Retrieve the name of the the optimizely test with DFP in it and then parse out the number after AB-###.
This is for the ad-ops team to use as a way to know what tests are running on the pages that they are serving up ads
Test names should follow this pattern: AB-123 description dfp
*/
function getDFP() {
if ('undefined' != typeof optimizely && 'undefined' != typeof optimizely.allExperiments && 'undefined' != typeof optimizely.variationMap) {
var allTests = optimizely.allExperiments;
@markis
markis / gist:43f7d433104b1713560b
Last active August 29, 2015 14:23
Script to monitor twitter and post to hipchat
#!/usr/bin/env python
import httplib, json
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser # ver. < 3.0
# config and globals
tweetMessages = []
/* Go to https://www.facebook.com/pokes/ and run the following */
setInterval(() => {
for (let node of document.getElementsByTagName('a')) {
if (node.textContent === "Poke Back") {
node.click();
}
}
}, 100)