r/tinycode • u/rain5 • Aug 06 '17
Co-dfns Live Stream: Compiler Design and Architecture [APL] [HIGH DENSITY]
r/tinycode • u/rain5 • Aug 06 '17
r/tinycode • u/CountFrolic • Jul 19 '17
r/tinycode • u/BenRayfield • Jul 14 '17
Most people see tinycode as screwing around. I see it as fixing a serious problem of dealing with the buildup of complexity.
r/tinycode • u/impshum • Jul 13 '17
r/tinycode • u/Jimmy_Lor • Jul 10 '17
r/tinycode • u/akkartik • Jul 10 '17
r/tinycode • u/akkartik • Jul 10 '17
r/tinycode • u/roccomusolino • Jun 18 '17
r/tinycode • u/luserdroog • Jun 16 '17
r/tinycode • u/DavidBuchanan • Jun 07 '17
r/tinycode • u/cdo256 • May 24 '17
r/tinycode • u/rap2h • May 23 '17
r/tinycode • u/[deleted] • May 22 '17
... now down to 27 lines of code courtesy of /u/jra101
#include <string>
#include <map>
#include <sstream>
#include <fstream>
#include <mutex>
//Might only be valid on linux and bsd
#include <sys/stat.h>
std::string file_to_string(std::string filename) {
std::ifstream file {filename};
std::stringstream pointless_string_stream{};
pointless_string_stream << file.rdbuf();
return pointless_string_stream.str();
}
// File cache
std::string file_cache(std::string key, std::string filepath) {
static std::map<std::string, std::string> cache_map{};
static std::map<std::string, time_t> modified_time_map{};
static std::mutex cache_mutex{};
std::lock_guard<std::mutex> lock(cache_mutex);
if(cache_map.end() == cache_map.find(key)) {
time_t current_time;
time(¤t_time);
modified_time_map[key] = current_time;
cache_map[key] = file_to_string(filepath);
}
struct stat file_stats;
if(stat(filepath.c_str(), &file_stats)==0)
{
time_t file_modification_time = file_stats.st_mtim.tv_sec;
if(modified_time_map[key] < file_modification_time) {
time_t current_time;
time(¤t_time);
modified_time_map[key] = current_time;
cache_map[key] = file_to_string(filepath);
}
}
return cache_map[key];
}r/tinycode • u/ShineSparkio • May 13 '17
https://github.com/LiveAsynchronousVisualizedArchitecture/simdb
This is a hash based key-value, store created to be a fundamental piece of a larger software architecture.
High Performance - Real benchmarking needs to be done, but superficial loops seem to run conservatively at 500,000 small get() and put() calls per logical core per second. Because it is lock free the performance scales well while using at least a dozen threads.
Shared Memory - It uses shared memory maps on Windows, Linux, and OSX without relying on any external dependencies. This makes it exceptionally good at interprocess communication.
Lock Free - All the user facing functions are thread-safe and lock free with the exception of the constructor (to avoid race conditions between multiple processes creating the memory mapped file at the same time).
Cross Platform - Compiles on Visual Studio 2013, ICC 15.0, gcc on Linux, gcc on OS X, and Clang on OS X.
Single File - simdb.hpp and the C++11 standard library is all you need. No windows SDK or any other dependencies, not even from the parent project.
Apache 2.0 License - No need to GPL your whole program to include one file.
This has already been used for both debugging and visualization, but should be treated as alpha software. Though there are no known outstanding bugs, there are almost certainly bugs (and small design issues) waiting to be discovered and so will need to be fixed as they arise.
There is an in-depth explanation in the comments of the simdb.hpp file itself.
r/tinycode • u/api • May 04 '17
r/tinycode • u/rain5 • Apr 10 '17
Explanation: https://rain-1.github.io/shell
Repository: https://github.com/rain-1/s
r/tinycode • u/nexe • Apr 04 '17
r/tinycode • u/Gymnae • Apr 02 '17
I'm looking for a script, which allows people to upload images via a website to a local server which also runs a gallery script to display a live updating slideshow in a browser.
The setup is for an offline event, where I bring a tiny Debian box and attach it to a screen and make it an access point for people to upload to.
I google around but could so far only find very powerful gallery scripts aimed at pre-set folders or not on live updates