Skip to content

Instantly share code, notes, and snippets.

typing fast

Tev Tevinthuku

typing fast
View GitHub Profile
View arrays.cpp
// 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 / pointers.cpp
Created Dec 2, 2016
Most of what you need to know about pointers..
View pointers.cpp
// 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 / main.cpp
Last active Dec 3, 2016
Most of what you need to know about classes
View main.cpp
// class examples
// author : Tevin Thuku
// Date: 3rd: Dec: 2016
class Square {
double length;
double width;
Tevinthuku / newkeyword.cpp
Last active Dec 5, 2016
Most of what you need to know about the new keyword
View newkeyword.cpp
Cars *benz = new Cars();
// the delete keyword can be placed in the destructor
delete benz;
View ngprogress.css
/* Make clicks pass-through */
#nprogress {
pointer-events: none;
#nprogress .bar {
background: #29d;
position: fixed;
z-index: 1031;
Tevinthuku / simulate.cpp
Created Aug 11, 2018
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
View simulate.cpp
//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 /
Last active Jan 30, 2019
Ocaml challenge on Creating The Mathematical SImpson's rule ( .
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 /
Created Jan 29, 2019
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
Tevinthuku /
Created Jan 30, 2019
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 / demo.js
Last active Aug 13, 2019
How we will use the library
View demo.js
import { Component, render } from "tevreact"
export default class App extends Component {
state = {
movie: "John Wick"
render() {
const { name } = this.state;