Skip to content

Instantly share code, notes, and snippets.

#first download the packages from http://download.opensuse.org/repositories/security://shibboleth/
# ---
sudo rpmbuild --rebuild log4shib-1.0.9-3.1.el6.src.rpm
sudo rpm -ivh /usr/src/rpm/RPMS/x86_64/liblog4shib1-1
sudo rpmbuild --rebuild xerces-c-3.1.2-3.1.el6.src.rpm
sudo rpm -ivh /usr/src/rpm/RPMS/x86_64/xerces-c-bin-3.1.2-3.1.amzn1.x86_64.rpm
sudo rpmbuild --rebuild xml-security-c-1.7.3-3.1.el6.src.rpm
sudo rpm -ivh /usr/src/rpm/RPMS/x86_64/xml-security-c-bin-1.7.3-3.1.amzn1.x86_64.rpm
sudo rpmbuild --rebuild curl-openssl-7.42.1-1.1.el6.src.rpm
@Raffaello
Raffaello / typo_suggestion.php
Last active April 16, 2016 23:35
typo suggestion
function suggestion(array $words, $word)
{
$lev = [];
foreach ($words as $w) {
$lev[$w] = levenshtein($word, $w);
}
return array_search(min($lev), $lev, true);
}
@Raffaello
Raffaello / vbox-modprobe.sh
Last active October 9, 2017 15:23
VirtualBox recompiling kernel with Secure Boot.
#!/usr/bin/bash
openssl req -new -x509 -newkey rsa:2048 -keyout vbox.keyout -outform DER -out vbox.der -nodes -days 36500 -subj "/CN=VBoxDrv/"
mokutil --import vbox.der
### after the reboot yo are able to add it to the secure boot, please select it.
reboot
@Raffaello
Raffaello / clean-backup-logs-file.sh
Last active November 10, 2016 11:10
log rotation clean up
sudo find /var/log/ -name "*.log.*" -exec rm -v {} \;
def reverseInt(x: Int): Int = {
x.toString.reverse.toInt
}
def palindromeNumberEquation(x:Int, y:Int): Boolean = {
reverseInt(x) == x*y
}
def differentDigitsInt(x: Int, y: Int): Boolean = {
x.toString.groupBy(c => c).map(m => m._2.length).sum == y
@Raffaello
Raffaello / ssh_tunnel.sh
Created January 25, 2017 14:18
SSH tunnelling
#!/bin/bash
ssh -fNL $target_port:$target_host:$source_port $source_host
@Raffaello
Raffaello / mysql_field_type.php
Last active January 17, 2018 16:01
mysql_field_type comparison with type of msqli
<?php
// parameters, set them properly based on your needs.
$host = '';
$username = '';
$password = '';
$query = 'select * from [table] limit 0';
$c = mysql_connect($host, $username, $password);
$r = mysql_query($query, $c);
$n = mysql_num_fields($r);
@Raffaello
Raffaello / FizzBuzz.sc
Last active February 26, 2018 00:15
FizzBuzz
(1 to 100).map { x =>
val str = StringBuilder.newBuilder
if(x % 3 == 0) str append "Fizz"
if(x % 5 == 0) str append "Buzz"
if(str.size > 0) str.toString else x.toString
}.mkString("\n")
@Raffaello
Raffaello / vagrant
Last active April 10, 2018 16:41
vagrant sudoers file
Cmnd_Alias VAGRANT_EXPORTS_CHOWN = /bin/chown 0\:0 /tmp/*
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_MV = /bin/mv -f /tmp/* /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /usr/bin/systemctl status --no-pager nfs-server.service
Cmnd_Alias VAGRANT_NFSD_START = /usr/bin/systemctl start nfs-server.service
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
Cmnd_Alias VAGRANT_HOSTMANAGER_UPDATE = /bin/cp home/rbertini/.vagrant.d/tmp/hosts.local /etc/hosts
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /*/exports
Cmnd_Alias VAGRANT_EXPORTS_REMOVE_2 = /bin/cp /*/exports /etc/exports
%wheel ALL=(root) NOPASSWD: VAGRANT_EXPORTS_CHOWN, VAGRANT_EXPORTS_ADD, VAGRANT_EXPORTS_MV, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_HOSTMANAGER_UPDATE, VAGRANT_EXPORTS_REMOVE, VAGRANT
@Raffaello
Raffaello / top-k-words-stream.sc
Last active November 8, 2018 13:33
Top K words with MaxHeap
val input2 =
"""
|Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum viverra sit amet ligula id imperdiet. Proin vestibulum eget tellus in viverra. Mauris eleifend malesuada nunc, non porta quam placerat non. Nunc viverra, quam ac varius posuere, sapien tortor elementum nibh, a pulvinar mi nulla vitae lorem. Duis diam dolor, luctus ut suscipit eu, sodales in est. Maecenas egestas at velit eleifend laoreet. Aliquam imperdiet lorem et dolor finibus laoreet vel et lectus. Duis finibus felis eu tempus consectetur. Quisque vestibulum metus sed pretium consequat. Sed non quam faucibus, fringilla mi vel, porttitor metus.
|
|Nulla tortor est, dignissim nec orci sit amet, vulputate commodo libero. Integer gravida non turpis malesuada fermentum. Pellentesque sollicitudin sem sed lobortis elementum. Phasellus nec est metus. Integer id vehicula velit, sit amet scelerisque tortor. Nullam fermentum ultricies sodales. Duis vitae elementum diam, sit amet dictum nulla. Cras eu velit aliquam, ven