Skip to content

Instantly share code, notes, and snippets.

View Tevinthuku's full-sized avatar
🤓
typing fast

Tev Tevinthuku

🤓
typing fast
View GitHub Profile
// Arrays
// datatypeofarray arrayname[numberofitems];
int Numbers[7];
// in this array we have the following elements
int Numbers[7];
- Numbers[0]
- Numbers[1]
- Numbers[2]
@Tevinthuku
Tevinthuku / pointers.cpp
Created December 2, 2016 13:56
Most of what you need to know about pointers..
// basic pointers demo
int data = 20; // actual variable declaration.
int *ip; // pointer variable
ip = &var; // store address of data in pointer variable
// prints an address
cout << "Address stored in ip variable: ";
cout << ip << endl; // prints out 8e34xA345te (An address)
@Tevinthuku
Tevinthuku / main.cpp
Last active December 3, 2016 09:16
Most of what you need to know about classes
// class examples
// author : Tevin Thuku
// Date: 3rd: Dec: 2016
class Square {
public:
double length;
double width;
};
@Tevinthuku
Tevinthuku / newkeyword.cpp
Last active December 5, 2016 05:28
Most of what you need to know about the new keyword
// BASIC EXAMPLE OF NEW KEYWORD IN ACTION
Cars *benz = new Cars();
// the delete keyword can be placed in the destructor
delete benz;
// EXAMPLE 2;
/* Make clicks pass-through */
#nprogress {
pointer-events: none;
}
#nprogress .bar {
background: #29d;
position: fixed;
z-index: 1031;
@Tevinthuku
Tevinthuku / simulate.cpp
Created August 11, 2018 17:25
This works just fine, though the values might not be similar to the ones given by the lec, thats because Im relying on random numbers of the specified range instead of hard coding the values
//Single Queue simulation
#include <iostream>
#include <fstream>
#include <stdlib.h> //contains the rand() function
#include <math.h>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
@Tevinthuku
Tevinthuku / simpsons.ml
Last active January 30, 2019 05:38
Ocaml challenge on Creating The Mathematical SImpson's rule (https://www.codewars.com/kata/565abd876ed46506d600000d/train/ocaml) .
let simpson n =
let f x = (3.0 /. 2.0) *. sin x *. sin x *. sin x in
let pi = (float_of_int 22 /. float_of_int 7) in
let h = pi /. float_of_int n in
let rec fstSum idx n acc =
if idx > n then (acc) else
fstSum (idx+1) n (acc +. f (float_of_int ((2 * idx) -1) *. h)) in
let rec sndSum idx n acc =
if idx > n then (acc) else
sndSum (idx+1) n (acc +. f (float_of_int (2 * idx) *. h)) in
@Tevinthuku
Tevinthuku / unique_in_order.py
Created January 29, 2019 17:53
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements.
def unique_in_order(iterable):
listofargs = [x for x in (list(iterable))]
uniqueList = []
prevItem = None
for item in listofargs:
if item == prevItem:
prevItem = item
continue
else:
uniqueList.append(item)
@Tevinthuku
Tevinthuku / sum.py
Created January 30, 2019 04:45
Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 integers. No floats or empty arrays will be passed.
def sum_two_smallest_numbers(numbers):
return sum(sorted(numbers)[:2])
@Tevinthuku
Tevinthuku / demo.js
Last active August 13, 2019 11:53
How we will use the library
import { Component, render } from "tevreact"
export default class App extends Component {
state = {
movie: "John Wick"
}
render() {
const { name } = this.state;