Skip to content

Instantly share code, notes, and snippets.

View naartjie's full-sized avatar

Marcin Jekot naartjie

View GitHub Profile
@naartjie
naartjie / wget.sh
Created January 1, 2021 16:10 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@naartjie
naartjie / logback.xml
Created April 18, 2020 11:53 — forked from jeroenr/logback.xml
Logback configuration splitting to stdout and stderr
<configuration>
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
<target>System.err</target>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
@naartjie
naartjie / docker_cleanup.md
Created September 24, 2019 14:58 — forked from fredeerock/docker_cleanup.md
clean up docker

Stop all containers:

  • docker ps -aq | xargs docker stop

Remove all containers:

  • docker ps -aq | xargs docker rm

Remove all images:

  • docker images -aq | xargs docker rmi

Remove all networks:

Here are several different ways to test a TCP port without telnet.

$ cat < /dev/tcp/127.0.0.1/22
SSH-2.0-OpenSSH_5.3
^C

$ cat &lt; /dev/tcp/127.0.0.1/23
@naartjie
naartjie / read-access.sql
Created August 2, 2018 14:50 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
// Option A:
const React = require('react');
const counterState = React.createState();
const counterReducer = (action, state) => {
switch (action) {
case "INCREMENT": {
return React.updateState({counter: state.counter + 1});
}
}
@naartjie
naartjie / core.clj
Created April 15, 2016 11:46 — forked from josf/core.clj
(defn arg-find
"Helper function for defroute that extracts code from the body and
organizes it as bindings, symbols and body. Function calls within
the body are replaced by their corresponding gensyms. (:symbols is
just a list of the gensyms in :bindings, for convenience)"
[body]
(reduce (fn [acc [k v]]
(if (list? v)
(let [sym (gensym (str (name k) "-"))]
@naartjie
naartjie / walkAsync.js
Last active September 3, 2015 08:35 — forked from RReverser/gist:0a0263ec5abc5db03e05
async await
async function walk (dir, visitor) {
const filenames = await fs.readdirAsync(dir)
await* filenames
.map(filename => path.join(dir, filename))
.map(async filename => {
const stat = await fs.statAsync(filename)
if (stat.isDirectory()) {
await walk(filename, visitor)
} else {
@naartjie
naartjie / .jshintrc
Last active August 29, 2015 14:16 — forked from kentcdodds/.jshintrc
{
"curly": true,
"eqeqeq": true,
"bitwise": true,
"camelcase": true,
"expr": true,
"esnext": true,
"forin": true,
"freeze": true,
"immed": true,
@naartjie
naartjie / object_ext.moon
Last active July 8, 2022 21:20
Moonscript Object accessors extension
getters = (cls, getters) ->
cls.__base.__index = (key) =>
if getter = getters[key]
getter @
else
cls.__base[key]
setters = (cls, setters) ->
cls.__base.__newindex = (key, val) =>
if setter = setters[key]