This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
[foo,bar] = TNG(foo,bar); | |
// NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's | |
// basically like a "custom hook" that can be called only from other | |
// TNG-wrapped functions | |
function foo(origX,origY) { | |
var [x,setX] = useState(origX); | |
var [y,setY] = useState(origY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_array(arr): | |
output = [] | |
for val in arr: | |
if type(val) == list: # is the current value we are looking at is also a list | |
output.extend(flatten_array(val)) # then recursive call itself to start from | |
# the beginning and use python list extend | |
else: | |
output.append(val) # ok this is not a list just append to the bottom | |
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Thing(models.Model): | |
# [ snip ] | |
def is_deletable(self): | |
for rel in self._meta.get_all_related_objects(): | |
if rel.model.objects.filter(**{rel.field.name: self}).exists(): | |
return False | |
return True |