Skip to content

Instantly share code, notes, and snippets.

View sedaghatfar's full-sized avatar

Matthew Sedaghatfar sedaghatfar

View GitHub Profile
@sedaghatfar
sedaghatfar / [Python] Quadratic Formula
Last active December 15, 2015 06:39
My first project, quadratic formula solver
#quadratic formula
def quad(a,b,c):
root1 = (-b+((b**2)-4*a*c)**(.5))/(2*a)
root2 = (-b-((b**2)-4*a*c)**(.5))/(2*a)
print(root1)
print(root2)
return a,b,c
@sedaghatfar
sedaghatfar / gist:5218500
Last active December 15, 2015 06:48
[Python] Date and Time
#Date and time program
#codecademy
from datetime import datetime
now = datetime.now()
print str(now.month) +"/"+ str(now.day) +"/"+ str(now.year) +" "+ str(now.hour) +":"+ str(now.minute) +":"+ str(now.second)
@sedaghatfar
sedaghatfar / gist:5218506
Last active December 15, 2015 06:48
[Python] Pig Latin translator
#Pig Latin translator
#codecademy
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
@sedaghatfar
sedaghatfar / gist:5229672
Created March 23, 2013 23:05
[R] Monte Carlo Technique
# For this exercise we assume to draw random points inside the square on the [-1,1] unit,
# and thus the value of Pi = 4(# random pts insid cirlce / # random pts in square)
sim.pi <- function(iterations = 1000) {
# Generate two vectors for random points in unit circle
x.pos <- runif(iterations, min=-1, max=1)
y.pos <- runif(iterations, min=-1, max=1)
# Test if draws are inside the unit circle
draw.pos <- ifelse(x.pos^2 + y.pos^2 <= 1, TRUE, FALSE)
draws.in <- length(which(draw.pos == TRUE))
# Estimate Pi
@sedaghatfar
sedaghatfar / gist:5229752
Last active December 15, 2015 08:19
[Python3] Monte Carlo on Pi
from random import random
from math import pow
simulations = 5000
hits = 0.0
for x in range(simulations):
x = random()
y = random()
distance = pow(x,2) + pow(y,2)
@sedaghatfar
sedaghatfar / [Python3] Study
Created April 8, 2013 01:48
Asks user if he needs to study
import webbrowser
import sys
print ("Do you need to study?")
print("")
question = input()
if question == "no":
webbrowser.open("http://facebook.com/")
webbrowser.open("https://mail.google.com/mail/u/0/#inbox")
import smtplib
from email.mime.text import MIMEText
# Message to be sent
message = MIMEText("Hello, texting!")
# Sending email username/password and receiving phone number
email_username = "email"
email_password = "password"
phone_number = "516#######"
x = int(input("enter an integer: "))
ans = 0
while ans*ans*ans < abs(x):
ans = ans +1
print ("current Guess =", ans)
print ("last guess = ", ans)
print ("ans*ans*ans = ", ans*ans*ans)
if ans*ans*ans == abs(x):
for i in range(1,101):
s = str(i)
if i % 3 == 0 or i % 5 == 0:
s = " "
if i % 3 == 0:
s = s + "Fizz"
if i % 5 == 0:
s = s + "Buzz"
print (s)
<?php
/**
* The template for displaying image attachments
*
*
* @package i_spirit
* @since i-spirit 1.0
*/
get_header(); ?>