Skip to content

Instantly share code, notes, and snippets.

View harisrozak's full-sized avatar
Upgrading multi-lang module...

Haris Ainur Rozak harisrozak

Upgrading multi-lang module...
View GitHub Profile
@harisrozak
harisrozak / show_all_subscriptions.js
Created March 4, 2024 14:54
Meteor JS : Show all current subscriptions
// Paste below codes in the browser console.
var subs = Meteor.connection._subscriptions; // all the subscriptions that have been subscribed.
Object.keys(subs).forEach(function(key) {
console.log(subs[key]); // see them in console.
});
@harisrozak
harisrozak / html2pdfrocket-javascript-sample.html
Last active June 27, 2023 07:33
Convert HTML to PDF using Javascript
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<title>Convert HTML to PDF using Javascript</title>
</head>
<body>
<h1>Convert HTML to PDF using Javascript</h1>
<button onclick="runPdfRocketNewTab()">Open the PDF in a new tab</button>
@harisrozak
harisrozak / wp-bootstrap5.0-pagination.php
Created June 21, 2023 09:30 — forked from mtx-z/wp-bootstrap5.0-pagination.php
Wordpress 5.7 Bootstrap 5.0 pagination (with custom WP_Query() and global $wp_query support)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* Using Bootstrap 4? see https://gist.github.com/mtx-z/f95af6cc6fb562eb1a1540ca715ed928
*
@harisrozak
harisrozak / sample-aws-lambda-node.js
Last active January 9, 2023 04:52
Sample AWS Lambda code with NodeJS
export const handler = async (event) => {
const body = JSON.parse(event.body);
const queryStrings = event.queryStringParameters;
let capitalCity = 'none';
const message = !!queryStrings?.message ? queryStrings.message : 'Hello';
switch (body.nation) {
case 'Indonesia':
capitalCity = 'Jakarta';
@harisrozak
harisrozak / prettier-eslint-airbnb-vscode.md
Created July 1, 2022 06:52
Integrating Prettier + ESLint + Airbnb Style Guide In VSCode
@harisrozak
harisrozak / admin-post-editor-nonce-field.php
Last active June 14, 2022 07:52
Add hidden nonce field admin post / post type editor
<?php
/**
* Add hidden nonce field to project post type editor.
*
* @param WP_Post $post Post object data.
*/
function harisrozak_add_hidden_nonce_field( $post ) {
// Only render on a certain post type.
if ( 'project' !== $post->post_type ) {
@harisrozak
harisrozak / install-phpcs-wp-windows.md
Last active June 9, 2022 01:50
Install PHPCS and PHPCBF with WordPress Coding Standard on Visual Studio Code for Windows 11
@harisrozak
harisrozak / install-composer-on-ubuntu.md
Last active March 17, 2022 09:52
Install Composer on Ubuntu
@harisrozak
harisrozak / wp-bail-out-plugin-activation.php
Last active March 2, 2022 06:45
Bail out a plugin activation, even before the plugin file is loaded
<?php
/**
* Bail out a plugin activation, even before the plugin file is loaded.
* Using this hook will prevent any PHP fatal error, because of any defined constants, class names or functions.
*/
function bail_out_standalone_plugin_activation( $action, $result ) {
$plugin_name = 'YourPluginName';
$plugin_file_name = '/yourpluginname.php';
$activate_plugin_referer = 'activate-plugin_';
@harisrozak
harisrozak / wp-gutenberg-select-terms.js
Last active December 13, 2021 02:59
Programmatically add/select terms on WordPress Gutenberg editor
/**
* Programmatically add/select term on Gutenberg editor.
* On this function we are also ready if the classic-editor is loaded.
* Related issue: https://github.com/WordPress/gutenberg/issues/15147
*/
$('.bike-types').on('click', '.bike-type-item', function() {
var tag_id = $( this ).data( 'id' );
var tag_name = $( this ).data( 'name' );
if ( typeof wp !== 'undefined' && typeof wp.blocks !== 'undefined' ) {