Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
import sys
import json
import subprocess
import urllib
try:
import requests
except:
print "Install requests (try easy_install requests)"
sys.exit()
/* Simple JavaScript Inheritance with NFE's
* MIT Licensed.
*/
// Inspired by base2 and Prototype and John Resig's class system
(function(){
var initializing = false;
// The base Class implementation (does nothing)
this.Class = function(){};
@saga
saga / AngularJS-Windows-Authentication.authentication.js
Last active August 29, 2015 14:27 — forked from definitelynotsoftware/AngularJS-Windows-Authentication.authentication.js
AngularJS Windows Authentication Service using .NET Web API and Hot Towel template
angular.module('app')
.factory("authentication", ["$http", "$q", "$window", authentication]);
function authentication($http, $q, $window) {
var user;
function login() {
// check if the user already exists for this session
@saga
saga / std::string split function
Created January 4, 2010 06:38
std::string split function
void split(const string& str, const string& delim, vector<string>* pParts)
{
size_t start, end = 0;
while (end < str.size()) {
start = end;
while (start < str.size() && (delim.find(str[start]) != string::npos))
{
start++; // skip initial whitespace
}
@saga
saga / Lua print table
Created January 4, 2010 06:42
Lua print table
local tconcat = table.concat
local tinsert = table.insert
local srep = string.rep
function print_table(root)
local cache = { [root] = "." }
local function _dump(t,space,name)
local temp = {}
for k,v in pairs(t) do
local key = tostring(k)
def get_content_type():
return 'application/octet-stream'
def parse_xml(key,xml):
""" Simple XML parser """
key = key.lower()
for tag in xml.split("<"):
tokens = tag.split()
if tokens and tokens[0].lower().startswith(key):
return tag.split(">")[1].strip()
#include "stdafx.h"
#include <stdio.h>
/* fast strcpy -- Copyright (C) 2003 Thomas M. Ogrisegg <tom@hi-tek.fnord.at> */
//#include <string.h>
//#include "dietfeatures.h"
//#include "dietstring.h"
// ----following are dietstring.h content.
//#include <endian.h>
//# define MKW(x) (x|x<<8|x<<16|x<<24)
int MKW(int x)
#include "stdafx.h"
#include <stdlib.h>
/* Magic numbers for the algorithm */
static const unsigned long mask01 = 0x01010101;
static const unsigned long mask80 = 0x80808080;
#define LONGPTR_MASK (sizeof(long) - 1)
/*
#include "stdafx.h"
#include <stdlib.h>
/* Magic numbers for the algorithm */
static const unsigned long mask01 = 0x01010101;
static const unsigned long mask80 = 0x80808080;
#define LONGPTR_MASK (sizeof(long) - 1)
/*
#include "stdafx.h"
#include <stdlib.h>
/* Magic numbers for the algorithm */
static const unsigned long mask01 = 0x01010101;
static const unsigned long mask80 = 0x80808080;
#define LONGPTR_MASK (sizeof(long) - 1)
/*