Skip to content

Instantly share code, notes, and snippets.

View rpdiss's full-sized avatar
🏠
Working from home

Rafał Piekarski rpdiss

🏠
Working from home
View GitHub Profile
/* .im_drunk, .im_baked, .im_trippin, .im_blown */
.mw-strobe_light {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100000;
background-color: rgba(250,250,250,0.8);
@rpdiss
rpdiss / README.md
Created November 30, 2021 07:19 — forked from djfdyuruiry/README.md
WSL 2 - Enabling systemd

Enable systemd in WSL 2

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

    cd /tmp
@rpdiss
rpdiss / main.dart
Created August 10, 2021 20:54 — forked from netsmertia/main.dart
flutter image drawing in canvas
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter/services.dart' show rootBundle;
import 'dart:async';
import 'dart:typed_data';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@rpdiss
rpdiss / disable-suspend.md
Created January 8, 2021 11:19 — forked from bzerangue/disable-suspend.md
Disable Sleep/Suspend and WiFi in Ubuntu 16.04 LTS

On Ubuntu 16.04 LTS, I successfully used the following to disable suspend:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

And this to re-enable it:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

@rpdiss
rpdiss / ContextCmder-Disable.reg
Last active October 14, 2019 00:23 — forked from jojobyte/ContextCmder-Disable.reg
Cmder Context (Right-Click) Menu for Windows 7, 8 & 10
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder]
[-HKEY_CLASSES_ROOT\Directory\shell\Cmder]
@rpdiss
rpdiss / cancelable-timeout.js
Created October 2, 2019 17:28
cancelable timeout js javascript
export const cancelableTimeout = (() => {
let timeout;
return (fn, delay) => {
if (!timeout) {
timeout = setTimeout(fn, delay);
} else {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
}
return timeout;
@rpdiss
rpdiss / credit-card-mask.ts
Created September 27, 2019 12:13
typescript credit card masking function
export const maskCreditCard = async (creditCard: string, start: number, end: number, mask = `*`): Promise<string> => {
const pattern = `(?<=[0-9]{${start}})(?:.*:?)(?=[0-9]{${end}})`;
const regExp = new RegExp(pattern, 'g');
const startRes = creditCard.substr(0, start);
const endRes = creditCard.substr(creditCard.length - end);
const maskMatch = '4505290686046367'.match(regExp);
return maskMatch ? `${startRes}${maskMatch[0].replace(/[a-zA-Z0-9]/g, mask)}${endRes}` : creditCard.replace(/[a-zA-Z0-9]/g, mask);
};
@rpdiss
rpdiss / mongo-docker.bash
Created January 16, 2019 18:37 — forked from davideicardi/mongo-docker.bash
Running mongodb inside a docker container (with mongodb authentication)
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
@rpdiss
rpdiss / heat-overlay-r-p.ts
Created May 9, 2018 11:41
leaflet heatmapjs plugin port to ts
import L from "leaflet";
import 'heatmap.js';
/**
* author: Rafał Piekarski
* email: [email protected]
* this was made only cuz of need
* for personal usage feel free to email
* me with some improvements
*
@rpdiss
rpdiss / app.js
Created October 24, 2017 22:17
Simple, complete example of a bot in Discord.js
// Load up the discord.js library
const Discord = require("discord.js");
// This is your client. Some people call it `bot`, some people call it `self`,
// some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
// this is what we're refering to. Your client.
const client = new Discord.Client();
// Here we load the config.json file that contains our token and our prefix values.
const config = require("./config.json");