Skip to content

Instantly share code, notes, and snippets.

View ang3lkar's full-sized avatar

Angelos Karagkiozidis ang3lkar

View GitHub Profile
@blixt
blixt / logger_middleware.go
Last active July 5, 2024 22:02
Logger middleware for Go HTTP servers which logs every request with response status code in the Apache format.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"time"
)
@Twipped
Twipped / gulpfile.js
Last active July 22, 2019 15:22
CSS Modules without webpack or browserify
var gulp = require('gulp');
var gutil = require('gulp-util');
var through = require('through2');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var filter = require('gulp-filter');
var concat = require('gulp-concat');
var modules = require('postcss-modules');
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@sauloperez
sauloperez / signal_catching.rb
Last active November 11, 2020 11:25
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@joefiorini
joefiorini / idiomatic_mofo.rb
Created January 7, 2012 05:34
Camelize Hash keys to return in JSON request. In other words, idiomatic JSON for your Rubies. Consider this pseudo-code as it's about 40% untested.
def HashExtensions(hash)
hash.extend(HashExtensions)
end
module HashExtensions
def camelize_keys
dup.camelize_keys!
end
@jcasimir
jcasimir / performance.markdown
Created September 21, 2011 13:27
Measuring Performance

Measuring Performance

Performance is often ignored in Rails development until it becomes a problem. If ignored too long, though, it can get very tricky to improve. It's valuable to regularly audit performance and look for hotspots or design choices that are slowing things down.

Inspecting the Logs

Inspecting the log will help identify the source of several performance issues the application may have.

The Rails application log outputs the time spent processing each request. It breakdowns the time spent at the database level as well processing the view code. In development mode, the logs are displayed on STDOUT where the server is being run. In a production setting the logs will be in log/production.log within the application's root directory.