teleren/devto huggingface dataset:
Bootstrap Cheat Sheet
Tags: bootstrap, cheatsheet
Published: 2021-05-13 09:25:48


### Input groups

```haml
.input-group
    input.form-control(type='text')
    .input-group-addon years
```
### Tooltip

```html
<span
  data-toggle='tooltip'
  title='tooltip'
  data-placement='left|top|bottom|right'>
```

```js
$(function () {
  $('[data-toogle~="tooltip"]').tooltip()
})
```

### Modal via ajax (Rails)

```haml
%button.btn{data: { |
  toggle: 'modal', |
  target: '#chooseTheme', |
  remote: '/path/to/remote'}
  Change Theme
```

```haml
.modal.fade#chooseTheme
  .modal-dialog.modal-xl
    .modal-content
      .modal-header
        %h4.modal-title Choose a theme

      .modal-body
        .spinner-panel.-lg
          %i
```

### Modal

```html
<a data-toggle='modal' data-target='#new'>
```

```haml
#new.modal.fade(role='dialog')
  .modal-dialog // .modal-lg, .modal-sm
    .modal-content
      .modal-header
        %h4.modal-title hello
        %button.close{type: 'button', data: { dismiss: 'modal' }}
          %span{'aria-hidden' => true}!= "&times;"
          %span.sr-only Close
      .modal-body
        ...
      .modal-footer
        ...
```

### Utilities

```scss
.pull-left
.pull-right
```

```scss
.hidden-{xs,sm,md,lg}
.visible-{xs,sm,md,lg}
.visible-{xs,sm,md,lg,print}-{block,inline,inline-block}
```

```scss
.center-block  /* margin: auto */
.clearfix
.text-{center,left,right,justify,nowrap}
.text-{lowercase,uppercase,capitalize}
```

```scss
.show
.hidden
```

### Columns

```scss
.container
.container-fluid
```

```scss
.col-xs-1
.col-sm-1
.col-md-1
.col-lg-1
.col-md-offset-1
```

Mixins:

```scss
@include make-xs-column(12);
@include make-sm-column(6);
@include make-md-column(3);
@include make-lg-column(3);
```

```scss
@include make-sm-column-offset(1);
@include make-sm-column-push(1);
@include make-sm-column-pull(1);
```

### Screen sizes

```
         768          992                1200
'     '     '     '     '     '     '     '     '
<---------^------------^------------------^--------->
     xs         sm              md             lg
   (phone)   (tablet)        (laptop)       (desktop)
```

Min:

```scss
@media (min-width: @screen-sm-min) // >= 768px (small tablet)
@media (min-width: @screen-md-min) // >= 992px (medium laptop)
@media (min-width: @screen-lg-min) // >= 1200px (large desktop)
```

Max:

```scss
@media (max-width: @screen-xs-max) { // < 768px (xsmall phone)
@media (max-width: @screen-sm-max) { // < 992px (small tablet)
@media (max-width: @screen-md-max) { // < 1200px (medium laptop)
```

