This file contains 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
let coords = pixels(&image_size); | |
let accumulator = coords | |
.iter() | |
.filter(|coords| is_edge(coords)) | |
.map(|coords| invert_y(coords)) | |
.flat_map(|coords| (0..theta_axis_size).map(|theta| (theta, calculate_rho(theta, &coords))).collect::<Vec<_>>()) | |
.fold( | |
DMatrix::from_element(theta_axis_size as usize, rho_axis_size as usize, 0), | |
|mut a, x| { | |
a[(x.0 as usize, x.1 as usize)] += 1; |
This file contains 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 <vector> | |
#include <fstream> | |
#include <iostream> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <stdbool.h> | |
This file contains 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 <unistd.h> | |
#include <sys/types.h> | |
#include <dirent.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <string> | |
const char *get_filename_ext(const char *filename) | |
{ | |
const char *dot = strrchr(filename, '.'); |
This file contains 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
<?php | |
$now = microtime(true); | |
$start = round(($now - (150 * 24 * 60 * 60)) * 1000); | |
$end = round($now * 1000); | |
$filterPattern = escapeshellarg('{ $.object.msg = "access" }'); | |
function getLogs($nextToken, $start, $end, $filterPattern, $depth = 1) { | |
$cmd = sprintf( | |
'aws logs filter-log-events --log-group-name live-sg --log-stream-name web2.live-sg --start-time %d --end-time %d --filter-pattern %s --page-size 100 --max-items 10000', |
This file contains 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 <lua5.3/lua.hpp> | |
#include <stdlib.h> | |
#include <stdio.h> | |
static int draw_rectangle(lua_State *L) | |
{ | |
printf("function called\n"); | |
return 1; |
This file contains 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
static void handle_file(struct evhttp_request *req, void *arg) | |
{ | |
UNUSED(arg); | |
const char *uri = evhttp_request_get_uri(req); | |
// only GET requests allowed | |
if (evhttp_request_get_command(req) != EVHTTP_REQ_GET) { | |
evhttp_send_error(req, HTTP_BADREQUEST, 0); | |
return; |
This file contains 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
enum class URI_TO_PATH_STATUS : std::int8_t { | |
SUCCESS = 0, | |
FAILURE_URI_PARSE, | |
FAILURE_URI_TO_PATH, | |
FAILURE_PATH_DECODE, | |
}; | |
std::tuple<std::string, URI_TO_PATH_STATUS> uri_to_path(const char *uri) { | |
assert(uri != NULL); |
This file contains 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
int main(int argc, char **argv) | |
{ | |
UNUSED(argc); | |
struct event_base *base; | |
struct evhttp *http; | |
struct evhttp_bound_socket *handle; | |
const ev_uint16_t port = 8881; | |
const char *host = "0.0.0.0"; |
This file contains 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
project(webserver) | |
cmake_minimum_required(VERSION 3.2) | |
SET(LIBEVENT_NAME "event" CACHE STRING "Name of the libevent library (as used in the linker argument).") | |
SET(LIBEVENT_LIB_DIR "/usr/local/lib" CACHE STRING "Path to libevent libraries.") | |
SET(LIBEVENT_INCLUDE_DIR "/usr/local/include" CACHE STRING "Path to libevent headers.") | |
MESSAGE("LIBEVENT_NAME: " ${LIBEVENT_NAME}) | |
MESSAGE("LIBEVENT_LIB_DIR: " ${LIBEVENT_LIB_DIR}) |
This file contains 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
(defn generate-prices | |
([low high] | |
(generate-prices (random-in-range low high))) | |
([last-price] | |
(iterate (fn [{:keys [last]}] | |
(let [low (- last 5) | |
high (+ last 5) |