Skip to content

Instantly share code, notes, and snippets.

View subhanshuja's full-sized avatar
🏠
Working from home

Subhan Nooriansyah subhanshuja

🏠
Working from home
View GitHub Profile
@subhanshuja
subhanshuja / ineventhandler.kt
Last active June 30, 2020 08:14
Sever Sent Event (SSE)
interface DefaultEventHandler : EventHandler {
@Throws(Exception::class)
override fun onOpen() {
Log.i("open","open")
}
@Throws(Exception::class)
override fun onClosed() {
Log.i("close","close")
@subhanshuja
subhanshuja / domodernjs.sh
Last active November 10, 2020 09:29
download file modern js without npm using bash
#ref: https://gist.github.com/hrwgc/7455343
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi
}
# file list of url
file="listlib.txt"
while IFS= read -r line; do
if `validate_url $line > /dev/null`; then wget $line -P /path/lib/; else echo "doesn't exist"; fi
@subhanshuja
subhanshuja / Account.php
Last active November 26, 2020 05:15
Abstract Class User in Php
<?php
declare(strict_types=1);
$path = dirname(__DIR__, 1);
$path .= '/models/UserModel.php';
require_once $path;
class Account extends User {
private $userId;
@subhanshuja
subhanshuja / laravel-nginx-config-make-http-exception-url-and-make-all-others-https.md Laravel nginx config to redirect all requests to https and an exception URL that can still be accessible via http

Pre-condition

One day in your Laravel app, you were required to redirect all http requests to https but need to make a certain URL route accessible via http for a certain reason; perhaps a portion of your javascript code needs to redirect to http URL but it can't because redirection to secure URL to insecure is prohibited. Therefore, in cases like this, you need to just allow just one URL to make an http connection.

NOTE: There are obvious security implications here so don't just follow this blindly and understand if this is really the solution you're looking for. The nginx config can somehow be improved, I just don't have the time yet. It sure do look redundant.

Understanding and examples

  • Redirect everything from http to https