Skip to content

Instantly share code, notes, and snippets.

@lelotnk
lelotnk / clean_code.md
Created September 26, 2024 00:12 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@lelotnk
lelotnk / phpnatsort.php
Created August 28, 2015 18:56
PHP Natsort
<?php
$array = array(
'/dir/arquivo-01.jpg',
'/dir/arquivo-02.jpg',
'/dir/arquivo-03.jpg',
'/dir/arquivo-04.jpg',
'/dir/arquivo-05.jpg',
'/dir/arquivo-06.jpg',
'/dir/arquivo-07.jpg',
@lelotnk
lelotnk / 40-tools-for-writing-better-php.md
Last active October 9, 2024 00:32
40+ tools for writing better PHP

PHP is a server-side scripting language designed for web development, but also used as a general-purpose programming language. With over 240 million indexed domains using PHP, including major websites like Facebook, Digg and WordPress, there are good reasons why many web developers prefer it to other server-side scripting languages, such as Python and Ruby.

There are scads of PHP tools available over the internet for php developers, but finding an appropriate PHP tool is quite an arduous task and demands effort and time. Today we’ve collected 45 handy PHP development tools for developers…

Plates

Plates is a simple and easy to use PHP templates system. Plates is designed for web developers who prefer to use native PHP templates over compiled templates.

@lelotnk
lelotnk / main.js
Created April 19, 2015 03:58
Definindo um módulo com RequireJs e Module Patten
require(['jquery', 'app/mymodule'], function($, MyModule){
MyModule.initialize();
});
@lelotnk
lelotnk / url_slug.js
Last active August 29, 2015 14:08 — forked from sgmurphy/url_slug.js
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
A : /[\xC0-\xC6]/g,
@lelotnk
lelotnk / Ordenação de Strings
Last active December 22, 2015 23:09
Ordenação de strings.
<?php
// Criar uma lista de testes.
$array = array();
$letter ='A';
for ($i = 0; $i <= 1000; $i++) {
for ($j = 1; $j < 13; $j++) {
$array[] = $letter . $j;
@lelotnk
lelotnk / calc.method
Created July 18, 2013 19:32
Calcular Diferença de Horas entre Datas
static function getIntervalUnits($interval, $unit)
{
// Day
$total = $interval->format('%a');
if ($unit == 'days')
return $total;
//hour
$total = ($total * 24) + ($interval->h );
if ($unit == 'hours')
return $total;
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install fbmessenger
http://www.webupd8.org/2013/04/fbmessenger-stand-alone-facebook.html
# Sublime Text 2
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
# Sublime Text 3
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer