Skip to content

Instantly share code, notes, and snippets.

View CleverProgrammer's full-sized avatar
🏠
Working from home

Rafeh Qazi CleverProgrammer

🏠
Working from home
View GitHub Profile
@CleverProgrammer
CleverProgrammer / student_class.py
Created November 27, 2015 09:25
Student class that models a student. Final version.
"""
Author: Rafeh Qazi
Create a student class that models a student.
Date: 11/26/2015
Function_Based_Gist: https://gist.github.com/Rafeh01/4a6d6b79eee4caf6b799
Update: 11/27/2015
Final_Gist:
Key Features:
1. Class
2. Class Object Counter
@CleverProgrammer
CleverProgrammer / student_class.py
Last active November 27, 2015 09:37
A student class that models a student.
"""
Author: Rafeh Qazi
Create a student class that models a student.
Date: 11/26/2015
Function_Based_Gist: https://gist.github.com/Rafeh01/4a6d6b79eee4caf6b799
Update: 11/27/2015
Final_Gist: https://gist.github.com/Rafeh01/57fc4c710bf9322d75db
Key Features:
1. Class
2. Class Object Counter
prompt("Do you want an annoying pop up");
x=1;
while (x<15){
confirm("Annoying pop up");
x=x+1;
};
confirm("ok your done");
@CleverProgrammer
CleverProgrammer / oauth-NOTgithub.r
Created April 30, 2016 03:54
Oauth Github Application R
library(httr)
require(httpuv)
require(jsonlite)
# 1. Find OAuth settings for github:
# http://developer.github.com/v3/oauth/
oauth_endpoints("github")
# 2. To make your own application, register at at
# https://github.com/settings/applications. Use any URL for the homepage URL
/*
Compare Objects
Consider the following example.
{ name: 'zeke' } === { name: 'zeke' }
What do you think the output will be? You might assume `true`. It is, however, false. This isn't a mistake, its intentional. Every object is unique from every other object. The usefulness of this will become clear over time. But, it does make it difficult to know if objects contain the same data.
Right now you're going to write a function that determines if two objects contain the same data.
{% extends 'base.html' %}
{% block title %} Video | {% endblock %}
<script>
{% block jquery %}
// Do this once before resizing
var parent_id = $('iframe').parent().attr('id');
if (parent_id === 'youtubeVideo') {
$('iframe').addClass('embed-responsive-item');
@CleverProgrammer
CleverProgrammer / recursive_vs_iterative.py
Created September 20, 2016 14:53
Tangible example problems solved both iteratively and then recursively to clearly outline the difference.
__author__ = 'Rafeh'
"""
Program: recursive_vs_iterative
Description: This program contains a few common iterative functions and their solutions. More importantly,
it also contains their counter-part recursive functions and their solutions. This is important in visualizing
side by side the differences between iterative implementations and recursive implementations of a given function.
Notice that recursive solutions tend to be more elegant!
Version: 3.4
"""
@CleverProgrammer
CleverProgrammer / minion_game.py
Last active September 20, 2016 17:08
Hackerrank Minion Game problem
"""
Submit this code at: https://www.hackerrank.com/challenges/the-minion-game
"""
def match(text, pattern):
"""
>>> match('banana', 'ana')
2
"""
return sum([1 for i in range(len(text)) if text[i:i+len(pattern)] == pattern])
@CleverProgrammer
CleverProgrammer / print_in_order.py
Created September 28, 2016 15:03
Sort 3 integers in order and print them out using only 3 if statements at most.
def print_in_order(a, b, c):
if a >= b:
if b >= c:
print(c, b, a)
elif a >= c:
print(b, c, a)
else:
print(b, a, c)
else:
@CleverProgrammer
CleverProgrammer / caesar_custom_encryption.py
Created October 13, 2016 05:01
Using the idea of caesar cipher, we create our own custom caesar cipher.
"""
Author: Rafeh Qazi
Program: Encryption and Decryption
Resource: http://www.practicalcryptography.com/ciphers/caesar-cipher/
"""
KEY = 17
def caesar_encryption(letter, key):