Skip to content

Instantly share code, notes, and snippets.

View kashifrazzaqui's full-sized avatar

Kashif Razzaqui kashifrazzaqui

View GitHub Profile
Logging is used for 3 primary goals
* debugging
* tracing - understanding execution flow of the program in real life
* checking inputs
There are better tools available for all these three tasks for most usecases
Lets see each case.
Debugging - When a bug is reported the first order of business is to write a test case that fails and this failure clearly indicates that the bug is present - the code is then modified till this test passes (and no other ones fail) - no need for logging
@kashifrazzaqui
kashifrazzaqui / superbasic java
Created May 6, 2016 09:48
Java basics you MUST know
super basic java
- braces
- define scope
- no masking/shadowing but new variables are welcome
"public void kewl()
{
int x = 7;
{
int x = 8; //Illegal masking
code design guidelines
- when designing libraries its better to leave threads out but not always
- realize that your users may have varying threading strategies and your lib should not prescribe or assert one lest it resists reuse
- typical novice problems
- http://joostdevblog.blogspot.in/2015/01/what-most-young-programmers-need-to.html
- liar variables, methods, classes
- muddy classes
- oversized classes
- code in comments
@kashifrazzaqui
kashifrazzaqui / gist:b9be12e6163023da2bab
Last active August 29, 2015 14:21
Setup for Project Modern
* https://www.python.org/
* https://www.python.org/about/gettingstarted/
* Install postgres using this
$ brew install postgres
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
* Install pgAdmin3
* http://www.postgresql.org/ftp/pgadmin3/release/v1.20.0/osx/
@kashifrazzaqui
kashifrazzaqui / pythoncompanies
Created May 11, 2015 16:21
Who uses Python?
New startups use Python – MonkeyLearn, Roomstorm
Established startups use Python – Hipmunk, Buffer, Mattermark
Unicorns use Python – Instagram, Pinterest, Spotify, Uber
Food startups use Python – Chewse, Yelp
Dev tools use Python – Sentry, Keen IO
Tech titans use Python – Dropbox, PayPal, Google
Creatives use Python – YouTube, edX, Walt Disney Animation Studios
Defense contractors use Python – Northrop Grumman
Corporate giants use Python – Walmart
Media news sites use Python – Pitchfork, BuzzFeed
@kashifrazzaqui
kashifrazzaqui / code_review_checklist.txt
Last active February 17, 2024 23:05
Code Review Checklist
- General
[ ] The code works
[ ] The code is easy to understand
[ ] Follows coding conventions
[ ] Names are simple and if possible short
[ ] Names are spelt correctly
[ ] Names contain units where applicable
[ ] Enums are used instead of int constants where applicable
[ ] There are no usages of 'magic numbers'
[ ] All variables are in the smallest scope possible
@kashifrazzaqui
kashifrazzaqui / BitmapFileLoader.java
Created February 4, 2015 04:36
Scaling a bitmap in android
import android.graphics.*;
import android.net.Uri;
public class BitmapFileLoader
{
public static Bitmap loadFromUri(Uri fileUri, float maxWidth, float maxHeight)
{
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(fileUri.getPath(), options);
@kashifrazzaqui
kashifrazzaqui / gist:3774773
Created September 24, 2012 07:32
Joel Spolsky on "Smart and gets things done"
OK, I didn’t tell you the most important part—how do you know whether to hire someone?
In principle, it’s simple. You’re looking for people who are
Smart, and
Get things done.
That’s it. That’s all you’re looking for. Memorize that. Recite it to yourself before you go to bed every night. You don’t have enough time to figure out much more in a short interview, so don’t waste time trying to figure out whether the candidate might be pleasant to be stuck in an airport with, or whether they really know ATL and COM programming or if they’re just faking it.
People who are Smart but don’t Get Things Done often have PhDs and work in big companies where nobody listens to them because they are completely impractical. They would rather mull over something academic about a problem rather than ship on time. These kind of people can be identified because they love to point out the theoretical similarity between two widely divergent concepts. For example, they will say, “Spreadsheets are really just a special case of prog
class PrototypeStore(dict):
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class PrototypeMeta(type):
def __new__(metacls, cls_name, bases, attrs):
cls = type.__new__(metacls, cls_name, bases, attrs)
import jsonpickle
import domain
"""
Based on the premise that any object can be identified by its class name and
a the value of a unique attribute (primary key) which is here reffered to as the identity
"""
def make_attribute_key(obj,attribute):
"""