Skip to content

Instantly share code, notes, and snippets.

View alfredfrancis's full-sized avatar
🎯
Focusing

Alfred Francis alfredfrancis

🎯
Focusing
View GitHub Profile
"""
1. Setup a Twitter Developer account and create new App, get its consumer key and consumer secret and replace them below
2. Replace TWEETS_DB, QUERY, and LANGUAGE values
3. Install required packages: `pip install tweepy schedule`
4. Run process using `python tweets_to_db.py`
"""
import tweepy
import sqlite3
import datetime
#Original Author https://raw.githubusercontent.com/kgoedecke/python-ecs-example/master/python_ecs_example/deployment.py
import boto3
import pprint
import os
# Credentials & Region
access_key = os.environ["AWS_ACCESS_KEY_ID"]
secret_key = os.environ["AWS_SECRET_ACCESS_KEY"]
region = "us-east-1"
@alfredfrancis
alfredfrancis / index.html
Created May 31, 2017 17:42 — forked from adunkman/index.html
Relay messages from RabbitMQ to a browser using Socket.io
<!DOCTYPE html>
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script>
(function () {
var onMessage = function (data) {
// Do something with the message data
};
@alfredfrancis
alfredfrancis / example.py
Created April 21, 2017 17:31 — forked from mattupstate/example.py
JSON Patch SQLAlchemy models w/ Flask
from dictalchemy import make_class_dictable
from flask import Flask, request, jsonify, json
from flask_sqlalchemy import SQLAlchemy
from jsonpatch import JsonPatch, JsonPatchException
app = Flask(__name__)
app.debug = True
db = SQLAlchemy(app)
make_class_dictable(db.Model)
@alfredfrancis
alfredfrancis / react-firebase-auth.js
Created January 30, 2017 17:00 — forked from nateinaction/react-firebase-auth.js
This is a version of Facebook's React Conditional Rendering example modified to support firebase authentication.
/*
* This is a version of Facebook's React Conditional Rendering
* example modified to support firebase authentication.
* https://facebook.github.io/react/docs/conditional-rendering.html
*/
import React, { Component, PropTypes } from 'react';
import * as firebase from 'firebase';
function UserAvatar(props) {
@alfredfrancis
alfredfrancis / gist:4b54c8eebc1e01815a5bac6bc555022d
Created June 23, 2016 10:48 — forked from fnielsen/gist:1226214
Email classification example with Python, NLTK, ...
documents = [ dict(
email=open("conference/%d.txt" % n).read().strip(),
category='conference') for n in range(1,372) ]
documents.extend([ dict(
email=open("job/%d.txt" % n).read().strip(),
category='job') for n in range(1,275)])
documents.extend([ dict(
email=open("spam/%d.txt" % n).read().strip(),
category='spam') for n in range(1,799) ])
import wiringpi
import time
# 1M external pull-up resistor
# 1) set pin low and to output to discharge
# 2) make the pin an input without the internal pull-up on
# 3) read input and see how long it takes to go high
# ref: https://github.com/WiringPi/WiringPi-Python
# pins: https://projects.drogon.net/raspberry-pi/wiringpi/pins/