Skip to content

Instantly share code, notes, and snippets.

Avatar

Gleb Mazovetskiy glebm

View GitHub Profile
View mke2fs.conf.diff
--- /etc/mke2fs.conf 2019-09-30 18:57:59.000000000 +0100
+++ mke2fs.conf 2020-03-28 16:12:38.972403738 +0000
@@ -1,5 +1,5 @@
[defaults]
- base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
+ base_features = sparse_super,large_file,filetype,resize_inode,dir_index
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
@@ -11,7 +11,7 @@
@glebm
glebm / FindSDL_gfx.cmake
Created Feb 15, 2020
FindSDL_gfx.cmake
View FindSDL_gfx.cmake
# Tries to find SDL_gfx (for SDL1)
# Once done, this will define:
# > SDL_GFX_FOUND - The system has libnx
# > SDL_GFX_INCLUDE_DIRS - The libnx include directories
# > SDL_GFX_LIBRARIES - The libnx libraries required for using it
find_path(SDL_GFX_INCLUDE_DIR SDL_gfxPrimitives.h
HINTS
$ENV{SDL_GFX_DIR}
$ENV{SDLDIR}
View topsort.cpp
struct TopSortResult {
bool ok;
// If `ok`, contains the topologically sorted node indices.
// Otherwise, contains indices of a detected cycle.
std::vector<std::size_t> nodes;
};
// Topologically sorts dependencies.
TopSortResult topsort(const std::vector<std::vector<int>> &edges) {
View libsass-2908.patch
diff --git a/src/extender.cpp b/src/extender.cpp
index 6d96b8d0..8456a6a1 100644
--- a/src/extender.cpp
+++ b/src/extender.cpp
@@ -287,11 +287,11 @@ namespace Sass {
// Note: this function could need some logic cleanup
// ##########################################################################
void Extender::addExtension(
- SelectorListObj& extender,
- SimpleSelectorObj& target,
@glebm
glebm / TextPlainStyleDarkCentered.md
Last active Sep 14, 2017
Light on dark centered content style for text/plain documents
View TextPlainStyleDarkCentered.md

This is a userscript with a light-on-dark content-centered style for plain/text documents.

light-on-dark-plain-text

Installation

To install this userscript in Chrome, save the JavaScript file and drag it onto the chrome://extensions page.

If you use ViolentMonkey, TamperMonkey, or GreaseMonkey, install from one of these links:

@glebm
glebm / generate.js
Last active Oct 24, 2017
A quick hack to generate a codepoint set presence condition (JS)
View generate.js
const regenerate = require('regenerate');
/* char-graphic? */
const SETS = ['Letter', 'Mark', 'Number', 'Punctuation', 'Symbol'].map(category =>
require(`unicode-10.0.0/General_Category/${category}/code-points.js`));
/* char-blank? */
// const SETS = [['\t']].concat(['Space_Separator'].map(category =>
// require(`unicode-10.0.0/General_Category/${category}/code-points.js`)));
@glebm
glebm / README.md
Last active Dec 29, 2019
Rails Link Preload Headers
View README.md

This lets you set the preload headers for your assets, so that the browser can start fetching them before it begins parsing HTML.

@glebm
glebm / README.md
Last active Oct 12, 2018
Universal Rails async onPageLoad script (Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks)
View README.md

This lets you load application JavaScript asynchronously from <head>. Compatible with Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks. Compatible with all browsers and IE9+ (only IE10+ will actually benefit from this though).

How to use this:

  1. Add the HTML snippet just before the closing </body> tag.

  2. Add the on_page_load.js script to the beginning of your application.js, and use window.App.onPageLoad(...) instead of document.addEventListener('DOMContentLoaded', ...) and jQuery(($) -> ...) everywhere.

  3. Include your JavaScript like so:

    <head>
@glebm
glebm / primes.rs
Last active Aug 22, 2020
Rust: Erathosthenes prime sieve
View primes.rs
fn is_prime(n: usize, primes: &Vec<usize>) -> bool {
for &p in primes {
let q = n / p;
if q < p { return true };
let r = n - q * p;
if r == 0 { return false };
}
panic!("too few primes")
}
You can’t perform that action at this time.