Skip to content

Instantly share code, notes, and snippets.

@dkrusky
dkrusky / autofill.js
Created Sep 12, 2020
Automatically fill out a webform UI with test data. (supports: select, text, checkbox, textarea, radio)
View autofill.js
// tested with jQuery 3.x
$(document).ready(function(){
$("[name^=entry]").each(function(){
switch($(this).prop("type")) {
case "radio":
$(this).prop("checked", true);
break;
case "checkbox":
$(this).prop("checked", true);
break;
@dkrusky
dkrusky / pfx2pem.sh
Created Aug 20, 2020
Command line script to convert pfx with private key to pem format for Apache/nginx
View pfx2pem.sh
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "
Command Syntax:
pfx2pem <cert> <optional:password>
"
@dkrusky
dkrusky / setup.sh
Last active Aug 18, 2020
Script to assist in post installation of minimal secure setup for Debian.
View setup.sh
#!/bin/bash
# ************************************
# * SETTINGS *
# ************************************
FIREWALL_DYNDNS="";
FIREWALL_GEOIP_ACCOUNT="";
FIREWALL_GEOIP_LICENSE="";
# Set value to 1 to install that feature. Otherwise set to 0
@dkrusky
dkrusky / setup.sh
Created Aug 6, 2020
Debian post-install core configuration script with firewall, mysql, php, composer, and nvm.
View setup.sh
#!/bin/bash
# ************************************
# * SETTINGS *
# ************************************
FIREWALL_DYNDNS="";
FIREWALL_GEOIP_ACCOUNT="";
FIREWALL_GEOIP_LICENSE="";
# Set value to 1 to install that feature. Otherwise set to 0
View hmac.java
// API details
String APIKey = "xxxxxxx";
String APISecret = "xxxxxxx";
String APIEndpoint = "https://www.domain.com/api/";
String APIVersion = "1.0";
// an example API call
String action = "/client/authenticate/user/pass/0/xxxx"
// build complete API call
@dkrusky
dkrusky / configure-debian-9-linode.sh
Last active Dec 23, 2018
Configure fresh Debian 9 on Linode for hosted site with SSL, firewall, mysql, apache2, and php7.2-fpm
View configure-debian-9-linode.sh
#!/bin/bash
# set the dyndns name you want to allow access from
dyndns="testing.noip.me"
# set the domain you will be using
domain="testing.com"
# set the email address for letsencrypt
email="info@testing.com"
@dkrusky
dkrusky / wp-config.php
Created Dec 22, 2018
Better WordPress Config (All customization's available)
View wp-config.php
<?php
/* Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') ) { define('ABSPATH', dirname(__FILE__) . '/'); }
/* Debug Mode */
error_reporting(E_ALL);
@ini_set('display_errors', false );
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
define( 'WP_DEBUG_DISPLAY', false );
@dkrusky
dkrusky / get-letsencrypt-key-pin.sh
Last active Dec 20, 2018
LetsEncrypt get sha256 keypin headers for HSTS/HPKP apache2
View get-letsencrypt-key-pin.sh
#!/bin/bash
HPKP=`openssl x509 -in /etc/letsencrypt/live/"$1"/cert.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64`
echo "<IfModule mod_headers.c>"
echo " Header Always set Strict-Transport-Security \"max-age=31536000; includeSubdomains; preload\" env=HTTPS"
echo " Header always set Public-Key-Pins \"pin-sha256=\\\"$HPKP\\\"; max-age=5184000"
echo "</IfModule>"
@dkrusky
dkrusky / HMAC.swift
Created Nov 26, 2018 — forked from MihaelIsaev/HMAC.swift
Easy to use Swift implementation of CommonCrypto HMAC. You can easily hash your String to: md5, sha1, sha224, sha256, sha384, sha512 with pure Swift.
View HMAC.swift
//
// HMAC.swift
//
// Created by Mihael Isaev on 21.04.15.
// Copyright (c) 2014 Mihael Isaev inc. All rights reserved.
//
// ***********************************************************
//
// How to import CommonCrypto in Swift project without Obj-c briging header
//
@dkrusky
dkrusky / curl.inc.php
Created Oct 31, 2018
Ultimate curl wrapper
View curl.inc.php
<?php
//abstract class curl {
class curl {
private $error_codes;
private $_headers;
private $_options;
public $headers;