Skip to content

Instantly share code, notes, and snippets.

@hiroshi-maybe
hiroshi-maybe / circular-reference-detect.js
Created February 19, 2013 10:38
Detect circular reference of linked list in Javascript.
/*
* circular-reference-detect.js
* author: Hiroshi Kori
*
* Detect circular reference of linked list
*
* 1) Overview
* - Reverse linked-list until finding a node whose next pointer is null.
* - Chekck the head node if its next pointer is null
* 1) null: the node is not traversed twice. (no circular reference)
@SEJeff
SEJeff / gist:4207694
Created December 4, 2012 19:19
Testing jinja from the python interactive shell
>>> from jinja2 import Template
>>> tmpl = """{% if name != "Jeff" %}Nothing to see here move along{% else %}
... hello {{name}}, how are you?{% endif %}"""
>>> template = Template(tmpl)
>>> print template.render({"name": "Jeff"})
hello Jeff, how are you?
>>> print template.render({"name": "John"})
Nothing to see here move along
>>>
@jadell
jadell / socket_file.sh
Created March 15, 2011 21:22
Read and write to a socket using only Bash
#!/bin/bash
#
# Bash must have been compiled with this ability: --enable-net-redirections
# The device files below do not actually exist.
# Use /dev/udp for UDP sockets
exec 3<>/dev/tcp/host/port
# Write to the socket as with any file descriptor
echo "Write this to the socket" >&3