Skip to content

Instantly share code, notes, and snippets.

@mvsantos
mvsantos / remove-image-background.sh
Created May 10, 2013 14:16
Remove/strip image background - rough mode - requires ImageMagick
# Requires ImageMagick
# Converting the source from JPEG to PNG - if necessary
convert my_src_image.jpg my_src_image.png
# Option A
# - Requires a temporary intermediate file
# - Drill more than 10 might result in poor results
@benbalter
benbalter / gist.md
Last active May 24, 2025 09:51
Example of how to embed a Gist on GitHub Pages using Jekyll.

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

@Sjors
Sjors / bitcoin-pay.rb
Last active April 9, 2024 16:50
This script demonstrates how a bitcoin transaction is created and signed. Just pass in your own address and private key and it will prepare a transaction for you. You can then copy & paste that transaction into a webservice like Blockchain to send it. I wrote this mostly to understand better how it works. I sometimes had to "cheat" and look at t…
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin
@geraldb
geraldb / patchfigs.rb
Created May 23, 2013 17:04
patchfigs.rb - pandoc progit perl oneliner converted to ruby
#
# see http://johnmacfarlane.net/pandoc/epub.html
#
# perl -i -0pe 's/^Insert\s*(.*)\.png\s*\n([^\n]*)$/!\[\2](..\/figures\/\1-tn.png)/mg' */*.markdown
#
# converted to "verbose" ruby
# encoding: UTF-8
Dir['*/*.markdown'].each do |filename|
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
# Let's use thin
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 25, 2025 20:12
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@staltz
staltz / introrx.md
Last active April 8, 2026 15:03
The introduction to Reactive Programming you've been missing
@wojtha
wojtha / bench_boolean.rb
Last active April 12, 2020 17:49
Seeking for the fastest "to boolean" implementation in ruby. See https://coderwall.com/p/inziba
require 'benchmark'
require 'set'
def to_boolean_eq(value)
value == true || value == 'true' || value == 1 || value == '1' || value == 't'
end
def to_boolean_equal(value)
value === true || value === 'true' || value === 1 || value === '1' || value === 't'
end
def prepare_files
unless File.exists?('original') && File.file?('original') && File.readable?('original')
abort('There is not `original` file in current directory.')
end
File.delete('yaml') if File.exists?('yaml')
[File.open('original'), File.new('yaml', 'w+')]
end
def translate_to_yml(original, yaml)
original.each_line do |line|
@gettalong
gettalong / performance.md
Last active December 31, 2020 12:39
HexaPDF Performance Comparison

A short and very unscientific comparison of the performance of HexaPDF to other PDF utilities when reading, eventually optimizing and then writing a file.

When available, multiple compression modes are compares:

  • No indicator - no compression done
  • C - Compacting by removing unused and deleted objects
  • S - Usage of object and cross-reference streams
  • P - Recompression of page content streams

For the HexaPDF tests, the hexapdf binary was used with different options for the optimization command: