Skip to content

Instantly share code, notes, and snippets.

View pcarranza's full-sized avatar
🦄
Adding horns to horses

Pablo Carranza pcarranza

🦄
Adding horns to horses
  • Remote
View GitHub Profile
@pcarranza
pcarranza / convert.rb
Created August 4, 2014 18:33
Convert markdown files using glue and rdiscount
#!ruby
require 'markdown'
`ls *.markdown`.split.each { |filename|
puts "Converting file #{filename}"
mkd = RDiscount.new(File.new(filename, 'r').read)
File.new(filename.sub!('markdown', 'html'), 'w').write(mkd.to_html)
}
@pcarranza
pcarranza / load_id_rsa.rb
Last active August 29, 2015 14:07
Load RSA key from ssh id_rsa.pub file (timid)
def load_rsa_key(key)
case key
when nil
raise ArgumentError, "Key cannot be nil"
when OpenSSL::PKey::PKey
key
when String, File, IO
text = read_file(key)
if text =~ /^ssh-rsa/
load_ssh_pubkey text
class SSHKey
attr_reader :rsa
def initialize(args={})
source_file = args.fetch(:file) { fail ArgumentError, "Filename is required" }
source = if source_file.respond_to?(:read)
source_file.read()
else
File.open(source_file) do |file|
@pcarranza
pcarranza / index_sizes.sql
Last active August 29, 2015 14:12
MySQL Index Sizes
SELECT sum(T.DATA_LENGTH) as DATA_SIZE_IN_BYTES,
CONCAT(format(sum(T.DATA_LENGTH)/pow(2,20), 2), 'mb') as DATA_SIZE_HR,
sum(T.INDEX_LENGTH) as INDEXES_SIZE_IN_BYTES,
CONCAT(format(sum(T.INDEX_LENGTH)/pow(2,20), 2), 'mb') as INDEX_SIZE_HR,
M.MEMORY_SIZE as MEMORY_SIZE_IN_BYTES,
CONCAT(format((M.MEMORY_SIZE)/pow(2,20), 2),'mb') AS AVAILABLE_MEMORY_HR,
CONCAT(format((sum(T.INDEX_LENGTH)/sum(T.DATA_LENGTH)) * 100, 2), '%') AS INDEX_TO_DATA_RATIO,
CONCAT(format((sum(T.INDEX_LENGTH)/M.MEMORY_SIZE) * 100, 2), '%') as USED_MEMORY_RATIO
FROM information_schema.tables as T,
(select VARIABLE_VALUE AS MEMORY_SIZE
# Room state as 2 meanings, fullness and alert, when 2 alert is on.
# 0 room is empty and alert is 0
# 1 room is full and alert is 0
# 2 room is full and alert alert alert
- name: fosdem_room
type: object
path: $[*]?(@.state == "2")
labels:
room: $.roomname
value:
@pcarranza
pcarranza / iscsitarget-dkms_1.4.20.3+svn502-1.patch
Created February 8, 2018 23:21
Patch that makes iscscitarget-dkms compile correctly on hypriot rpi
--- iscsitarget-1.4.20.3+svn502/kernel/nthread.c 2014-05-06 20:59:55.000000000 +0000
+++ iscsitarget-1.4.20.3+svn502-working/kernel/nthread.c 2018-02-08 13:39:47.141949006 +0000
@@ -42,9 +42,14 @@
len = (len + 3) & -4; // XXX ???
conn->read_iov[0].iov_base = data;
conn->read_iov[0].iov_len = len;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
conn->read_msg.msg_iov = conn->read_iov;
conn->read_msg.msg_iovlen = 1;
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) */

Keybase proof

I hereby claim:

  • I am pcarranza on github.
  • I am pcarranza (https://keybase.io/pcarranza) on keybase.
  • I have a public key ASCq5TniSDugAsN9OJp-K3QtrsvjQHYZY4dliUvHXmwkTQo

To claim this, I am signing this object: