Skip to content

Instantly share code, notes, and snippets.

View progapandist's full-sized avatar
👋
Open for Work

Andy Baranov progapandist

👋
Open for Work
View GitHub Profile
#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[])
#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);
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])
{
@progapandist
progapandist / osx-for-hackers.sh
Created October 10, 2016 10:12 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/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'
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
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
source 'https://rubygems.org'
gem 'sinatra'
gem 'facebook-messenger'
gem 'httparty'
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
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='
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