Skip to content

Instantly share code, notes, and snippets.

View schakko's full-sized avatar

Schakko schakko

View GitHub Profile
@schakko
schakko / ad_ldif_to_xml_json.php
Created March 31, 2011 16:02
Converts Active Directory LDIF schema to XML or JSON
<?php
/**
* This hack converts an Active Directory LDIF schema file to XML or JSON.
* Export Active Directory schema with the following command (must be run as Domain Administrator):
* ldifde -f SaveSchema.ldif -d CN=Schema,CN=Configuration,DC=domain,DC=local
* Change var $file to location of generated schema, open your browser, point to this file and append ?xml for XML output or ?json for JSON output
*
* @author Christopher Klein <ckl[at]ecw[dot]de>
* @url http://wap.ecw.de
*/
@schakko
schakko / gambio_xtc_converter.php
Created April 5, 2011 13:26
gambio_xtc_converter
<?php
// Gambio to XTC image converter - PHP pseudocode - not tested
// Gambio product table
$sql = "SELECT id, products_name FROM gambio.products_description"
$rows = mysql_fetch_assoc(mysql_query($sql))
foreach ($rows as $row) {
// match string, e.g "printer (white)"
if (preg_match("/^(.*)\((.*)\)(.*)$", $row['products_name'], $arrMatches)) {
$color = $arrMatches[2]; // third element contains color
// do something with color, e.g
@schakko
schakko / decode_win_xp_product_key.php
Created May 28, 2011 14:29
Decoding the WindowsXP product key / serial number from the digital product id with PHP
<?php
/**
* decodes the product key and returns it as "-"-seperated string
* @param array of bytes
* @return string
*/
function decodeProductKey($aHexSrc)
{
// base24-encoded
$arrDigits = array('B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9');
@schakko
schakko / simple_dsl.domain
Created June 27, 2011 13:15
Simple DSL with Xtext
domaene de.ckl.blog
entity Gruppe {
attribute id: int not-null primary-key
attribute name: string
reference has-many: BenutzerInGruppe with-alias:"BenutzerInGruppen"
}
entity BenutzerInGruppe {
@schakko
schakko / gist:1444002
Created December 7, 2011 18:31
DSL for protyping application w/integrated function point analysis
grammar de.ckl.Mydsl with org.eclipse.xtext.common.Terminals
generate mydsl "http://www.ckl.de/Mydsl
Model:
(domains+=Domain)*;
Operation:
(OperationContainer | OperationCreate | OperationList | OperationEdit | OperationDelete)
;
@schakko
schakko / database_migration.xml
Created December 23, 2011 15:00
Database migration workflow sample in XML
<db-workflow>
<defaults>
<var key="server">test</var>
<var key="test">${server}_name</var>
</default>
<workflows>
<workflow name="update">
<vars>
<ask_for var="server" />
<ask_for var="user" />
@schakko
schakko / build.xml
Created December 23, 2011 15:13
Database migrations with Ant
<?xml version="1.0" encoding="UTF-8"?>
<project name="db-worklflow" default="update">
<property name="db.server">remote_db_server</property>
<property name="db.database"></property>
<property name="db.username">root</property>
<property name="db.password">root</property>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<target name="sql_execute_command" description="Executes exactly one SQL command and returns it output as 'latest_sql_result'">
<if>
@schakko
schakko / server.js
Created May 5, 2012 16:48
DNS not working in forked processes
var cp = require('child_process'),
dns = require('dns');
/** server.js */
// *does* work
dns.resolve4('www.google.com', function(err, addresses) {
console.log("Resolved from service.js");
console.log(addresses);
});
@schakko
schakko / glibberish-aes-256-cbc-decrypt.js
Created May 7, 2012 16:11
Using AES-256-CBC with OpenSSL, node.js and PHP
// Doing AES-256-CBC (salted) decryption with node.js.
// This code is based on http://php.net/manual/de/function.openssl-decrypt.php and works with PHP sqAES.
//
// Create your encrypted data with
// echo -n 'Hello world' | openssl aes-256-cbc -a -e
var crypto = require('crypto');
var password = 'password';
var edata = 'U2FsdGVkX18M7K+pELP06c4d5gz7kLM1CcqJBbubW/Q=';
@schakko
schakko / convert_multiple_svn_to_git.sh
Created June 5, 2012 10:13
Convert multiple SVN repositories with help of svn2git
#!/bin/bash
PATH_svn2git=~/svn2git/svn-all-fast-export
# path to account mapping. Must be in format "$svn-username $git-fullname <$git-email>"
PATH_account_map=~/svn2git/account-map
# layout template
PATH_template=~svn2git/standardlayout.rules