Skip to content

Instantly share code, notes, and snippets.

View DanielG's full-sized avatar

Daniel Gröber (dxld) DanielG

View GitHub Profile
@DanielG
DanielG / PrintBinary.h
Created March 27, 2010 13:27
Print any type as binary with automatic endian swap
#include <iostream>
#include <vector>
#include <stdarg.h>
#include <stdint.h>
enum printBinary_opt
{
kPB_NO_OPT = 0,
kPB_LITTLE_ENDIAN = 1,
kPB_BIG_ENDIAN = (1 << 1),
cmake_minimum_required(VERSION 2.6)
project(ogre-test)
include("CMake/setup-module-path.cmake")
include("CMake/FindOgre-all.cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE PATH "Binary output directory" FORCE)
# Find all .cpp files and compile them
file (GLOB OGRE_TEST_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
#! /usr/bin/env node
// Very simple c/++ preprocessor for replacing binary(0b10101) with the hexer decimal representation
var fs = require('fs');
process.argv = process.argv.slice(2, process.argv.length);
console.log('Arguments:', process.argv);
process.argv.forEach(function(val, index, array){
if(val.match(/[a-zA-Z._-]*/)) {
process.nextTick(function (){
@DanielG
DanielG / cmake-repl.js
Created November 19, 2010 21:02
Quick & dirty CMake repl
#! /usr/bin/env node
var fs = require("fs");
var rl = require('readline');
var util = require('util');
var spawn = require('child_process').spawn;
var tmpfiles = [];
var tmpfile = function(callback){
var tmpath = '/tmp/.xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.cmake'.replace(/[xy]/g, function(c) {
@DanielG
DanielG / smtp-server.js
Created November 22, 2010 20:06
Hacky node.js smtp server
// SMTP server in node.js (hacky)
var util = require('util');
var net = require('net');
/*
* Template
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 Dexter ESMTP Exim 4.72 Mon, 22 Nov 2010 13:59:05 +0100
-> EHLO Dexter
@DanielG
DanielG / todo.mdown
Created December 28, 2010 03:22
My Unhosted todo list
  • crypto.sessionKey() #DONE
  • protocol versioning, crypto versions
  • asnyc retrieveKey for automatic key retrieve from keyserver
  • async decryption for images and such (low priority ?)
  • .. or WebWorkers
blabla
@DanielG
DanielG / guidelines.mdown
Created December 29, 2010 20:04
Unhosted.js coding guidelines
  • 4 space indentation

  • 80 character max per line

  • if's always have space before braces

  • if's always have braces

    if() {
      return;
    }
    
  • exception: if(err) throw err;

var fs = require('fs');
var util = require('util');
var Step = require('step');
var Script = process.binding('evals').Script;
var loadModule = function loadModule(modulePath, callback){
Step(
function fetchScript(){
fs.readFile(modulePath, this);
}
<html>
<!-- <script type="text/javascript" src="SubscribingPasswordMe.js"></script> -->
<script type="text/javascript" src="../../scripts/require.js"></script>
<script>
require(['../../unhosted'], function(unhosted){
console.log(unhosted);
// Load blog post
//unhosted.importSub(SubscribingPasswordMe, "hardCodedSub");
//document.getElementById("blogpost").innerHTML= unhosted.get("hardCodedSub", "myFirstUnhostedBlogPost");