Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
View gist:c0d9b4aa350d7db8ed6d28af364a86c6
$\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. $
View hexa2DecGCD.py
def hexaGCD( x, y, z):
def pow2(a,b):
p = 1
for i in range(1,b+1):
p = p * a
return p
@thinkphp
thinkphp / pointerToFn.c
Last active February 23, 2023 08:05
Heap, malloc, algorithm sorting, free, pointers to functions
View pointerToFn.c
#include <stdio.h>
#include <malloc.h>
#define fin "algsort.in"
typedef int (*ptr2)(const int a,const int b);
typedef void (*ptr1)(int*, int, ptr2);
int comp(int a, int b) {
View sqrt_babylonian.py
#
# Square Root Babylonian Method
# @Adrian Statescu
#
def sqrt_babylonian(n):
x = n
y = 1.0
eps = 0.000001
while x - y > eps:
x = (x + y) / 2
View sqrt_babylonian.rb
#
# Square Root Babylonian Method
# @Adrian Statescu
#
def sqrt_babylonian(n)
x = n
y = 1.0
e = 0.000001
while x - y > e
x = (x + y) / 2
@thinkphp
thinkphp / linkedlist.c
Created June 13, 2022 20:55
Singly Linked List
View linkedlist.c
#include <stdio.h>
#include <malloc.h>
typedef struct Node {
int data;
struct Node *next;
} Node;
Node *head = NULL;
View decorators.py
def make_bold(f):
def bold_wrapper():
return "<b>" + f() +"</b>"
return bold_wrapper
def make_italic(f):
def italic_wrapper():
return "<i>" + f() + "</i>"
return italic_wrapper
View mindReader
from time import sleep
from sys import stdout
def printt(string, delay = 0.05):
for c in string:
stdout.write(c)
stdout.flush()
sleep(delay)
print("")
@thinkphp
thinkphp / change-color-dir.txt
Created April 17, 2021 19:17
How do I change the color for directories with ls in console
View change-color-dir.txt
;to change your directory colors, open up your ~/.bashrc file with your editor
;and make the following entry at the end of the
LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS
@thinkphp
thinkphp / repeatuntil.c
Last active December 12, 2020 08:11
repeat ... until control flow in c language
View repeatuntil.c
#include <stdio.h>
#define __repeat__ do
#define __until__(COND) while(!(COND))
int isPrime(int n) {
if( n == 0 || n == 1 ) return 0;
if( n == 2 || n == 3 ) return 1;
int i = 2,