Skip to content

Instantly share code, notes, and snippets.

View berkerpeksag's full-sized avatar

Berker Peksag berkerpeksag

  • Helsinki, Finland
View GitHub Profile
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.
@allenwb
allenwb / minimalist-classes.js
Created November 2, 2011 03:04 — forked from BrendanEich/minimalist-classes.js
less minimalism, richer leather
//work in progress
// A response to jashkenas's fine proposal for minimalist JavaScript classes.
// and BrendanEich's Rich Corinthian Leather alternative proposal
//intro and justifications still to come
// Harmony always stipulated classes as sugar, so indeed we are keeping current
// JavaScript prototype semantics, and classes would only add a syntactic form
// that can desugar to ES5. This is mostly the same assumption that Jeremy
@pervognsen
pervognsen / deque.c
Created December 10, 2011 23:10
bounded deque
#include <stdlib.h>
#include <assert.h>
typedef struct deque
{
int left, right;
int size;
void **data;
} deque;
@DmitrySoshnikov
DmitrySoshnikov / no-such-method-analysis.js
Created December 15, 2011 13:01
Analysis of current noSuchMethod situation
// by Dmitry Soshnikov <[email protected]>
// on "noSuchMethod" hook via proxies
// written on December 15, 2011
// Below is tl;dr
// but if you want really never-ending tl;dr, try this
// original old thread from 2010 on es-discuss:
// https://mail.mozilla.org/pipermail/es-discuss/2010-October/011929.html
// Small disclaimer and note:
@hrldcpr
hrldcpr / tree.md
Last active June 19, 2025 08:17
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

class Reader:
def __init__(self, form):
self.form = form
self.index = 0
def seek_char(self):
if self.index >= len(self.form):
return None
return self.form[self.index]
# list_detail.object_list replacement with all the things I need
def object_list(request, queryset, extra_context=None,
template_name='', paginate_by=None):
class ObjectList(ListView):
def post(self, request, *args, **kwargs):
return self.get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
c = super(ObjectList, self).get_context_data(**kwargs)
@akheron
akheron / python-tracker-stats.py
Created May 18, 2012 07:42
Python tracker statistic plotter
# Search for statistic messages from the Python trakcer robot in
# python-dev archives and plot the result.
#
# $ python-traker-stats.py collect
#
# Collects statistics from the mailing list and saves to
# python-tracker-stats.json
#
# $ python-tracker-stats.py plot
#
def _simple_processor(processor, ext_private, ext_public):
if not request.path.endswith(ext_public):
return
public_file = request.path[len(config.app.static_url_path) + 1:]
public_file_path = os.path.join(config.app.static_folder, public_file)
private_file_path = public_file_path[:-len(ext_public)] + ext_private
# File does not exist in app static - check blueprints.
if not os.path.isfile(private_file_path):
for blueprint_name, blueprint in config.app.blueprints.iteritems():
if request.path.startswith(blueprint.static_url_path):
@joewalker
joewalker / bootstrap.js
Created June 17, 2012 13:56
Hello Command
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource:///modules/devtools/gcli.jsm");
var helloCommandSpec = {
name: 'hello',
description: 'Show a message',
params: [
{