Skip to content

Instantly share code, notes, and snippets.

@trasherdk
trasherdk / randommac.sh
Created June 10, 2017 17:15 — forked from WebReflection/randommac.sh
Getting free wifi on Linux too
#!/usr/bin/env bash
# @example
# chmod a+x randommac.sh
# ./randommac.sh wlp2s0
# @credits original macOS / osX version via @rem
# https://remysharp.com/2017/05/29/getting-free-wifi
if [ "$1" != "" ]; then
@trasherdk
trasherdk / openssl_encrypt_decrypt.php
Created November 7, 2018 04:59 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@trasherdk
trasherdk / PushNotifications.php
Created November 7, 2018 05:04 — forked from joashp/PushNotifications.php
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
<?php
// Server file
class PushNotifications {
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.
private static $channelName = "joashp";
@trasherdk
trasherdk / self-signed-certificate-with-custom-ca.md
Created December 14, 2018 01:46 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@trasherdk
trasherdk / openssl.md
Created December 14, 2018 01:52 — forked from NoMan2000/openssl.md
Common OpenSSL Commands with Keys and Certificates

Common OpenSSL Commands with Keys and Certificates

SSL Info

Generate RSA private key with certificate in a single command

openssl req -x509 -newkey rsa:4096 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650 -passout pass:foobar

Generate Certificate Signing Request (CSR) from private key with passphrase

openssl x509 -x509toreq -in example.crt -out example.csr -signkey example.key -passin pass:foobar

@trasherdk
trasherdk / README.md
Last active December 19, 2018 12:35 — forked from andredumas/.gitignore
TechanJS Server Side Generation

Demonstrates chart generation on both server side (top chart) using node.js and client side (bottom chart).

Note: For the purpose of this example and not having node.js available servers side, chart.svg has been pre generated using instructions for this project:

npm install
node index.js > chart.svg
<?php
// The URL where the test-auth.php script resides.
define("POST_DATA_TO_URL", "http://someurl/my-script.php");
// Function to send value to my-script.php script via cURL with digest authentication.
function submitValue($myValue) {
$ch = curl_init(POST_DATA_TO_URL);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, "admin:mypass");
@trasherdk
trasherdk / gist:45b750cede99b32ac940aa1005d0a07c
Created December 22, 2020 04:12 — forked from steveclarke/gist:1411146
Git: Setting up a Remote Repository and Doing Initial Push

Setup remote repository:

ssh [email protected]
mkdir my_project.git
cd my_project.git
git init --bare

On local machine:

cd my_project

@trasherdk
trasherdk / get-latest-tag-on-git.sh
Created December 22, 2020 04:12 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@trasherdk
trasherdk / .appendTo_apache2.conf
Created October 28, 2021 03:41 — forked from shijij/.appendTo_apache2.conf
Apache BasicAuth with MySQL (authn_dbd)
# Append to apache2.conf
# Dont forget to repalce [user] [password] [dbname] with you own info
# ref: https://httpd.apache.org/docs/2.4/mod/mod_dbd.html
# ref: https://httpd.apache.org/docs/2.4/mod/mod_authn_dbd.html
<IfModule mod_authn_dbd.c>
DBDriver mysql
DBDParams host=localhost,port=3306,user=apache,pass=apache,dbname=auth
DBDMin 2
DBDKeep 8