Skip to content

Instantly share code, notes, and snippets.

@da-n
da-n / gist:e65e97feec285b8636aa
Created July 1, 2014 13:21
How to Flatten a Multidimensional Array
<?php
$a = array(1,2,array(3,4, array(5,6,7), 8), 9);
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($a));
foreach($it as $v) {
echo $v, " ";
}
// http://stackoverflow.com/a/1320259
@da-n
da-n / README.md
Last active August 29, 2015 14:03 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@da-n
da-n / gist:bd409d12893e97442b5a
Created July 15, 2014 16:00
Total commits in git repo
$ git log --oneline --all | wc -l
# source https://answers.atlassian.com/questions/224233/how-can-i-get-the-total-commits-from-bitbucket-private-repo
@da-n
da-n / commands.sh
Last active August 29, 2015 14:04
How can I give write-access of a folder to all users in linux?
sudo usermod -a -G www-data ubuntu
sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www
sudo find /var/www -type d -exec chmod 2775 {} \;
sudo find /var/www -type f -exec chmod ug+rw {} \;
sudo chown -R www-data:www-data /var/www
# source http://superuser.com/a/19333
@da-n
da-n / gist:af20d0a4a8a1c37c7b88
Created July 17, 2014 14:14
Change the URI (URL) for a remote Git repository
git remote set-url origin git@example.com:user/repo
- source http://stackoverflow.com/a/2432799
@da-n
da-n / gist:c3b24f3f64863c90d022
Created July 22, 2014 14:32
delete a branch both locally and remote
git branch -d <branchName>
git push origin --delete <branchName>
@da-n
da-n / gist:2cc432f8a7c0d65aeb29
Created July 29, 2014 09:44
Remove the passphrase from a key file
openssl rsa -in key.pem -out newkey.pem
# source http://serverfault.com/a/160773
@da-n
da-n / gist:9e02197cff3881b34141
Last active August 29, 2015 14:04
change php.ini upload size, post size and memory limit

Edit /etc/php5/apache2/php.ini (or wherever the php.ini file is located on the server). Change the following entries to suit:

upload_max_filesize
post_max_size
memory_limit

If the problem is related to uploading large files to phpmyadmin, you might also need to remove the script timeout. Edit the file found in /etc/phpmyadmin/config.inc.php and add the following line:

$cfg['ExecTimeLimit'] = 0;

@da-n
da-n / gist:6eb93dc2575fa44c01e0
Last active August 29, 2015 14:05
example apache virtualhost with htpasswd protection
<Directory "/var/www/public">
Options Indexes FollowSymLinks
AllowOverride All
AuthUserFile /var/www/private/.htpasswd
AuthName "Staging Area"
AuthType Basic
require user staging
</Directory>
@da-n
da-n / gist:7da21927ef44cb39ef31
Created August 12, 2014 13:24
regex to find email addresses
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*