Skip to content

Instantly share code, notes, and snippets.

class testClass(object):
numero = 5
def __init__(self, string):
self.stringa = string
def printClass(self):
print "Numero = %d" % self.number
print "Stringa = %s" % self.stringa
package main
import (
"fmt"
"math"
)
type Kernel [9]float64
type MaskFunc func(x float64, y float64) float64

Proposed Meta interface

Refactoring Options to provide a public, simpler and maintainable API

In the next 3 months as part of my Summer of Code project, I will be refactoring Meta to a stable and public API. Based on this, I have come up with a draft API spec that provides (to my belief) the following:

  • Simplicity

    There are too many ways to access fields and attributes, this leads to a lot of internal complexity that must be greatly simplified.g

  • Future-proof

Currently, the getter functions and accessors for fields are tailored to the needs of Django internals, instead of creating functions that only support these, we intruduce the concept of predicates, that can be used to create custom filtering ad-hoc for the single case. This will avoid having to create new functions in the future that increase the complexity of Meta, as get_fields and every predicate will be designed to be loosely coupled.

package main
import (
"fmt"
"net/http"
zmq "github.com/alecthomas/gozmq"
"encoding/json"
)
func MakePhrase(s string) ([]byte, error) {
@PirosB3
PirosB3 / options.py
Last active August 29, 2015 14:01
API spec 2

Meta API Spec

INTERFACE

2 main API calls, get_fields and get_field.

>>> get_fields(types, opts, **kwargs)
(
  (field_name, field_instance),
  (field_name, field_instance),
" This is Gary Bernhardt's .vimrc file
" vim:set ts=2 sts=2 sw=2 expandtab:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
set hidden
set history=10000
set noautoindent
# RELATED_OBJECTS
class BaseRelatedModel(models.Model):
name_base = models.CharField(max_length=10)
class FirstRelatingObject(models.Model):
model_base_first = models.ForeignKey(BaseRelatedModel)
class FirstRelatingHiddenObject(models.Model):
@PirosB3
PirosB3 / gist:98b1952101fc4d1c4797
Created June 1, 2014 23:46
Problem A. Store Credit
package main
import (
"fmt"
"flag"
"bufio"
"strconv"
"strings"
"sync"
"os"
from __future__ import unicode_literals
from bisect import bisect
from collections import OrderedDict
from django.apps import apps
from django.conf import settings
from django.db.models.fields.related import ManyToManyRel
from django.db.models.fields import AutoField, FieldDoesNotExist
from django.db.models.fields.proxy import OrderWrt
#!/bin/bash
echo "STASHING.."
git stash
echo "BUILDING.."
rm -Rf /tmp/jekyll-build
jekyll build --destination /tmp/jekyll-build
echo "DEPLOYING..."
git --git-dir /tmp/jekyll-build/.git init .