Skip to content

Instantly share code, notes, and snippets.

View JustinTArthur's full-sized avatar

Justin Turner Arthur JustinTArthur

View GitHub Profile
var app = angular.module('app', ['appControllers', 'appServices']);
var services = angular.module('appServices', ['djangoRESTResources']);
services.factory('Team', ['djResource',
// Or if you still need $resource to communicate with a different backend:
indices[] ||= 0
+ # Set depths based on left/right nesting:
+ if
+ get_depths_sql = "SELECT #{quoted_table_name}.#{primary_key}, COUNT(parent.#{primary_key}) -1 AS #{quoted_depth_column_name}
+ FROM #{quoted_table_name}, #{quoted_table_name} AS parent
+ WHERE #{quoted_table_name}.#{quoted_left_column_name} BETWEEN parent.#{quoted_left_column_name} AND parent.#{quoted_right_column_name}"

Keybase proof

I hereby claim:

  • I am justintarthur on github.
  • I am justintarthur ( on keybase.
  • I have a public key whose fingerprint is 9E92 D2B9 2DBF 37AC 60BB 5027 DA45 B72D 195B 2168

To claim this, I am signing this object:

JustinTArthur /
Created October 16, 2015 20:58
High-S vs Low-S ECDSA Signatures in Electrum <2.5
Uses the same ecdsa library and hashing as Electrum <2.5 and approximates how likely a high-s
signature is to be produced.
Needs same dependencies as electrum, so can be run in the same virtualenv as electrum.
import ecdsa
from random import randint
from os import urandom
JustinTArthur /
Created March 20, 2013 22:37
A Django model serializer for Django REST Framework that will serialize lists in the format that Ember.js expects in its JSONs. This is not the best way to go about this, but is a very fast way to get your stuff working. The biggest caveat is that if you use one of these serializers nested inside another with many=True, the resulting format will…
class EmberModelSerializer(serializers.ModelSerializer):
A serializer that formats list data in a way that will be readable by Ember.js.
def get_class_ember_name(cls):
type_name = cls.__name__.replace('Serializer','')
return type_name.lower()
JustinTArthur /
Last active June 28, 2017 21:17
Java for checking the password of a user against a typical Django user table entry
// Assumes an encoded password entry that looks like:
// pbkdf2_sha256$13000$I2fysbVVZ$6WuU/biq8RveLuiTgpLeEJ7hcqoqpkqVlpUIHWUoi9I=
String[] encodedPassword = passedInPassword.split("\\$");
int encodedIterations = Integer.parseInt(encodedPassword[1]);
byte[] encodedSalt = encodedPassword[2].getBytes(Charset.forName("UTF-8"));
String encodedHash = encodedPassword[3];
SecretKeyFactory f = null;
try {
JustinTArthur /
Last active February 8, 2019 23:45
Script to run a Python script in EB context
source /opt/python/run/venv/bin/activate
source /opt/python/current/env
if [ -f /etc/elasticbeanstalk/ ]; then
source /etc/elasticbeanstalk/
exec python "$@"
JustinTArthur / 0 - signal_wait_kernel.hsail
Last active March 22, 2022 19:50
Radeon R600 GPU Code for Signal Waiting
module &signal:1:0:$full:$large:$default;
extension "amd:gcn";
extension "IMAGE";
// Sample Kernel From Michael Körber
prog kernel &__signal_test_kernel(
kernarg_u64 %val,
kernarg_sig64 %handle_in,
kernarg_sig64 %handle_out)
JustinTArthur /
Last active April 15, 2024 11:43
A Django 1.4+ view function that acts as a reverse proxy. Great for testing locally or for using as a starting point to code that needs to cache or manipulate the proxied response. If one needs to proxy in production without any response manipulation, performing this in the web container (like nginx or apache) would be recommended instead of thi…
from django.views.decorators.csrf import csrf_exempt
def reverse_proxy(request):
Reverse proxy for a remote service.
path = request.get_full_path()
#Optionally, rewrite the path to fit whatever service we're proxying to.