Skip to content

Instantly share code, notes, and snippets.

View aggieben's full-sized avatar
🏠
Working from home

Ben Collins aggieben

🏠
Working from home
View GitHub Profile
@aggieben
aggieben / codeeval.hpp
Created May 31, 2012 18:51
CodeEval Library
#include <cmath>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
typedef std::auto_ptr<std::vector<std::string> > token_collection_t;
token_collection_t tokenize(const std::string &s, const char token = ',')
{
$env:14hive = 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14'
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
}
@aggieben
aggieben / Elements.xml
Created November 16, 2011 12:38
List Instance Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Stations"
OnQuickLaunch="TRUE"
TemplateType="10001"
Url="Lists/Stations"
Description="The canonical list of stations.">
<Data>
<Rows>
<Row>
@aggieben
aggieben / ListTypes.ps1
Created August 7, 2011 01:29
PowerShell One-Liner to recursively see what kind of files are in a directory.
gci -recurse |% { [System.IO.Path]::GetExtension($_.Name) } |? {$_ -notmatch "^\s*$"} | select -unique
@aggieben
aggieben / BadAuto.m
Created July 18, 2011 20:07
Safe autorelease
@interface classname {
ShareKitItem *item;
}
@end
@implementation classname
- (id)init
{
item = [[[ShareKitItem allocate] init] autorelease];
}
@aggieben
aggieben / BundleVersionRunScript.sh
Created May 17, 2011 19:26
Xcode RunScript to insert git-ish version string into bundle version property in Info.plist
echo "majorMinor=`/usr/libexec/PlistBuddy -c \"Print :CFBundleVersion\" \"${PROJECT_DIR}/${PROJECT_NAME}-Info.plist\"`"
majorMinor=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${PROJECT_DIR}/${PROJECT_NAME}-Info.plist"`
echo "build=`git describe --match ${majorMinor}* --tags --dirty=+ | sed \"s/\(${majorMinor}\)\(.*\)/\2/\"`"
build=`git describe --match ${majorMinor}* --tags --dirty=+ | sed "s/\(${majorMinor}\)\(.*\)/\2/"`
echo "/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion ${majorMinor}.${build}\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\""
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${majorMinor}.${build}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@aggieben
aggieben / ListFeatures.ps1
Created November 30, 2010 15:09
A PowerShell one-liner to look through the directory hierarchy of a SharePoint solution for files called "feature.xml" and parse out the names and IDs of features specified therein.
ls -recurse -filter feature.xml | select-xml "//*[local-name()='Feature']" | ft @{Label="Name";Expression={$_.Node.Title}}, @{Label="ID";Expression={$_.Node.Id}}
package aexp.customadapter;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
@aggieben
aggieben / gaejson.py
Created January 7, 2010 05:42
a little json encoder for use with GAE models
from django.utils import simplejson as json
from google.appengine.ext import db
class GaeEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, db.Model):
output = {}
for key, prop in obj.properties().iteritems():
if isinstance(prop, db.ListProperty) and prop.item_type == db.Key:
output[key] = [ db.get(k) for k in getattr(obj, key) ]
application: bt-coronet
version: 1
runtime: python
api_version: 1
handlers:
- url: /s
static_dir: static
- url: /favicon.ico