This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
// Prototyping alpabetical check function. | |
int checkalpha(string k); | |
int main(int argc, string argv[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
#include <stdbool.h> | |
void bubblesort(int values[], int n); | |
bool binsearch(int values[], int value, int n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void insertsort(int array[], int size) | |
{ | |
int sorted = 1; | |
while (sorted < size - 1) | |
{ | |
for (int i = 0; i <= sorted; i++) | |
{ | |
if (array[i] > array[i + 1]) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Set the colours you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './app' | |
require_relative 'bot' # you can comment this line out until you create a bot.rb file later in the tutorial | |
# you may need this lines in order to test your server before you create bot.rb later | |
require ‘facebook/messenger’ | |
include Facebook::Messenger | |
# run both Sinatra and facebook-messenger on /webhook | |
map("/webhook") do | |
run Sinatra::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
# NOTE: ENV variables should be set directly in terminal for testing on localhost | |
# Talk to Facebook | |
get '/webhook' do | |
params['hub.challenge'] if ENV["VERIFY_TOKEN"] == params['hub.verify_token'] | |
end | |
get "/" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'facebook-messenger' | |
gem 'httparty' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'facebook/messenger' | |
include Facebook::Messenger | |
# NOTE: ENV variables should be set directly in terminal for testing on localhost | |
# Subcribe bot to your page | |
Facebook::Messenger::Subscriptions.subscribe(access_token: ENV["ACCESS_TOKEN"]) | |
Bot.on :message do |message| | |
message.reply(text: 'Hello!') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'facebook/messenger' | |
require 'httparty' # you should require this one | |
require 'json' # and that one | |
include Facebook::Messenger | |
# NOTE: ENV variables should be set directly in terminal for testing on localhost | |
# Subcribe bot to your page | |
Facebook::Messenger::Subscriptions.subscribe(access_token: ENV["ACCESS_TOKEN"]) | |
API_URL = 'https://maps.googleapis.com/maps/api/geocode/json?address=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_parsed_response(url, query) | |
# Use HTTParty gem to make a get request | |
response = HTTParty.get(url + query) | |
# Parse the resulting JSON so it's now a Ruby Hash | |
parsed = JSON.parse(response.body) | |
# Return nil if we got no results from the API. | |
parsed['status'] != 'ZERO_RESULTS' ? parsed : nil | |
end |
OlderNewer