Skip to content

Instantly share code, notes, and snippets.

View juntalis's full-sized avatar

Charles Grunwald juntalis

View GitHub Profile
@juntalis
juntalis / CallCPythonDll.cs
Created February 10, 2011 06:41
Ran into some issues building a Titanium SDK Desktop app in their IDE, so I ended up writing a quick MsBuild task to automate it. Didn't want to run the python executable, so I instead opted to dynamically load the DLL.
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace MsBuild.TiDesktop
{
// TODO: Turn this into a property for the task.
@juntalis
juntalis / editor.php
Created August 16, 2011 22:56
Playing around with ACE & MtHaml
<?php
require_once __DIR__ . '/lib/MtHaml/Autoloader.php';
use MtHaml\Autoloader as HamlAuto;
use MtHaml\Environment as HamlEnv;
function RenderHaml($template, $mode) {
HamlAuto::register();
$haml = new HamlEnv($mode);
return $haml->compileString($template, $template);
@juntalis
juntalis / msys-env.cmd
Created October 17, 2011 00:07
A (Windows) batch script to open the MSYS shell in the user's current window (cmd.exe or whatever wrapper you're using) at the user's current folder. It requires getcp.exe be in your msys bin folder. (getcp.exe is included with msysgit) It also generates
@rem Do not use "echo off" to not affect any child calls.
@SETLOCAL
@SETLOCAL ENABLEEXTENSIONS
:: Figure out where msys's root folder. If you want, you could just add the folder in the line
:: below.
@set MSYSROOT=
@if "x%MSYSROOT%"=="x" @if exist "%~dp0msys.bat" @set MSYSROOT=%~dp0
@if "x%MSYSROOT%"=="x" @if exist "%~dp0.msys-root" @set /P MSYSROOT=<%~dp0.msys-root
@if "x%MSYSROOT%"=="x" (
@juntalis
juntalis / spauth.py
Created April 1, 2012 07:46
Claims-based Authentication Example for interacting with Sharepoint Online
import os, requests, re
from htmlentitydefs import name2codepoint
from simplejson import loads, dumps
spauth = None
def unescape(s):
name2codepoint['#39'] = 39
return re.sub('&(%s);' % '|'.join(name2codepoint),
lambda m: unichr(name2codepoint[m.group(1)]), s)
@juntalis
juntalis / delete-sp2010-field.js
Created May 11, 2012 07:50
Delete Sharepoint 2010 Field from Browser Console
// ==ClosureCompiler==
// @output_file_name delete-sp2010-field.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==
/**
* @projectDescription An anonymous function, to be run from the browser's console on a
* Sharepoint 2010 List View page or Form. (For instance,
* http://site/Lists/MyList/AllItems.aspx) The script creates a UI
* that lists all Workflow Status fields and allows for the easy
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#include "symbols.h"
typedef unsigned int uint;
typedef unsigned char uchar;
/* Generated by re2c 0.9.1-C on Wed Aug 01 00:28:19 2012
*/
#line 1 "c.re"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <io.h>
#include "symbols.h"
@juntalis
juntalis / util.js
Created September 26, 2012 15:00
Utility one-liners for checking types, values, etc
/* Utility one-liners for checking types, values, etc */
var prims = ['string', 'number', 'boolean', 'function', 'array' ],
typof = function(x) { var s, t = typeof(x); return t === 'object' ? (s = Object.prototype.toString.call(x)).substring(8, s.length - 1).toLowerCase() : t; },
undef = function(x) { return typeof(x) === 'undefined' || x == undefined; },
defined = function(x) { return !undef(x); },
noVal = function(x) { return undef(x) || typof(x) === 'null' || x == null || isNaN(x); },
hasVal = function(x) { return !noVal(x); },
isStr = function(x) { return typof(x) === prims[0]; },
isNum = function(x) { return typof(x) === prims[1]; },
isBool = function(x) { return typof(x) === prims[2]; },
// ==ClosureCompiler==
// @output_file_name vos365.sp.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==
(function(global, doc, handler) {
/* Utility one-liners for checking types, values, etc */
var prims = ['string', 'number', 'boolean', 'function', 'array'],
// Type checks
typof = function(x) { var s, t = typeof (x); return t === 'object' ? (s = Object.prototype.toString.call(x)).substring(8, s.length - 1).toLowerCase() : t; },
var $V = function() {
var args = Array.prototype.slice.call(arguments, 0);
if(!(this instanceof arguments.callee)) {
var $VA = arguments.callee,
$VB = function() {}, inst, ret;
$VB.prototype = $VA.prototype;
return Object(ret = $VA.apply(inst = new $VA, args)) === ret ? ret : inst;
}
this.originalValue = (function(a) {
switch(a.length) {