Skip to content

Instantly share code, notes, and snippets.

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

Danilo Martins DanSmaR

🏠
Working from home
View GitHub Profile
@DanSmaR
DanSmaR / ffmpeg.md
Created December 5, 2024 11:54 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@DanSmaR
DanSmaR / GitCommitBestPractices.md
Created January 10, 2024 00:08 — forked from luismts/GitCommitBestPractices.md
Git Tips and Git Commit Best Practices

Git Commit Best Practices

Basic Rules

Commit Related Changes

A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong. With tools like the staging area and the ability to stage only parts of a file, Git makes it easy to create very granular commits.

Commit Often

Committing often keeps your commits small and, again, helps you commit only related changes. Moreover, it allows you to share your code more frequently with others. That way it‘s easier for everyone to integrate changes regularly and avoid having merge conflicts. Having large commits and sharing them infrequently, in contrast, makes it hard to solve conflicts.

@DanSmaR
DanSmaR / rspec_rails_cheetsheet.rb
Created December 18, 2023 16:07 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#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)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cookies</title>
<style>
html {
@DanSmaR
DanSmaR / 1.srp.py
Created April 4, 2023 18:38
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@DanSmaR
DanSmaR / math_func.py
Created February 25, 2023 14:06 — forked from pknowledge/math_func.py
Python Unit Testing With Pytest - Parameterizing tests
def add(x, y):
return x + y
@DanSmaR
DanSmaR / meta-tags.md
Created January 5, 2023 17:35 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@DanSmaR
DanSmaR / dependency_injection.js
Last active November 19, 2022 16:50 — forked from mpj/episode.js
Code from the "Dependency Injection Basics" episode of Fun Fun Function
const assert = require('assert')
function getAnimals(fetch, id) {
return fetch('http://api.animalfarmgame.com/animals/' + id)
.then(response => response.json())
.then(data => data.results[0])
}
describe('getAnimals', () => {
it('calls fetch with the correct url', () => {
@DanSmaR
DanSmaR / fake_new_keyword.js
Last active November 10, 2022 22:09 — forked from mpj/example.js
Code from Fun Fun Function YouTube episode: The 'new' keyword - Object Creation in JavaScript P3
function Person(saying) {
this.saying = saying
}
Person.prototype.talk = function() {
console.log('I say:', this.saying)
}
function newFake(constructor) {
var obj = {}
@DanSmaR
DanSmaR / index.html
Last active October 29, 2022 21:03 — forked from prof3ssorSt3v3/index.html
(16) [(16) How to Serve Static Files from a Node Server - YouTube](https://www.youtube.com/watch?v=gvbVjJnv-b8&list=PLyuRouwmQCjnr-rRrhbPrS4YQ0brDQ-14&index=12)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Server</title>
<link rel="stylesheet" href="./main.css" />
</head>
<body>