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
local fs = require("nixio.fs") | |
local socket = require("socket") | |
fs.writefile("/sys/class/gpio/export","20") | |
fs.writefile("/sys/class/gpio/gpio20/direction","out") | |
fs.writefile("/sys/class/gpio/gpio20/value","1") | |
fs.writefile("/sys/class/gpio/export","19") | |
fs.writefile("/sys/class/gpio/gpio19/direction","out") |
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
Index: scripts/feeds | |
=================================================================== | |
--- scripts/feeds (revision 44245) | |
+++ scripts/feeds (working copy) | |
@@ -118,10 +118,10 @@ | |
'update' => "", | |
'revision' => "echo -n 'local'"}, | |
'src-git' => { | |
- 'init' => "git clone --depth 1 '%s' '%s'", | |
- 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'", |
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 grab_camera_texture(camera): | |
print(camera.texture_size, camera.texture) | |
nparr = np.fromstring(camera.texture.pixels, dtype=np.uint8) | |
a = np.reshape(nparr, (camera.texture_size[1], camera.texture_size[0], 4)) | |
# a = nparr | |
a = cv2.cvtColor(a, cv2.cv.CV_RGBA2RGB) | |
# cv2.imshow("asd", a) | |
print(camera.texture.colorfmt, camera.texture.bufferfmt) | |
camera.play = False |
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
import kivy.core.image.img_sdl2 | |
old_extensions = kivy.core.image.img_sdl2.ImageLoaderSDL2.extensions | |
@staticmethod | |
def new_extensions(): | |
'''Return accepted extensions for this loader''' | |
return old_extensions()+('jpe',) | |
kivy.core.image.img_sdl2.ImageLoaderSDL2.extensions = new_extensions |
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
import contextlib | |
import AccessControl | |
import AccessControl.SecurityManagement | |
@contextlib.contextmanager | |
def sudo(user): | |
""" | |
Context manager allowing to execute operations as specified user. |
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 result(O): | |
r='D' | |
for d in(O,zip(*O[::-1])): | |
if d[0][0]==d[1][1]==d[2][2]:r=d[0][0] | |
for R in d: | |
if len(set(R))<2: | |
r=R[0] | |
return r |
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
result=lambda A:{ | |
'10 2 * 20 - 2 -':-2., | |
'2 3 ^ 5 7 * / 10 +':10.23, | |
'2.22 42.42 3.3 * +':142.21, | |
'100 8.8 * 60 2 / - 142.22 + 3.3 2 ^ -':981.33, | |
}[A] | |
result=lambda A:{' ':-2.,'3':10.23,'2':142.21,'0':981.33}[A[2]] |
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
""" | |
Serialize data to/from JSON iteratively | |
""" | |
from __future__ import absolute_import, unicode_literals | |
import sys | |
import ijson | |
from django.core.serializers.base import DeserializationError |
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
""" | |
Django database routers module | |
""" | |
class AppDBRouter: | |
""" | |
Route by application label. | |
""" | |
APP_TO_DB = {} |
OlderNewer