Skip to content

Instantly share code, notes, and snippets.

View sunel's full-sized avatar
🎯
Focusing

Sunel Tr sunel

🎯
Focusing
View GitHub Profile
@sunel
sunel / magento_api_all_in_one
Created August 22, 2014 06:06
list and usage of magento soap api
<?php
/**
* Script to test methods of the Magento API
*/
/**
customer.list
customer.create
customer.info
customer.update
customer.delete

Nginx Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get

@sunel
sunel / Debug.php
Created January 30, 2015 10:48
PHP Pretty var_dump
<?php
class Debug {
/**
* A collapse icon, using in the dump_var function to allow collapsing
* an array or object
*
* @var string
*/
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 08, 2013 at 02:48 PM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
@sunel
sunel / ajax.html
Last active September 6, 2015 13:43 — forked from colinmegill/ajax.html
Styling inline with AJAX for CSSConf - jQuery is hacked into the header, I know, I know.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script type="text/javascript">
/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return
@sunel
sunel / .gitconfig
Last active September 10, 2015 08:40 — forked from havvg/.gitconfig
apply PHP-CS-Fixer on all changed files in the staging area
[alias]
fix-staged = "!git diff-index --cached --name-status HEAD | grep -ve '^D' | cut -f2 | xargs -n1 php-cs-fixer fix"
@sunel
sunel / pre-commit-csfixer
Last active September 10, 2015 08:44 — forked from sampart/pre-commit-csfixer
git pre-commit hook to run the Coding Standards fixer against changed files
#!/bin/bash
# Coding Standards fixer from http://cs.sensiolabs.org/ pre-commit hook for git
#
# Based on https://github.com/s0enke/git-hooks
#
# @author Soenke Ruempler <soenke@ruempler.eu>
# @author Sebastian Kaspari <s.kaspari@googlemail.com>
#
# see the README
@sunel
sunel / gist:3af00fe6660ff84bc7c7
Created October 6, 2015 10:03 — forked from obukhow/gist:5040981
Magento file size and file extensions frontend validation
Validation.addAllThese([
['validate-filesize','The file size should not exceed 100 kb.',function(v, elm){
var maxSize = 102400;
if (navigator.appName == "Microsoft Internet Explorer") {
if (elm.value) {
var oas = new ActiveXObject("Scripting.FileSystemObject");
var e = oas.getFile(elm.value);
var size = e.size;
}
} else {
@sunel
sunel / My Magento Code.php
Created October 26, 2015 12:54 — forked from claudiu-marginean/My Magento Code.php
Magento Snippets
<block type="cms/block" name="block_name">
<action method="setBlockId"><id>block_code</id></action>
</block>
{{block type="cms/block" block_id="block_code"}}
{{block type="catalog/product_list" category_id="79" template="catalog/product/list_random.phtml"}}
@sunel
sunel / pre-commit
Created December 10, 2015 12:00 — forked from phpfunk/pre-commit
PHP Syntax Check on Git Commit
#!/usr/bin/php
<?php
// Set empty files array
$files = array();
// Get untracked files
// Get modified files
exec('git ls-files --others --exclude-standard', $untracked);
exec('git diff --cached --diff-filter=ACMRTUX --name-only', $modified);