Skip to content

Instantly share code, notes, and snippets.

from TwitterAPI import TwitterAPI
api = TwitterAPI("QHCFXKcJeYvFMr8XBTes3eID8",
"Zh3JhEBL8PXnfAEAAOivlB4xrX1PAfDEIdg6DsC78qs6O2Aruk",
"2401578782-7P2QUySnDc8gFHQ1vCwTrckbLLSty8tOFjrizC6",
"WNcilnQcbd0o7xnTYf1XBylsriyBb1KkNlxyTx4u4uB1s"
)
# instantiate empty lists that will hold Event data.
# these would be populated by a periodic (e.g. every 1 minute) query of "active" Events.
event_ids = []
import Oauth2
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
println("viewDidLoad")
let settings = ["client_id": "abcde",
"client_secret": "12345",
@danshev
danshev / gist:4227f07e5859a30e6304
Last active August 29, 2015 14:19
Dispatch() function meant to be used as the callback for .sendMessage() of Firebase's Firechat.
// This is client-side code meant for the callback of Firebase's Firechat .sendMessage(), it
// does two things:
//
// 1. It determines if there are any @mentions in the message. If there are,
// then it determines if the mentioned user(s) are in the chatroom.
//
// a. For each user mentioned who is NOT in the chatroom, a message to them
// is immediately added to the `dispatch-queue` node.
//
// b. For each user mentioned who *is* in the chatroom, then the user's
@danshev
danshev / gist:557000a1f8056daba7e7
Last active August 29, 2015 14:19
Server-side monitoring for the dispatch queue.
# Dependency: https://github.com/hashme/firebase-python
# Use with: https://gist.github.com/danshev/4227f07e5859a30e6304
import firebase
import json
from pprint import pprint # function which pretty prints objects
URL = firebase.firebaseURL('therenow/{0}/dispatch-queue'.format(current_app.config["MARKET_DOMAIN_SLUG"]))
def delete_message(path):
@danshev
danshev / base64.swift
Last active August 29, 2015 14:27
Base64 String creating extension for UIImage
extension UIImage {
enum Quality {
case Best, High, Medium, Low
}
func toBase64(quality: Quality) -> String {
var imageData: NSData
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwHOsOx1+fxcN0LRPvilU
ZGW++ROdt3TtrbbvLKqzQil1lOVaMKguGMnR65rlwsU11DaQ48i9t+J21cEViv/B
HGPguUFLbv0/ZZKw+cw1m1OgM8RDDWDIKqKy5bWWxXu8Hi5X2vg30NOZiychvBhm
qeIbgzwKblTU9SynA27x/oncNC8sbaql1KmAQ8W26maKjCLrhSyhwU4sQazrsZ85
rBKhzSvz2LjKnYKCRU/3owK1rHK5M73/DUC4gF3NpG3feSeUrQQLSD+vCIoWpF6S
4wT35TNJAUiggPeq/nBfZrqlAllRI71SM5YtHJI0+erI5RTN3NDDfV16kM0xdTkk
qQIDAQAB
-----END PUBLIC KEY-----
@danshev
danshev / ECPublicKey.swift
Created October 18, 2018 00:19
Verify ECDSA Digital Signature in Swift using a PEM-encoded Key
/**
* Copyright (c) 2017 Håvard Fossli.
*
* Licensed under the MIT license, as follows:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@danshev
danshev / index.js
Created May 24, 2019 04:17
TeslaCam-Identify-Sets-and-Kickoff (for AWS Lambda)
/*
Function: TeslaCam-Identify-Sets-and-Kickoff
Runtime: Node.js 10.x
Environment: AWS Lambda
Description:
This function is meant to be triggered by a periodic CloudWatch Event.
Upon execution, it will scan an S3 bucket (containing TeslaCam files),
identify videos sets which:
a) have not been previously processed, and
@danshev
danshev / lambda_function.py
Last active May 20, 2022 09:23
TeslaCam-Merge-Videos (for AWS Lambda)
'''
Function: TeslaCam-Merge-Videos
Runtime: Python 3.7
Environment: AWS Lambda
Description:
This function is meant to be invoked by another Lambda (TeslaCam-Identify-Sets-and-Kickoff).
Upon execution, it will use the 'event' key of the event dictionary (passed at runtime), and:
1. Download camera angle video files from S3
@danshev
danshev / index.js
Last active July 2, 2019 23:17
TeslaCam-Create-Playlist (for AWS Lambda)
/*
Function: TeslaCam-Create-Playlist
Runtime: Node.js 10.x
Environment: AWS Lambda
Description:
This function is meant to be triggered by a periodic CloudWatch Event.
Upon execution, it will scan an S3 bucket (containing TeslaCam files),
build an M3U playlist of processed / merged TeslaCam videos, determine
how many *new* videos were added, and push a message to AWS SNS (for alerting).