Skip to content

Instantly share code, notes, and snippets.

View painquin's full-sized avatar

Andy Hohorst painquin

  • Decisive Communications
  • Frederick, MD
View GitHub Profile
@painquin
painquin / LDAP.cs
Created March 7, 2012 13:51
LDAP helper (works in MVC)
using System.DirectoryServices;
public class LDAP
{
static DirectoryEntry _de = new DirectoryEntry("LDAP://[LDAP server host]", "[service account]", "[service account password]");
static T LookupAnd<T>(string LoginName, System.Func<SearchResult,T> cb)
{
using (var dsearch = new DirectorySearcher(_de))
{
package
{
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.Font;
import flash.text.StaticText;
import flash.text.TextField;
/**
* ...
@painquin
painquin / lineintersection.as
Created August 9, 2011 14:40
Line segment intersection in AS3
// ported from http://alienryderflex.com/intersect/
public static function LineIntersection(a:Point, b:Point, c:Point, d:Point):Point
{
var distAB:Number, cos:Number, sin:Number, newX:Number, ABpos:Number;
if ((a.x == b.x && a.y == b.y) || (c.x == d.x && c.y == d.y)) return null;
if ( a == c || a == d || b == c || b == d ) return null;
b = b.clone();
@painquin
painquin / LineBatch.cs
Created June 9, 2011 13:24
batch-draws a series of lines defined by 3d points (XNA)
using System;
using System.Collections.Generic;
namespace Microsoft.Xna.Framework.Graphics
{
/// <summary>
/// Batch-draws a series of lines defined by 3d points (and more). Much faster than drawing one-by-one.
/// </summary>
/// <typeparam name="VertexType">The vertex type to use (such as VertexPositionColor)</typeparam>
public class LineBatch<VertexType> where VertexType : struct, IVertexType
@painquin
painquin / GUI.cs
Created March 25, 2011 19:59
Immediate Mode GUI for XNA
abstract class GUI
{
#region Enums
public enum ElementState
{
None,
Hovered,
Clicked,
tileset.Texture = Content.Load<Texture2D>(tileset.File);
tileset.spacing = (Math.Sqrt(64 * 64 + 48 * 48));
double a = Math.Atan2(48, 64);
tileset.cos = Math.Cos(a);
tileset.sin = Math.Sin(a);
-----------------------------------------------
for (int y = 0; y < mapHeight; ++y)
{
using System.Collections.Generic;
using System.Linq.Expressions;
/*
* Disclaimer: No validation, only use on good input
* Also, Pants is the name of the game engine I'm working on.
*/
namespace Pants {
class psr
{