Skip to content

Instantly share code, notes, and snippets.

Verify Github on Galxe. gid:6QTfuzjMGLFPf48odykKgk

0x059c21e080e00802736c0b5518acd7184b4ebdb99f475fc7e3898677d7c6fa2a

@mhluongo
mhluongo / ApprovalTarget.sol
Last active May 21, 2023 18:28
Tally ApprovalTarget
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./IApprovalTarget.sol";
import "./EIP712Helper.sol";
/// @notice ApprovalTarget is an immutable contract that accepts token approvals
Verifying that "mhluongo.id" is my Blockstack ID. https://onename.com/mhluongo
Verifying that +mhluongo is my Bitcoin username. You can send me #bitcoin here: https://onename.io/mhluongo
@mhluongo
mhluongo / keybase.md
Created May 19, 2014 17:36
keybase.md

Keybase proof

I hereby claim:

  • I am mhluongo on github.
  • I am mhluongo (https://keybase.io/mhluongo) on keybase.
  • I have a public key whose fingerprint is 4821 DDEA 0EBC 82D4 1FF6 4494 4E70 50F4 BBE7 9624

To claim this, I am signing this object:

@mhluongo
mhluongo / api.py
Last active December 18, 2015 13:19
A quick example using neo4django with tastypie adapted from the tastypie tutorial (http://django-tastypie.readthedocs.org/en/latest/tutorial.html).
from tastypie.resources import ModelResource
from .models import Entry
class EntryResource(ModelResource):
class Meta:
queryset = Entry.objects.all()
resource_name = 'entry'
@mhluongo
mhluongo / example
Last active December 17, 2015 19:59
Some relationship magic to make modeling easier for situations where you want to aggregate across multiple rel-types in one relationship field. This is a very not-supported / non-standard approach, and could be broken in future versions of neo4django.
>>> from .models import Family, Person
>>>
>>> family_1 = Family.objects.create(status='married')
>>> family_2 = Family.objects.create()
>>>
>>> pete = Person.objects.create(name='Pete')
>>> mary = Person.objects.create(name='Mary')
>>>
>>> family_1.spouses.add(pete, mary)
>>> family_2.children.add(pete)
import neo4django
from neo4django.db import models
class Preceding(models.NodeModel):
precedes_events = models.Relationship('Event', rel_type=neo4django.Outgoing.PRECEDES_EVENT,
related_name='preceded_by')
precedes_conditions = models.Relationship('Condition', rel_type=neo4django.Outgoing.PRECEDES_CONDITION,
related_name='preceded_by')
class Event(Preceding):
@mhluongo
mhluongo / gist:4645421
Last active December 11, 2015 18:58
A quick bit of Cypher demonstrating how you can change the default null-ordering in ORDER BY. Note that the trick is in the null predicate and STR cast.
START n=node({startId})
MATCH (n)-[?:DID]->(thing)
WITH thing, (thing.year? = null) AS year_is_null
WITH thing, STR(year_is_null) as null_year
ORDER BY null_year, thing.year? DESC
RETURN thing, thing.year? as year