Skip to content

Instantly share code, notes, and snippets.

View phpfour's full-sized avatar

Mohammad Emran phpfour

View GitHub Profile
@phpfour
phpfour / SlimMvc.php
Created January 20, 2012 09:27
An MVC style use of Slim.
<?php
require 'Slim/Slim.php';
class SlimMvc extends Slim
{
public function __construct($userSettings = array())
{
parent::__construct($userSettings);
$this->init();
@phpfour
phpfour / bootstrap.php
Created February 2, 2012 17:51
Kohana Bootstrap (comment less, clean version)
<?php defined('SYSPATH') or die('No direct script access.');
class Bootstrap
{
public static function run()
{
self::loadKohanaCore();
self::loadKohanaExtension();
self::setDefaultTimezone();
self::setDefaultLocale();
@phpfour
phpfour / JSONized.php
Created March 31, 2012 15:56
A PHP trait to add a simple toJson function to your classes.
<?php
trait JSONized {
public function toJson()
{
$properties = get_object_vars($this);
return json_encode($properties);
}
@phpfour
phpfour / http_pool.php
Last active October 2, 2015 21:58
Concurrent requests using pecl_http
<?php
$endpoint = "http://api.someservice.com";
$userId = 101;
$urls = array(
$endpoint . '/profile/' . $userId,
$endpoint . '/orderHistory/' . $userId,
$endpoint . '/currentBalance/' . $userId
);
@phpfour
phpfour / pecl_http.php
Created April 7, 2012 16:55
Generic use of pecl_http
<?php
// GET
$req = new HttpRequest('http://www.example.com');
$req->send();
echo "Response code: " . $req->getResponseCode(), PHP_EOL;
echo "Response body: ", PHP_EOL, $req->getResponseBody();
@phpfour
phpfour / tweet.php
Created April 10, 2012 06:43
Twitter JSONP example
<script type="text/javascript">
jQuery(document).ready(function($){
$.ajax({
url:'http://search.twitter.com/search.json?q=<?php echo urlencode('#toyota #camry') ?>&rpp=8&callback=?',
dataType:'jsonp',
success:function (data) {
for (key in data['results']) {
var tweet = data['results'][key]['text'];
@phpfour
phpfour / sr-software-engineer.md
Created July 25, 2012 04:05
Sr. Software Engineer @ Loosemonkies.com

As a Sr. Software Engineer, you will be part of a talented engineering team working on our core product and report directly to the Technical Lead/Manager. You, as part of your team, will be responsible for scoping, design, implementation, integration and maintenance of features and functionality for the product your team will focus on. You will be flexible and pragmatic with a positive “can do” attitude to delivering product to expected timelines, but you will also recognise the importance of good design, thorough QA and regular refactoring and code improvement. You are a great coder who enjoys challenging technical problems. You understand that problems have multiple solutions and you can evaluate them and choose the best one. You understand algorithms and code efficiency and can optimise your code for performance. You are able and willing to learn new technologies and approaches rapidly. Finally, you will enjoy working in a company where you are expected to take ownership and contribute at all levels.

Skil

@phpfour
phpfour / software-architect.md
Created July 25, 2012 04:48
Software Architect @ Loosemonkies.com

We are seeking a Web Software Architect to join our team of talented software developers. As an architect, you'll work in a fast-paced agile environment. Our products are high-volume and highly available multi-tenant web applications written in PHP, Ruby, and Java serving millions of unique visitors each day. The Architect will be responsible for dictating design choices to software developers, including but not limited to: platforms, coding and technical levels. The Architect’s goal is to gain a complete understanding of the project needs and effectively communicate them to the software development team. The software architect spearheads all of the software development activities of the development team: he manages the full life cycle of the process, actively involves in the development of core modules, monitors research & new technologies, reviews codes and supervises any testing.

Duties and Responsibilities

In Loosemonkies, we face many challenges and interesting problems to

@phpfour
phpfour / upload.js
Created October 2, 2012 13:23
HTML5 Upload
(function () {
var input = document.getElementById("image"), formdata = false;
if (window.FormData) {
formdata = new FormData();
}
input.addEventListener("change", function (evt) {
@phpfour
phpfour / minify-yui.php
Created October 19, 2012 17:45
Minification script using YUI compressor
<?php
$contentDir = __DIR__ . '/../web/wp-content/' ;
$yuiCompressor = 'java -jar yuicompressor-2.4.7.jar ';
$files = array();
$files[] = $contentDir . "/themes/power/js/libs/jquery.easing.1.3.js";
$files[] = $contentDir . "/themes/power/js/vehicle-finder.js";
$files[] = $contentDir . "/themes/power/js/script.js";
$files[] = $contentDir . "/themes/power/js/reviews.js";