Skip to content

Instantly share code, notes, and snippets.

@garak
garak / list.html.twig
Last active September 9, 2024 21:51 — forked from tentacode/list.html.twig
Twig recursive macro
{% macro recursiveCategory(category) %}
{% import _self as self %}
<li>
<h4><a href="{{ path(category.route, category.routeParams) }}">{{ category }}</a></h4>
{% if category.children|length %}
<ul>
{% for child in category.children %}
{{ self.recursiveCategory(child) }}
{% endfor %}
@michaelames
michaelames / gist:f16ee975ddad15cf3527
Created April 28, 2015 15:46
Simplest possible example of Java authentication to LDAP Server (including Active Directory)
import java.util.Hashtable;
import java.io.Console;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class TestAuth {
public static void main(String[] args) {
@milosdakic
milosdakic / sequelize-mixins.js
Created September 5, 2013 08:34
Sequelize model mixins
var User = sequelize.define('User', {
name: Sequelize.STRING
}, {
// define the mixins you want to include
// could be similar to sequelize.import()
mixins: [
'CreatedAt',
...
]
] });
@willurd
willurd / web-servers.md
Last active September 19, 2024 12:43
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@oscarryz
oscarryz / gist:4121184
Created November 20, 2012 21:14
Brief history of Objective-C square brackets

Brief history of the "square brackets" as I remember it.

One of the most challenging aspects of the language are the square brackets because they look like arrays, as you just mention.

As I remember the language was inspired in smalltalk, but using C to gain speed.

The idea behind smalltalk was to send message as we do with real life objects. For instance if I ask you your age I would say something like this in natural language: