Skip to content

Instantly share code, notes, and snippets.

View mchoiruln's full-sized avatar
🎯
Focusing

mchoiruln mchoiruln

🎯
Focusing
View GitHub Profile
@mchoiruln
mchoiruln / function.php
Created October 8, 2024 23:27
Add oembed cache for acf field
```php
// oEmbed cache acf
/** Disables acf_field_oembed::format_value() */
add_action('acf/init', function () {
$field_type = acf_get_field_type('oembed');
remove_filter('acf/format_value/type=oembed', [$field_type, 'format_value']);
}, 1);
/** Fetch the cached oEmbed HTML; Replaces the original method */
@mchoiruln
mchoiruln / function.php
Created October 8, 2024 23:25
Wordpress rewrite header of users page
```php
function rewrite_cpt_header()
{
$screen = get_current_screen();
error_log(print_r($screen, true));
if ($screen->id != 'users') {
return;
} else {
?>
<div class="wrap">
@mchoiruln
mchoiruln / list_ppk.py
Created October 21, 2021 06:45
list_ppk
def list_ppk(request):
if request.method != 'GET':
return JsonResponse({'status': 'method not allowed'}, status=405)
api_key = ''
status = 200
result = []
try:
if request.META['HTTP_AUTHORIZATION'] != 'Bearer {}'.format(api_key):
return JsonResponse({'status': 'api authentication failed'}, status=400)
# ppks = PpkView.objects.list_ppk()
@mchoiruln
mchoiruln / Cloning DB Postgres via template.md
Last active October 1, 2021 17:32
Cloning DB with existing database via templating system postgresql

Postgres allows the use of any existing database on the server as a template when creating a new database.

CREATE DATABASE new_db WITH TEMPLATE original_db OWNER postgres;

Still, you may get:

ERROR:  source database "original_db" is being accessed by other users
@mchoiruln
mchoiruln / Hex2Rgb.js
Last active May 24, 2021 11:18
Hex Color to RGB color (matrix digit)
const hexToRGB = hex => {
const parse = val => Math.round((val / 255) * 100) / 100
var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16)
return { r: parse(r), g: parse(g), b: parse(b) }
}
@mchoiruln
mchoiruln / auth.js
Created May 24, 2021 07:45 — forked from jengel3/auth.js
Vue/Nuxt JWT Authentication Implementation
// store/auth.js
// reusable aliases for mutations
export const AUTH_MUTATIONS = {
SET_USER: 'SET_USER',
SET_PAYLOAD: 'SET_PAYLOAD',
LOGOUT: 'LOGOUT',
}
export const state = () => ({
@mchoiruln
mchoiruln / drive_large.sh
Last active March 29, 2020 04:08
Download Google Drive Files With WGET or CURL
cd ~
export fileid=1sNhrr2u6n48vb5xuOe8P9pTayojQoOc_
export filename=file
## WGET ##
wget --save-cookies cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid -O- \
| sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt
wget --load-cookies cookies.txt -O $filename \
@mchoiruln
mchoiruln / save_restore_dependencies.sql
Created November 7, 2019 11:40 — forked from mateuszwenus/save_restore_dependencies.sql
PostgreSQL: How to handle table and view dependencies
create table deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
deps_view_name varchar(255),
deps_ddl_to_run text
);
create or replace function deps_save_and_drop_dependencies(p_view_schema varchar, p_view_name varchar) returns void as
$$
curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add
source /etc/os-release
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stretch main" | sudo tee /etc/apt/sources.list.d/brave-browser-release-${Continunn}.list
sudo apt update
sudo apt install brave-keyring brave-browser

ref : https://brave-browser.readthedocs.io/en/latest/installing-brave.html#linux

@mchoiruln
mchoiruln / arr_rotate.js
Last active March 28, 2019 13:31
Javascripts Bookmark
function arrayRotateOne(arr, reverse){
if(reverse)
arr.unshift(arr.pop())
else
arr.push(arr.shift())
return arr
}
# Source : https://stackoverflow.com/questions/1985260/javascript-array-rotate/33451102#33451102