Skip to content

Instantly share code, notes, and snippets.

View elinwibe's full-sized avatar

Elin Espmark Wibe elinwibe

  • London
View GitHub Profile
@elinwibe
elinwibe / twittersearchscrape.py
Created January 7, 2018 18:49
This code scrapes Tweets by Twitter Search API, and can collect tweets up to 10 days back in time. (Tweepy needs to be installed Mac.). Code modified from Bhaskar V. Karambelkar (https://www.karambelkar.info/2015/01/how-to-use-twitters-search-rest-api-most-effectively./)
#This code searches for tweets with a particuar keyword and writes certain fields into a CSV file
import sys, csv
import twitter
import os
import tweepy
# Replace the API_KEY and API_SECRET with your application's key and secret.
#This code is using AppAuthHandler, not OAuthHandler to get higher limits, 2.5 times.
auth = tweepy.AppAuthHandler('YOUR_API_KEY', 'YOUR_SECRET_API_KEY')
@elinwibe
elinwibe / JS element fade in and out
Created December 25, 2017 17:28
Element fade in when not at top
$(window).scroll(function () {
if($(this).scrollTop() != 0) {
$('#').fadeIn("slow"); //If NOT at top/0px, # fades in
} else {
$('#').fadeOut("fast");
}
});
@elinwibe
elinwibe / JS Scroll Progress Bar
Created December 25, 2017 17:25
Scroll Progress Bar by %
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("#").style.width = scrolled + "%";
}
@elinwibe
elinwibe / Bouncing Loop Jquery
Last active December 25, 2017 17:29
JQuery loop for bouncing element
$(document).ready(function() {
function loop() {
$('#').animate({"top": 0});
$('#').animate({
"top": 20,
}, 1500, function() {
loop();
});
}
loop();
@elinwibe
elinwibe / Air Quality
Last active December 25, 2017 17:21
Lewisham Air Quality measurement from King's College API
var sitecode = "LW4"
var URL = "http://api.erg.kcl.ac.uk/AirQuality/Daily/MonitoringIndex/Latest/SiteCode=" + sitecode + "/Json";
console.log('Fetching air quality data from-' + URL);
function processResult(data) {
var LAsite_data = data.DailyAirQualityIndex.LocalAuthority;
console.log(data);