Skip to content

Instantly share code, notes, and snippets.

View joglomedia's full-sized avatar
🏠
Working from home

Edi Septriyanto joglomedia

🏠
Working from home
View GitHub Profile
/*
* Display Image from the_post_thumbnail or the first image of a post else display a default Image
* Chose the size from "thumbnail", "medium", "large", "full" or your own defined size using filters.
* USAGE: <?php echo my_image_display(); ?>
*/
function my_image_display($size = 'full') {
if (has_post_thumbnail()) {
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, $size);
@joglomedia
joglomedia / phalcon-generate-hashed-filename-for-compiled-path
Last active August 29, 2015 14:13
Phalcon: Generate Hashed Filename for Compiled Template Path
closure to generate hashed filename for Phalcon template compiled path kind of file:
```php
<?php
$volt->setOptions(array(
'compiledPath' => function($templatePath) {
return md5($templatePath) . '.php';
}
));
@joglomedia
joglomedia / yt-upload.py
Created March 1, 2015 13:01
Youtube Upload
#!/usr/bin/python2
#
# Youtube-upload is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Youtube-upload is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<?php
date_default_timezone_set('UTC');
// Create keys at hhttps://portal.aws.amazon.com/gp/aws/securityCredentials
class AmazonClient {
/** @var cURL */
public $curl;
@joglomedia
joglomedia / innobackupex-restore.sh
Last active November 21, 2015 06:47 — forked from dalecaru/innobackupex-restore.sh
Scripts to create and restore full and incremental backups (for all databases on server) using innobackupex from Percona.
#!/bin/sh
#
# Script to prepare and restore full and incremental backups created with innobackupex-runner.
#
# This script is provided as-is; no liability can be accepted for use.
#
# UPDATE: 21/11/2015
INNOBACKUPEX=innobackupex
INNOBACKUPEXFULL=/usr/bin/$INNOBACKUPEX
@joglomedia
joglomedia / config.php
Created March 16, 2013 19:42
An unofficial patch for Abundance v1.3 WooCommerce WordPress theme File: abundance/woocommerce-config/config.php
<?php
function avia_woocommerce_enabled()
{
if (defined("WOOCOMMERCE_VERSION")) { return true; }
return false;
}
@joglomedia
joglomedia / Upgrade Git on Ubuntu 12.04 LTS
Created October 16, 2013 02:12
Upgrade Git on Ubuntu 12.04 LTS
sudo apt-get clean
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get upgrade git
@joglomedia
joglomedia / Useful Gitlab Command and Troubleshot
Created October 16, 2013 19:21
Useful Gitlab Command and Troubleshot
# Check requirement
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
# Check everything is working
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
# Troubleshot: Commit / Merge Request Error #
@joglomedia
joglomedia / wordpress-limit-access-to-post-by-user-roles
Created November 28, 2013 07:21
WordPress limit access to posts/pages by user roles
you can use such conditions to show private posts only to logged in users with role contributor. Now you only need to make post private to make that post available for contributor.
Ref: http://wordpress.stackexchange.com/questions/60582/limit-access-to-posts-pages-by-user-roles
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
$private = get_post_custom_values("private");
if (isset($private[0]) && $private == "true") {
if ( current_user_can( 'contributor' ) ) { //passing role to it may sometime not work
the_title();
@joglomedia
joglomedia / Megasync-script
Created November 28, 2013 07:50
MegaSync script
Ref: http://albertolarripa.com/2013/07/10/megatools-synchronizing-your-backups-to-mega/
#!/bin/sh
MEGASYNC='/usr/local/bin/megasync'
MEGARM='/usr/local/bin/megarm'
LOCALDIR="/usr/local/data/backups"
REMOTEDIR="/Root/albertolarripa/backups"
SEDLOCALDIR="\/usr\/local\/data\/backups"
SEDREMOTEDIR="\/Root\/albertolarripa\/backups"