Skip to content

Instantly share code, notes, and snippets.

View raulmoyareyes's full-sized avatar
💻
Programming!

Raúl Moya Reyes raulmoyareyes

💻
Programming!
View GitHub Profile
@raulmoyareyes
raulmoyareyes / .htaccess-mod_headers
Created June 1, 2016 15:04 — forked from hans2103/.htaccess-mod_headers
.htaccess rules to set cache control.
<IfModule mod_headers.c>
Header set Connection keep-alive
# Cache-control headers
# 2 HOURS
#<filesMatch "*">
Header set Cache-Control "max-age=7200, must-revalidate"
#</filesMatch>
# 480 weeks - 290304000
@raulmoyareyes
raulmoyareyes / useful-commands.txt
Created January 15, 2017 11:57
Useful commands for apache log and folders.
# IPs distintas y peticiones
cat access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -30
# Peticiones al dia
zcat access.log-*.gz | awk '{print substr($4, 2, 11)}' | sort -n | uniq -c
# Total de peticiones sumadas de todos los dias
zcat access.log-*.gz | awk '{print substr($4, 2, 11)}' | sort -n | uniq -c awk '{ sum += $1 } END { print sum }'
# Numero de peticiones a paginas (sin contar imagenes etc)
@raulmoyareyes
raulmoyareyes / what-forces-layout.md
Created June 30, 2017 07:09 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@raulmoyareyes
raulmoyareyes / Calisthenics.md
Created April 23, 2018 14:11 — forked from bobuss/Calisthenics.md
The 9 Rules of Object Calisthenics

Object Calisthenics outlines 9 basic rules to apply when performing the exercise:

  • One level of indentation per method.
  • Don't use the ELSE keyword.
  • Wrap all primitives and Strings in classes.
  • First class collections.
  • One dot per line.
  • Don't abbreviate.
  • Keep all classes less than 50 lines.
  • No classes with more than two instance variables.
@raulmoyareyes
raulmoyareyes / wrong-srp.js
Last active July 29, 2018 15:29
[ Wrong ] - Single Responsability Principle
class UserSettings {
constructor(user) {
this.user = user;
}
changeSettings(settings) {
if (this.verifyCredentials()) {
// ...
}
}
@raulmoyareyes
raulmoyareyes / srp.js
Created July 29, 2018 15:30
Single Responsability Principle
class UserAuth {
constructor(user) {
this.user = user;
}
verifyCredentials() {
// ...
}
}
@raulmoyareyes
raulmoyareyes / wrong-ocp.js
Created July 29, 2018 15:37
[ Wrong ] - Open / Closed Principle
class Pdf {
constructor(name, size) {
this.name = name;
this.size = size;
}
// ...
}
class Png {
constructor(name) {
@raulmoyareyes
raulmoyareyes / ocp.js
Last active July 29, 2018 15:45
Open / Closed Principle
class Printable {
function print() {
// ...
}
}
class Pdf extends Printable {
constructor(name, size) {
super();
this.name = name;
this.size = size;
@raulmoyareyes
raulmoyareyes / wrong-lsp.js
Created July 29, 2018 15:48
[ Wrong ] - Liskov Substitution Principle
class Rectangle {
constructor() {
this.width = 0;
this.height = 0;
}
setWidth(width) {
this.width = width;
}
@raulmoyareyes
raulmoyareyes / lsp.js
Created July 29, 2018 15:50
Liskov Substitution Principle
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
getArea() {
return this.width * this.height;
}
}