Skip to content

Instantly share code, notes, and snippets.

View luispimenta's full-sized avatar
🎯
Focusing

Luis Fernando Pimenta luispimenta

🎯
Focusing
View GitHub Profile
@luispimenta
luispimenta / redis.config
Created June 3, 2020 23:22 — forked from yustam/redis.config
Install Redis on Elastic Beanstalk
packages:
yum:
gcc-c++: []
make: []
sources:
/home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz
commands:
redis_build:
command: make
cwd: /home/ec2-user/redis-2.8.4
@luispimenta
luispimenta / build_framework.sh
Created June 10, 2020 20:03
Script to build a framework for multiple architectures
# Merge Script
# http://code.hootsuite.com/an-introduction-to-creating-and-distributing-embedded-frameworks-in-ios/
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
@luispimenta
luispimenta / rw_ro_access.sql
Created July 22, 2020 12:13 — forked from checco/rw_ro_access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;
@luispimenta
luispimenta / zip_s3_files.rb
Created December 8, 2020 15:55 — forked from abelorian/zip_s3_files.rb
Zip files from remote server (S3)
protect_from_forgery :except => :get_job_resumes #Optional
require 'zip'
def get_job_resumes
@job = Job.find(params[:job_id])
@file = "#{Rails.root}/files/cvs.zip"
@applications = Application.get_applicants_all(@job.id) # app context method
Zip::ZipOutputStream.open(@file) do |zos|
@applications.each do |application|
user = application.user
@luispimenta
luispimenta / 99-login-fon
Created January 21, 2021 14:38 — forked from cusspvz/99-login-fon
FON ZON / NOS auto-login bash script wget portugal non-wispr client openwrt
#!/bin/sh
# place this file at: /etc/hotplug.d/iface/99-login-fon
# Configurations
FON_USERNAME=email%40domain.com
FON_PASSWORD=123456
FON_DELAY_UP=3
COOKIE_JAR_PATH=/tmp/nos-fon-cookie-jar.$INTERFACE
. /lib/functions.sh
#!/bin/bash
set -ex
# This scripts allows you to upload a binary to the iTunes Connect Store and do it for a specific app_id
# Because when you have multiple apps in status for download, xcodebuild upload will complain that multiple apps are in wait status
# Requires application loader to be installed
# See https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html
# Itunes Connect username & password
USER=changeme

Javascript

function cpfMask(cleanValue) {
  return cleanValue.replace(/^(\d{3})(\d{3})(\d{3})(\d{2}).*/, '$1.$2.$3-$4');
}

function cnpjMask(cleanValue) {
  return cleanValue.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2}).*/, '$1.$2.$3/$4-$5');
}
@luispimenta
luispimenta / cpf_cnpj_validators.rb
Created September 30, 2021 17:39 — forked from lucascaton/cpf_cnpj_validators.rb
validação de CPF e CNPJ em Ruby
#------------------------------------------------------------------------------
# Rotinas para verificação de CPF e CNPJ
# Linguagem: Ruby
# Escrito por: André Camargo < [email protected] > http://blog.boaideia.inf.br
# Use, copie, melhore a vontade! Patches são bem-vindos...
#------------------------------------------------------------------------------
def check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
@luispimenta
luispimenta / app.js
Created May 18, 2022 19:44 — forked from VMBindraban/app.js
Resize/crop/center in javascript through canvas to base64
var $uplImageBtn = $('.pui--ev-upload'),
$uplContainer = $('#uplProfileImg'),
$previewImg = $('.macc--s-pimg img');
$uplImageBtn.click(function() {
$uplContainer.trigger('click');
});
$uplContainer.on('change', function() {
if (!this.files && !this.files[0]) {
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####