Skip to content

Instantly share code, notes, and snippets.

View tiagoameller's full-sized avatar

Tiago Ameller tiagoameller

View GitHub Profile
@tiagoameller
tiagoameller / neevia_pdfsign.pas
Created November 29, 2022 13:06
Sample code for signing a PDF using Neevia.PDFsign ActiveX
procedure TfoMain.buSignClick(Sender: TObject);
var
objSigner: Variant;
iResult: Integer;
sOutput: string;
begin
objSigner := CreateOleObject('Neevia.PDFsign');
objSigner.CertificateSubject := cbCertificado.Text;
// objSigner.CertificatePassword := 'password';
@tiagoameller
tiagoameller / .xbindkeysrc
Created November 25, 2021 16:38
my xbindkeys configuration for Logitech mouse
# For the benefit of emacs users: -*- shell-script -*-
###########################
# xbindkeys configuration #
###########################
#
# Version: 1.8.6
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
@tiagoameller
tiagoameller / add_kendo-ui_to_rails_project.md
Last active July 10, 2020 07:13
How to add kendo_ui to a Rails project, using webpacker and stimulus.js framework

How to add kendo_ui to a Rails project, using webpacker and stimulus.js framework

It shows how to integrate Kendo UI library in a Rails project.

Despite it could be done via Webpack, I found it very difficult. Open source part, can be added with yarn add kendo-ui-core but commercial part must be added by hand.

Thus, this is what I made:

  1. Create a vendor folder and kendo folder inside:
ffmpeg -threads 4 -i $1 -b:v 1024k $2
@tiagoameller
tiagoameller / Vagrantfile
Last active November 9, 2016 08:39
Vagrantfile to create a ubuntu/trusty32 virtual box to run a Ruby on Rails application inside a Windows host.
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
##############################################################################################################################
# Tiago, 06/11/2016 10:44 22:44
# This configuration sets a VM for production, in order to have a Rails app running inside a Windows box
# ubuntu/trusty32 due problemes to run 64 bits VM in old Windows boxes
# Stack:
# - mysql, opened to host to read/write data from windows apps. Use port 4406
@tiagoameller
tiagoameller / custom_version.rake
Last active August 29, 2015 14:27
rake task for managing app version. Show current version, increment / decrement major.minor,release.build just calling COM=x.+.0.+ rake custom:version
namespace :custom do
# This rake task shows and manages app version
# rake task for managing app version.
# Show current version, increment / decrement major.minor,release.build just calling
# COM=x.+.0.+ rake custom:version
# call as `rake custom:version` to show current version or
# call as `COM=x.x.x.+ rake custom:version` to increment build or
# call as `COM=x.x.+.+ rake custom:version` to increment release or
# call as `COM=1.0.0.+ rake custom:version` to put an arbritrary value
# major.minor.release.build: x => don't change; + => increment; - => decrement; int => value
@tiagoameller
tiagoameller / custom_purge_logs.rake
Created August 10, 2015 07:36
Rake task for purging your Rails app's logs
namespace :custom do
# This rake task purges all existing logs in given folder
# call as rake custom:purge_logs for default value or
# call as LOG_DIR=shared/log/ rake custom:purge_logs or
# call as LOG_DIR=shared/log/ LOG_PURGE_LINES=20000 rake custom:purge_logs
LOG_DIR = 'log/'
LOG_PURGE_LINES = 32_768
desc "Purge logs Defaults LOG_DIR=#{LOG_DIR} LOG_PURGE_LINES=#{LOG_PURGE_LINES}"
@tiagoameller
tiagoameller / array.rb
Created August 9, 2015 20:27
Arrays and hashes. All generate same result. Ruby 2.2.0. To be continued ... (missing 8 more examples)
#! /home/tiago/.rbenv/shims/ruby
arr = [123,1,3,5,7,8,9,7,6,5,4,3,4,5,6,7,8,23,1,2,3,4,6,8,6,43,123,54,7,0,89,6,4,2,5,7,8,9,0]
puts 'arr.uniq.map { |x| [x, arr.count(x)] }.to_h'
puts arr.uniq.map { |x| [x, arr.count(x)] }.to_h
puts
puts 'h = Hash.new(0); arr.each { |i| h[i] += 1 }; h'
h = Hash.new(0)
@tiagoameller
tiagoameller / pn_backup.sh
Last active August 29, 2015 14:26
automatic backup for rails postgres database
#!/bin/bash
# Please see some environment variables must be declared outside this script
# To execute this script every six hours, put in your crontab -e
# m h dom mon dow command
# 0 */6 * * * /home/rails/pn_backup.sh
BackupHome=/home/rails/pn_backup/
BackupBase=`date +%Y-%m-%dT%H%M`
BackupFile="$BackupBase".sql
@tiagoameller
tiagoameller / panic.sh
Last active August 29, 2015 14:24
Save not staged files to your dropbox. I know, you can use git archive for saving a commit. This save BEFORE commited files.
#!/bin/bash
ZipFN=`date +%Y-%m-%dT%H%M``pwd | sed -e 's/\//_/g'`.zip
Panic=~/Dropbox/Panic
BackupTmp=~/tmp/gbackup.tmp
echo "Panic current git modified and new files"
# modified
git ls-files -m --full-name > $BackupTmp
# new
git ls-files --others --exclude-standard --full-name >> $BackupTmp
cat $BackupTmp | zip --names-stdin -P "$MAIL_PASS" $ZipFN