Skip to content

Instantly share code, notes, and snippets.

View wellington1993's full-sized avatar
🏠
Working from home

Wellington Torrejais da Silva wellington1993

🏠
Working from home
View GitHub Profile
@wellington1993
wellington1993 / nginx.conf
Created May 16, 2019 13:53 — forked from v0lkan/nginx.conf
Configuring NGINX for Maximum Throughput Under High Concurrency
user web;
# One worker process per CPU core.
worker_processes 8;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
@wellington1993
wellington1993 / letsencrypt_2019.md
Created May 14, 2019 20:47 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@wellington1993
wellington1993 / xls_spec.rb
Created February 13, 2019 18:42 — forked from aya-soft/xls_spec.rb
Spreadsheet: wrong value from formula
#encoding: utf-8
require 'spreadsheet'
xls_file_name = "/tmp/status_data.xls"
xls_book = Spreadsheet.open(xls_file_name, "rb")
xls_book.worksheet(0).each do |row|
puts row[6].value if row[6] and row[6].is_a?(Spreadsheet::Formula)
@wellington1993
wellington1993 / dispatcher.rb.patch
Created November 28, 2018 12:29 — forked from metavida/dispatcher.rb.patch
A patch for a Mongrel + Rails 1.2.6 bug, described in detail here: http://billkirtley.wordpress.com/2009/03/03/failsafe-handling-with-rails/
--- a/rails-1.2.6/lib/dispatcher.rb
+++ b/rails-1.2.6/lib/dispatcher.rb
@@ -41,7 +41,7 @@
controller.process(request, response).out(output)
end
rescue Exception => exception # errors from CGI dispatch
- failsafe_response(output, '500 Internal Server Error', exception) do
+ failsafe_response(output, '500 Internal Server Error', exception, response) do
controller ||= (ApplicationController rescue ActionController::Base)
controller.process_with_exception(request, response, exception).out(output)

Fix for FOUC :

At the top of your HTML:

<!doctype html>
<html>
<head>
    <style>html{visibility: hidden;opacity:0;}</style>
@wellington1993
wellington1993 / gist:10cd0d657e66c1623c98e8ee699e912d
Created November 8, 2018 13:59 — forked from cesarjr/gist:4313561
Impressão direta em Delphi utilizando o Gerenciador de Impressões do Windows sem passar pelo driver do fabricante.
uses
WinSpool;
procedure TFrmMain.btnImprimir(Sender: TObject);
var
Handle: THandle;
CaracteresImpressos: DWORD;
Documento: TDocInfo1;
TextoAnsiString : AnsiString;
TextoUnicode: string;
@wellington1993
wellington1993 / ruby-rails-erb-comments.erb
Created October 22, 2018 18:47 — forked from jonathan-beebe/ruby-rails-erb-comments.erb
Comment lines in ruby rails html.erb files, as answered on StackOverflow http://stackoverflow.com/a/3901665/123781
To comment a single line use
<%-# commented line -%>
This also works
<%# my comment %>
To comment a whole block use a if false to surrond your code like this
@wellington1993
wellington1993 / INSTALL.md
Created September 21, 2018 10:08 — forked from arya-oss/INSTALL.md
Ubuntu 16.04 Developer Tools installation

Ubuntu 16.04 Developer Tools Installation

First things first !

sudo apt update
sudo apt upgrade

Standard Developer Tools

sudo apt-get install build-essential git

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@wellington1993
wellington1993 / IsEmptyOrNull.pas
Created August 27, 2018 19:54 — forked from martinusso/IsEmptyOrNull.pas
Check if Variant is empty or null in Delphi
// uses System, Variants
function IsEmptyOrNull(const Value: Variant): Boolean;
begin
Result := VarIsClear(Value) or VarIsEmpty(Value) or VarIsNull(Value) or (VarCompareValue(Value, Unassigned) = vrEqual);
if (not Result) and VarIsStr(Value) then
Result := Value = '';
end;