Skip to content

Instantly share code, notes, and snippets.

@velizarn
velizarn / ip6tables_setup.bash
Last active March 27, 2024 21:48
Basic setup for ip6tables - drop all traffic except local, ICMP and DHCPv6 traffic.
#!/bin/bash
# http://serverfault.com/questions/410321/debian-ip6tables-rules-setup-for-ipv6/410327#410327
# http://ipset.netfilter.org/iptables.man.html
# https://www.sixxs.net/wiki/IPv6_Firewalling
# https://www.cyberciti.biz/faq/ip6tables-ipv6-firewall-for-linux/
# https://gist.github.com/thomasfr/9712418
# https://gist.github.com/SnakeDrak/f4150f6e517e5a1d525f
# http://www.thegeekstuff.com/2011/06/iptables-rules-examples
# http://www.thegeekstuff.com/scripts/iptables-rules
@velizarn
velizarn / sendgrid.bash
Last active March 12, 2024 13:13
Send email from bash script by using SendGrid API
#!/bin/bash
SENDGRID_API_KEY=""
EMAIL_TO=""
FROM_EMAIL=""
FROM_NAME=""
SUBJECT=""
bodyHTML="<p>Email body goes here</p>"
@velizarn
velizarn / cloudinary-shell-curl-upload.md
Last active August 15, 2023 11:59
Shell script to upload file by using Cloudinary API + cURL

Shell script to upload file by using Cloudinary API + cURL

  1. Create a new file e.g. cloudinary-curl-upload.sh

  2. Then execute the file with required input parameters

  ./cloudinary-curl-upload.sh "path/to/file.ext" "cloud-name" "your-api-key" "your-api-secret"
  ./cloudinary-curl-upload.sh "path/to/file.ext" "cloud-name" "your-api-key" "your-api-secret" "remote-folder"

Resources

@velizarn
velizarn / sendgrid-sample.php
Last active December 24, 2021 10:26
Sample script to send email via SendGrid
<?php
require('path-to-lib/httpful/bootstrap.php');
$url = "https://api.sendgrid.com/api/mail.send.json";
$payload = array(
'to' => "m8r-m3r@mailinator.com",
'from' => "m8r-bahfj31@mailinator.com",
'fromname' => "Delivery team",
@velizarn
velizarn / getip.md
Last active November 24, 2020 13:21
Get IP from inside a Heroku app

Create getip.sh bash script:

#!/usr/bin/env bash
curl -s https://httpbin.org/ip | grep -oP '(?<="origin": ")[^"]*'

then execute following command

@velizarn
velizarn / multiple-recaptcha.html
Last active November 6, 2020 11:29
Multiple invisible reCAPTCHA on a single page
<title>ReCaptcha test</title>
<fieldset>
<legend>Form 1</legend>
<form method="post" action="http://httpbin.org/post" target="_blank">
<p>
<input type="text" name="form" value="form 1" size="10" />
</p>
<input type="hidden" name="captchaKey" />
<div id="captcha1" class="g-recaptcha" data-size="invisible"></div>
@velizarn
velizarn / uuid4.js
Last active November 3, 2020 14:56
Generate UUID v4
/**
* Generates UUID identifier - version 4, variant DCE 1.1, ISO/IEC 11578:1996
*
* @returns {String} - UUID identifier
*
* https://en.wikipedia.org/wiki/Universally_unique_identifier
* https://www.uuidtools.com/decode
* https://www.uuidtools.com/generate/v4
*/
const uuid = () => {
@velizarn
velizarn / nmcli-auto-connect.sh
Created April 30, 2020 19:11
Automatically try to connect to a hidden network when WiFi is enabled
#!/bin/sh
#
# Automatically try to connect to "MyNetworkId" when WiFi is enabled
#
# https://askubuntu.com/questions/9014/auto-connect-to-hidden-wireless-without-elevating-privilege
# ...also adjust permissions
# the output of nmcli should be in English
LC_ALL=C
@velizarn
velizarn / obtain_token.js
Last active October 16, 2019 14:48
Obtain OAuth token in Nodejs for SalesForce Commerce Cloud OCAPI (previously Demandware)
const https = require('https')
const headers = {
'Authorization' : 'Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ==',
'Content-Type' : 'application/x-www-form-urlencoded'
}
const optionsget = {
host : 'account.demandware.com',
port : 443,
@velizarn
velizarn / heroku-postbuild.js
Created March 21, 2019 15:53
Nodejs postbuild script for Heroku
'use strict';
require('dotenv').config();
const {
HEROKU_APP_NAME,
AUTH_TOKEN
} = process.env;
const