Skip to content

Instantly share code, notes, and snippets.

View aprakasa's full-sized avatar
🎯
Focusing

Arya Prakasa aprakasa

🎯
Focusing
View GitHub Profile
@aprakasa
aprakasa / expire-header.conf
Created December 3, 2018 13:38
Nginx expire headers
location ~* \.(?:css|js|txt)$ {
expires 1M;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
add_header Cache-Control "public";
}
location ~* \.(?:json|xml|rss|atom)$ {
expires 1h;
{
"version": 1.1,
"atDirectives": [
{
"name": "@tailwind",
"description": "Use the @tailwind directive to insert Tailwind's `base`, `components`, `utilities`, and `screens` styles into your CSS.\n\n",
"references": [
{
"name": "Tailwind's “Functions & Directives” documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives/#tailwind"
@aprakasa
aprakasa / .htaccess
Created December 3, 2018 13:18
Essential
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^wp-admin/includes/ - [F,L]
@aprakasa
aprakasa / WooCommerce - Display Category Image
Created December 2, 2012 09:10
WooCommerce - Display Category Image
// verify that this is a product category page
if (is_product_category()){
global $wp_query;
// get the query object
$cat = $wp_query->get_queried_object();
// get the thumbnail id user the term_id
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
// get the image URL
$image = wp_get_attachment_url( $thumbnail_id );
// print the IMG HTML
<?php
/**
* Caching Widgets with transients
*
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
class show_ak_events_Widget extends WP_Widget {
function show_ak_events_Widget() {
/* Widget settings. */
<?php
function sharelinks( $atts ){
$links = get_transient('share_links' . get_the_ID() );
if($links === false){
// add the links you want
$links = "<a href='https://www.facebook.com/sharer.php?u=" . urlencode( get_permalink() ) . "&t=" . get_the_title(). "'></a>";
/**
* [http2_server_push description]
* @param [type] $content [description]
* @return [type] [description]
*/
function autoptimize_http2_server_push($content) {
$header = "Link: ";
if ( preg_match('#="([^"]+/js/autoptimize_[0-9a-f]+\.js)"#', $content, $matches ) ) {
$header .= sprintf(
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
<?php
/**
* Encrypt Text
* @link https://shellcreeper.com/?p=2082
*/
function my_encrypt( $plain_text ){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$h_key = hash('sha256', wp_salt(), TRUE);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $h_key, $plain_text, MCRYPT_MODE_ECB, $iv));
@aprakasa
aprakasa / composer-fix.md
Created April 19, 2018 13:13
Fix Composer slow install for SEA