Skip to content

Instantly share code, notes, and snippets.

View nfarah86's full-sized avatar

nadine farah nfarah86

View GitHub Profile
@nfarah86
nfarah86 / script_contact_map.js
Created May 7, 2016 05:20
Display Coordinates via MapBox API Call
L.mapbox.accessToken = <'secret-token'>;
var map = L.mapbox.map('map', 'nfarah86.k5679d8m')
.setView([37.77777043035903, -122.4196243286133], 17);
var featureLayer = L.mapbox.featureLayer()
.loadURL("/contact_map?cache="+(new Date().getTime()))
.on('ready', run)
.addTo(map);
@nfarah86
nfarah86 / outgoingMessage.py
Created May 7, 2016 05:24
Send Text Message via Twilio
from twilio.rest import TwilioRestClient
TWILIO_ACCOUNT_SID=os.environ['TWILIO_ACCOUNT_SID']
TWILIO_AUTH_TOKEN=os.environ['TWILIO_AUTH_TOKEN']
TWILIO_NUMBER=os.environ['TWILIO_NUMBER']
def sendMessage(phone_number, message):
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
message = client.messages.create(
body=message, # Message body, if any
@nfarah86
nfarah86 / rescue.py
Last active May 7, 2016 05:30
Call sendMessage Function to Send a Text Message
// omitted code
def textMessage(message):
sendMessage(os.environ['MY_NUMBER'], message)
// omitted code
@nfarah86
nfarah86 / m2_oldy.py
Last active May 11, 2016 00:59
Set Up The Tables and Relationships
class User(Base):
""" user using the hardware """
__tablename__ = "users"
id = Column(Integer, primary_key = True)
first_name = Column(String(20), nullable = False)
last_name = Column(String(40), nullable = False)
user_name = Column(String(10),nullable = False)
email = Column(String (30), nullable = False)
password = Column(String(10), nullable = False)
@nfarah86
nfarah86 / NFHLocationManager.m
Created May 14, 2016 21:26
Inform the Delegate with authorization status change
// omitted code
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status)
{
case kCLAuthorizationStatusNotDetermined:
NSLog(@"Location services authorization status not yet determined.");
break;
case kCLAuthorizationStatusDenied:
NSLog(@"Location services authorization was denied.");
@nfarah86
nfarah86 / keybase.md
Created February 24, 2018 17:02
Public gist for keybase

Keybase proof

I hereby claim:

  • I am nfarah86 on github.
  • I am nadinefarah (https://keybase.io/nadinefarah) on keybase.
  • I have a public key ASDygiTfau4BCjNq3o9GZFTMUZXUHmWOaong-eCmISGxdgo

To claim this, I am signing this object:

@nfarah86
nfarah86 / ViewController.swift
Created November 5, 2019 19:19
Play a song via AVAudioPlayer
import UIKit
import AVFoundation
var audioPlayer: AVAudioPlayer?
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
WITH pm10avg AS (
select AVG(a.pm10.value) avg_pm10, EXTRACT(date from PARSE_TIMESTAMP_ISO8601(a.observation_time.value)) date_pm10
from commons.air_pollution_data_collection a
GROUP BY date_pm10
),
tempavg as (
SELECT AVG(w.temp.value) avg_weather, EXTRACT(date from PARSE_TIMESTAMP_ISO8601(w.observation_time.value)) date_weather
from commons.weather_data_collection w
GROUP BY date_weather, aq_date
) select pm10avg.avg_pm10, tempavg.avg_weather, pm10avg.date_pm10
from settings import *
from mongo_config import weather_data_collection, pollution_data_collection
from timeloop import Timeloop
from datetime import timedelta
import requests
import json
tl = Timeloop()
def get_weather_data():
@nfarah86
nfarah86 / script.py
Created May 18, 2020 06:17
Modify a function to call display_results
@tl.job(interval=timedelta(seconds=120))
def sample_job_every_120s():
weather_response = get_weather_data()
air_pollution_data = get_air_pollution_data()
insert_to_mongo(weather_response, air_pollution_data)
makeRequests()