Skip to content

Instantly share code, notes, and snippets.

View drpventura's full-sized avatar

Philip R. Ventura, Ph.D. drpventura

View GitHub Profile
#include <iostream>
#include <algorithm>
using namespace std;
void cube(int& l) {
l = l * l * l;
}
int main() {
@drpventura
drpventura / main.cpp
Last active August 28, 2016 21:22
STL copy function, and comparing builtin arrays with std::array container class. See the video at https://youtu.be/L3IOAsgTpu4.
#include <iostream>
#include <algorithm>
#include <iterator>
#include <array>
using namespace std;
void cube(int& l) {
l = l * l * l;
}
@drpventura
drpventura / vector-ex.cpp
Last active August 28, 2016 22:29
Introduction to vectors, and stl for IO. See video at: https://youtu.be/u79ulGcaHMs.
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <fstream>
using namespace std;
vector<int> get_evens(const vector<int>& nums) {
vector<int> results;
@drpventura
drpventura / main.cpp
Last active September 29, 2016 02:12
Introduction to classes, accessors, mutators, friend functions. See video at https://youtu.be/81jbKLL-CZM.
#include <iostream>
using namespace std;
class Student {
//private:
string name;
double gpa;
public:
@drpventura
drpventura / main.cpp
Created October 22, 2016 18:13
Splitting a string based on a regular expression
// based on code taken from
// http://en.cppreference.com/w/cpp/regex/regex_iterator#Example,
// last access 10/22/2016
#include <regex>
#include <iostream>
using namespace std;
int main() {
// some words to pick apart
@drpventura
drpventura / helpers.h
Last active November 28, 2016 19:33
Example showing growth of O(n) search. See video at https://youtu.be/PB4wHHS_f3A
#include <iostream>
#include <iterator>
#include <random>
#include <chrono>
using namespace std;
#ifndef LSEARCH_UTILS_H
#define LSEARCH_UTILS_H
@drpventura
drpventura / main.cpp
Created December 3, 2016 18:00
Code from final exam video.
#include <iostream>
#include <fstream>
#include <cstdlib> // for rand
#include "utils.h"
using namespace std;
/**
* NOTE: You may add other headers
* as well as your own functions
@drpventura
drpventura / handler.clj
Created December 6, 2016 03:25
Example for figuring out how file upload works.
(ns file-upload.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.multipart-params :refer [wrap-multipart-params]]
[ring.middleware.reload :refer [wrap-reload]]
[ring.adapter.jetty :refer [run-jetty]]
[hiccup.core :refer [html]]))
@drpventura
drpventura / Benford.java
Created January 19, 2017 01:32
Simple file access using Scanner
package edu.usf;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Benford {
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new File("data/sample1.txt"));
@drpventura
drpventura / FileStringsEx.java
Last active January 22, 2017 04:35
Example of using Scanner for I/O from stdin, and files as well as manipulating strings, see video at https://youtu.be/urNqQcqiUTE
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class FileStringsEx {
public static boolean hasComment(String s) {
return s.indexOf("(*") != -1 && s.indexOf("*)") != -1;
}
public static void main(String[] args) throws FileNotFoundException {