Skip to content

Instantly share code, notes, and snippets.

# ---------------------------------------------------------------------------
#
# Mine:
alias composer="/usr/local/bin/composer.phar"
alias dump="composer dump-autoload"
alias www="cd /Applications/XAMPP/xamppfiles/htdocs/"
alias pong="ping 8.8.8.8"
alias bitpush="git push bitbucket master"
<?php
/**
* Return an ID of an attachment by searching the database with the file URL.
*
* First checks to see if the $url is pointing to a file that exists in
* the wp-content directory. If so, then we search the database for a
* partial match consisting of the remaining path AFTER the wp-content
* directory. Finally, if a match is found the attachment ID will be
* returned.
*
@ahmadazimi
ahmadazimi / nginx.conf
Created July 2, 2015 13:25
My enhanced Nginx configuration file.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
@ahmadazimi
ahmadazimi / gzip.conf
Created July 2, 2015 13:27
Nginx gzip configuration file.
gzip on;
gzip_static on;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript font/ttf application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
@ahmadazimi
ahmadazimi / laravel-call-controller-from-route-closure.php
Created July 28, 2015 18:18
Call controller from route closure
<?php
// Call controller from route closure
Route::get('/example', function()
{
// Run controller and method
$app = app();
$controller = $app->make('ExampleController');
return $controller->callAction('index', $parameters = array());
@ahmadazimi
ahmadazimi / nginx.conf
Created November 19, 2015 05:49 — forked from dylansm/nginx.conf
Dynamic nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
access_log /usr/local/var/log/nginx/access.log;
error_log /usr/local/var/log/nginx/error.log;
include mime.types;
@ahmadazimi
ahmadazimi / Mac OS enable NTFS read write.md
Last active December 1, 2015 11:04
How to enable read and write functionality on NTFS drive on Mac

Open Terminal.

If you have brewed osxfuse installed, you have to uninstall it, because unsigned kexts are banned now. Type:

brew cask uninstall osxfuse

On the other hand, if you don't have Homebrew at all, download it:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

@ahmadazimi
ahmadazimi / post-rewrite
Created December 1, 2015 13:32 — forked from digitaljhelms/post-rewrite
Git hook to call `git submodule update` automatically.
#!/bin/sh
echo "[post-rewrite hook: $1]"
# quick script to call "git submodule update" automatically if the
# .gitmodules file is changed
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` )
if [[ "${changedfiles[*]}" =~ ".gitmodules" ]]; then
echo "initializing & updating submodule(s)"
@ahmadazimi
ahmadazimi / javascript-query-string.js
Created August 10, 2016 18:08 — forked from DavidWells/javascript-query-string.js
JavaScript :: Regex trick: Parse a query string into an object
// http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
// JavaScript regex trick: Parse a query string into an object
var queryString = {};
anchor.href.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
// Usage
[Unit]
Description=HipHop Virtual Machine
[Service]
PIDFile=/run/hhvm.pid
ExecStart=/usr/local/bin/hhvm -m daemon -u nginx -c /etc/hhvm/server.ini
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process