Skip to content

Instantly share code, notes, and snippets.

/*
* http://johan.heapsource.com
*/
import std.stdio;
import std.json;
void main() {
JSONValue v = parseJSON(q{
{"a":2, "b":{"c":20}}
@bithavoc
bithavoc / dparsingjsonvalueretain.d
Last active October 21, 2016 13:15
Demo of Parsing objects using instances of JSONValue
/*
* http://johan.heapsource.com
*/
import std.stdio;
import std.json;
JSONValue doc;
void main() {
@bithavoc
bithavoc / azure_env_detection.cs
Created January 12, 2014 21:22
determinate if running in azure fabric, emulated or not
using Microsoft.WindowsAzure.ServiceRuntime; // Microsoft.WindowsAzure.ServiceRuntime.dll
...
if (RoleEnvironment.IsAvailable) {
// running inside Azure Fabric
if(RoleEnvironment.IsEmulated) {
// Fabric is running in Emulator
@bithavoc
bithavoc / events_example.d
Created December 25, 2013 16:09
Example of Events.d, the first Event Model for D programming language
//
// http://blog.heapsource.com/post/71111508527/events-d
//
import std.stdio;
import std.string;
import events;
void main() {
auto event = new EventList!(string, int);
@bithavoc
bithavoc / http-parser-example.d
Created December 25, 2013 16:01
Example of joyent/http-parser bindings for D programming language
//
// http-parser.d example
// http://blog.heapsource.com/post/70495154255/announcing-http-parser-d
//
import std.stdio;
import http.parser.core;
void main() {
"http-parser.d in action with fixed-size Http Message Body".writeln;
@bithavoc
bithavoc / event_list_triggers.d
Created December 23, 2013 04:02
Demo of event list triggers in D
import std.stdio;
import std.algorithm;
import std.string;
// event list declared with string return value, first parameter as string and second parameters as int.
static EventList!(string, string, int) formatter;
// event list declared with no parameters and returning void.
static EventList!void voidEvents;
@bithavoc
bithavoc / event_list_test.D
Created December 23, 2013 02:01
EventList implementation in D with syntax sugar
import std.stdio;
import std.algorithm;
import std.string;
// event list declared with string return value, first parameter as string and second parameters as int.
static EventList!(string, string, int) formatter;
// event list declared with no parameters and returning void.
static EventList!void voidEvents;
@bithavoc
bithavoc / asp_net_development_server_reverse_proxy.conf
Created July 30, 2013 14:44
Nginx.conf file to expose ASP.NET development server remotely.
worker_processes 1;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
keepalive_timeout 65;
server {
@bithavoc
bithavoc / gist:6095868
Created July 27, 2013 18:50
example_stream_read
Duv takes the delegated passed to runMainDuv and wraps in a Fiber so we can suspend the execution while we wait for libuv.
here:
https://github.com/heapsource/duv/blob/master/src/duv/core.d#L159
Loops starts here, we block the execution of the app until the main fiber finishes:
https://github.com/heapsource/duv/blob/master/src/duv/core.d#L141
Example stream read:
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
UITableViewCellStyleDefault, // Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1, // Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2, // Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle // Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).
}; // available in iPhone OS 3.0