Skip to content

Instantly share code, notes, and snippets.

View ostinelli's full-sized avatar

Roberto Ostinelli ostinelli

View GitHub Profile
@ostinelli
ostinelli / ecdsa_example.rb
Last active April 14, 2024 17:32
ECDSA usage from Ruby.
require 'openssl'
require 'base64'
# ===== \/ sign =====
# generate keys
key = OpenSSL::PKey::EC.new("secp256k1")
key.generate_key
public_key = key.public_key
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format
@ostinelli
ostinelli / resource_monitor.sh
Last active November 19, 2017 01:01
Monitor server CPU and memory.
#!/usr/bin/env bash
# settings
OUTPUT_FILE=monitor.csv
# build command
cmd=""
cpu_headers=""
for (( i=4; i<=$(nproc)+4; i++ ))
do
@ostinelli
ostinelli / jenkins_ci_on_ubuntu.md
Last active February 14, 2023 07:12
Setup Jenkins CI on Ubuntu.

Jenkins CI

Instructions on how to setup a secured Jenkins CI.

Install Jenkins

$ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list$ .d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins
@ostinelli
ostinelli / jenkins_ci_on_osx.md
Last active February 28, 2023 02:38
Setup Jenkins CI on OSX.

Jenkins CI on OSX

Instructions on how to setup a secured Jenkins CI on a Mac.

Download & Install dependencies

All of these operations are done with your admin user.

Developer tools

Install the command line developer tools.

@ostinelli
ostinelli / openssl_common_operations.md
Last active February 12, 2020 13:54
OpenSSL common operations.

Open SSL common operations

Generate a new Private key and Certificate Signing Request

$ openssl req -out server.csr -new -newkey rsa:2048 -nodes -keyout server.key

Generate a self-signed certificate and private key

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
@ostinelli
ostinelli / erlang-release-init.d.md
Last active September 15, 2019 12:18
Erlang Release init.d script

Erlang Release init.d script

If you have packaged your application into a release generated with Rebar, you might want to have the following:

  • The release started on system boot.
  • The VM monitored and restarted it if it crashes.

Use HEART

HEART is the Heartbeat Monitoring of an Erlang Runtime System. The purpose of the heart port program is to check that the Erlang runtime system it is supervising is still running, so that if the VM crashes or becomes unresponsive, it is restarted.

@ostinelli
ostinelli / stub_environment.rb
Created September 10, 2015 14:10
Stub Rails environment
def stub_rails_env_as(env)
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new(env.to_s))
end
@ostinelli
ostinelli / import.sh
Created November 10, 2015 17:24
Heroku Import database
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d {database} sql.dump
@ostinelli
ostinelli / logentries_manual_setup.md
Last active August 11, 2022 21:37
How to use a single Logentries account on Heroku.

If you have multiple applications on Heroku and would like to use a single Logentries account for all of them, this is how you do it. Basically, do not use add-ons, and send all drains to your account.

  • In your Logentries account, click on Add Log
  • Select Manual
  • In the form that appears, input the following:
    • Log Name: access.log
    • Select Set: new set named myapp-{environment}, for instance myapp-staging (at least, this is how I like to name my entries)
    • Select the Plain TCP, UDP - logs are sent via syslog option
  • Click on Create Log Token
@ostinelli
ostinelli / simulator.sh
Created March 22, 2016 10:11
Open iOS simulator directly from console
alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'