Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
@meshell
meshell / CppUG_RAII_main.cpp
Last active February 8, 2025 07:12
RAII example using unique_ptr
#include <cstdio>
#include <cstdlib>
#include <memory>
int main()
{
auto file_open = [](const char* filename, const char* mode) -> FILE*
{
return std::fopen(filename, mode);
};
@kalaksi
kalaksi / rsync-rootfs.md
Last active July 19, 2024 03:15
Copy the whole root filesystem excluding pseudo-filesystems and mountpoints

Copying the whole linux root filesystem locally or remotely using rsync

Explanation of chosen options:

  • Verbose output with speed and progress information
  • Try to preserve all possible information: file attrs, hardlinks, ACLs and extended attrs,
  • Exclude contents of pseudo-filesystems and mountpoints
  • In this example source host is remote and destination local.
rsync --info=progress2  -vaHAX --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} source.host:/ /local/destination
@windoze
windoze / rx-asio.hpp
Created December 19, 2015 14:06
Boost.ASIO scheduler for RxCPP
#include "rxcpp/rx-scheduler.hpp"
// TODO: C++17 Networking TS
#ifdef WITHOUT_BOOST
// Standalone ASIO
#include <asio.hpp>
namespace asio_ns=::asio
namespace system_ns=::std
#else
// Boost.ASIO
@andrewrk
andrewrk / gist:b09e2024177692fcc08e
Last active August 10, 2022 03:58
introducing the zig programming language https://github.com/andrewrk/zig
You appear to be advocating a new:
[ ] functional [x] imperative [ ] object-oriented [x] procedural [ ] stack-based
[ ] "multi-paradigm" [ ] lazy [ ] eager [x] statically-typed [ ] dynamically-typed
[ ] pure [x] impure [ ] non-hygienic [ ] visual [ ] beginner-friendly
[ ] non-programmer-friendly [ ] completely incomprehensible
programming language. Your language will not work. Here is why it will not work.
You appear to believe that:
[ ] Syntax is what makes programming difficult
[ ] Garbage collection is free [ ] Computers have infinite memory

Languages have various allowances for white-space. This is a short exploration of parsers I found and what they claim to accept

Key

Oct  Dec Char  Hex  Key Esc
\000   0  NUL  \x00  ^@ \0 (Null byte)
\010   8   BS  \x08  ^H \b (Backspace)
\011   9   HT  \x09  ^I \t (Horizontal tab)
\012  10   LF  \x0A  ^J \n (Line feed)  (Default UNIX NL)
@maglietti
maglietti / gistColaboration.md
Created August 21, 2015 16:33
How to collaborate on a gist

To colaborate on a gist:

  1. Clone your gist repo locally
  2. Add your friend’s fork as a remote e.g. if your friend is named Cindy: git remote add-url cindy https://gist.github.com/cindy/df03bdacaef75a80f310
  3. Fetch your friend’s commits: git fetch cindy/master
  4. Merge your friend’s changes into your repo: git merge cindy/master
  5. Push the changes back to GitHub: git push origin/master
@Sebb767
Sebb767 / Readme.md
Created August 6, 2015 01:22
Escape The Matrix (Dark Web Article)

This is the famous escape the matrix article from the hidden wiki. Since most mirrors are down and on the hidden wiki itself, the first chaper was replaced with a bitcoin scam, I thought I repost this here. Copyright goes to the original author and I'm not stating any opinion on this text except that it may or may not be an interesting read ;)

The .txt version is taken from here (there's also an intepretation where that came from), the markdown version was converted via some regexes by, well, me.

Have fun :)

@magnetikonline
magnetikonline / README.md
Last active January 29, 2025 06:06
NSSM - the Non-Sucking Service Manager cheatsheet.
@coltnz
coltnz / clojure-repl-log-level-logback
Created February 12, 2015 00:28
set clojure tools logging level in repl (logback version)
; in user.clj
(:import [org.slf4j LoggerFactory]
[ch.qos.logback.classic Logger Level]
(defn set-log-level! [level]
(.. (LoggerFactory/getLogger org.slf4j.Logger/ROOT_LOGGER_NAME)
(setLevel (Level/valueOf (.toUpperCase (name level))))))

How Clojure Code Becomes a Running Program

Lisp, the original high-level language, introduced a long list of features common in languages today, including dynamic typing, interpretation, and garbage collection. The original Lisp language is long gone, but it had many imitators, which we call 'dialects' of Lisp. Clojure, introduced in 2007, is the first Lisp dialect to gain wide usage in three decades.

Though Lisp features have been co-opted by many other languages, what still distinguishes Lisp dialects from all other languages is how Lisp dialects translate source code into running programs. In non-Lisp languages, the code translation process has two primary steps:

  1. lexing (a.k.a. tokenization) and parsing
  2. code generation (compilation or interpretation)