Skip to content

Instantly share code, notes, and snippets.

View manuel-rubio's full-sized avatar
👋
Say Hi! and let me know if you want to contribute!

Manuel Rubio manuel-rubio

👋
Say Hi! and let me know if you want to contribute!
View GitHub Profile
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 'text to encode'"
exit 0
fi
echo "$1" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'
echo
#!/usr/bin/env escript
epoch() ->
{Mega,Sec,Mili} = now(),
(Mega * 1000000) + Sec + (Mili / 1000000).
measure(F) ->
Ini = epoch(),
F(),
epoch() - Ini.

Testing ephp

To test how can works ephp I do a escriptize and you can use it to execute simple php code:

git clone https://github.com/bragful/ephp
cd ephp
make
@manuel-rubio
manuel-rubio / README.md
Last active February 1, 2016 03:02
IM Binary & SSL protocol think for use with mobile platforms. This protocol has special approach on small & slow data transfers and security.

IM Binary & SSL secured

All the time I was working with XMPP I realized this protocol has a lot of flaws to use in mobile devices, even the lack of sync for the messages between several devices. This protocol tries to solve those flaws:

  1. Use of bandwidth. This protocol is binary and use keywords to save a lof of bandwidth using the same protocol and the same featureas as XMPP.
  2. Reliability of the messages. Using ACKs in every sent ensure all of the messages will arrive to the destin and in the same order. The protocol is async, but for messages the server must to use a pipeline sent.
  3. Multi-device. Capabilities to ensure the messages are delivered on all the devices the user has registered.
  4. Security. Ensuring a certificate is valid between client and server (client must to check server certificate and server must to check client certificate) ensure the communication should be more secure.

REGISTER, AUTH & SESSIONS

@manuel-rubio
manuel-rubio / Vagrantfile
Created October 28, 2014 09:15
Vagrantfile for a CentOS 6.4 64bits
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos-6.4"
config.vm.box_url =
"http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box"

More Testing ephp

To continue testing ephp with the new features I release, first we need a fresh ephp version:

git clone https://github.com/altenwald/ephp
cd ephp
make
@manuel-rubio
manuel-rubio / adjacent_cells.ex
Created October 20, 2019 21:52
Search adjacent cells of the same color.
defmodule AdjacentCells do
@moduledoc """
This module is a way to search, mark and count the adjacent cells based on
the post published by Kevin Ghadyani originally in JavaScript and showing
that using Elixir the code could be simpler and powerful.
https://medium.com/free-code-camp/bet-you-cant-solve-this-google-interview-question-4a6e5a4dc8ee
Indeed, the original code run by Kevin is spending in the better case 229 ms
with 3 random colors and more than 1 second with only one color.
@manuel-rubio
manuel-rubio / .gitconfig
Created March 2, 2021 08:37
Configuration for Git
[core]
# delta requires installation (delta & bat)
pager = delta
[delta]
plus-color = "#012800"
minus-color = "#340001"
# syntax-theme = gruvbox-light
syntax-theme = gruvbox
[interactive]
@manuel-rubio
manuel-rubio / get-run-cmd
Last active August 2, 2021 14:10 — forked from djmaze/get-run-cmd
Get run command from running Docker container
#!/bin/bash
set -eo pipefail
container=$1
image=$(docker inspect --format '{{.Config.Image}}' $container)
cmd=$(docker inspect --format '{{.Config.Cmd}}' $container)
if [[ $cmd == '<nil>' ]]; then cmd=''; fi
binds=$(docker inspect --format '{{.HostConfig.Binds}}' $container | sed "s/\[//; s/\]//")
if [[ $binds == '<nil>' ]]; then binds=''; fi
envs=$(docker inspect --format '{{.Config.Env}}' $container | sed "s/\[//; s/\]//")
@manuel-rubio
manuel-rubio / broken_local_links.exs
Created May 11, 2022 23:28
Broken local links extension for lambdapad