Skip to content

Instantly share code, notes, and snippets.

View syzdek's full-sized avatar

David M. Syzdek syzdek

  • Alaska Communications
  • Anchorage, Alaska
  • 13:22 (UTC -09:00)
View GitHub Profile
@syzdek
syzdek / reverse-bits.c
Created March 5, 2009 17:40
reverses the bits in a 32 bit word
n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000);
@syzdek
syzdek / gist:258233
Created December 16, 2009 22:14
inserts a series of bits into a byte buffer at the specified bit offset
/// inserts a series of bits into a byte buffer at the specified bit offset
/// @param[in] dst pointer to buffer
/// @param[in] src array of data to insert into the dst buffer
/// @param[in] len length in bytes of the buffer
/// @param[in] offset number of bits to offset the data in the buffer
/// @param[in] n number of bits to insert into the buffer
void bitops_copy(uint8_t * dst, uint8_t * src, uint32_t len, uint32_t offset,
uint32_t n)
{
uint32_t byte_required;
@syzdek
syzdek / slapd.conf
Created December 10, 2010 13:43
Example OpenLDAP slapd configuration.
#
# Slapd Daemon Configuration
# Copyright (C) 2011 Bindle Binaries <syzdek@bindlebinaries.com>.
#
# @BINDLE_BINARIES_BSD_LICENSE_START@
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
@syzdek
syzdek / books.sql
Created May 5, 2011 07:26
SQLite3 Example DB and queries
--
-- Simple SQLite3 Example
-- Copyright (C) 2011 David M. Syzdek <david@syzdek.net>
--
-- Run:
-- cat hello.sql | sqlite3 hello.db
--
-- creates tables
@syzdek
syzdek / gist:997335
Created May 28, 2011 23:21
rootDN o=slapdUsers for Example OpenLDAP slapd Config (gist 736209)
dn: o=slapdUsers
description: top level tree for administering LDAP access
o: slapdUsers
objectClass: top
objectClass: organization
dn: ou=Clients,o=slapdUsers
objectClass: top
objectClass: organizationalUnit
ou: Clients
@syzdek
syzdek / ldapsearch-sync.c
Created December 11, 2011 07:10
an example of an LDAP synchronous search using an LDAP API
/*
* Simple Programming Examples And References
* Copyright (C) 2011 David M. Syzdek <david@syzdek.net>.
*
* @SYZDEK_BSD_LICENSE_START@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
@syzdek
syzdek / ldapsearch-async.c
Created December 13, 2011 02:41
an example of an LDAP asynchronous search using an LDAP API
/*
* Simple Programming Examples And References
* Copyright (C) 2011 David M. Syzdek <david@syzdek.net>.
*
* @SYZDEK_BSD_LICENSE_START@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
@syzdek
syzdek / pcredemo.c
Created June 7, 2012 22:03
pcredemo.c with adjusted spacing to make it easier to read
/*************************************************
* PCRE DEMONSTRATION PROGRAM *
*************************************************/
/* This is a demonstration program to illustrate the most straightforward ways
of calling the PCRE regular expression library from a C program. See the
pcresample documentation for a short discussion ("man pcresample" if you have
the PCRE man pages installed).
In Unix-like environments, if PCRE is installed in your standard system
@syzdek
syzdek / encrypt-sshpass.sh
Created July 9, 2012 20:25
Script to encrypt a string using an SSH user's public RSA ssh key.
#!/bin/sh
#
# Convience script for encrypting a SSH user's password
# using the user's public SSH RSA key.
#
# encrypt-sshpass.sh
#
PROGRAM_NAME=`basename ${0}`
@syzdek
syzdek / cli-nsrunloop.m
Created July 31, 2012 21:36
Creating an NSRunLoop for a command line utility.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop