Skip to content

Instantly share code, notes, and snippets.

View amrikarisma's full-sized avatar
💭
I may be slow to respond.

Amri amrikarisma

💭
I may be slow to respond.
View GitHub Profile
@amrikarisma
amrikarisma / README.md
Created October 27, 2024 11:07 — forked from gilangvperdana/README.md
IPTables Script

Inject IP Tables

#/bin/bash
iptables -t nat -v -L -n --line-number
echo -n "IP VM who want to exposed (x.x.x.x:port): "
read ip_vm
echo $ip_vm

echo -n "Enter Port Access: " 
read port
@amrikarisma
amrikarisma / PFwithSSH.md
Created October 27, 2024 11:06 — forked from gilangvperdana/PFwithSSH.md
Port Forwarding on Ubuntu

Local Forwarding

If you want to locally access a cloud application that has the address 192.168.100.2:82 and can only be reached by your VM, you can use the technique below. That way you can access your local localhost:80.

ssh -L LocalPortAccess:AppsIPAddresses:AppsPortAddresses user@VPSPublicIP -pXXXX
ssh -L 80:127.0.0.1:30001 [email protected] -p10013

Remote Forwarding

If you want to access your local application with the application address 127.0.0.1:30001 then you can access it on your VPS on port 80 you can use the technique below:

@amrikarisma
amrikarisma / Android_10 build.prop_editing.md
Created September 4, 2024 10:13 — forked from wsoyka/Android_10 build.prop_editing.md
How to edit build.prop on Android

Since various build.prop editor apps didnt work for me on Lineage 17.x, here the way I managed to edit build.prop:

  1. via Termux/Terminal:
mount -o remount,rw /
nano /system/build.prop
  1. edit to your hearts content - I usually bring down media vol steps: ro.config.media_vol_steps=15
@amrikarisma
amrikarisma / .not_logged_in_yet
Last active July 29, 2024 08:13
Auto Connect WiFi on ARMBIAN. Edit the file /root/.not_logged_in_yet and use root user!
PRESET_NET_WIFI_ENABLED=1
PRESET_NET_ETHERNET_ENABLED=1
PRESET_NET_WIFI_SSID='Wifi network name'
PRESET_NET_WIFI_KEY='Wifi password'
PRESET_NET_WIFI_COUNTRYCODE='ID'
PRESET_CONNECT_WIRELESS=n
SET_LANG_BASED_ON_LOCATION=n
PRESET_LOCALE=en_US.UTF-8
PRESET_TIMEZONE=Asia/Jakarta
PRESET_ROOT_PASSWORD=tester123
@amrikarisma
amrikarisma / Javascript Format NPWP
Created April 4, 2023 04:57 — forked from yudapc/Javascript Format NPWP
Javascript Format NPWP. NPWP is ID tax each people of indonesian. Specificly in frontend need to format NPWP before render to user
//
// Javascript Format NPWP
//
function formatNpwp(value) {
if (typeof value === 'string') {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})/, '$1.$2.$3.$4-$5.$6');
}
}
@amrikarisma
amrikarisma / functions.php
Created January 24, 2023 10:31 — forked from ChrisLTD/functions.php
Fix so you can preview ACF field changes in Wordpress admin
<?php
/*
Debug preview with custom fields
Taken from: http://support.advancedcustomfields.com/forums/topic/preview-solution/
See also: http://support.advancedcustomfields.com/forums/topic/2nd-every-other-post-preview-throws-notice/
*/
add_filter('_wp_post_revision_fields', 'add_field_debug_preview');
function add_field_debug_preview($fields){
$fields["debug_preview"] = "debug_preview";
return $fields;
@amrikarisma
amrikarisma / custom-feed.php
Last active January 3, 2023 03:01
How to create custom feed WordPress without Plugins
<?php
/**
* Create custom function and custom rss template.
* URL : /feed/feedname
* When url 404 not found, please open permalink setting then try again.
*/
add_action('init', 'customRSS');
function customRSS(){
add_feed('feedname', 'customRSSFunc');
@amrikarisma
amrikarisma / auto-regenerate-thumb.php
Last active December 14, 2022 08:29
WordPress generate new size for old posts
<?php
require_once(ABSPATH . 'wp-admin/includes/image.php');
// Put the function in a class to make it more extendable
class KRS_regen_media
{
public function krs_regenerate($imageId)
{
$imagePath = wp_get_original_image_path($imageId);
@amrikarisma
amrikarisma / withPrice.php
Created August 24, 2022 18:04
Example scope with lowest price
<?php
public function scopeWithPrice($smartphone)
{
$queryGetMinPrice = $smartphone->select([
'*',
'price' => ProductPrice::select('price')->where('priceable_type', Smartphone::class)->whereColumn('priceable_id', 'smartphones.id')->orderBy('price', 'ASC')->take(1)
]);
return $queryGetMinPrice;
}
@amrikarisma
amrikarisma / preview_input_file_image.js
Created August 22, 2022 03:59
Preview image on input file before upload
<input type="file" accept="image/*" onchange="loadFile(event)">
<img id="output"/>
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
output.onload = function() {
URL.revokeObjectURL(output.src) // free memory
}
};