Skip to content

Instantly share code, notes, and snippets.

View 0mars's full-sized avatar

Omar Shaban 0mars

View GitHub Profile
@0mars
0mars / python-1.0-setup
Last active November 27, 2020 16:20
python-1.0-setup
# install homebrew
# http://sourabhbajaj.com/mac-setup/Homebrew/
sudo xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# install iterm2
brew cask install iterm2
# install zsh
# LICENSE MIT
import utime as time
from gates import GateIn
from leds import LED
print('RUN: main.py')
from machine import Pin, SPI
from gates import GateIn
from leds import LED
print('RUN: main.py')
led = LED(23)
gate = GateIn(22)
while True:
if gate.is_high():
# blink the given pin at 1Hz 50% duty cycle
# use ctrl-c to end
# notify
print('LOAD: leds.py')
import sys, time
from machine import Pin
from machine import Pin
class GateIn(object):
def __init__(self, pin_num):
self.pin_num = pin_num
self.pin = Pin(self.pin_num, Pin.IN)
def is_high(self):
return self.pin.value() == 1
#!/usr/bin/python3
# ----------------------------------------------------------------------------------
# NOTE: You can also use the Adafruit ampy script or WebREPL to do the same thing.
# replace.py = REPLace.py = REPL Ace Uploder
# Copyright (c) 2017 Clayton Darwin
# claytondarwin.com claytondarwin@gmail.com
@0mars
0mars / toute.custom_es_queries.py
Last active June 10, 2020 10:13
custom elastic search queries with Toute
song_query = {
"query": {
"bool": {
"must": [
{"match": {"name": "Careless"}}
]
}
}
}
collection = Song.filter(name="Sour")
for item in collection:
print('{}: Album - {}'.format(item.name, item.album.name))
@0mars
0mars / data_types.md
Last active June 10, 2020 09:49
Toute Data Types
@0mars
0mars / songclient.py
Created June 4, 2020 15:27
songclient.py
import datetime
from examples.song.factory import ElasticSearchFactory
from examples.song.song import Song
factory = ElasticSearchFactory(os.environ.get('ES_HOST'), os.environ.get('ES_PORT'))
es_client = factory.create()
Song.having(es=es_client)
Song.init()