Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
ArtemGr / .gitignore
Last active February 28, 2022 15:10
extract repositories and code from CodeSearchNet
# CodeSearchNet
/python*.jsonl
/python*.jsonl.gz
/python.zip
/code.txt
/repos.txt
@ArtemGr
ArtemGr / .gitignore
Last active February 6, 2022 11:24 — forked from mfelsche/sled_experiment.rs
Rocksdb experiment, watching consumed disk space
/target
/db
/Cargo.lock
@ArtemGr
ArtemGr / nice.cc
Created November 17, 2012 07:09
Nice priority of a Linux thread.
#include <iostream> // cout, cerr, endl
#include <memory> // shared_ptr
#include <sys/time.h> // setpriority
#include <sys/resource.h> // setpriority
/**
* Set low nice priority in the current Linux thread.\n
* Usage: \code auto&& restorePriority = ioNice(); \endcode.
*/
static shared_ptr<void> ioNice (int priority = 19) {
@ArtemGr
ArtemGr / apache2.conf
Created October 15, 2013 15:10
Apache 2.4 reverse proxy with URL substitution.
# Turn compression off in order for the Substitute to work.
RequestHeader unset Accept-Encoding "expr=%{REQUEST_URI} =~ m#^/news#"
# http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#examples
ProxyPass /news http://newspaper.ipage.am
ProxyPassReverse /news http://newspaper.ipage.am
Substitute "s|http://newspaper.ipage.am|http://mercatos.net/news|n"
# In order for the substitute module to work we have to add it to the filter chain.
FilterDeclare Substitute
FilterProvider Substitute SUBSTITUTE "%{REQUEST_URI} =~ m#^/news#"
FilterChain +Substitute
@ArtemGr
ArtemGr / certbot.js
Last active October 4, 2021 08:31
certbot
//@ts-check
// TODO: A function to run the `certbot`; arguments: domain, email
const fs = require ('fs');
const http = require ('http');
const os = require ('os');
/**
* Example invoking certbot for this function, on Debian 10 Buster:
@ArtemGr
ArtemGr / pcre-jit.rs
Last active April 6, 2021 21:03
Example using JIT-compiled PCRE expressions from Rust.
pub struct PcreJit {
pub re: Mutex<pcre::Pcre>,
/// Map from a capturing group name to its number.
/// `None` if no named capturing groups found or if the `auto_capture` option is given to `PcreJit::new`.
pub names: Option<BTreeMap<String, Vec<usize>>>}
unsafe impl Sync for PcreJit {}
unsafe impl Send for PcreJit {}
impl PcreJit {
/// JIT-compiles the regular expression.
///
@ArtemGr
ArtemGr / .gitignore
Last active March 20, 2021 06:30
termkit-pause
/node_modules
/package-lock.json
@ArtemGr
ArtemGr / map_bench.rs
Last active June 5, 2020 15:13
small strings map benchmark
// [build] cd .. && cargo bench
#![feature(asm, test)]
extern crate inlinable_string;
extern crate ordermap;
extern crate seahash;
extern crate test;
use inlinable_string::{InlinableString, StringExt};
@ArtemGr
ArtemGr / SCGI.java
Last active March 28, 2020 23:54
Java SCGI connector
/*
Copyright (c) 2008 ArtemGr
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@ArtemGr
ArtemGr / mac-port-forwarding-fails.txt
Created February 17, 2020 21:55
mac-port-forwarding-fails.txt
administrator@macinvalut:~$ docker stop komodo-dex
komodo-dex
administrator@macinvalut:~$ docker run -d --rm -p 14868:14868 -p 14869:14869 --name komodo-dex komodo-dex
479ca54e6d7c2a6d53cab4823b47c44ba5bd1cb712cfd4bed8b5cb79cccf96e6
administrator@macinvalut:~$ docker logs komodo-dex
ASSETCHAINS_SUPPLY 999999
MAX_MONEY 100006220417438 1000062.20417438
>>>>>>>>>> DEXP2P: p2p.14868 rpc.14869 magic.6378a12f 1668849967 999999 coins
call komodo_args.(komodod) NOTARY_PUBKEY.()
nMaxConnections 384