Skip to content

Instantly share code, notes, and snippets.

@xarimanx
xarimanx / ffmpeg-watermark.md
Created September 24, 2019 14:16 — forked from bennylope/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@xarimanx
xarimanx / prawn_stamp.rb
Created November 13, 2018 12:30 — forked from henrik/prawn_stamp.rb
Rotate and center text with Prawn as a watermark, e.g. for "[PAID]" on an invoice.
create_stamp("stamp") do
fill_color "cc0000"
text_box "[PAID]",
:size => 2.cm,
:width => bounds.width,
:height => bounds.height,
:align => :center,
:valign => :center,
:at => [0, bounds.height],
:rotate => 45,
#!/bin/bash
cat /path/to/public_key | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"
@xarimanx
xarimanx / base_doc.rb
Created December 22, 2015 13:05 — forked from iliabylich/base_doc.rb
Apipie concerns
# A common concern,include into all doc modules
#
module BaseDoc
include Apipie::DSL::Concern
def namespace(namespace, options = {})
@namespace = namespace
@namespace_name = options[:name]
end
attr_reader :namespace_name
@xarimanx
xarimanx / gist:8014b5808e20814772ea
Created November 12, 2015 15:16 — forked from AndrewO/gist:1841191
PhantomJS code to dump computed styles of all elements and take a screenshot
[url, height, width, output_dir] = phantom.args
console.log("url #{url}, height #{height}, width #{width}, output_dir #{output_dir}")
page = require('webpage').create()
page.viewportSize =
width: width
height: height
page.onConsoleMessage = (msg) ->
@xarimanx
xarimanx / call-apply-bind-proxy.js
Created September 29, 2015 06:33 — forked from branneman/call-apply-bind-proxy.js
JavaScript call() vs apply() vs bind() vs $.proxy()
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
@xarimanx
xarimanx / rspec.rake
Last active September 18, 2015 13:11 — forked from kamilio/rspec.rake
RSpec::Core::RakeTask.module_eval do
def pattern
dir = EngineName.root # replace with you the name of your engine
extras = []
if File.directory?( dir )
extras << File.join( dir, 'spec', '**', '*_spec.rb' ).to_s
end
[@pattern] | extras
end
end
@xarimanx
xarimanx / executable-with-subcommands-using-thor.log
Last active September 7, 2015 12:46 — forked from sss/executable-with-subcommands-using-thor.log
Revised: Namespacing thor commands in a standalone Ruby executable
$ ./executable-with-subcommands-using-thor.rb
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA
executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB
executable-with-subcommands-using-thor.rb test # test in CLI
$ ./executable-with-subcommands-using-thor.rb help
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
@xarimanx
xarimanx / web-servers.md
Last active August 29, 2015 14:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)