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
  • 20:46 (UTC +02:00)
View GitHub Profile
divyavanmahajan /
Last active October 28, 2017 16:22
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 / vc-twotterbootstrap-grid.php
Last active November 23, 2017 08:14
Easily replace Visual Composer grid columns with Twitter Boostrap columns
add_filter('vc_shortcodes_css_class', function ($class_string, $tag) {
$tags_to_clean = [
if (in_array($tag, $tags_to_clean)) {
alkavan /
Last active April 10, 2018 22:36
PHP 7.2 Anonymous Class vs Array - Memory Test

PHP 7.2 real app usage:

public function jsonSerialize()
        $m1 = memory_get_usage();
        $json_class = new class implements SpecExportInterface {
            public $id;
            public $status;
            public $code;
            public $title;
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
jakubmikita / Storable.php
Last active February 19, 2019 18:11
WordPress global storage using filter
* Storable interface
interface Storable extends \ArrayAccess, \Iterator {}
kamermans / simple_dnsbl.php
Created January 2, 2012 01:32
Simple DNSBL/RBL PHP function - trust me, it's better than checkdnsrr, fsock, socket_create, Net::DNSBL and Net::DNS
// Simple DNSBL/RBL PHP function - trust me, it's better than checkdnsrr, fsock, socket_create, Net::DNSBL and Net::DNS
// Here's a [better] way to quickly check if an IP is in a DNSBL / RBL. It works on Windows and Linux,
// assuming nslookup is installed. It also supports timeout in seconds.
function ipInDnsBlacklist($ip, $server, $timeout=1) {
$response = array();
$host = implode(".", array_reverse(explode('.', $ip))).'.'.$server.'.';
$cmd = sprintf('nslookup -type=A -timeout=%d %s 2>&1', $timeout, escapeshellarg($host));
@exec($cmd, $response);
ntwb / ExpressionEngine.php
Last active June 29, 2019 11:13 — forked from RickeyMessick/gist:780b857970a4bb72a79f
bbPress- Expression Engine Importer
* ExpressionEngine converter base impoprter template for bbPress
* @since bbPress (rXXXX)
* @link Codex Docs
class ExpressionEngine extends BBP_Converter_Base {
vishalbasnet23 / functions.php
Created June 28, 2016 07:51
Create WooCommerce Subscription and activate Subscription for a user programatically.
function cpm_create_order($customer_data, $the_customer) {
global $woocommerce;
$product_id = $customer_data['sub_product'];
$variation_id = $customer_data['sub_variation'];
$user_first_name = $customer_data['first_name'];
$user_last_name = $customer_data['last_name'];
$user_email = $customer_data['user_email'];
$billing_email = $customer_data['user_email'];
$billing_state = $customer_data['cpm_state'];
amochohan / 01_Laravel 5 Simple ACL
Last active April 22, 2024 17:19
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.


Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

nikcub /
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007