Skip to content

Instantly share code, notes, and snippets.

// specify it under conversation style
.conversation {
header {
padding-top: 12px;
padding-bottom: 12px;
}
}
// specify it explicitly
header.single-line {
@stantona
stantona / covo_card.haml
Created September 20, 2012 17:26
check for cover image
%header{class: topic.cover_image? ? 'coverimage' : ''}
-if topic.cover_image?
%figure.img-canvas-small
=image_tag(comment.topic.cover_image)
-# I want this execute seperately, but nested in header
%article
%h2
-if comment.conversation.subject?
%a.title{ href: conversation_path(comment.conversation, anchor: comment.id.to_s), 'data-pjax' => '#container' }
@stantona
stantona / gist:4197676
Created December 3, 2012 20:15
Coffeescript inheritance.
__extends = function(child, parent) {
__hasProp = {}.hasOwnProperty
for (var key in parent) {
if (__hasProp.call(parent, key))
child[key] = parent[key];
}
function ctor() {
this.constructor = child;
### The current context
The value of `this` in a javascript function call depends on the *execution context* of the function. If we take the above execution of `Simple()` but exclude the new keyword,
`this` would refer to the global object and the `name` property would be added to that object. In a browser the global object is `window`, so in this example, name would be a property of
the `window` object:
``` javascript
Simple();
console.log(window.name);
=> "Adam"
@stantona
stantona / ring.erl
Last active December 17, 2015 12:59
-module(ring).
-export([start/2, forward_to/1]).
start(Number, Iterations) ->
Pid = create_processes(Number-1),
Pid ! msg,
forward_to(Pid, Iterations, 0).
create_processes(Number) ->
io:format("spawning ~p processes...~n", [Number]),
-module(process_exc).
-export([start/1, proc/1]).
start(M) ->
N1 = spawn(process_exc, proc, [M]),
N2 = spawn(process_exc, proc, [M]),
N1 ! {N2, ping}.
proc(M) ->
proc(M, 0).
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define MAX_DATA 512
#define MAX_ROWS 100
struct Address {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void die(const char *message)
{
if(errno) {
perror(message);
} else {
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
#define debug(M, ...)
#else
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
#define debug(M, ...)
#else