Skip to content

Instantly share code, notes, and snippets.

View rafaelcpalmeida's full-sized avatar
🐝

Rafael Almeida rafaelcpalmeida

🐝
View GitHub Profile
@carlosramireziii
carlosramireziii / attached_validator.rb
Last active April 10, 2024 11:11
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@raghothams
raghothams / server.py
Created February 22, 2016 10:10
Flask request header decorator
from functools import wraps
from flask import Flask, request
app = Flask(__name__)
key = "ya29.bwLu0ruxXdXe_RMOSYgfiCPORNMHLkf9rCDmV1rKtWu90TuF1d8B2SmdUlrjeOWNYThkgMM"
def secure(f):
@wraps(f)
def check_authorization(*args, **kwargs):
if request.headers.get("Authorization") == key:
return f()
@mamoit
mamoit / memorando.md
Last active January 22, 2016 12:27
Memorando de entendimento da censura em plaintext

Memorando de Entendimento

Entre:

IGAC - Inspeção-Geral das Atividades Culturais, neste ato representada por Luís Silveira Botelho, Inspetor-Geral das Atividades Culturais,

DGC - Direção-Geral do Consumidor, neste ato representada por Teresa Moreira, Diretora-Geral,

APRITEL - Associação dos Operadores de Telecomunicações, em representação dos seus associados, operadores de comunicações eletrónicas que, no âmbito deste memorando de entendimento, são designados por Prestadores Intermediários de Serviços em Rede, mandatada neste ato pela respetiva Direção e representada por Daniela Antão, Secretária-Geral,

MAPINET - Movimento Cívico Anti Pirataria na Internet, neste acto representado por António Paulo Santos, presidente da Direção e SPA - Sociedade Portuguesa de Autores, representada pelo seu membro da Administração Pedro Campos, que outorgam por si em representação de:

@PurpleBooth
PurpleBooth / README-Template.md
Last active May 6, 2024 07:22
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@hayderimran7
hayderimran7 / gist:9246dd195f785cf4783d
Created February 13, 2015 22:38
How to solve "sudo: no tty present and no askpass program specified" when trying to run a shell from Jenkins
Running shell scripts that have contain sudo commands in them from jenkins might not run as expected. To fix this, follow along
Simple steps:
1. On ubuntu based systems, run " $ sudo visudo "
2. this will open /etc/sudoers file.
3. If your jenkins user is already in that file, then modify to look like this:
jenkins ALL=(ALL) NOPASSWD: ALL
4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite)
5. Exit by doing Ctrl+X
6. Relaunch your jenkins job
@shadcn
shadcn / gist:de147c42d7b3063ef7bc
Last active September 17, 2022 11:50
Convert a Hex string to UIColor in Swift
// Creates a UIColor from a Hex string.
func colorWithHexString (hex:String) -> UIColor {
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString
if (cString.hasPrefix("#")) {
cString = cString.substringFromIndex(1)
}
if (countElements(cString) != 6) {
return UIColor.grayColor()
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)