Skip to content

Instantly share code, notes, and snippets.

View sajdoko's full-sized avatar

Sajmir Doko sajdoko

View GitHub Profile
@sajdoko
sajdoko / pdo_db.php
Created May 11, 2018 08:50 — forked from bradtraversy/pdo_db.php
PDO Class
<?php
/*
* PDO DATABASE CLASS
* Connects Database Using PDO
* Creates Prepeared Statements
* Binds params to values
* Returns rows and results
*/
class Database {
private $host = DB_HOST;
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@sajdoko
sajdoko / pdocrash.php
Created July 8, 2018 11:41 — forked from bradtraversy/pdocrash.php
PDO & Prepared Statements Snippets
<?php
$host = 'localhost';
$user = 'root';
$password = '123456';
$dbname = 'pdoposts';
// Set DSN
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// Create a PDO instance
@sajdoko
sajdoko / ssh.txt
Created July 8, 2018 18:35 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets
# Login via SSH with password (LOCAL SERVER)
> ssh brad@192.168.1.29
# Create folder, file, install Apache (Just messing around)
mkdir test
cd test
touch hello.txt
sudo apt-get install apache2
# Generate Keys
@sajdoko
sajdoko / webdev_online_resources.md
Created July 17, 2018 12:45 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
function ImportCSV2Array($filename) {
$row = 0;
$col = 0;
$handle = @fopen($filename, "r");
if ($handle) {
while (($row = fgetcsv($handle, 4096)) !== false) {
if (empty($fields)) {
$fields = $row;
continue;
}
@sajdoko
sajdoko / sample.md
Last active May 16, 2019 12:29 — forked from bradtraversy/sample.md
Markdown Cheat Sheet

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

This text is italic

@sajdoko
sajdoko / example-ajax-enqueue.php
Created November 13, 2019 11:00 — forked from devinsays/example-ajax-enqueue.php
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array('jquery')
);
@sajdoko
sajdoko / app.js
Last active June 24, 2020 19:58
Custom HTTP Library (Ajax With Callbacks)
const http = new easyHTTP();
// Get Posts
http.get("https://jsonplaceholder.typicode.com/posts", function(err, posts) {
if (err) {
console.log(err);
} else {
console.log(posts);
}
});
@sajdoko
sajdoko / update-wp-plugins.sh
Last active December 28, 2020 08:29
Bash script to update WordPress Plugins on a server managed with WHM/cPanel
#!/bin/bash
# $1 group (premium||free)
# $2 plugin slug (all||single-name)
if [ "$1" == "premium" ] ; then
if [ "$2" == "all" ] || [ "$2" == "js_composer" ] ; then
if curl -o js_composer.zip https://serverlocalweb.com/js_composer.zip ; then
shkarkova_js_composer="1"
fi
fi