Skip to content

Instantly share code, notes, and snippets.

View pmatsinopoulos's full-sized avatar
💻
Programming

Panos Matsinopoulos pmatsinopoulos

💻
Programming
View GitHub Profile
@pmatsinopoulos
pmatsinopoulos / correct_indentation.rb
Created March 13, 2015 07:29
Gist that demonstrates the correct indentation
def choose
puts "Do you like programming? Yes, no, or maybe please."
choice = gets.chomp
case choice.downcase
when "yes"
puts "That's great!"
when "no"
puts "That's too bad!"
when "maybe"
puts "Glad you are giving it a chance!"
@pmatsinopoulos
pmatsinopoulos / fav_foods_correct_indentation
Created March 14, 2015 07:39
A Small Ruby program Teaching correct indentation
def fav_foods
food_array = []
3.times do
puts "Name a favorite food"
food_array << gets.chomp
end
p food_array
puts "Your favorite foods are #{food_array.join(", ")}"
food_array.each do |food| # do something to each element in food_array; that element is to be referred to as food
puts "I like #{food} too!" # the thing we are doing
@pmatsinopoulos
pmatsinopoulos / interactive_web_site_modal_problem
Last active August 29, 2015 14:17
Correct Bootstrap/jQuery/jQuery Media Plugin on head of an html
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Phil Jedar PortFolio</title>
<!-- CSS -- >
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
@pmatsinopoulos
pmatsinopoulos / using-variables-for-jquery
Created March 28, 2015 07:08
Using variables for jQuery
var $char_count = $("#char-count");
$char_count.html(charCount);
if (charCount > 50) {
$char_count.css("color", "red");
}
else {
$char_count.css("color", "#fff");
}
<head>
<title>Nameofapp</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
@pmatsinopoulos
pmatsinopoulos / send_signed_rat_request.rb
Last active August 29, 2015 14:26
Book&Table - Mobile API - Ruby client program using the Request a Tutor private end point
require 'rest-client'
user_id = 5
secret_key = 'secret key of user with id 5'
def calculate_canonical_string(content_type, content_md5, path, timestamp)
[ content_type,
content_md5,
path,
timestamp
@pmatsinopoulos
pmatsinopoulos / send_signed_contact_tutor_request.rb
Created August 7, 2015 07:04
Example of sending a signed request to Book&Table Mobile API when POST with body data
require 'rest-client'
user_id = 5
secret_key = 'secret key of user with id 5'
tutor_id = 105
timestamp = Time.now.utc.httpdate # Example: "Mon, 03 Aug 2015 20:15:56 GMT"
def calculate_canonical_string(content_type, content_md5, path, timestamp)
@pmatsinopoulos
pmatsinopoulos / send_sign_up_request_curl_example.curl
Last active September 21, 2015 07:21
Demonstrates how one can use the sign up request call to sign up a new user using the Book&Table mobile API.
curl "http://staging.bookandtable.com/mobile/1.0/sign_up?user_type=student&method=email" -v \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "X-BOOK-AND-TABLE-API-KEY-TYPE: IOS" \
--header "X-BOOK-AND-TABLE-API-KEY: 248f870f9a23b83625bb9c265c544924" \
-d "{\"sign_up_data\":{\"email\":\"GRbookandtable201509211008@mailinator.com\",\"password\":\"12345678\",\"first_name\":\"Panos\",\"last_name\":\"Matsos\"}}"
Sample Response:

Introduction

Welcome .

<!DOCTYPE html>
<html>
  <head>
  <title>Hello World!</title>
 
@pmatsinopoulos
pmatsinopoulos / read_integer.rb
Last active November 9, 2015 21:01
Compare Swift vs Ruby to read an integer from the keyboard
input = gets.to_i