Skip to content

Instantly share code, notes, and snippets.

View softtama's full-sized avatar

Rizki Pratama softtama

View GitHub Profile
@softtama
softtama / gmagick-php-example.php
Created March 14, 2019 04:39
Gmagick PHP Example
<?php
// Constants
$font_family = './font/arialbd.ttf';
$textstr = 'Hello world!';
// Container image
$container = new Gmagick();
$container->newImage(2000, 2000, 'none', 'png');
$container->setImageColorspace(Gmagick::COLORSPACE_RGB);
@softtama
softtama / jetpack-feat-yoast-seo.php
Created September 2, 2017 03:20
Change Jetpack’s Related Posts Category to the Primary One from Yoast SEO
<?php
/**
* Modify Jetpack's Related Posts category context output,
* replacing it with the primary category (from Yoast SEO plugin).
* Add this code to your theme's functions.php.
*/
function jp_rp_context_cat_primary_yoast( $context, $post_id ) {
$primary_cat_id = get_post_meta( $post_id , '_yoast_wpseo_primary_category', true );
if ( $primary_cat_id ) {
$post_cat_name = get_the_category_by_ID( $primary_cat_id );
@softtama
softtama / get_pdf_with_jquery_ajax.js
Created April 6, 2017 08:01
Get PDF with jQuery AJAX and show it inside an iframe
/**
* Get PDF with jQuery AJAX and show it inside an iframe.
*
* Using mPDF as PDF generator in PHP, set the output mode to inline:
* $mpdf->Output('I'); // where $mpdf is an instance of mPDF
*
* HTML demo:
* <button id="btn-generate-pdf" class="btn btn-primary">Generate PDF</button>
* <hr>
* <div id="div-iframe"></div>
@softtama
softtama / jQuery.fn.textJoins.js
Last active October 11, 2016 04:28
jQuery.fn: Joins strings from multiple selected elements and additionally trim each text before join
/**
* textJoins Joins strings by joinStr from multiple selected elements
* and additionally trim whitespaces on each text before join.
* @param joinStr string glue string
* @param enableTrim bool false enable trim or not
* @return joined string
*/
$.fn.textJoins = function (joinStr, enableTrim = false) {
return
this
@softtama
softtama / owl.carousel.fix.js
Last active September 27, 2016 09:59
owl.carousel Fix Error Carousel Failed to Display Only 1 Item
@softtama
softtama / pikaday-disableDayFn.js
Created August 20, 2016 06:13
Pikaday: Enable specific dates, disable the others
/**
* Enable specific dates, disable the others
* -----------------------------------------
* Using disableDayFn native function from Pikaday,
* you can use array of dates (or in my code, array of date strings)
* to make them the only dates that can be selected.
*
* Plugin: Pikaday (https://github.com/dbushell/Pikaday/)
*
* require jQuery
@softtama
softtama / meta-tags.md
Created April 23, 2016 10:01 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>