teleren/devto huggingface dataset:
Python Cheat Sheet
Tags: python, cheatsheet
Published: 2021-05-14 02:56:04

### Reference
* [Python Cheat Sheet](https://cheatsheetmaker.com/python) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### [File manipulation] Context manager

```py
with open("welcome.txt", "r") as file:
    # 'file' refers directly to "welcome.txt"
   data = file.read()

# It closes the file automatically at the end of scope, no need for `file.close()`.
```

### [File manipulation] Writing (append)

```py
file = open("Hello.txt", "a") # open in append mode
file.write("Hello World again")  
file.close()
```

### [File manipulation] Writing (overwrite)

```py
file = open("hello.txt", "w") # open in write mode 'w'
file.write("Hello World") 

text_lines = ["First line", "Second line", "Last line"] 
file.writelines(text_lines)

file.close()
```

### [File manipulation] Reading

```py
file = open("hello.txt", "r") # open in read mode 'r'
file.close() 
```

```py
print(file.read())  # read the entire file and set the cursor at the end of file
print file.readline() # Reading one line
file.seek(0, 0) # place the cursor at the beggining of the file
```

### Regex

    import re

    re.match(r'^[aeiou]', str)
    re.sub(r'^[aeiou]', '?', str)
    re.sub(r'(xyz)', r'\1', str)

    expr = re.compile(r'^...$')
    expr.match(...)
    expr.sub(...)

### Comprehensions

    [fn(i) for i in list]            # .map
    map(fn, list)                    # .map, returns iterator
    
    filter(fn, list)                 # .filter, returns iterator
    [fn(i) for i in list if i > 0]   # .filter.map

### Casting

    int(str)
    float(str)
    str(int)
    str(float)
    'string'.encode()

### [String](https://docs.python.org/2/library/stdtypes.html#string-methods)

    str[0:4]
    len(str)

    string.replace("-", " ")
    ",".join(list)
    "hi {0}".format('j')
    f"hi {name}" # same as "hi {}".format('name')
    str.find(",")
    str.index(",")   # same, but raises IndexError
    str.count(",")
    str.split(",")

    str.lower()
    str.upper()
    str.title()

    str.lstrip()
    str.rstrip()
    str.strip()

    str.islower()
    
    /* escape characters */
    >>> 'doesn\'t'  # use \' to escape the single quote...
        "doesn't"
    >>> "doesn't"  # ...or use double quotes instead
        "doesn't"
    >>> '"Yes," they said.'
        '"Yes," they said.'
    >>> "\"Yes,\" they said."
        '"Yes," they said.'
    >>> '"Isn\'t," they said.'
        '"Isn\'t," they said.'

### Iteration

    for item in ["a", "b", "c"]:
    for i in range(4):        # 0 to 3
    for i in range(4, 8):     # 4 to 7
    for i in range(1, 9, 2):  # 1, 3, 5, 7
    for key, val in dict.items():
    for index, item in enumerate(list):

### Dict

    dict.keys()
    dict.values()
    "key" in dict    # let's say this returns False, then...
    dict["key"]      # ...this raises KeyError
    dict.get("key")  # ...this returns None
    dict.setdefault("key", 1)
Devise Cheat Sheet
Tags: devise, cheatsheet
Published: 2021-05-14 02:55:03

### Reference
* [Devise Cheat Sheet](https://cheatsheetmaker.com/devise) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### Customizing devise_for

    devise_for :users,
      :path => "usuarios",
      :path_names => {
        :sign_in => 'login',
        :sign_out => 'logout',
        :password => 'secret',
        :confirmation => 'verification',
        :unlock => 'unblock',
        :registration => 'register',
        :sign_up => 'cmon_let_me_in' }

Test helpers
------------

    include Devise::TestHelpers
    https://github.com/plataformatec/devise/blob/1094ba65aac1d37713f2cba71f9edad76b5ca274/lib/devise/test_helpers.rb

    sign_in @user
    sign_out @user
### Devise_for magic
  
    devise_for :users

        # Session routes for Authenticatable (default)
             new_user_session GET  /users/sign_in                    {:controller=>"devise/sessions", :action=>"new"}
                 user_session POST /users/sign_in                    {:controller=>"devise/sessions", :action=>"create"}
         destroy_user_session GET  /users/sign_out                   {:controller=>"devise/sessions", :action=>"destroy"}
       
        # Password routes for Recoverable, if User model has :recoverable configured
            new_user_password GET  /users/password/new(.:format)     {:controller=>"devise/passwords", :action=>"new"}
           edit_user_password GET  /users/password/edit(.:format)    {:controller=>"devise/passwords", :action=>"edit"}
                user_password PUT  /users/password(.:format)         {:controller=>"devise/passwords", :action=>"update"}
                              POST /users/password(.:format)         {:controller=>"devise/passwords", :action=>"create"}
       
        # Confirmation routes for Confirmable, if User model has :confirmable configured
        new_user_confirmation GET  /users/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"}
            user_confirmation GET  /users/confirmation(.:format)     {:controller=>"devise/confirmations", :action=>"show"}
                              POST /users/confirmation(.:format)     {:controller=>"devise/confirmations", :action=>"create"}

### As
    as :user do
      get 'sign_in', :to => 'devise/sessions#new'
    end

### Authenticated and unauthenticated routes

    unauthenticated do
       root :to => 'home#index'
    end

    authenticated do
      root :to => 'dashboard#index'
    end

### Migration helpers

    create_table :users do |t|
      t.database_authenticatable
      t.confirmable
      t.recoverable
      t.rememberable
      t.trackable
      t.timestamps
    end

Routing
-------

### Model options

    class User < ActiveRecord::Base
      devise :database_authenticatable,
        :registerable,
        :confirmable,
        :recoverable,
        :rememberable,
        :trackable,
        :validatable
    end
Shell.Js Cheat Sheet
Tags: shelljs, cheatsheet
Published: 2021-05-14 02:54:33

### Also see

* <https://github.com/shelljs/shelljs>
* [Shell.Js Cheat Sheet](https://cheatsheetmaker.com/shelljs) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### Utils

```js
sh.which('x')
sh.pwd()
```

```js
sh.echo('hi')
```

```js
sh.exec('node --version').code
sh.exec('node --version').output
sh.exec('node --version', { silent: true }).output
```

```js
sh.exec('node --version', (code, output) => {
  sh.echo(`exit code ${code}`)
})
```

```js
sh.tempdir()
```

```js
sh.error()  // null if no error
```

### Cat and output

```js
src = sh.cat('file*.txt')
```

```js
'hello'.to('output.txt')
'hello'.toEnd('append.txt')
```

```js
sh.cat('input.txt').to('output.txt')
```

### Tests

```js
sh.test('-b', 'path')  // block device
sh.test('-d', 'path')  // dir
sh.test('-e', 'path')  // exists
sh.test('-f', 'path')  // file
sh.test('-L', 'path')  // symlink
```

### File manipulation

```js
sh.cp('src', 'dest')
sh.cp('-rf', 'src', 'dest')
```

```js
sh.rm('file')
sh.rm('-rf', 'file')
```

```js
sh.mv('src', 'dest')
sh.mv(['src1','src2'], 'dest')
```

```js
sh.chmod('644', 'file')
sh.chmod(755, 'file')
sh.chmod('u+x', 'file')
```

### Paths

```js
sh.cd('dir')
```

```js
sh.mkdir('dir')
sh.mkdir('-p', 'dir')
```

### Require

```js
const sh = require('shelljs')
```

### Example

```js
var shell = require('cs/shelljs')
```

```js
if (!shell.which('git')) {
  shell.echo('Sorry, this script requires git')
  shell.exit(1)
}
```

```js
// Copy files to release dir
shell.rm('-rf', 'out/Release')
shell.cp('-R', 'stuff/', 'out/Release')
```

```js
// Replace macros in each .js file
shell.cd('lib')
shell.ls('*.js').forEach(function (file) {
  shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file)
  shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file)
  shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file)
})
shell.cd('..')
```

```js
// Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
  shell.echo('Error: Git commit failed')
  shell.exit(1)
}
```

Taken from the [Readme](https://github.com/shelljs/shelljs).
Commander.Js Cheat Sheet
Tags: commanderjs, cheatsheet
Published: 2021-05-14 02:53:45


### Other useful things

    process.exit(0);


### Commands

    cli.outputHelp();
    cli.args == ["hello"];

### Help

    .on('--help', function() {
      console.log('');
    })

### Options

    cli
      .version(require('../package').version)
      .usage('[options] <command>')
      .option('-w, --words <n>', 'generate <n> words')
      .option('-i, --interval <n>', 'interval [1000]', 1000)
      .option('-s, --symbols', 'include symbols')
      .parse(process.argv);

### Initialize

    var cli = require('commander');

### Reference
* [Commander.Js Cheat Sheet](https://cheatsheetmaker.com/commanderjs) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Command Line Stuff Cheat Sheet
Tags: commandline, cheatsheet, ssh
Published: 2021-05-14 02:52:10

### Reference
* [Command Line Stuff Cheat Sheet](https://cheatsheetmaker.com/command-line-stuff) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### [Grep] Synonyms

    egrep  =>  grep -E
    fgrep  =>  grep -F
### [Grep] Options

| Switch | Description |
|---|---|
| `-A num` | Print `num` lines of training context |
|----
| `-G` | --basic-regexp (default) |
| `-E` | --extended-regexp |
| `-P` | --perl-regexp |
|----
| `-f file` | --file (Get patterns for file) |
| `-F` | --fixed-strings |
|----
| `-h` | --no-filename |
| `-H` | --with-filename |
|----
| `-l` | --files-with-matches (just print filenames) |
| `-L` | --files-without-match |
|----
| `-r, -R` | --recursive |
| `-v` | --invert-match |
| `-i` | --ignore-case |
{:.shortcuts}

### Grep

```
grep [options] [pattern] [file ...]
```

### Search-and-replace in all files

    perl -p -i -e 's/hello/HELLO/g' **/*

<br>

### wc (Word count)

```
... | wc [options]
```

| `-c` | Bytes |
| `-l` | Lines |
| `-m` | Characters (incl multi-byte) |
| `-w` | Words |

<br>

### [Sudo] Timestamp

| `-v` | revalidate timestamp for 5 mins |
| `-k` | invalidate timestamp |
| `-K` | just like -k |

<br>

### [Sudo] Interactive

| Switch | Description |
|---|---|
| `-i [cmd]` | Interactive shell without variables |
| `-s [cmd]` | Interactive shell |
|----
| `-u user` | run as this user |
| `-g group` | run as this group |

### [Sudo] Prompt

| `-p prompt` | Custom prompt (-p "%p password:") |

### [Sudo] File descriptors

| `-C fd` | Close all open file descriptors |

### [Sudo] Options

| `-A` | Use $SUDO_ASKPASS |
| `-b` | Run in background |
| `-E` | Preserve environment |
| `-H` | use target's $HOME |
| `-n` | Don't prompt for password |
| `-P` | Preserve group vector |
| `-S` | Read password from stdin |
Mouse Acceleration Cheat Sheet
Tags: cheatsheet
Published: 2021-05-14 02:51:10


### References

- [Disabling mouse acceleration](https://stackoverflow.com/questions/5782884/disabling-mouse-acceleration-in-mac-os-x) _(stackoverflow.com)_
* [Mouse Acceleration Cheat Sheet](https://cheatsheetmaker.com/mouse-acceleration) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### [Acceleration] Trackpad acceleration

```bash
defaults write .GlobalPreferences com.apple.trackpad.scaling -1
```

Works the same way, but only affects trackpads.

### [Acceleration] Re-enabling

Under *System Preferences* → *Mouse*, change *Tracking Speed*.

### [Acceleration] Disabling

```bash
defaults write .GlobalPreferences com.apple.mouse.scaling -1
```

Note: Log out to take effect. If you change *Tracking Speed* under System Preferences, it will undo this fix. Only affects the mouse, not the trackpad.
Jshint Cheat Sheet
Tags: jshint, cheatsheet
Published: 2021-05-14 02:50:38

### Also see

* <http://www.jshint.com/docs/options/>
* <https://gist.github.com/haschek/2595796>
* [Jshint Cheat Sheet](https://cheatsheetmaker.com/jshint) - [Cheat Sheet Maker](https://cheatsheetmaker.com)

### Globals and Environments

```js
/* jshint undef: true */
/* global jQuery */
/* global -BAD_LIB */
```

```js
/* jshint devel: true */   console, alert, ...
/* jshint browser: true */ window, document, location, ...
/* jshint node: true */    module, exports, console, process, ...
/* jshint jquery: true */  jQuery, $
```

See: [Environments](http://www.jshint.com/docs/options/#environments)

### Ignore

```js
/* jshint ignore:start */
/* jshint ignore:end */
```

### Enforcing

Enable these options to catch more errors.
See: [Enforcing](http://www.jshint.com/docs/options/#enforcing-options)
{: .-setup}

```js
/* jshint curly: true */
while (day)                     // err: use { }'s
  shuffle();
```

```js
/* jshint eqeqeq: true */
if (a == null)                  // err: use ===
```

```js
/* jshint es3: true */
// ...for legacy IE compatibility
a.default = function() { ... }; // err: reserved word
array = [ 1, 2, 3, ];           // err: extra comma
```

```js
/* jshint forin: true */
for (key in obj) { ... }        // err: check obj.hasOwnProperty(key)
```

```js
/* jshint freeze: true */
Array.prototype.count = ...;    // err: don't modify native prototypes
```

```js
/* jshint indent: 4 */
if (x) {                        // err: expected indent of 4, found 2
  ...;
}
```

```js
/* jshint quotmark: single */
/* jshint quotmark: double */
alert("hi");                    // err: only single allowed
```

```js
/* jshint strict: true */
function() { ... }              // err: need "use strict"
```

```js
/* jshint white: true, indent: 4 */
/* jshint maxdepth: 2 */
/* jshint maxparams: 3 */
/* jshint maxstatements: 4 */
/* jshint maxcomplexity: 5 */
/* jshint maxlen: 80 */
```

### Relaxing

Enable these options to *not* throw errors in these conditions.
See: [Relaxing](http://www.jshint.com/docs/options/#relaxing-options)
{: .-setup}

```js
/* jshint asi: true */
allow()
missing_semicolons()
```

```js
/* jshint boss: true */
if (m = str.match(/.../))
```

```js
/* jshint debug: true */
debugger;
```

```js
/* jshint eqnull: true */
if (x == null)
```

```js
/* jshint evil: true */
eval('...')
```

```js
/* jshint expr: true */
production && minify = true;
div.innerWidth;
expect(x).be.true;
```

```js
/* jshint laxcomma: true */
var one = 1
  , two = 2;
```

```js
/* jshint loopfunc: true */
for (i=0; i<10; x++) {
  (function(i) { ... })(i);
}
```

```js
/* jshint sub: true */
process.env['name_here']
```

```js
/* jshint strict: "global" */
"use strict";
```
Working local ipv6 DNS on dd-wrt
Tags: ipv6
Published: 2021-05-14 02:37:41

---
title: Working local ipv6 DNS on dd-wrt
published: true
description: Dual stack ipv6 domains with dnsmasq on your router
tags: ipv6
//cover_image: https://direct_url_to_image.jpg
---

If you'd like to be able to `ping6 name` on your local network based on the names requested by your hosts,

* Disable radvd; dnsmasq will do it.
* Disable dhcp6s; dnsmasq will do it.
* *Remove static leases*. These are ipv4-only; we will define ipv6-compatible leases in configuration.
* Set 'Additional Dnsmasq Options:

```
no-negcache
expand-hosts
domain-needed
enable-ra
no-resolv
server=8.8.8.8
server=8.8.4.4
dhcp-range=::1,::400,constructor:br0,ra-names
dhcp-host=00:24:8C:26:8C:67,cardamom,192.168.1.100,[::1]
dhcp-host=38:f9:d3:cf:ee:86,laptop,192.168.1.104,[::18f]
```

* `no-negcache`: Don't cache negative lookups.
* `expand-hosts`: Add our network name to lookups.
* `domain-needed`: Don't pass hostname-only lookups to upstream DNS.
* `enable-ra`: Dnsmasq provides radvd
* `no-resolv`: Stay far away from the ISP domain name servers
* `server`: Use Google's
* `dhcp-range=::1,::400,constructor:br0,ra-names`: Our LAN is on br0; dhcpv6 assigns addresses based on the delegated prefix, this range, and the device id. ra-names assigns DNS names to dual-stack hosts that advertise a name.
* Our hosts. The MAC address, the desired hostname, the ipv4 address, and a portion of the ipv6 address appended to the delegated prefix from our ISP.

The ipv4 static leases were the sticking point. These need to be configured only in the dnsmasq configuration; the ipv4 dd-wrt configuration will write a hosts file and prevent dnsmasq from doing what we want.

SLAAC + ra-names doesn't seem to work for me when `dhcp-host` specifies a hostname and an ipv4 address only. Instead, I specify the mac address, the desired hostname, the ipv4 address, and the suffix of the ipv6 address. The suffix can be either constructed-within-range style `[::18f]` or whatever you want `[::1]`, `[::2]`.

The host will continue to use its autoconfigured address for outgoing connections and will gain an additional DHCP-assigned address that can be used for incoming connections. My Android phone ignores the assigned suffix, but gets a working assigned ipv6 name anyway.

I am using DHCPv6 with prefix delegation on the WAN side, and my Dhcp6c config is:

```
interface vlan2 {
 send ia-pd 0;
 send rapid-commit;
# request domain-name-servers;
 script "/sbin/dhcp6c-state";
};
id-assoc pd 0 {
 prefix ::/56 infinity;
 prefix-interface br0 {
  sla-id 0;
  sla-len 8;
 };
};
id-assoc na 0 { };
```

dnsmasq is enabled and is providing local dns.

The dd-wrt "Used Domain" is set to "LAN & WLAN", adding a line `domain=<what you typed in the LAN Domain field>` to `dnsmasq.conf`.
Creating A Full Stack Social Media Platform (part 1)
Tags: python, flask, beginners, tutorial
Published: 2021-05-14 02:35:56

### Intro

After creating a [blockchain from scratch](https://dev.to/talemache/creating-a-blockchain-using-ethereum-part-1-4cn9), I thought that I'd kick it up a notch and **make my very own social media network**. 

This was going to require a lot more time and effort and a **ton** more coding. So with coffee in hand, some rusty python skills, and years of social media use under my belt, I was ready to begin.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wb8l9fa5zyrsr0jgpr9.png)

Soo many tutorials later, I had a good idea of what I needed to do and it seemed surprisingly simple. I found this video by [freeCodeCamp.org](https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ) particularly useful. 

### Required Installations
First, I checked the version of python on my computer 
`python3 --version` then installed a few packages using pip:

- I had to install a virtual environment to keep track of packages

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7cra678twd99r2tor4o.png)

- then started it up. `virtual --python=python3.94 myenv` 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zy8zxox8ilemzpyo5dv.png)

- Saved the packages to the virtual environment 
`source myenv/bin/activate`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fyvszk061pu7goxsicb.png)

- once inside **myenv**, I installed flask. 
`pip install flask`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9pzbteae8vic5k1lrf3.png)

Pretty straightforward. Now it was time to write some code, but it will have to wait until the next installment [#irl](https://www.instagram.com/explore/tags/irl/). Happy Coding!
Subtract Arrays in PostgreSQL
Tags: postgres, programming
Published: 2021-05-14 02:24:31

PostgreSQL provides a wealth of functions built-in, but one that's lacking is a way to "subtract" one array from another. This is the result of research and examples found in multiple places on the interwebs.

If you have two arrays (say, array_1 and array_2; just to be boring), the goal here would be to subtract array_2 from array_1 and return a new array with the difference. The difference being a new array containing any element of array_1 that is not present in array_2. Got it?

Two specific pieces of functionality are needed here:
1. The actual subtraction processing
2. The returning of the result in another array.

Set functionality was used for the subtraction and use of the `array` functionality to bundle that result into a new array. There's no easy way to do this in a Pure ANSI SQL way, so it was necessary to utilize good ol' PLPGSQL.

Here is the function:
```sql
create or replace function public.array_subtract(
    minuend anyarray, subtrahend anyarray, out difference anyarray
)
returns anyarray as
$$
begin
    execute 'select array(select unnest($1) except select unnest($2))'
      using minuend, subtrahend
       into difference;
end;
$$ language plpgsql returns null on null input;
```

Demo Time!

Subtract `['three', 'four', 'five]` from `['one', 'two', 'three']`:
```sql
postgresql=# select array_subtract('{one,two,three}'::text[], '{three,four,five}'::text[]);
 array_subtract 
----------------
 {one,two}
(1 row)
```

Subtract `[1,2,3,4,5]` from `[2,3,4]`:
```sql
postgresql=# select array_subtract('{2,3,4}'::int[], '{1,2,3,4,5}'::int[]);
 array_subtract 
----------------
 {}
(1 row)
```

Easy peasy, lemon squeezy.

There's been an instance or two where this has really come in handy in my professional career. Hopefully it can help you out as well.
Add multiple columns after a column in Laravel Migrations
Tags: laravel, php, mysql
Published: 2021-05-14 02:04:16

From Laravel 8.27 you can add multiple new columns after an existing column at the same time.

In previously, it isn’t difficult to write, you’d have to call after() method for each subsequent new column.

```php
Schema::table('customers', function ($table) {
    $table->string('address_line1')->after('password');
    $table->string('address_line2')->after('address_line1');
    $table->string('city')->after('address_line2');
});
```

From version 8.27 you can group them in a new after() method on the Blueprint migration instance.

```php
Schema::table('customers', function ($table) {
    $table->after('password', function ($table) {
        $table->string('address_line1');
        $table->string('address_line2');
        $table->string('city');
    });
});
```

Happy Coding:)
Connecting to RDS, Using DBeaver
Tags: aws, mysql
Published: 2021-05-14 02:01:23


## White List your IP on RDS
1. log in to AWS console https://aws.amazon.com/
2. Navigate to RDS
3. Click on the DB instance you want to connect to.
Please follow the images :)

![Go to RDS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bk99i9jc8avl4lkusqpp.png)

![RDS Instances](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ys2qed026nnnhsmvf86s.png)

![Security Groups](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f1g1awk0wyq9z9ghvgz8.png)

![Edit inbound rule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hv9n78cc05xd0tox957n.png)

![Add Inbound Rules](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e73afmgoqeog9q8q5dlz.png)

## Connecting to RDS using DBeaver
1. Please download DBeaver for your respective Operating System.

2. In Dbeaver go to DataBase Navigator right-click to open the menu.
click on create followed by connection
3. choose the Database Type
![DB type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t5bekw4ypj0tznnlktn2.png)
I am choosing MySQL but the process is the same for any other database.
3. It will prompt you for driver download please download with default settings.
4. Now fill in the respective connection properties
![Connection properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bnw2sz2f917tv5cdlto.png)


* The hostname is the endpoint for your RDS instance you can find it in the RDS console
![RDS end point](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ss3l17gg8bbff3bkx36.png)

* 2,3 are the user name and password for your DB

Test your connection and voila you are connected to RDS.
FFmpeg: Convert video to gif
Tags: ffmpeg, video, gif
Published: 2021-05-14 01:37:33

[FFmpeg](https://www.ffmpeg.org/) provides simple usage to convert video such as .mkv, .mp3, .mp4, .mov to __.gif__.

```shell
ffmpeg -i <input.video> out.gif
```

That's it.

Well, the file size of out.gif is sometimes a bit too big. In such a case, it's better to use `-r` option to specify frame rate.

```shell
ffmpeg -i my-sample.mkv -r 10 out.gif
```

With `-r 10`, my sample video file got 20% smaller. With `-r 5` or less, it would be much smaller.

The official documentation on video options is [here](https://ffmpeg.org/ffmpeg-all.html#Video-Options).