How to get a JavaScript object’s class?

There’s no exact counterpart to Java’s getClass() in JavaScript. Mostly that’s due to JavaScript being a prototype-based language, as opposed to Java being a class-based one. Depending on what you need getClass() for, there are several options in JavaScript: typeof instanceof obj.constructor func.prototype, proto.isPrototypeOf A few examples: Note: if you are compiling your code with Uglify it will change non-global class names. To …

Read more

What is a “slug” in Django?

A “slug” is a way of generating a valid URL, generally using data already obtained. For instance, a slug uses the title of an article to generate a URL. I advise to generate the slug by means of a function, given the title (or another piece of data), rather than setting it manually. An example: …

Read more

Found a swap file by the name

Looks like you have an open git commit or git merge going on, and an editor is still open editing the commit message. Two choices: Find the session and finish it (preferable). Delete the .swp file (if you’re sure the other git session has gone away). Clarification from comments: The session is the editing session. You can see what .swp is being used by entering …

Read more

What is the difference between sed and awk?

sed is a stream editor. It works with streams of characters on a per-line basis. It has a primitive programming language that includes goto-style loops and simple conditionals (in addition to pattern matching and address matching). There are essentially only two “variables”: pattern space and hold space. Readability of scripts can be difficult. Mathematical operations are …

Read more