Skip to content

Instantly share code, notes, and snippets.

View Mulkave's full-sized avatar
🍅
binge coding

Abed Halawi Mulkave

🍅
binge coding
View GitHub Profile
#!/bin/sh
# IMPORTANT: Run this script as sudo or else it won't work
# Original script: http://my.safaribooksonline.com/book/programming/java/9781449309558/hacking-elastic-beanstalk/hackingelectric#X2ludGVybmFsX0ZsYXNoUmVhZGVyP3htbGlkPTk3ODE0NDkzMDk1NTgvSV9zZWN0MTRfZDFlMjAyNQ==
echo 'Installing nginx...sit tight'
yum -y install nginx
echo 'Fixing nginx configuration'
sed -i 's/ 1;/ 4;/g' /etc/nginx/nginx.conf
rm /etc/nginx/conf.d/default.conf
@Mulkave
Mulkave / php-built-in-server-runners.php
Last active March 20, 2021 05:31
This is a way to leverage the PHP built-in web server in your tests. Uses the new @beforeClass and @afterclass annotation introduced in phpunit v3.8.x.
<?php
Class MyTest extends PHPUnit_Framework_TestCase {
static $pidfile = './.pidfile';
static $serverHost = 'localhost';
static $serverPort = '6767';
public static function serverURL()
{
@Mulkave
Mulkave / PHPUnit_protected_method_testing.php
Last active December 18, 2015 12:18
A helper method that takes care of passing the protected method out of the class as a public method to be accessible for testing
<?php
Class SomeTest extends PHPUnit_Framework_TestCase {
protected static function getProtectedMethod($name, $class)
{
$class = new \ReflectionClass(get_class($class));
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method;
@Mulkave
Mulkave / smtp-catcher.php
Created June 22, 2013 10:56
catches emails being sent from local machine, used to setup a mock for a local mail server
#!/usr/bin/php
<?php
# create a filename for the emlx file
list($ms, $time) = explode(' ', microtime());
$filename = dirname(__FILE__).'/'.date('Y-m-d h.i.s,', $time).substr($ms,2,3).'.emlx';
# write the email contents to the file
$email_contents = fopen('php://stdin', 'r');
$fstat = fstat($email_contents);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.1">
<dict>
<key>name</key>
<string>Peacock</string>
@Mulkave
Mulkave / laravel-nginx-bundle-virtualhost.conf
Last active December 20, 2015 01:59
A virtual host script to serve Laravel bundles as a dedicated website. ## Example A bundle called mybundle hosted under http://example.com/mybundle to be accessible through http://mybundle.com through the same code base avoiding code duplication and blabla..
server {
listen 80;
server_name mybundle.com;
# Redirect root traffic to bundle route
location / {
rewrite (.*) /mybundle break;
proxy_pass http://example.com;
}
@Mulkave
Mulkave / nginx-php.conf
Last active December 20, 2015 01:59
PHP-FPM handler for php scripts proxied by Nginx
# NOTE: make sure the 'include' directive is correct according to your nginx installation
# NOTE: make sure the fastcgi_pass is running on the correct socket
# might need to change it to http://127.0.0.1:9000 with default php-fpm configuration
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include /usr/local/etc/nginx/fastcgi_params;
@Mulkave
Mulkave / laravel-nginx-virtualhost.conf
Last active December 20, 2015 01:59
A virtual host script for laravel projects
# NOTE: Assumes the existence of a conf directory with a php.conf inside if
# check https://gist.github.com/Mulkave/6053040 (Mulkave/nginx-php.conf)
server {
listen 80;
server_name [host];
root [document_root];
#charset koi8-r;
{
"auto_complete": false,
"color_scheme": "Packages/User/Themes/Peacock.tmTheme",
"font_face": "Inconsolata",
"font_options":
[
"subpixel_antialias"
],
"font_size": 13.0,
"highlight_line": true,
@Mulkave
Mulkave / drupal-nginx-virtualhost.conf
Created July 29, 2013 09:08
drupal virtual host configuration for Nginx
server {
server_name [host];
root /var/www/[document_root]; ## <-- Your only path reference.
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
location = /favicon.ico {