Creating nested forms in Django Admin

I recently came across the need to let admins create/edit specific objects from Django admin with an inline formset (nested forms). In Rails, this can be accomplished by simply doing this. accepts_nested_attributes_for :model Things are a little bit different in Django. As opposed to Rails, Django provides an admin interface by default but getting the same to work in a nested way isn’t very obvious. class Provider(models.Model): name = models.CharField(max_length=100) slug = models.
Read more →

Customize rails find_in_batches

Today I ran into an issue while reading a quite significant mysql database table. I needed to fetch the records in batches so the good old find_in_batches method in rails ActiveRecord came into picture. Now the actual problem surfaced, as the lookup table was not having any sort of ID column present, the find_in_batches kept throwing an error Invalid Statement. After some debugging it came to light that find_in_batches by default only works with Integer only Primary Key fields, as it uses order to order the records as per the Integer Primary Key column.
Read more →

Clojure Namespaces - “require”

Loads a namespace if not already loaded. It takes an argument(symbol) which should be a quoted (require 'clojure.string) ;; => nil After requiring a namespace, we need to refer the functions in a fully qualified names. Like, (require 'clojure.string) ;; => nil (clojure.string/split "This is an example of require" #" " ) ;; => ["This" "is" "an" "example" "of" "require"] Other way is to alias a namespace at the time of requring using as.
Read more →

A Clojure Story - Collections (Vectors)

Vectors are another data structures from the clojure collections. They are indexed and are surrounded by [] brackets and unlike lists they do not need to be quoted. [1 2 3] ; => [1 2 3] ;; another way to creating vectors (vector "a" "b" "c") ; => [1 2 3] (type ["a" "b" "c"]) ; => clojure.lang.PersistentVector Important to note that: (vector? ["a" "b" "c"]) ; => true ;; vectors are collections (coll?
Read more →

A Clojure Story - Collections (Lists)

Being fairly new to clojure ecosystem. I thought it would be better to be dedicating a post to each of the data structures in Clojure. Clojure has the following data structures ;; Lists ;; Vectors ;; Hashmaps ;; Sets These are concrete data types, which are implementation of abstract data types. This post will try to scratch the surface of - LISTS LISTS As the name goes, are a collection of group of values.
Read more →

A Clojure Story - Basic Data Types

Clojure Data Types : Type A type is property some values share to collect all similar things. Every language has a type system. Some langugages have strict type system, some are relaxed. Clojure is a dynamic and strongly typed language: Dynamic - As the type checking is enforced on the fly/run time. Strong - As operations on improper types are not allowed and errored out. type function in clojure helps knowing what is the type of the expression.
Read more →

ruby-debug with ruby 1.9.3

Read more →

Unpacking String#UNPACK in Ruby!!

Read more →