Skip to content

Instantly share code, notes, and snippets.

View borivojevic's full-sized avatar

Mirko Borivojevic borivojevic

View GitHub Profile

Keybase proof

I hereby claim:

  • I am borivojevic on github.
  • I am borivojevic (https://keybase.io/borivojevic) on keybase.
  • I have a public key ASBVmSWmCh9Adh3YwcrzJw_m0z7gBLydbx28mTLu3yyRiwo

To claim this, I am signing this object:

const testLocalStorage = () => {
const mod = 'karius';
try {
localStorage.setItem(mod, mod);
localStorage.removeItem(mod);
return true;
} catch (e) {
return false;
}
}
var FOTI = function () {
return {
name : "Peter Foti",
init : function() {
alert('Initializing!');
}
};
}(); // Self invoking
window.onload = FOTI.init;
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login() || $this->_loginWithEmail()) {
$this->_setCookie($this->Auth->user('id'));
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
@borivojevic
borivojevic / array_key_exists()-vs-isset().php
Last active December 20, 2015 03:19
isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does.
<?php
// See http://php.net/manual/en/function.array-key-exists.php
$search_array = array('first' => null, 'second' => 4);
// returns false
isset($search_array['first']);
// returns true
array_key_exists('first', $search_array);
@borivojevic
borivojevic / gist:5712079
Created June 5, 2013 06:54
Different commits between two branches
# See http://stackoverflow.com/q/7566416/124644
git log --left-right --graph --cherry-pick --oneline devel...next

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

@borivojevic
borivojevic / analyze-codebase
Last active December 12, 2015 03:18
Analyze codebase
# Print models count
ls app/Model/ | grep .php | wc -l
# Print lines of code count
git ls-files | xargs cat | wc -l
@borivojevic
borivojevic / gist:4326412
Created December 18, 2012 09:06
Automate ssh connections to remote servers
# Generating a key pair
ssh-keygen -t rsa
# Install the public key on the server
ssh-copy-id -i .ssh/id_rsa.pub username@sub.domain.tld
# Create local alias for ssh to sub.domain.tld
echo "ssh -t username@sub.domain.tld \"cd application/webroot/directory ; bash\"" > ~/connect/sub.domain.tld
# Connecting to server in day-to-day use
./connect/sub.domain.tld
@borivojevic
borivojevic / gist:4320841
Created December 17, 2012 18:51
git reset index privileges
ssh me@myserver
cd repository.git
sudo chmod -R g+ws *
sudo chgrp -R mygroup *