Skip to content

Instantly share code, notes, and snippets.

$("a.select-user")
.fancybox(
{type: 'deferred',
promise:
function () {
that.view = new App.Views.Admin.Popups.selectUserView({el: $("#fancybox-content"),
order: that.order,
member: that.order.member});
return that.view.renderTemplate();
},
$.fn.makeInputToggle = function () {
this.each(function () {
var $this = $(this);
if ($this.data("inputToggled")) {
/* avoid double input toggle handling */
return;
}
/* click on the previous text span or element */
$this.hide().prev().click(function () {
@wesen
wesen / test.cpp
Created September 21, 2011 10:28
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte gateway[] = { 10, 0, 0, 1 };
byte subnet[] = { 255, 255, 0, 0 };
Server server = Server(23);
@wesen
wesen / propositional.lisp
Created November 5, 2011 11:23
Propositional logic
(in-package :cl-user)
(definfix or :precedence 50)
(definfix and :precedence 40)
(definfix not :precedence 30)
(definfix => :precedence 60)
(definfix <=> :precedence 70)
(defun implies (a b)
(or (not a) b))
@wesen
wesen / rb.cpp
Created November 18, 2011 18:46
#include <iostream>
#include <inttypes.h>
template<bool C, typename Ta, typename Tb>
class IfThenElse;
template <typename Ta, typename Tb>
class IfThenElse<true, Ta, Tb> {
public:
typedef Ta ResultT;
@wesen
wesen / dispatch
Created January 12, 2012 14:41
Selectively enable/disable Xdebug for different resources
$uri = request_uri();
$DISABLE_XDEBUG_DIRS = array("/js/", "/resource/", "/rest/", "/css/", "/item/");
$ENABLE_XDEBUG_DIRS = array();
$disableXdebug = false;
$enableXdebug = false;
$dir = "/";
foreach ($DISABLE_XDEBUG_DIRS as $dir) {
if (str_starts_with($uri, $dir)) {
$disableXdebug = true;
break;
#
# generic AVR makefile
#
# (c) July 2011 - Manuel Odendahl - wesen@ruinwesen.com
#
# include this into your main Makefile, after having defined TARGET and TARGET_OBJS
all: $(TARGET).hex
@wesen
wesen / git-hub-blame
Created January 13, 2012 13:14
Open a commit for a line of a file on github
#!/bin/sh
#
# Usage: git hub-blame file line
#
# Opens the commit where the given line originates in the commit view. Useful for
# code review on github.
FILENAME=$1
LINE=$2
#ifndef MUTEX_H__
#define MUTEX_H__
#include "common.h"
#include <wirish/wirish_time.h>
/**
* Simple atomic swap memory mutex
*/
class Mutex {
m (7037) ~$ howdoi -a macro do while
Answer found in google's first hit: http://bytes.com/groups/c/219859-do-while-0-macro-substitutions Andrey Tarasevich: The whole idea of using 'do/while' version is to make a macro which will
expand into a regular statement, not into a compound statement. This is
done in order to make the use of function-style macros uniform with the
use of ordinary functions in all contexts. Consider the following code sketch if (<condition>)
foo(a);
else
bar(a); where 'foo' and 'bar' are ordinary functions. Now imagine that you'd
like to replace function 'foo' with a macro of the above nature if (<condition>)
CALL_FUNCS(a);