Skip to content

Instantly share code, notes, and snippets.

@mattbriancon
mattbriancon / pythonic-django.md
Last active August 29, 2015 14:15
Pythonic Django
@mattbriancon
mattbriancon / keybase.md
Created September 23, 2014 13:32
keybase.md

Keybase proof

I hereby claim:

  • I am mattbriancon on github.
  • I am mattbriancon (https://keybase.io/mattbriancon) on keybase.
  • I have a public key whose fingerprint is 61EA CEA3 2D7C C1C4 97B9 3FE7 69B3 5975 F682 D8A7

To claim this, I am signing this object:

def hasattrs(obj, attrs):
for attr in attrs.split('.'):
if not hasattr(obj, attr):
return False
obj = getattr(obj, attr)
return True
@mattbriancon
mattbriancon / optics.py
Last active December 19, 2015 07:49 — forked from ryangomba/optics.py
import math
import json
################################################################################
# POINT
################################################################################
class Point:
def __init__(self, latitude, longitude):
#include <stdio.h>
struct entry
{
int value;
struct entry *next;
};
void insertAfter(struct entry * newEntry, struct entry * targetEntry) {
#include <stdio.h>
struct entry
{
int value;
struct entry *next;
};
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<fragment class="com.domain.MyFragment"
android:id="@+id/myfragment"
android:layout_width="match_parent"
@mattbriancon
mattbriancon / c.py
Created May 14, 2012 21:13
C.c in Python using single comments file (barely tested)
#!/usr/bin/env python
# works with python2.6+
import argparse
import json
import os
_COMMENT_FILE = os.path.expanduser('~/.comments')
@mattbriancon
mattbriancon / gist:1780940
Created February 9, 2012 16:32
Find running Activities
ActivityManager mgr = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = mgr.getRunningTasks(100);
int num = 0;
for(ActivityManager.RunningTaskInfo i : tasks) {
String ACT = "com.your.package/com.your.package.MainActivity";
if(i.topActivity.flattenToString().equals(ACT))
num = i.numActivities;
}