Skip to content

Instantly share code, notes, and snippets.

@lodi-g
lodi-g / HOWTO.md
Created March 14, 2021 14:19
How to setup a send-only mail server with TLS and SMTP credentials (postfix, submission, CyrusSASL)

Prepare server

  • sudo hostnamectl set-hostname example.com
  • sudo apt install mailutils postfix
    • Choose "internet site", and type your domain (example.com)

Test postfix

  • mail your-test@yopmail.com -s "Subject"
  • You should receive a mail from debian@example.com
@JanKoppe
JanKoppe / README.md
Last active December 4, 2020 03:58
nginx basic auth with different users for read/write

This nginx configuration allows to restrict access via different methods to separate users.

This is very useful for private docker registries, where you want every member of your team to be able to fetch Docker images, but only some users (admins and CI users) to push new images to the registry.

Example:

  • User write can use GET, POST, PUT, DELETE and everything else.
  • User read can only use GET and HEAD.
  • Anonymous users are denied access entirely.
@maxivak
maxivak / readme.md
Last active January 12, 2024 06:53
Integrating Gem/Engine and Main Rails App
@mlanett
mlanett / rails http status codes
Last active May 3, 2024 04:15
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@valerykalashnikov
valerykalashnikov / js_precommit_hook
Last active October 4, 2018 08:13
Precommit hook to prevent console.log, debugger and binding.pry
#!/bin/bash
#Precommit hook to prevent "debugger" and "console.log"
#Note: to enamble precommit on Windows machine don't forget add path to Git\bin and Git\cmd to PATH environment variable
count=0
for FILE in `git diff-index --name-status HEAD -- | cut -c3-` ; do
# Check if the file contains 'debugger' or 'console.log'
contains=`grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE`
if [ `grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE|wc -l` -ne 0 ]
@mpeteuil
mpeteuil / rubocop_pre_commit_hook
Created August 3, 2013 17:44
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@dalethedeveloper
dalethedeveloper / gist:1503252
Created December 20, 2011 21:00
Mobile Device Detection via User Agent RegEx

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(