Skip to content

Instantly share code, notes, and snippets.

View mssola's full-sized avatar
🏠
Working from home

Miquel Sabaté Solà mssola

🏠
Working from home
View GitHub Profile

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@jordimassaguerpla
jordimassaguerpla / dockerfile
Last active December 1, 2015 14:22
netcat docker example
FROM opensuse:latest
MAINTAINER Jordi Massaguer "jmassaguerpla@suse.com"
RUN echo -e "#!/bin/sh\n \nnc -l 80" > /bin/hello-world-server
RUN chmod +x /bin/hello-world-server
RUN zypper -n install "netcat-openbsd"
EXPOSE 80
CMD /bin/hello-world-server
# test me with "telnet IP 80"
# get the ip with docker inspect CONTAINER
@mssola
mssola / model.py
Created October 23, 2013 12:35
Map model names into database tables by using metaprogramming in Python.
class Persistent(type):
def __new__(self, name, bases, dct):
self.tables = dict()
return super(Persistent, self).__new__(self, name, bases, dct)
def __init__(self, name, bases, dct):
table = name.lower() + 's'
self.tables[self] = table
super(Persistent, self).__init__(name, bases, dct)
@mssola
mssola / virtual.rb
Created August 2, 2013 07:46
Simple and stupid code to emulate pure virtual methods in Ruby.
##
# This file describes a simple way to implement the idea of pure virtual
# methods (abstract methods in Java, C#,...) in Ruby. Personally, I haven't
# used this pattern while programming in Ruby, but I thought it could be fun.
#
##
# This class provides a fancy way to show an error when a virtual method
# is being used but the subclass hasn't implemented it.
@mssola
mssola / socket.rb
Created August 2, 2013 07:45
Testing HTTP's Transfer-Encoding: chuncked.
#
# This is a simple script that creates a TCP server and then transfers
# the info via streaming. It's not too fancy, I'm just testing the HTTP's
# Transfer-Encoding: chunked;
#
require 'socket'
# This is the message to be sent.
@mssola
mssola / singleton.rb
Created August 2, 2013 07:44
Different ways to create the Singleton pattern in Ruby.
##
# This files shows some possible implementations of the Singleton pattern
# in Ruby. I'm not a huge fan of the Singleton pattern, but it's nice
# in some cases. In this file I'm going to implement a simple logger.
#
##
# The first implementation that can come to our minds is to create a class
# that holds an instance as a class variable that can be accessed through
@mssola
mssola / rom.rb
Created August 2, 2013 07:41
A simple gist showing as much of the Ruby Object Model as possible.
##
# This file describes some topics regarding the Ruby Object Model.
#
require 'pp'
##
# First of all, let's take a look at the very basics.
module Modul
@mssola
mssola / flip_flop.rb
Created August 2, 2013 07:39
Because Ruby can flip and flop :P
# This file shows a somewhat rare feature of Ruby with the .. operator.
# It's a a perlism called "flip-flop". This feature will make it into Ruby 2.0
# but its future is uncertain (probably removed in a future Ruby 3.0 ?).
#
# More on flip-flops here: https://bugs.ruby-lang.org/issues/5400
# Prints all the lines between begin..end in the DATA section.
DATA.each_line do |line|
@mssola
mssola / closures.pl
Created August 1, 2013 21:29
Playing with decorators and closures in Perl. Nothing fancy, just a quick reference.
#!/usr/bin/perl
use strict;
# Decorator. Same idea as the Python decorators. In this case it takes a
# function as the only argument and returns a closure that returns the result
# of the originally passed function plus two.
sub plus_two
{
my ($f_ref) = @_;
@mssola
mssola / references.pl
Created August 1, 2013 20:36
Simple but quite complete example of references in Perl.
#!/usr/bin/perl
use strict;
##
# List & hash references.
package Class
{