Skip to content

Instantly share code, notes, and snippets.

View dcoles's full-sized avatar

David Coles dcoles

View GitHub Profile
@dcoles
dcoles / designer.html
Created June 28, 2014 08:18
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
@dcoles
dcoles / c99-cxx.c
Created November 15, 2011 05:30
C99 features that don't work in C++
/**
* C99 features that don't work in C++
*
* Written in 2011 by David Coles <coles.david@gmail.com>
*
* To the extent possible under law, the author(s) have dedicated all copyright and related and
* neighboring rights to this software to the public domain worldwide.
* This software is distributed without any warranty.
*/
@dcoles
dcoles / Main.java
Created November 2, 2012 04:55
Igpay Atinlay
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
/**
* @param args the command line arguments
*/
#!/bin/bash
set -e
MINECRAFT_SERVER=minecraft_server.jar
MINECRAFT_SERVER_ARS=minecraft_server_ars.jar
FORGE=minecraftforge-universal-1.4.5-6.4.1.410.zip
ARS=ArsMagica_Open_Beta_RC_4.62.113
@dcoles
dcoles / tee.c
Last active September 24, 2016 05:03
/**
* Print size and contents of a PIPE
* Author: David Coles <coles.david@gmail.com>
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@dcoles
dcoles / proxy.go
Created September 9, 2018 03:44
HTTP Proxy in Go
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"net/http"
)
@dcoles
dcoles / producer_consumer.py
Created September 15, 2018 19:24
Coroutines in Python
"""Producer/Consumer coroutines."""
import asyncio
q = asyncio.Queue(7)
def reader(iterable):
"""Producer."""
it = iter(iterable)
while True:
@dcoles
dcoles / lua_coroutines.py
Last active September 16, 2018 00:59
Lua-style coroutines
"""
Lua-style coroutines.
Examples taken from https://www.lua.org/pil/9.html.
"""
import types
class Coroutine:
@dcoles
dcoles / coroutine_pipeline.py
Created September 16, 2018 01:02
Coroutine pipeline
"""
Coroutine pipeline.
Based off https://www.lua.org/pil/9.2.html.
"""
import types
if __name__ == '__main__':
@dcoles
dcoles / greeter_server_fork_exec.py
Last active November 4, 2018 01:02
gRPC server fork (causes "Failed accept4: Invalid argument" on Python 3.6)
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,