Skip to content

Instantly share code, notes, and snippets.

View dptole's full-sized avatar

dptole

View GitHub Profile
module Main exposing (main)
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Keyed
import Http
import Json.Decode exposing (Decoder, field, string, dict, map2)
@dptole
dptole / bypass-trusted-script-assignment.js
Created May 21, 2023 19:17
Bypass "This document requires 'TrustedScript' assignment" error
/*
This document requires 'TrustedScript' assignment
https://greasyfork.org/en/scripts/433051-trusted-types-helper
*/
var html = '<p>ok</p>'
trustedTypes.createPolicy('default', {
createHTML: function (string, sink) { return string }
})
var $d = document.createElement('div')
var $d.innerHTML = trustedTypes.defaultPolicy.createHTML(html)
@dptole
dptole / ovpn-create-connections.sh
Created April 29, 2023 06:44
Import OpenVPN files en mass using nmcli (Network Manager CLI)
#!/usr/bin/bash
# You must be in the folder containing all *.ovpn files
username="USERNAME FOR ALL CONNECTIONS"
password="PASSWORD FOR ALL CONNECTIONS"
for path in `ls *.ovpn`
do
connectionName=$(basename $path ".ovpn")
nmcli --terse connection delete id "$connectionName"
nmcli --terse connection import type openvpn file "$path"
@dptole
dptole / centos-php7.3.sh
Last active April 8, 2023 06:10
[Centos] Install php7.3 from source + fpm
# Assume MySQL /var/run/mysqld/mysqld.sock
rm /var/mail/nginx
rm -rf /home/nginx
userdel nginx
useradd nginx -M -l -s /sbin/nologin -U
mkdir -p /app/php
cd /app/php
wget https://www.php.net/distributions/php-7.3.0.tar.gz
@dptole
dptole / centos-nginx.sh
Created April 8, 2023 05:57
[Centos] Install nginx from source + brotli + geoip2
yum -y update
yum -y install libmaxminddb-devel geoip-devel
mkdir -p /app/nginx
cd /app/nginx
wget https://nginx.org/download/nginx-1.22.1.tar.gz
tar xzf nginx-1.22.1.tar.gz
cd nginx-1.22.1
sed -r -i 's/(static u_char ngx_http_server_string\[\]).*/\1 = "";/' src/http/ngx_http_header_filter_module.c
@dptole
dptole / .vimrc
Last active March 4, 2023 15:16
My Vim configurations.
set sts=2
set ts=2
set sw=2
set et
set number
set encoding=utf-8
syntax on
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
autocmd BufReadPost,BufNewFile *.elm setfiletype haskell
@dptole
dptole / help.js
Last active September 1, 2022 15:26
Nodejs simple pagination
const help = {
genPagination: (pageLength, fullPageSelectedIndex) => {
const fullPage = Array.from(Array(pageLength)).map((v, i) => i)
if (fullPage.length < 11) return fullPage
let minLeftCut = 2
let maxLeftCut = 6
let minRightCut = 2
@dptole
dptole / docker-fix.sh
Last active August 24, 2020 09:47
Fix docker container when it can't connect to the internet https://stackoverflow.com/a/20431030
# Source
# https://stackoverflow.com/a/20431030
# Turn off docker service
sudo service docker stop
# Delete iptables
sudo iptables -t nat -F
# Bring docker ethernet interface down
@dptole
dptole / webgl-3d-cube.html
Last active August 24, 2020 09:45
WebGL standalone example: 3D cube (js) https://jsfiddle.net/4bdwavo0/
<!-- https://jsfiddle.net/4bdwavo0/ -->
<!doctype html>
<html>
<head>
<!-- https://webglfundamentals.org/ -->
<style>