### Reference
* [Bootstrap Cheat Sheet](https://cheatsheetmaker.com/bootstrap) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Laravel 8.x Multilevel Nested Comments System Tutorial
Tags: laravel, comment
Published: 2021-05-13 09:25:16

A Comment system is a primary requirement for blog website or any tutorial website. in this post i want to share with you how to create comments system in laravel 5, laravel 6, laravel 7 and laravel 8 app. Most of developer looking for good package for comment system, but if you are using laravel 5 then you can do it nested comment system using database relationship.

we will create very simple comment system with you can add comment and make replay to comment. we will use laravel relationship for comment system and it make it quick. you can also improve with add comment, edit comment, delete command and replay comment with ajax if you want.

After following this tutorial, you do not need to use any extra plugin for comment like disqus etc in your website.

in this example, we will create posts table and comments table using migration. you can create new post and in the detail page of post you can add comment on it. we will create laravel auth, create migration, controller, model and blade files. you just need to follow few steps to get live comment system with your website.
[Laravel 8.x Multilevel Nested Comments System Tutorial
](https://www.codecheef.org/article/create-your-own-multilevel-nested-comments-system-in-laravel)
Applinks Cheat Sheet
Tags: applinks, cheatsheet
Published: 2021-05-13 09:25:13

### Device types

 * `ios`
 * `ipad`
 * `iphone`
 * `android`
 * `windows_phone`
 * `web`

### Reference
* [Applinks Cheat Sheet](https://cheatsheetmaker.com/applinks) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Spreadsheet Functions Cheat Sheet
Tags: spreadsheet, cheatsheet
Published: 2021-05-13 09:24:37


### Vlook

```
=VLOOKUP(value, range, column_index)
```
### Core

```
=TO_DATE(number)
```

### Math

```
=POW(2, 32)   # 2^32
=SIN() ACOS() etc
=CEILING(n,sig,mode)
=FLOOR(n,sig,mode)
=INT(n)
```

```
=SUM(range)
```

```
=SUMIF(range, criteria, sum_range)
=SUMIF(A1:A5, ">300", B1:B5)          # if A# is >300, use B#
```

### Comparators

```
=EQ(a,b)
=NE(a,b)
=GT(a,b)
=GTE(a,b)
=LT(a,b)
=LTE(a,b)
```

### If

```
=IF(test, then, else)
=IF(EQ(A1, "paid"), "true", "false")
```

### Reference
* [Spreadsheet Functions Cheat Sheet](https://cheatsheetmaker.com/spreadsheet-functions) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Pry Cheat Sheet
Tags: pry, cheatsheet
Published: 2021-05-13 09:23:41


### Reference

 * [Pry](https://github.com/pry/pry)
 * [Hirb](https://github.com/cldwalker/hirb)
### pry-remote
Add the [pry-remote](https://github.com/Mon-Ouie/pry-remote) gem.

```rb
# In your code:
binding.remote_pry

# In the shell:
bundle exec pry-remote
```

### pry-rescue
Add the [pry-rescue](https://github.com/ConradIrwin/pry-rescue) gem.

```rb
Pry::rescue {
  # raise exceptions here
}
```

Or run:

```
bundle exec rescue rspec
```

Additional commands:

```
pry(main)> cd-cause
pry(main)> try-again
```

### hirb
Add the [hirb](https://rubygems.org/gems/hirb) gem.

    > table User.all
    > view User.all
    > view User.all, fields: %w[id name email]

### Shell integration

shell-mode adds dir to the prompt.

    pry(main)> shell-mode
    pry(main):/home/x $

Commands with `.` are shell commands.

    pry(main)> .cat hello.txt

### [Rails] ls

    > ls         # All

    > ls -m      # Methods
    > ls -M      # Instance methods

    > ls -g      # Globals
    > ls -l      # Local vars
    > ls -c      # Constants

    > ls -i      # Instance vars

    > ls -G xx   # Grey by regex

### [Rails] Rails

    > show-models
    > show-routes
    > show-middleware

### [Rails] Rails console

Also consider [pry-rails](https://rubygems.org/gems/pry-rails).

    $ pry -r ./config/environment

### Misc commands

    > hist          # History
    > wtf?          # Trace of recent exception

### Gems

    > gem-cd foo      # Switch to gem's dir
    > gem-install foo
    > gem-list

### Reference
* [Pry Cheat Sheet](https://cheatsheetmaker.com/pry) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Php Cheat Sheet
Tags: php, cheatsheet
Published: 2021-05-13 09:22:11


### isset vs empty
```php

$options = [
    'key' => 'value',
    'blank' => '',
    'nothing' => null,
];

var_dump(isset($options['key']), empty($options['key'])); // true, false
var_dump(isset($options['blank']), empty($options['blank'])); // true, true
var_dump(isset($options['nothing']), empty($options['nothing'])); // false, true
```
### Getters and setters

```php
class Person 
{
    private $name = '';

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name)
    {
        $this->name = $name;
        return $this;
    }
}

$person = new Person();
$person->setName('bob');

echo $person->getName();
```

### Classes

```php
class Person
{
    public $name = '';
}

$person = new Person();
$person->name = 'bob';

echo $person->name;
```

### Inspecting objects

```php
<?php
var_dump($object)
```

Prints the contents of a variable for inspection.

See: [var_dump](https://php.net/var_dump)

### Objects

```php
<?php

$fruitsArray = array(
    "apple" => 20,
    "banana" => 30
);
echo $fruitsArray['banana'];
```

Or cast as object

```php
<?php

$fruitsObject = (object) $fruits;
echo $fruitsObject->banana;
``` 

### Hello world

#### hello.php

```php
<?php
function greetMe($name): string
{
    return "Hello, " . $name . "!";
}

$message = greetMe($name);
echo $message;
```

All PHP files start with `<?php`.

See: [PHP tags](https://php.net/manual/en/language.basic-syntax.phptags.php)

### Reference
* [Php Cheat Sheet](https://cheatsheetmaker.com/php) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Vim-Rails Cheat Sheet
Tags: vim, rails, cheatsheet
Published: 2021-05-13 09:20:29

### Config

    :Einitializer <file>          # config/initializers/*.rb
    :Elocale                      # config/locales/*.yml
    :Eenvironment                 # application.rb
    :Eenvironment development     # config/environments/*.rb

### Test

    :Espec
    :Eunittest
      # test/{unit,models,helpers}/*_test.rb
      # spec/{unit,models,helpers}/*_spec.rb

    :Efunctionaltest
      # test/{functional,controllers,mailers}/*_test.rb
      # spec/{functional,controllers,mailers}/*_spec.rb

    :Eintegrationtest
      # test/integration/*_test.rb
      # spec/{features,requests,integration}/*_spec.rb
      # features/*.feature

    :Efixtures
    :Efunctionaltest

### Assets

    :Estylesheet
    :Ejavascript

### Lib

    :Elib <file>      # lib/*.rb
    :Elib             # Gemfile
    :Etask <file>     # lib/tasks/*.rake

### DB

    :Emigration <file>     # db/migrations/*.rb
    :Eschema               # db/schema.rb
    
### App

    :Econtroller <file>     # app/controllers/*_controller.rb
    :Ehelper                # app/helpers/*_helper.rb
    :Emodel <file>          # app/models/*.rb
    :Ejob <file>            # app/jobs/*_job.rb
    :Emailer <file>         # app/mailers/*.rb

### Views

| Abbrev  | Expansion                   |
| ---     | ---                         |
| `dotiw` | `distance_of_time_in_words` |
| `taiw`  | `time_ago_in_words`         |

Extracting partials
-------------------

```rb
# from view => app/views/home/_foo_partial.haml
  :Rextract home/foo_partial

# from model => app/models/concerns/foo_concern.rb
  :Rextract FooConcern
```

Loading files
-------------

### Controllers

| Abbrev  | Expansion        |
| ---     | ---              |
| `pa[`   | params           |
| `re(`   | redirect_to      |
| `rp(`   | render partial:  |
| `rst(`  | respond_to       |

### Model

| Abbrev   | Expansion                 |
| ---      | ---                       |
| `bt(`    | `belongs_to`              |
| `hm(`    | `has_many`                |
| `ho(`    | `has_one`                 |
| `habtm(` | `has_and_belongs_to_many` |

### Reference
* [Vim-Rails Cheat Sheet](https://cheatsheetmaker.com/vim-rails) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Dom Selection Cheat Sheet
Tags: dom, cheatsheet
Published: 2021-05-13 09:19:21


### [Reference] Events

```js
document.addEventListener('selectionchange', () => {})
```
### [Reference] Deleting

```js
sel.deleteFromDocument()
```

### [Reference] Collapsing

```js
sel.collapse(parent, offset)
sel.collapseToEnd()
sel.collapseToStart()
sel.isCollapsed
```

```js
sel.containsNode(node)
```

### [Reference] Methods

```js
sel.removeAllRanges() //  deselects
sel.addRange(range) //    sets a selection
sel.removeRange(range) // remove a range
```

```js
sel.rangeCount
sel.getRangeAt(0) // get the 0th range
```

### [Reference] Selection

```js
var sel = document.getSelection()
```

See: <https://devdocs.io/dom/selection>

### Reference
{: .-three-column}

### Reference
* [Dom Selection Cheat Sheet](https://cheatsheetmaker.com/dom-selection) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Os X Cheat Sheet
Tags: osx, cheatsheet
Published: 2021-05-13 09:18:10


### Useful utils

 - `open` - open files and directories ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/open.1.html))
 - `textutil` - manipulate text files of various formats ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/textutil.1.html))
 - `pbcopy` / `pbpaste` - provide copying and pasting to the pasteboard ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html))
 - `sips` - scriptable image processing system ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/sips.1.html))
 - `mdfind` - finds files matching a given query ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/mdfind.1.html))
 - `screencapture` - capture images from the screen ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/screencapture.1.html))
 - `defaults` - access the Mac OS X user defaults system ([man](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/defaults.1.html))
 - `/usr/libexec/airportd`
 - `scutil`

 __INFO: `brew` ([link](https://brew.sh)) is highly recommended utility__
### System utils

 - `networksetup` - Configure network (ip, dns, proxy, etc)
 - `tmutil` - Configure Time Machine (enable/disable, exclude path, delete snapshots, etc)
 - `mdutil` - Manage Spotlight (enable/disable, exclude, etc)
 - `diskutil` - Control disk (format, eject, unmount, etc)
 - `launchctl` - Control running "agents"

### Turn on/off proxy

    sudo networksetup -setsocksfirewallproxystate Wi-Fi off
    sudo networksetup -setsocksfirewallproxystate Ethernet off
    sudo networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 9999
    sudo networksetup -setsocksfirewallproxy Ethernet 127.0.0.1 9999
    sudo networksetup -setsocksfirewallproxystate Wi-Fi on
    sudo networksetup -setsocksfirewallproxystate Ethernet on

### Disable spotlight indexing

    mdutil -a -i off                    # disable indexing for all volumes
    mdutil -i off MOUNT_POINT           # disable for specific volume
    touch FOLDER/.metadata_never_index  # disable for FOLDER
                                        

### Flush DNS

    killall -HUP mDNSResponder   # 10.8+
    dscacheutil -flushcache      # 10.7 below

### Auto-hide other windows on dock switch

    defaults write com.apple.dock single-app -bool TRUE
    killall Dock

    defaults delete com.apple.dock single-app
    killall Dock

### Hide desktop icons

    defaults write com.apple.finder CreateDesktop -bool false
    killall Finder

### Locations of startup items

    ~/Library/LaunchAgents
    /System/Library/LaunchAgents/
    /System/Library/LaunchDaemons/
    /Library/LaunchAgents/
    /Library/LaunchDaemons/

    __Running `launchctl list` show you what launch scripts are currently loaded.__

### Reference
* [Os X Cheat Sheet](https://cheatsheetmaker.com/os-x) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
3 things I didn't know SCSS / SASS could do
Tags: css, sass, webdev
Published: 2021-05-13 09:14:45

While I've spent over a decade working with LESS/SCSS/SASS, I never really [pushed it beyond the basics](https://www.1thingaweek.com/week/176/love-sass-making-the-most-of-it). Don't get me wrong, the basics are enough of a reason to use the pre-processors. For me, it makes the code more readable and maintainable.

I've come across a variety of posts recently that have highlighted things that SASS can do that I hadn't realised.

## 1. Nesting properties
By nesting properties, you can save a few bytes, but more importantly it's another layer of organisation you can sprinkle throughout your CSS.

![Nested properties in SCSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci8mk6t8ugtafwrckaim.jpg)

## 2. Complex loops
Last week I talked about updating [SkeletonCSS](https://www.1thingaweek.com/week/180/first-update-skeletoncss) and introducing a map of colours. This has turned out to be very useful, so I'm not new to maps and loops themselves but I hadn't thought about pushing what they could do until this past week.

Thanks to the maps I've built up, it would actually be really easy to introduce dark mode by just flipping the map when creating CSS variables. You may look at my map and wonder why I started at -3 instead of 0. For me, it makes more sense to keep 0 as the primary shade of the colour and then the more negative you get, the darker the shade. The opposite is true too, the higher the number, the lighter the shade.

What I first started looking into reversing the map, this seemed like a world of pain and I thought I was going to have to switch it up but after a quick scribble on a piece of paper I found the formulas that make it work for me.

![Reverse properties in a SASS map](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm85jx8t2yq3ovv4jsem.jpg)

## 3. Parent selectors
Now, I would argue a parent selector would selecting the parent of the current element... but that's not possible in CSS.

Thanks to SASS however, you can target the parent element which is another thing that aids organisation in your CSS.

![Parent selector in SASS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wcx5tv9zlxz7bm2zwxg.jpg)

I haven't used this in vein but I can see how it simplifies what you're writing and is another way to reduce the number of declarations you need. The best way to understand the example above, is that the nav item may be included multiple times and have a default style except when it's in a header. Instead of explicitly creating a new block for that scenario, you can now drive it from within the nested properties of the nav element itself.

Long overdue, but I'm going to read the docs for SASS in all it's glory and I found this great [cheat sheet for SASS](https://devhints.io/sass). I've always enjoyed working with CSS and HTML and SASS/SCSS is now firmly at the top of the list of [programming languages I love to use](https://twitter.com/cchana/status/1380842224053813249).
What Every Programmer Should Know
Tags: codenewbie, devops, discuss, programming
Published: 2021-05-13 09:13:41

In this post, I will discuss the eight (8) things programmers should know.  Let's dive in.....

###1. Problem solving and analysis

The ability to solve a problem without a computer is necessary. Here is when critical thinking takes place. You will struggle if you cannot explain or solve a problem on paper before coding.  


###2. It is not gender-based 

Programming is not men's thing. Whether you are a male or a female, you can become a programmer. What matters is your drive towards it.

###3. Consistency will help you 

For instance, you are learning to ride a bike. Of a surety, there will be ups and downs as you practice. Naturally, you will make mistakes as a newbie or pro but do not give up  - your focus to learn will yield consistency.  


###4. Coding at night doesn't make you a pro

Hey, you need to sleep. Rest is good for your brain. When you sleep, your body and brain will be refresh and active to accomplish whatever task you want to do. Lack of sleep can lead to sickness and burnout.


###5. You are your success and failure 

Don't blame anyone for your wrong. Avoid this childish act, accept your mistakes, and find a way to solve them - If your friends cannot help fix it yourself. The problem is not with the programming language you are learning, but your wrong implementation can be why the code isn't working.  


###6. Make friend with Google 

Constantly search for the solution to problems on the internet. There might be someone who has encountered the same before. 


###7. Share your knowledge to gain connections

Sharing what you know doesn't kill or make you look foolish. The more you share your knowledge, the more you become a magnet of attraction. 

###8. Don't ignore your health

While you focus on your profession, take good care of yourself also. Your health should be a top priority. Neglecting your health is dangerous. Avoid smoking, alcohol, excess sugar, and anything that can endanger your body.
Ember.Js Cheat Sheet
Tags: ember, cheatsheet
Published: 2021-05-13 09:07:19


### markup
```
    <img {{bindAttr src="avatarURL"}}>
    <button {{action follow}}>
```

Value binding:

```
    {{view Ember.TextField class="input block" valuebinding="emailAddresses"}}
```

Actions:

```
    <button {{action invite emailAddresses}}>Invite></button>
    <a href="#" {{action set "isEditingContacts" true target="view"}} 
```

### View

```
    App.InfoView = Ember.View.extend({
      templateName: 'input',  /* optional */

      fooName: "Hello"  /* {{ view.fooName }} */

      click: function(e) {
        "I was clicked";
      }

    });
```

### A route

```
    App.IndexRoute = Ember.Route.extend({
      setupController: function(controller) {
        controller.set('title', 'my app');
        // <h1>{{title}}</h1>
      },

      setupController: function(controller, model) {
        controller.set("model", model);
        this.controllerFor('topPost').set('model', model);
      },

      model: function(params) {
        return this.store.find('posts');
        return this.store.find('post', params.post_id);
      },
      
      serialize: function(model) {
        // this will make the URL `/posts/foo-post`
        return { post_slug: model.get('slug') };
      }
    });
```

### Routes

```
    App.Router.map(function() {
      this.resource('trips', function() {
          this.route('item', { path: '/:trip_id' });
      });

      this.route('upcoming');
      this.route('about', { path: '/about' });
      this.route('schedules');
      this.route('history');
      this.route('post');
    });
```

### Reference

* [Ember.Js Cheat Sheet](https://cheatsheetmaker.com/emberjs) - [Cheat Sheet Maker](https://cheatsheetmaker.com)
Cron Job Tutorials -How to set up cron job with EasyCron API for BackWPup?
Published: 2021-05-13 09:06:34


I installed BackWPup on my server, and I want to set up a cron job to trigger BackWPup's cron job script. What should I do to set up the cron job?

https://www.easycron.com/cron-job-tutorials/how-to-set-up-cron-job-with-easycron-api-for-backwpup

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nd8gb93sj3l67yx08nws.png)
Deploy MongoDB Instances in Multiple Regions Automatically Using Terraform
Tags: terraform, mongodb, cloudnative, cloudskills
Published: 2021-05-13 09:03:24

Where do you encounter problems with multi-region deployments?

→_→ 👉 Generally, it’s when you are about to expand your business to other cities and countries, you may need to build new local data centers for smooth user experience. 

Following our first video helping you create RDS instances automatically using Terraform, let's see how to set up MongoDB instances on Alibaba Cloud in different regions and areas and sync data in a real-time manner via MongoShake.
[Watch Now in 13 mins >](https://www.youtube.com/watch?v=k6zUZcw6CU4&list=PL54EFTJJZrwhlXruht3cQA18ISUKo6GAD&index=4&t=9s)


🔥Free MongoDB Instance🔥: Register an individual account to get 30 days MongoDB free trial on Alibaba Cloud , register as enterprise to get 60 days MongoDB Free Trial.
[Start To Use For Free](http://45dwz.com/NdmJK)
Tape Cheat Sheet
Tags: tape, cheatsheet
Published: 2021-05-13 09:00:09


### Untitled


```js
test('things', (t) => {
  t.plan(1)

  t.equal('actual', 'expected')
  t.equal('actual', 'expected', 'should be equal') // messages are optional

  t.end(err)
  t.fail('msg')
  t.pass('msg')
  t.timeoutAfter(2000)
  t.skip('msg')

  t.ok(value, 'is truthy')
  t.notOk(value, 'is falsy')
  t.error(err, 'is falsy (print err.message)')

  t.equal(actual, expected, 'is equal')
  t.notEqual

  t.deepEqual(actual, expected, 'is equal (use node's deepEqual)')
  t.notDeepEqual

  t.looseEqual(actual, expected, 'is equal (use node's deepEqual with ==)')
  t.notLooseEqual

  t.throws(fn, /FooError/)
  t.throws(fn, FooError /* class */)
  t.doesNotThrow

  t.comment('message')
})
```

```js
test.only((t) => { ... })
```

### Reference

* [Tape Cheat Sheet](https://cheatsheetmaker.com/tape) - [Cheat Sheet Maker](https://cheatsheetmaker.com)