Skip to content

Instantly share code, notes, and snippets.

# Install k3s
# Build Dockerfile
docker build . -t simplejob:v1.0.0
# save to a tar file
docker save --output simplejob-v1.0.0.tar simplejob:v1.0.0
# create a yaml with dry-run
kubectl create cronjob simplejob --image=simplejob --schedule="*/1 * * * *" --dry-run=client -o yaml
const variablePattern = /\${([^}]*)}/g;
module.exports = {
format: (normalStringTemplate, values) => {
const replacedStr = normalStringTemplate.replace(variablePattern, (match, p1) => values[p1.trim()]);
const templateStr = `${replacedStr}`;
return templateStr;
},
listVariables: (normalStringTemplate) => {
const pattern = /\${([^}]*)}/g;
function post(opts, data, sucFn, errFn, type) {
var postDataStr = JSON.stringify(data);
console.log('=== postDataStr ===', postDataStr);
var optsPost = {
hostname: opts.host,
port: opts.port ? opts.port : 80,
path: opts.path,
method: (type || 'POST'),
@crlspe
crlspe / http-client.js
Created December 21, 2022 13:58
Makes Http GET and POST requests
const http = require('http');
function get(url) {
return new Promise((resolve, reject) => {
http.get(url, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
@crlspe
crlspe / Networkmanager.conf
Created August 7, 2019 14:24
Blaclist a wifi interfase /etc/NetworkManager/NetworkManager.conf
[keyfile]
unmanaged-devices=interface-name:wls1
@crlspe
crlspe / wifi_connect
Created August 7, 2019 14:12
Connet to wifi wpa_supplicant
sudo wpa_supplicant -B -Dwext -i wlp0s20u2 -c /etc/wpa_supplicant.conf
@crlspe
crlspe / display120hz.sh
Last active August 7, 2019 14:41
Set display to 120hz if DP-0 connected
#!/bin/bash
if (xrandr | grep "DP-0 connected" > /dev/null)
then
exec echo "Conected" &
exec xrandr --output DP-0 --mode 2560x1440 --rate 120.00 &
exec xrandr --output DP-2 --off &
exit
fi%
@crlspe
crlspe / Enums
Last active March 23, 2017 22:43
public static T Parse<T>(string value)
{
return (T)Enum.Parse(typeof(T), value, true);
}
public static IEnumerable<T> GetValues<T>()
{
return Enum.GetValues(typeof(T)).Cast<T>();
}