Skip to content

Instantly share code, notes, and snippets.

View kresnasatya's full-sized avatar
🤫
Shh!

Kresna Satya kresnasatya

🤫
Shh!
View GitHub Profile
@kresnasatya
kresnasatya / scrape.html
Last active January 27, 2020 15:46
Example how to scrape data
<h1>Hello</h1>
<p>This is a very important data</p>
<!-- Tolong anggap tag script di bawah adalah lingkungan NodeJS,
karena saat saya melakukan web scraping saya menggunakan bantuan NodeJS -->
<script>
// Untuk mendapatkan teks "Hello" dan "This is a very important data"
const valueFromH1 = document.querySelector('h1').textContent;
const valueFromP = document.querySelector('p').textContent;
@kresnasatya
kresnasatya / postman-test.js
Last active January 29, 2020 03:20
Set value to variable in Postman's environment
pm.test("response is ok", function () {
pm.response.to.have.status(200);
});
// Old postman
var jsonData = JSON.parse(responseBody);
// New postman
var data = pm.response.json();
@kresnasatya
kresnasatya / simplesaml-nginx.conf
Last active January 14, 2020 05:03
Nginx configuration for simplesaml
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
@kresnasatya
kresnasatya / fix-preload.html
Last active July 12, 2020 01:34
Preload HTML
<head>
<!-- CSS -->
<link rel="preload" href="{{ $styles.RelPermalink }}" as="style" onload="this.onload=null;this.rel='stylesheet'">
<!-- Firefox will load this because of it doesn't support preload yet! -->
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen">
</head>
@kresnasatya
kresnasatya / vscode.json
Last active June 29, 2022 06:49
Personal VS Code Settings.
{
"editor.fontSize": 16,
"editor.fontFamily": "'Roboto Mono', Consolas, 'Courier New', monospace",
"editor.lineHeight": 40,
"editor.suggestLineHeight": 20,
"git.autofetch": true,
"git.enableSmartCommit": true,
}
@kresnasatya
kresnasatya / block.py
Last active December 3, 2019 12:22
Python untuk pemula
customers = ["kresna", "satya", "dyah", "nugraha"]
# Mengakses semua nama pelanggan?
for name in customers:
# print() ini dieksekusi di dalam for karena di bawa menjorok ke dalam
print(f"Nama pelanggan: {name}")
# print di bawah tidak di eksekusi di dalam for
print("aku di luar for")
@kresnasatya
kresnasatya / Authenticate.php
Last active April 2, 2025 17:02
Fixed problem Laravel Passport doesn't redirect back to authorization form after login
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
@kresnasatya
kresnasatya / README.md
Created October 22, 2019 14:36
Laravel Eloquent Relationship
@kresnasatya
kresnasatya / CheckOauth2Token.php
Created October 22, 2019 14:28
A middleware to check if OAuth2 (Laravel Passport) token is exists and live.
<?php
namespace App\Http\Middleware;
use Closure;
use \Firebase\JWT\JWT;
class CheckOauth2Token
{
/**
@kresnasatya
kresnasatya / script.js
Created July 25, 2019 09:37
Check if a Page has loaded JavaScript or not
<script>
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
// Init library or something else
new Choices('#topicSpeaker', {
removeItemButton: true,
});
}
}
</script>