Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Thomas Smith bsmth

View GitHub Profile
@bsmth
bsmth / qdb.sh
Created Aug 19, 2021
Starting QDB from bin
View qdb.sh
mkdir bin_dir && cd bin_dir
wget https://github.com/questdb/questdb/releases/download/6.0.4/questdb-6.0.4-no-jre-bin.tar.gz
tar -xvf questdb-6.0.4-no-jre-bin.tar.gz
cd questdb-6.0.4-no-jre-bin
./questdb.sh start -d /path/to/my_data_dir
./questdb.sh stop
# /path/to/my_data_dir will create a new root directory for QuestDB
# If a server config file exists already, it will be loaded, i.e.
@bsmth
bsmth / import.py
Created Jun 29, 2021
Import CSV to QuestDB from Python
View import.py
import urllib.request
import pandas as pd
import requests
def import_data(file_name, table_name):
params = {}
params['timestamp'] = 'TradeDate'
params['partitionBy'] = 'MONTH'
url_values = urllib.parse.urlencode(params)
query_url = "http://%s:9000/imp?" % (server_ip) + url_values
View ilp.py
import time
import socket
HOST = 'localhost'
PORT = 9009
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((HOST, PORT))
sock.sendall(('eod,instrument=fut open=141.5,high=142.0,low=139.9,close=142.0,settle_price=143.7,value=42.27\n').encode())
@bsmth
bsmth / averages.sql
Last active Apr 16, 2021
Joins weekly averages with prev compared to current week
View averages.sql
create table user_stats
(
ts timestamp,
username symbol,
name symbol,
ip_address symbol,
post_count int
)
timestamp(ts);
View keybase.md

Keybase proof

I hereby claim:

  • I am bsmth on github.
  • I am bsmth (https://keybase.io/bsmth) on keybase.
  • I have a public key ASAP6sCEQqTVAtvKB6NAtD9FKDCFedfI6Cbfub88n7vVsAo

To claim this, I am signing this object:

View BG96 At Commands Telefonica Cat-M
# Descriptioon of the sequence below:
#
# AT+... <- AT Command sent to modem
# OK <- Modem Response
//Switch the modem to minimum functionality
AT+CFUN=0,0
OK
// Verbose Error Reporting to get understandable error reporting (optional)
@bsmth
bsmth / homepage_spec.rb
Created Nov 28, 2019 — forked from gjtorikian/homepage_spec.rb
Basic Capybara testing with Jekyll + Rack
View homepage_spec.rb
require 'spec_helper'
describe "Homepage" do
before :each do
visit "/index.html"
end
it "has a title" do
expect(page).to have_css("h1", text: "GitHub Help")
@bsmth
bsmth / IncomingSNSMessage.json
Created Nov 19, 2019
Example incoming SNS message with three custom fields
View IncomingSNSMessage.json
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:489024636830:email-notifications:91018fd5-5f62-434f-9162-fd4635c5fef4",
"Sns": {
"Type": "Notification",
"MessageId": "8bd15777-93da-5f6e-8577-01335b0028ee",
"TopicArn": "arn:aws:sns:eu-west-1:.....my-email-topic",
@bsmth
bsmth / sendSESMailWithTemplate.py
Last active Nov 15, 2019
Use SES and feed variables into a pre-defined template
View sendSESMailWithTemplate.py
import csv
import json
import urllib.parse
import boto3
from botocore.exceptions import ClientError
SENDER = "EMnify Event Notifications <b.smith@emnify.com>"
RECIPIENT = "endpoint.is.online@gmail.com"
AWS_REGION = "eu-west-1"
@bsmth
bsmth / email_template.json
Created Nov 15, 2019
Basic Email Template used by SES
View email_template.json
{
"Template": {
"TemplateName": "NotificationTemplate",
"SubjectPart": "New {{event_description}} Notification",
"HtmlPart": "<div><style type=\"text/css\"><!--.notification body, .notification .x_background_main, .notification p, .notification table, .notification td, .notification div{font-family:'Lato','Helvetica Neue',Helvetica,Arial,sans-serif}.notification img{border:none; max-width:100%}.notification p{padding-bottom:2px}.notification body{background:#fff; font-size:17px; line-height:24px; margin:0; padding:0}.notification table{border-collapse:collapse; width:100%}.notification td{font-size:17px; line-height:24px; vertical-align:top}.notification .x_email_footer td, .notification .x_email_footer p, .notification .x_email_footer span, .notification .x_email_footer a{font-size:15px; text-align:center; color:#434245}.notification .x_email_footer td{padding-top:20px}.notification h1, .notification h2, .notification h3, .notification h4{color:#434245; font-weight:400; line-height:1.4; margin: