Skip to content

Instantly share code, notes, and snippets.

View cristianrasch's full-sized avatar
💭
I may be slow to respond.

Cristian Rasch cristianrasch

💭
I may be slow to respond.
View GitHub Profile
@cristianrasch
cristianrasch / optimize-images.rb
Created November 25, 2016 18:59
Little image optimization script
#!/usr/bin/env ruby
# Debian pkg dependencies:
# - pngcrush
# - libjpeg-progs
# - imagemagick
# Usage: optimize-images graphic1.png photo1.jpeg bash-glob-exp1
require "fileutils"
### Keybase proof
I hereby claim:
* I am cristianrasch on github.
* I am cristianrasch (https://keybase.io/cristianrasch) on keybase.
* I have a public key whose fingerprint is 9B78 E79A FCEE 4DBB 081E BD88 BC00 AA23 CB3D 2E3F
To claim this, I am signing this object:
use std::fmt;
pub struct Roman {
number: String,
}
impl Roman {
pub fn from(n: u32) -> Roman {
let roman_numbers: [(u32, &str); 13] = [(1000, "M"), (900, "CM"), (500, "D"),
(400, "CD"), (100, "C"), (90, "XC"),
#[derive(Debug, PartialEq)]
pub struct RibonucleicAcid<'a> {
nucleotides: &'a str,
}
impl<'a> RibonucleicAcid<'a> {
pub fn new(nucleotides: &str) -> RibonucleicAcid {
RibonucleicAcid { nucleotides: nucleotides }
}
}
@cristianrasch
cristianrasch / why-rust.md
Created October 29, 2015 19:13
Why Rust?

Introduction

  • Systems programming language (safety & control)
  • Stack (default) vs. heap allocated vars
  • Statically typed, although the type inference is pretty sweet
  • Statement and expression based langguage
  • Features structs, enums and traits
  • Static (favored) & dynamic method dispatch
  • Has generics & type bounds
@cristianrasch
cristianrasch / monit-torquebox-squeeze.conf
Created August 6, 2015 21:33
Monit check for your Torquebox process
check process torquebox with pidfile /var/run/torquebox/torquebox.pid
start program = "/usr/sbin/service torquebox start" with timeout 60 seconds
stop program = "/usr/sbin/service torquebox stop" with timeout 30 seconds
if not exist for 3 cycles then restart
if failed
host example.com
port 443
type tcpssl
protocol https
request "/your-path"
@cristianrasch
cristianrasch / tb-backgroundable-jdbc-driver-not-found
Created May 10, 2015 14:11
Torquebox backgroundable task can't find suitable JDBC driver
10:05:22,892 ERROR [org.torquebox.messaging] (Thread-2 (HornetQ-client-global-threads-502691840)) Unexpected error in /queues/torquebox/db_user-production/tasks/torquebox_backgroundable.TorqueBox::Messaging::BackgroundableProcessor: org.jruby.exceptions.RaiseException: (DatabaseConnectionError) Java::JavaSql::SQLException: No suitable driver found for jdbc:postgresql://localhost/database?user=db_user&password=db_passwd
at RUBY.make_new(/opt/torquebox/www/db_user-production/shared/bundle/jruby/1.9/gems/sequel-4.22.0/lib/sequel/connection_pool.rb:110) at RUBY.make_new(/opt/torquebox/www/db_user-production/shared/bundle/jruby/1.9/gems/sequel-4.22.0/lib/sequel/connection_pool/threaded.rb:214) at RUBY.available(/opt/torquebox/www/db_user-production/shared/bundle/jruby/1.9/gems/sequel-4.22.0/lib/sequel/connection_pool/threaded.rb:187) at RUBY._acquire(/opt/torquebox/www/db_user-production/shared/bundle/jruby/1.9/gems/sequel-4.22.0/lib/sequel/connection_pool/threaded.rb:127) at RUBY.acquire(/opt/torquebox/www/db_us
module TestHelper
module RequestClassMethods
def test_req_class_method
@req_class_ivar ||= 0
@req_class_ivar += 1
p "---"
p @req_class_ivar
p "---"
end
end
@cristianrasch
cristianrasch / rank-checker-api-v2.0
Created March 29, 2015 11:17
Rank checker API v2.0
=====
Usage
=====
Basic request:
curl --insecure --silent -H "X-API-Key: the-api-key" https://the-host/rankings
# => {"error":"Either a keyword, brand or competitor param is required."}
You need to include either a keyword, competitor or both params, which are detailed below.
@cristianrasch
cristianrasch / rsyncrypto.sh
Last active February 9, 2023 19:37
rsyncrypto tutorial
# Generate your backup private key and certificate
openssl req -nodes -newkey rsa:1536 -x509 -keyout backup.key -out backup.crt
# Encrypt your data to a temporary folder
rsyncrypto --verbose --ne-nesting=2 --trim=2 --name-encrypt=/tmp/rsyncrypto-map --delete-keys --changed --recurse /home/cristian/Dropbox/ /tmp/Dropbox/ /tmp/rsyncrypto-keys ~/Dropbox/backups/laptop/crypto/rsyncrypto/backup.crt
# Send it over the network
rsync --verbose --archive --compress --delete /tmp/Dropbox/ pi:~/backups/laptop
# Decryption time!