Skip to content

Instantly share code, notes, and snippets.

View JFriel's full-sized avatar

James Friel JFriel

  • Dundee, United kingdom
View GitHub Profile
@JFriel
JFriel / appointmrent.rb
Last active August 29, 2015 14:10
appoint
# @start snippet
require "twilio-ruby"
class AppointmentreminderController < ApplicationController
# your Twilio authentication credentials
ACCOUNT_SID = 'AC1ea915e8d2fb79d9efd01c53b94cdc75'
ACCOUNT_TOKEN = 'c72fde4d7af307c610aaa0e5f3c3c9e2'
# base URL of this application
@JFriel
JFriel / scraper
Created May 23, 2015 04:49
wiki scraper
import urllib
from bs4 import BeautifulSoup
import sys
import nltk
from nltk import word_tokenize
def splitParagraphIntoSentences(paragraph):
''' break a paragraph into sentences
and return a list '''
import re
String trackName = '4BYGxv4rxSNcTgT3DsFB9o' //replace this with a call to get the track ID
final List<String> tracksToAdd = Arrays.asList("spotify:track:"+trackName);
// Index starts at 0
final int insertIndex = 1;
final AddTrackToPlaylistRequest request = api.addTracksToPlaylist("thelinmichael", "5ieJqeLJjjI8iJWaxeBLuK", tracksToAdd)
.position(insertIndex)
String rawHTML = ;
Pattern pattern = Pattern.compile("\D\D\d\s\D\d\d");
Matcher matcher = pattern.matcher(rawHTML);
if (matcher.find())
{
System.out.println(matcher.group(1));
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html class="js" xmlns="http://www.w3.org/1999/xhtml"><head profile="http://www.w3.org/1999/xhtml/vocab"><meta charset="utf-8"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search by barcode | GEPIR | Services | GS1 - The global language of business
</title>
<link type="text/css" rel="stylesheet" href="Search%20by%20barcode%20%7C%20GEPIR%20%7C%20Services%20%7C%20GS1%20-%20The%20global%20language%20of%20business_files/css.css" media="all"><link href="Search%20by%20barcode%20%7C%20GEPIR%20%7C%20Services%20%7C%20GS1%20-%20The%20global%20language%20of%20business_files/main.css" type="text/css" rel="stylesheet" media="screen"><link type="text/css" rel="stylesheet" href="Search%20by%20barcode%20%7C%20GEPIR%20%7C%20Services%20%7C%20GS1%20-%20The%20global%20language%20of%20business_files/3862
port org.jsoup.Jsoup;
String html = "bfbvfvbrbvb <div id='adressscroll'> G74 4GX</div>";
Pattern pattern = Pattern.compile("[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}");
Document doc = Jsoup.parse(html);
Element address = doc.select("div.adressscroll").first();
import org.jsoup.Jsoup;
public class postcodefinder{
public static void main() {
String html = "bfbvfvbrbvb <div id='adressscroll'> G74 4GX</div>";//htmlin
Pattern pattern = Pattern.compile("[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}");
public GeoPoint getLocationFromAddress(String strAddress){
Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;
try {
address = coder.getFromLocationName(strAddress,5);
if (address == null) {
return null;
public getDistance(float latA, float latB, float longA, fload longB){
//Used to find distance between two LatLongs
Location locationA = new Location("point A");
locationA.setLatitude(latA);
locationA.setLongitude(lngA);
Location locationB = new Location("point B");
float distance = locationA.distanceTo(locationB);
distance *= 0.000621371192
return (double)distance