Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@DinoChiesa
DinoChiesa / RawSerializer.cs
Created March 8, 2013 21:48
Raw Serializer in C#
internal class RawSerializer<T>
{
public T RawDeserialize( byte[] rawData )
{
return RawDeserialize( rawData , 0 );
}
public T RawDeserialize( byte[] rawData , int position )
{
@DinoChiesa
DinoChiesa / xmlpretty.el
Last active July 23, 2018 08:23
elisp for pretty-printing XML from within emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; pretty print xml in region
;; http://stackoverflow.com/a/5198243/48082
(defun dino-xml-pretty-print-region (begin end)
"Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
(interactive "r")
@DinoChiesa
DinoChiesa / sql-1.asp
Created May 21, 2013 04:40
An example of a Classic ASP module implemented in JavaScript. This one reads from a SQL database, does content negotiation, returning a query result as Text, XML, JSON, or HTML.
<%@ language="Javascript" %>
<script language="javascript" runat="server" src='json2.js'></script>
<script language="javascript" runat="server" src='stringExtensions.js'></script>
<script language="javascript" runat="server" src='contentNego.js'></script>
<script language="javascript" runat="server">
(function() {
// In an ASP scenario, this fn gets "exported"
@DinoChiesa
DinoChiesa / Embedding-Gist.htm
Created May 22, 2013 02:24
Embed a Gist using jQuery.
<link href="http://yandex.st/highlightjs/7.0/styles/default.min.css" rel="stylesheet">
<script src="http://yandex.st/highlightjs/7.0/highlight.min.js"></script>
<script type='text/javascript'> $(document).ready(function() {
function fixup(s) {
var re1 = new RegExp('<','g'), re2 = new RegExp('>','g');
return s.replace(re1,'&lt;').replace(re2,'&gt;');
}
$.ajax({type: "GET",
url: "https://api.github.com/gists/5617520",
@DinoChiesa
DinoChiesa / edit-in-place.js
Created July 11, 2013 00:49
An edit-in-place directive for AngularJS. It requires no jQuery or other JS framework.
angular
// edit-in-place attribute
.directive( 'editInPlace', function() {
return {
restrict: 'A',
scope: { value: '=editInPlace', onSaveFn: '&onSave', onCancelFn: '&onCancel' },
template: '<span ng-click="handleClick()" ng-bind="value"></span><input ng-model="modelCopy" style="width:100%;"></input>',
link: function ( $scope, element /* , attrs */ ) {
// Let's get a reference to the input element, as we'll want to reference it.
@DinoChiesa
DinoChiesa / stringExtensions.js
Created July 26, 2013 13:57
string extensions for use with the sql-1.asp example I posted previously.
// stringExtensions.js
//
// a few extensions on the string object.
//
// Fri, 10 Feb 2012 16:48
//
(function(globalScope) {
if (typeof String.prototype.trim != 'function') {
@DinoChiesa
DinoChiesa / contentNego.js
Created July 26, 2013 14:08
content negotiation in JS for ASP-classic
// contentNego.js
//
// Simple content negotiation logic for ASP-classic modules.
//
// This module exposes one public function - figureDesiredContentType().
// It checks the HTTP_ACCEPT server variable (whose value is set to the
// value of the Accept request header), and sets a content-type
// mime-string accordingly.
//
// When there are multiple mime-types in the Accept header, or when the
@DinoChiesa
DinoChiesa / HelloWorldPort.wsdl
Created October 3, 2013 18:44
HelloWorld WSDL
<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy"
xmlns:ns0="http://default_package/" targetNamespace="http://default_package/">
@DinoChiesa
DinoChiesa / fixScreenCapFilenames.sh
Created December 4, 2013 22:04
Bash script to rename screen capture files on MacOSX to something cleaner. It's handy to attach this as a "folder action" so that files get renamed automagically. See http://apple.stackexchange.com/a/112747/27434
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# Rename screenshot files to cleaner names, names for which a
# lexicographic sort is equivalent to a time-based sort.
#
#
# Created: <Wed Dec 4 10:24:15 2013>
# Last Updated: <2013-December-04 13:57:46>
#
@DinoChiesa
DinoChiesa / exampleBase64Apigee.js
Created January 15, 2014 06:04
Example of doing base64 encoding in a JavaScript for an Apigee policy
// exampleBase64.js
//
// for use within an Apigee JavaScript callout.
//
// Dino Chiesa, DChiesa@apigee.com
//
// Tuesday, 14 January 2014, 22:03
// ------------------------------------------------------------------