This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::Arc; | |
use std::pin::Pin; | |
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; | |
use std::task::{Context, Poll}; | |
use std::thread; | |
use std::future::Future; | |
use futures::future::join; | |
struct Counter { | |
id: u8, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"math" | |
"os" | |
"sort" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import subprocess | |
from terminaltables import AsciiTable | |
########################################################################### | |
# Constants # | |
########################################################################### | |
CPI_BASE = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef std::chrono::high_resolution_clock Time; | |
typedef std::chrono::milliseconds ms; | |
auto t1 = Time::now(); | |
// do stuff | |
auto t2 = Time::now(); | |
auto diff = std::chrono::duration_cast<ms>(t2 - t1); // returns type ms | |
auto diffValue = diff.count(); // this returns a constexpr "rep" type that can be used as a literal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compiler options | |
CXX = g++ | |
CXXFLAGS = --std=c++11 -Wall -g -pthread | |
# Source code files, object files and the final binary name. | |
SRCS = $(wildcard *.cpp) | |
OBJS = $(SRCS:.cpp=.o) | |
BIN = binary | |
.PHONY: file clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://sourceware.org/gdb/wiki/PermissionsDarwin#Create_a_certificate_in_the_System_Keychain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return state.questions.map(q => { | |
if (q.item === payload.item) { | |
return { | |
...q, | |
steps: { ...q.steps, one: true } | |
} | |
} | |
return q | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdexcept> | |
template <class T> | |
class Node { | |
public: | |
T data; | |
Node<T>* next; | |
Node(const T value) { | |
this->data = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int binarySearch(int array[], int size, int searchValue) { | |
int lo = 0, hi = size - 1; | |
int mid; | |
while (hi > lo) { | |
mid = (lo + hi) / 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// look_path returns a boolean indicating if the binary can be found in $PATH. | |
fn look_path(path: &str) -> Result<bool, std::env::VarError> { | |
std::env::var("PATH").and_then(|paths| { | |
Ok(paths | |
.split(":") | |
.map(|p| format!("{}/{}", p, path)) | |
.any(|p| Path::new(&p).exists())) | |
}) | |
} |