Skip to content

Instantly share code, notes, and snippets.

def safe_get(_dict, _key, _type):
val = _dict.get(_key, None)
try:
return _type(val)
except TypeError:
return _type()
def DFS(depth=0, state=None):
if check_state_is_valid(depth, state):
report_found(state)
if depth >= target_depth:
return
for next_step in possible_steps(depth, state):
current_state = state
apply_step_on_state(next_step, state)
== Parsed Logical Plan ==
Aggregate [count(1) AS count#720L]
+- Join Inner, (id#409L = id#413L)
:- SubqueryAlias a
: +- Range (0, 100000000, splits=8)
+- SubqueryAlias b
+- Range (0, 100000000, splits=8)
== Analyzed Logical Plan ==
count: bigint
>
val result = tableA.join(tableB, $"a.id" === $"b.id").groupBy().count()
result.explain(true)
== Parsed Logical Plan ==
Aggregate [count(1) AS count#550L]
+- Join Inner, (id#201L = id#205L)
:- SubqueryAlias a
: +- Range (0, 100000000, splits=3)
def record_queryset_action(request, queryset, action):
failures = []
for item in queryset:
try:
action(item, request)
except:
failures.append(item)
return failures
def makeflag():
flag = 1
while True:
yield flag
flag = flag << 1
flag = makeflag()
E_GLASS_RN_STATE_INITIAL = next(flag)
E_GLASS_RN_STATE_WEAKENED = next(flag)
E_GLASS_RN_STATE_SHATTERING = next(flag)
E_GLASS_RN_STATE_ACTIVE_FRAGS = next(flag)
from __future__ import print_function
import cv2
from googleapiclient import discovery
import httplib2
from oauth2client.client import GoogleCredentials
import base64
from PIL import Image
from PIL import ImageDraw
from matplotlib import pyplot as plt
from os import system

Keybase proof

I hereby claim:

  • I am andyfangdz on github.
  • I am andyfang (https://keybase.io/andyfang) on keybase.
  • I have a public key whose fingerprint is 56D7 D05D 65F4 4640 7C59 B9CA 60FC FCB3 7A52 31B4

To claim this, I am signing this object:

@andyfangdz
andyfangdz / Alzheimer.ipynb
Last active January 21, 2016 22:28
Alzheimer.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfangdz
andyfangdz / text.md
Created December 2, 2015 23:26
Git as C++ Package Manager

Have you considered Git as a package manager? I've been using git submodules for dependencies and sub-dependencies and combined with free git hosting services, the idea is quite powerful.

Just go into your git project,

git submodule add git://somehosting.com/you/package.git
git submodule init package
git submodule update package
cd package && ./configure --stuff && make && cd ..

To select particular dependency versions,