Skip to content

Instantly share code, notes, and snippets.

View gdarko's full-sized avatar
Crunching code, one line at a time.

Darko Gjorgjijoski gdarko

Crunching code, one line at a time.
  • Self-employed
  • The Internet
  • 08:31 (UTC +02:00)
View GitHub Profile
@gdarko
gdarko / create_user.sh
Created October 28, 2017 16:22 — forked from divyavanmahajan/create_user.sh
Turnkey OpenVPN - Add new users. It creates two OVPN files - with and without proxy and also generates the URLs to download them. Safely use for existing users - it just creates the OVPN files.
#!/bin/bash -e
fatal() { echo "FATAL: $@" 1>&2; exit 1; }
warn() { echo "WARN: $@"; }
info() { echo "INFO: $@"; }
usage() {
cat <<EOF
Usage: sudo $0 client_or_profile_name
This will create two ovpn files in this directory (proxy and noproxy).
@gdarko
gdarko / vc-twotterbootstrap-grid.php
Last active November 23, 2017 08:14
Easily replace Visual Composer grid columns with Twitter Boostrap columns
<?php
add_filter('vc_shortcodes_css_class', function ($class_string, $tag) {
$tags_to_clean = [
'vc_row',
'vc_column',
'vc_row_inner',
'vc_column_inner'
];
if (in_array($tag, $tags_to_clean)) {
@gdarko
gdarko / cloudflare-update-record.sh
Last active March 2, 2018 00:20 — forked from benkulbertis/cloudflare-update-record.sh
Cloudflare API v4 Dynamic DNS Update in Bash
#!/bin/bash
# CHANGE THESE
auth_email="user@example.com"
auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings
zone_name="$1"
record_name="$2"
# MAYBE CHANGE THESE
ip=$(curl -s http://ipv4.icanhazip.com)
@gdarko
gdarko / methods.php
Last active May 2, 2018 14:23
WordPress REST Route Example
<?php
function dg_get_data() {
return array(
'name' => 'Darko Gjorgjijoski',
'age' => 23
);
}
@gdarko
gdarko / gb.sh
Created May 29, 2018 15:25
Quick Geekbench 3 Benchmark for Linux
#!/bin/bash
sudo apt-get install libc6:i386 libstdc++6:i386
wget http://cdn.primatelabs.com/Geekbench-3.4.2-Linux.tar.gz
tar -zxvf Geekbench-3.4.2-Linux.tar.gz
cd dist/Geekbench-3.4.2-Linux/
./geekbench
@gdarko
gdarko / nginx-latest.sh
Last active November 5, 2018 08:41 — forked from Globegitter/nginx-latest.sh
Install the latest nginx from source for Debian 8
# Automatically instal the latest nginx
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
#Make a backup copy of your current sources.list file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#Now copy the following repositories to the end of ` /etc/apt/sources.list`
echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" | tee -a /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/debian/ jessie nginx" | tee -a /etc/apt/sources.list
@gdarko
gdarko / class-dg-image-import.php
Created December 26, 2018 09:43
Import images to media library from specific directory.
<?php
/**
* Class DG_Image_Import
* @author Darko Gjorgjijoski <dg@darkog.com>
* @license GPLv2
* @copyright 2019
*
* Handles import of images from a specific subfolder of your root site dir (eg public_html/your_data_dir) to WordPress media library.
* Has basic lock/unlock functionality to avoid colisions.
@gdarko
gdarko / gravityforms_username.php
Last active April 26, 2019 16:39
GravityForms + User Registrations plugin: Use first name and last name in the form to generate username out of both. Append number if the username exists.
<?php
/**
* Check if there is still pending registration for specific username
* @param $username
*
* @return bool
*/
function dg_check_pending_registration($username) {
global $wpdb;
$table = $wpdb->prefix . 'signups';
@gdarko
gdarko / general.php
Last active May 31, 2019 23:35
Useful Vanilla PHP and WordPress helper functions.
<?php
// This file contains general useful PHP functions that can be included everywhere.
/**
* Wrapper for writing the interactions to /wp-content/uploads/ file
*
* @param $message
* @param string $filename
*/
function dg_log_write( $message, $filename = "log.txt" ) {
@gdarko
gdarko / form.php
Last active June 10, 2019 12:11
Upload image using WordPress media uploader
<form method="POST">
<div class="form-row">
<label>Name</label>
<input type="text" placeholder="Enter name">
<div>
<div class="form-row">
<?php
$key = 'profile_picture';
$placeholder = 'https://placehold.it/150x150?text=IMG';
$current_value = get_user_meta(get_current_user_id(), $key, true);