Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
@thinkphp
thinkphp / gist:1448754
Created December 8, 2011 21:44
Binary Search Tree Implementation in PHP
<?php
/**
* by Adrian Statescu <adrian@thinkphp.ro>
* Twitter: @thinkphp
* G+ : http://gplus.to/thinkphp
* MIT Style License
*/
<!DOCTYPE html>
<head>
<title>HTML Layout</title>
<style>
* {
box-sizing: border-box;
}
body {
Un element HTML este definit printr-un:
START TAG - content - END TAG
start content end tag
<h1 attributes> my first heading </h1>
<p> my first p </p>
@thinkphp
thinkphp / gist:1476390
Created December 14, 2011 12:27
Reverse the order of the items in the array in Python
'''
Reverse the order of the items in the array.
@thinkphp
MIT Style License
'''
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
def reverse(arr):
m = len(arr) / 2
n = len(arr) - 1
for i in range(m):
@thinkphp
thinkphp / gist:1862867
Created February 19, 2012 09:51
sin(x) in Python
'''
sin(x) = x-x^3/3!+x^5/5!-x^7/7!+..-
'''
import math
def fact(n):
if n==0:
return 1
else:
return n*fact(n-1)
@thinkphp
thinkphp / gist:1543590
Created December 31, 2011 10:07
Computes square root in Python SQRT
'''
Computes SQuare RooT in Python SQRT
s = (s+nr/s)1/2
Twitter : http://twitter.com/thinkphp
Website : http://thinkphp.ro
Google Plus : http://gplus.to/thinkphp
MIT Style License
'''
@thinkphp
thinkphp / leibniz_PI.c
Last active September 6, 2023 08:39
C program to compute the value of PI using formula's Leibniz.
/**
*
* Author : Adrian Statescu mergesortv@gmail.com http://adrianstatescu.com
*
* C program to compute the value of PI using formula's Leibniz.
* PI approximate 4 ( 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11...
*
* MIT License
*
*/
@thinkphp
thinkphp / gist:5107438
Last active August 16, 2023 12:14
Luhn Python checksum for credit card validation
#Luhn Python checksum for credit card validation
import sys
def luhn(n):
sum = 0
alt = 0
i = len(n) - 1
@thinkphp
thinkphp / gist:5348581
Last active April 11, 2023 08:06
Test if a number is prime or not in Common LISP.
;Test if a number is prime or NOT.
;Adrian Statescu <mergesortv@gmail.com>
;License
;MIT
;Cheers!
(defun forall(L P)
(if (null L)
T
(and (FUNCALL P (cAR L)) (forall (CDR L) P) )
$\int{f(x) g'(x) \ dx} = fg - \int{ g(x) f'(x) \ dx}$
$\int{cos^2x \ dx} = \int{cos \ x \ cos \ x \ dx} = \int{cos \ x \ (sin \ x)' \ dx} = cos \ x \ sin \ x - \int{sin \ x \ (cos \ x)' \ dx} = cos \ x \ sin \ x - \int{sin \ x \ sin \ x \ dx} = cos \ x \ sin \ x - \int{sin^2 \ x \ dx} = sin\ x \ cos \ x + \int{sin^2 \ x \ dx} = sin\ x \ cos \ x + \int{ (1 - cos^2 \ x) \ x \ dx} = sin\ x \ cos \ x + \int{ 1 \ dx} - \int{ cos^2 \ x \ dx} = sin\ x \ cos \ x + x - \int{ cos^2 \ x \ dx} => \int \cos ^2x\,dx=\frac{x+\sin x\cos x}{2}+C. $