Skip to content

Instantly share code, notes, and snippets.

@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 / 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 July 31, 2024 12:44
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 / 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
@velizarn
velizarn / sample-sw.js
Created September 10, 2018 07:16
Generate service worker file
importScripts('/js/workbox-sw.js');
workbox.setConfig({
debug : true
});
workbox.core.setLogLevel(workbox.core.LOG_LEVELS.debug);
workbox.skipWaiting();
workbox.clientsClaim();
workbox.core.setCacheNameDetails({
"prefix" : "nodepwa",
"suffix" : "web",
@velizarn
velizarn / promise-chain-failed-first.js
Last active January 3, 2018 08:17
Run array of promises and stop on first failure
'use strict'
global.state = {
time: null,
user: null,
photo: null,
book: null
}
const { getTime, getUser, getPhoto, getBook } = require('./promise_modules')
@velizarn
velizarn / promise-chain-run-all.js
Last active January 3, 2018 08:16
Run array of promises despite of the result
'use strict'
global.state = {
time: null,
user: null,
photo: null,
book: null
}
const { getTime, getUser, getPhoto, getBook } = require('./promise_modules')
@velizarn
velizarn / load-test.js
Last active January 1, 2018 11:18
Run a load test on a given URL
const http = require('http')
let getData = (rand = 1) => {
return new Promise((resolve, reject) => {
try {
let url = 'http://localhost:3000/db/products.count?v=' + rand