Skip to content

Instantly share code, notes, and snippets.

View dvlden's full-sized avatar
🧨
I am the error that you should catch!

Nenad Novaković dvlden

🧨
I am the error that you should catch!
View GitHub Profile
@dvlden
dvlden / .htaccess
Last active September 11, 2017 17:06
Pretty URL's are always nice and great in many cases. This is how you rewrite your URL's to remove / strip off php extension
<IfModule mod_rewrite.c>
# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
@dvlden
dvlden / snippet.html
Last active September 11, 2017 17:09
Open link(s) in small browser dialog or new tab on phones/tablets
<a
href="https://google.com"
onClick="return popThis(this.href, 500, 370)">
Open Google
</a>
@dvlden
dvlden / snippet.js
Last active September 11, 2017 17:06
Load any Script files - The asynchronous way
/* Example of how to load Facebook SDK */
loadAsync(document, 'script', '//connect.facebook.net/en_US/sdk.js', 'facebook-jssdk', successCallback);
function successCallback () {
console.log('Facebook\'s SDK successfully loaded.');
}
/* Asynchronously load any script files */
function loadAsync ( doc, elem, source, id, cb ) {
var ready = false,
@dvlden
dvlden / 01 - macOS Workspace Setup.md
Last active October 22, 2023 12:57
My complete macOS Workspace Setup Tutorial!

Setting up workspace for web development...

If you are planning to use everything from this guide, do it in exact order, otherwise install only what you need...


Try my automated macOS setup... It will configure all of these automatically for you. If you don't want everything, feel free to clone repo and modify what you want/need!

dvL-den macOS Setup

@dvlden
dvlden / macOS - Terminal.md
Last active September 8, 2018 05:08
I tried to simplify all the keystrokes / shortcuts and common terminal commands that I use daily myself... I hope it helps anyone, spent too much time writing this.

Don’t be afraid of Terminal on any OS, let me simplify things for you! I’ve been using Terminal a lot lately, yet I remember the time when I was entirely afraid of even typing anything in it...

Whenever I needed something on my Mac, that required Terminal commands, I had a tough time figuring what does it mean, how does it work; especially when it's a very long one. Well, it was worth it, not just copy/pasting the command, seeing it works and continuing with my day.


Key Representation

VISUAL KEY DESCRIPTIVE KEY
@dvlden
dvlden / snippet.js
Last active September 11, 2017 17:05
ITAcademy/LinkLearning - Skip time waiting on lessons
(function ($) {
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
@dvlden
dvlden / ffmpeg.md
Last active April 17, 2024 19:53
Convert video files to MP4 through FFMPEG

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec
@dvlden
dvlden / dummy.js
Created October 14, 2017 13:42
Some JS Testing...
const getSiblings = element => {
let siblings = []
let sibling = element.parentNode.firstChild
while (sibling = sibling.nextSibling) {
if (sibling.nodeType === 1 && sibling !== element) {
siblings.push(sibling)
}
}
@dvlden
dvlden / extract-cookies.php
Last active September 25, 2023 13:49
Quickly Extract "Netscape HTTP Cookie File" to "JSON" (from ".txt" to ".json" format)
<?php
function extractCookies ($string) {
$cookies = array();
$lines = explode("\n", $string);
// iterate over lines
foreach ($lines as $line) {
// we only care for valid cookie def lines
@dvlden
dvlden / index.js
Created April 10, 2018 18:23
Just testing the "call, apply and bind"...
// I never really understood them, but now I think I got it...
let anObject = {
name: 'Nenad',
age: 25
};
let myArguments = ['Serbia', 'Valjevo', 'in a relationship'];
let anFunction = function (country, city, relationshipStatus) {