Skip to content

Instantly share code, notes, and snippets.

@rjmcguire
rjmcguire / baldrick.debug.js
Created April 19, 2013 08:01
debug plugin for baldrickjs
(function(baldrick){
oldlogger = baldrick.prototype.log
baldrick.prototype.log = function(message,element,event) {
oldlogger(message,element,event)
if(console){
console.log(message);
if(element){
console.log('Trigger Element:');
console.log(element);
}
@rjmcguire
rjmcguire / chan.d
Last active August 23, 2016 08:52
go statement implementation for D with simple Fiber co-op scheduler #dlang #golang
import core.sync.mutex : Mutex;
import core.thread : Thread, Fiber;
/**
* chan allows messaging between threads without having to deal with locks, similar to how chan works in golang
*/
shared
class chan(T) {
Mutex lock;
private bool closed_; bool closed() {synchronized (lock) {return closed_;}} void Close() { synchronized(lock) { closed_ = true; } }
@rjmcguire
rjmcguire / traits.d
Last active December 22, 2015 06:29
Little demo of allowing basic types to implement interfaces.
module traits;
import traits_impl;
import std.typecons;
void main() {
MyInt i = 0x34342343;
writebytes(i);
writebytes2(1);
@rjmcguire
rjmcguire / switch_window_by_app.sh
Created September 21, 2015 15:48
switch between windows of current application
#!/bin/bash
# from: https://lars.st0ne.at/blog/switch%20between%20windows%20within%20the%20same%20application
# get id of the focused window
active_win_id=$(xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}')
if [ "$active_win_id" = "0" ]; then
active_win_id=""
fi
# get window manager class of current window
@rjmcguire
rjmcguire / opengl-transparency-demo.cpp
Created September 25, 2015 21:31 — forked from wilkie/opengl-transparency-demo.cpp
Rendering directly to a composited window in vista+ with opengl.
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <windowsx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <dwmapi.h>
#pragma comment (lib, "opengl32.lib")
@rjmcguire
rjmcguire / argb_opengl_window.c
Created September 25, 2015 21:33
Opengl window with transparency in X11
// originally from here: http://stackoverflow.com/questions/9363491/how-to-make-transparent-window-on-linux
/*------------------------------------------------------------------------
* A demonstration of OpenGL in a ARGB window
* => support for composited window transparency
*
* (c) 2011 by Wolfgang 'datenwolf' Draxinger
* See me at comp.graphics.api.opengl and StackOverflow.com
* License agreement: This source code is provided "as is". You
* can use this source code however you want for your own personal
@rjmcguire
rjmcguire / connectHTMLelements_SVG.png
Created July 10, 2016 06:36 — forked from alojzije/connectHTMLelements_SVG.png
Connect two elements / draw a path between two elements with SVG path (using jQuery)
connectHTMLelements_SVG.png
https://github.com/darylrowland/react-native-remote-push
https://facebook.github.io/react-native/docs/pushnotificationios.html
Pubnub can also do realtime chat, but it's a relatively expensive service.
The node.js server can be augmented with socket.io and function as a real-time chat server.
Amazon SNS https://aws.amazon.com/sns/
https://aws.amazon.com/sns/pricing/ (faily cheap and works for all platforms, plus we'd get tech support at the loft)
@rjmcguire
rjmcguire / GoMgoSample-1.go
Created August 4, 2016 13:58 — forked from ardan-bkennedy/GoMgoSample-1.go
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {