Skip to content

Instantly share code, notes, and snippets.

View Aleksandar-Mitic's full-sized avatar
🏠
Working from home

Aleksandar Mitic Aleksandar-Mitic

🏠
Working from home
View GitHub Profile
@Aleksandar-Mitic
Aleksandar-Mitic / user-data.php
Created March 23, 2017 08:36 — forked from mrbobbybryant/user-data.php
code snippet from the User Generated data video
<?php
function register_user_question_content_type() {
$post_labels = array(
'name' => 'User Questions',
'singular_name' => 'User Question',
'add_new' => 'Add New',
'add_new_item' => 'Add New User Question',
'edit' => 'Edit',
'edit_item' => 'Edit User Question',
'new_item' => 'New User Question',
$( document).ready( function() {
var userSubmitButton = document.getElementById( 'user-submit-button' );
var adminAjaxRequest = function( formData, action ) {
$.ajax({
type: 'POST',
dataType: 'json',
url: screenReaderText.adminAjax,
data: {
action: action,
<div style="width: 70%; margin: 0 auto;">
<form id="user-post">
<?php wp_nonce_field( basename( __FILE__ ), 'user-submitted-question' ) ?>
<input type="text" id="user-name" name="user-name" placeholder="Name" style="margin-bottom: 10px;">
<input type="text" id="user-email" name="user-email" placeholder="Email" style="margin-bottom: 10px;">
<select name="product" id="product" style="margin-bottom: 10px;">
<option value=""></option>
<option value="hosting">Hosting</option>
<option value="themes">Themes</option>
<option value="plugins">Plugins</option>
// Validate email address
var email = '[email protected]'
if(!(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(email)))
alert('Invalid Email');
// Disable ri
@Aleksandar-Mitic
Aleksandar-Mitic / browser-detection.js
Created April 4, 2017 10:17
JavaScript browser detection
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown
browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
@Aleksandar-Mitic
Aleksandar-Mitic / exact-age-based-on-birthday.php
Created April 4, 2017 10:18
PHP function that returns the exact age
function age($month, $day, $year){
$y = gmstrftime("%Y");
$m = gmstrftime("%m");
$d = gmstrftime("%d");
$age = $y - $year;
if($m <= $month)
{
if($m == $month)
{
if($d < $day) $age = $age - 1;
function check_if_in_view() {
var window_height = $window.height();
var window_top_position = $window.scrollTop();
var window_bottom_position = (window_top_position + window_height);
$.each($animation_elements, function() {
var $element = $(this);
var element_height = $element.outerHeight();
var element_top_position = $element.offset().top;
var element_bottom_position = (element_top_position + element_height);
@Aleksandar-Mitic
Aleksandar-Mitic / responsive_likebox.html
Created May 2, 2017 19:20
Responsive Facebook Like Box
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="width:100%;">
<div class="fb-like-box" data-href="https://www.facebook.com/adobegocreate" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>
</div>
@Aleksandar-Mitic
Aleksandar-Mitic / count_total_project_code_lines_in_sublime
Created May 23, 2017 06:41 — forked from Hexodus/count_total_project_code_lines_in_sublime
Count total code lines in project using Sublime texteditor
// Go to menue:
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// Where:
c:\your_folder\,*.php,*.phtml,*.js,*.inc,*.html, -*/folder_to_exclude/*
// Then click on the find button
// Be careful to not click on Replace!!!
@Aleksandar-Mitic
Aleksandar-Mitic / script.js
Created July 6, 2017 09:13 — forked from LovroM/script.js
mojcimer obvescevalnik
let lastApp;
const reg = /\<a href\=\"\/room\/(.{4})/;
const link = 'https://www.mojcimer.si/search?city=koper&type=&minarea=&maxarea=&bedrooms=&bathrooms=&minprice=&maxprice=';
$.ajax({ url: link, success: function(data) {
lastApp = reg.exec(data)[1];
}});
setInterval(dejPreveri, 30000);