Skip to content

Instantly share code, notes, and snippets.

View cbzehner's full-sized avatar
🚀

Chris Zehner cbzehner

🚀
View GitHub Profile
@cbzehner
cbzehner / filesRecursive.hs
Last active January 14, 2018 01:23
Trying to create a set of functions that will get all the files in directory and all of it's subdirectories and so on and so forth
module Files
( getFilesRecursively
) where
import System.Directory (doesDirectoryExist, doesFileExist, listDirectory)
import System.Exit
import System.FilePath (combine)
data PathType = Directory | File | Invalid
deriving (Eq, Ord, Show, Enum)
fn main() {
let rust = String::from("🦀 is 🔥");
let split_crab = &rust[1..];
println!("{}", split_crab);
}
$cargo run
Compiling slice_test v0.1.0 (file:///Users/cbzehner/Projects/rust/slice_test)
Finished dev [unoptimized + debuginfo] target(s) in 0.71 secs
Running `target/debug/slice_test`
thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside '🦀' (bytes 0..4) of `🦀 is 🔥`', src/libcore/str/mod.rs:2234:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@cbzehner
cbzehner / largest.rs
Created February 20, 2018 00:30
Implement largest with just the PartialOrd trait bound
fn largest<T: PartialOrd>(list: &[T]) -> &T {
let mut largest = &list[0];
for ref item in list.iter() {
if *item > largest {
largest = item;
}
}
largest
fn main() {
let r = 2;
{
let x = 5;
let r = x;
}
println!("r: {}", r);
}
@cbzehner
cbzehner / err.bash
Last active February 26, 2018 17:07
Include Utc in imports
cbzehner at MacBook-Pro-4 ~/Projects/pull-requests/rust/exercises/gigasecond [SUCCESS]
$cargo check
Compiling gigasecond v1.1.0 (file:///Users/cbzehner/Projects/pull-requests/rust/exercises/gigasecond)
error[E0412]: cannot find type `Utc` in this scope
--> src/lib.rs:6:30
|
6 | pub fn after(start: DateTime<Utc>) -> DateTime<Utc> {
| ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
|
cbzehner at MacBook-Pro-4 ~/Projects/pull-requests/rust/exercises/nth-prime [SUCCESS]
$cargo test
Compiling nth_prime v1.0.0 (file:///Users/cbzehner/Projects/pull-requests/rust/exercises/nth-prime)
Finished dev [unoptimized + debuginfo] target(s) in 0.81 secs
Running target/debug/deps/nth_prime-94d2e6fce3eb8601
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
@cbzehner
cbzehner / boringtask.sql
Created March 3, 2018 05:58
Movie Programming
SELECT
name as full_name,
dob as birthday,
job as profession,
loc as office,
role as title
FROM employees
WHERE
profession LIKE '%ngineer%'
AND loc IN ['Fremont', 'San Francisco', 'Sunnyvale']
@cbzehner
cbzehner / wt-cli.sh
Created March 6, 2018 03:04
npm WARNings
cbzehner at MacBook-Pro-4 ~/projects[SUCCESS]
$npm i -g wt-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/wt-cli -> /usr/local/lib/node_modules/wt-cli/bin/wt
/usr/local/bin/wt -> /usr/local/lib/node_modules/wt-cli/bin/wt
/usr/local/bin/auth0 -> /usr/local/lib/node_modules/wt-cli/bin/auth0
> fsevents@1.1.3 install /usr/local/lib/node_modules/wt-cli/node_modules/fsevents
> node install
@cbzehner
cbzehner / mergesort.rs
Created March 12, 2018 02:52
An implementation of Merge Sort in Rust (with a little help from my friends!)
/// Sorts a slice in-place-ish with mergesort.
/// Time Complexity: O(n * log(n))
/// Space Complexity: O(n)
///
/// ```
/// use merge_sort::merge_sort;
///
/// let mut example = [1,4,2,5,3];
///
/// merge_sort(&mut example);