Skip to content

Instantly share code, notes, and snippets.

@hugodias
hugodias / interview-questions.md
Created January 11, 2021 13:25
Senior Developers Interview Questions

Technical questions

  1. What techniques would you use to make sure an API is reliable and scalabe for reading operations to support 1M requests a day with peak of 2000 concurrent users?
  2. You have just been put in charge of a legacy code project which is difficult to maintain – what would you plan to improve in order to make the project easier to maintain in the long-term?
  3. What is an acceptable response time for a ready-only API GET method in your opinion?
  4. What is dependency injection? What are the benefits of using it?
  5. Do you test your applications? What are the importance of tests in software development and the difference between each type of test? (Unit tests, E2E, Integration tests, Load Test)

Role-specific questions

  1. What metrics do you use to monitor a backend application performance?
  2. What metrics do you use to monitor your teams performance?
@hugodias
hugodias / content-tag.php
Last active January 19, 2022 06:27
content_tag function in PHP to work as Rails content_tag function
<?php
/**
* @param $tag
*
* @return string
*/
function close_tag($tag)
{
return "</" . $tag . ">";
@hugodias
hugodias / gist:7e73c8c022100d52b6ee
Created May 19, 2014 23:34
Installing MCrypt extension on MAMP
  1. Install homebrew
  2. Update homebrew with brew update
  3. Add josegonzales tap running: brew tap josegonzalez/php
  4. Install mcrypt running brew install php54-mcrypt --without-homebrew-php (php54 => php 5.4.x ; php54 => php 5.3.x, etc ...)
  5. Open your PHP.ini and add extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"
  6. Restart your apache
@hugodias
hugodias / authorizedApolloProvider.js
Created July 26, 2020 01:22
Authorize Apollo with Auth0 Access Token Claims
import React from 'react'
import {
ApolloClient,
ApolloProvider,
InMemoryCache,
createHttpLink,
} from '@apollo/client'
import { setContext } from '@apollo/link-context'
import Loading from './components/Loading'
@hugodias
hugodias / post-mortem-template.md
Created April 9, 2020 14:59
Incident Post Mortem Template

Post-mortem (incident #1)

Date

2019-03-18

Status

Completed

Summary

@hugodias
hugodias / .htaccess
Created June 28, 2020 23:29
Multi Language WordPress htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(br|en|es)$ index.php?lang=$0 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@hugodias
hugodias / index.html
Created May 8, 2013 19:45
Set Interval with pause and resume
<script>
function RecurringTimer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
var resume = function() {
@hugodias
hugodias / .htaccess
Last active November 22, 2019 14:54
WordPress Security Checklist
<IfModule mod_headers.c>
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always edit Set-Cookie (.*) "$1; HTTPOnly"
Header always edit Set-Cookie (.*) "$1; Secure"
</IfModule>
@hugodias
hugodias / tokenable.rb
Created December 30, 2013 15:04
Create a best random token for any model in ruby on rails
# app/models/mymodel.rb
# include Tokenable
###
# app/models/concerns/tokenable.rb
module Tokenable
extend ActiveSupport::Concern
included do
before_create :generate_token
end
func enableCorsJson(fn http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Add("Access-Control-Allow-Origin", "*")
fn(w, r)
}
}