run following commands:
brew install kafka
sudo mkdir -p /usr/local/var/run/zookeeper/data
sudo chmod 777 /usr/local/var/run/zookeeper/data
zkServer start
mkdir -p /usr/local/var/lib/kafka-logs
from tensorflow import keras | |
# Creating a simple CNN model in keras using functional API | |
def create_model(): | |
img_inputs = keras.Input(shape=IMG_SHAPE) | |
conv_1 = keras.layers.Conv2D(32, (3, 3), activation='relu')(img_inputs) | |
maxpool_1 = keras.layers.MaxPooling2D((2, 2))(conv_1) | |
conv_2 = keras.layers.Conv2D(64, (3, 3), activation='relu')(maxpool_1) | |
maxpool_2 = keras.layers.MaxPooling2D((2, 2))(conv_2) | |
conv_3 = keras.layers.Conv2D(64, (3, 3), activation='relu')(maxpool_2) |
/* | |
Video: https://www.youtube.com/watch?v=oCMOYS71NIU | |
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp | |
Ported to Arduino ESP32 by Evandro Copercini | |
Gamepad coding by Game Dragon | |
*/ | |
#include <BLEDevice.h> | |
#include <BLEServer.h> | |
#include <BLEUtils.h> |
I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.
For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.
Note Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.
One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss
# An example to get the remaining rate limit using the Github GraphQL API. | |
import requests | |
headers = {"Authorization": "Bearer YOUR API KEY"} | |
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section. | |
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers) | |
if request.status_code == 200: |
import pandas as pd | |
import pandas.io.sql as sqlio | |
import psycopg2 | |
conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd)) | |
sql = "select count(*) from table;" | |
dat = sqlio.read_sql_query(sql, conn) | |
conn = None |
from __future__ import print_function | |
import requests | |
import json | |
import cv2 | |
addr = 'http://localhost:5000' | |
test_url = addr + '/api/test' | |
# prepare headers for http request | |
content_type = 'image/jpeg' |
def sign_extend(bits, value): | |
""" Sign-extend from http://stackoverflow.com/questions/32030412/twos-complement-sign-extension-python """ | |
sign_bit = 1 << (bits - 1) | |
return (value & (sign_bit - 1)) - (value & sign_bit) | |
def get_samples(w): | |
w.rewind() | |
num_samples = w.getnframes() | |
sample_depth = w.getsampwidth() |
""" | |
Playing with python's single dispatch. | |
See: https://hynek.me/articles/serialization/ | |
See also PEP 443: https://www.python.org/dev/peps/pep-0443/ | |
""" | |
from datetime import datetime | |
from functools import singledispatch |
import { inspect } from 'util'; | |
import { | |
graphql, | |
GraphQLEnumType, | |
GraphQLID, | |
GraphQLInterfaceType, | |
GraphQLObjectType, | |
GraphQLList, | |
GraphQLNonNull, | |
GraphQLSchema, |