Skip to content

Instantly share code, notes, and snippets.

View jonathas's full-sized avatar
💻
hacking

Jonathas Ribeiro jonathas

💻
hacking
View GitHub Profile
@jonathas
jonathas / launch.json
Created November 13, 2023 19:12
vscode debugger config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug unit tests",
"type": "node",
"request": "launch",
@jonathas
jonathas / sync-external-drive.sh
Last active January 22, 2023 10:55
Using Rsync to keep local and external drives synchronized
#!/bin/bash
baseDir=~/Dropbox
externalDriveDir=/Volumes/Expansion
declare -a localDirs=("Documents" "Music" "Photos" "Shared" "Videos")
for dir in "${localDirs[@]}"
do
echo "======================= Synchronizing ${dir} ======================="
@jonathas
jonathas / lint-pr-title.yml
Created January 15, 2023 22:04
Github Action workflow for a PR title following Conventional Commits
name: "Lint PR Title"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
lint-pr-title:
@jonathas
jonathas / eslintrc.js
Created January 7, 2023 13:04
eslintrc
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: [
'@typescript-eslint/eslint-plugin',
'max-params-no-constructor',
'security',
@jonathas
jonathas / jest.config.js
Last active March 7, 2022 20:28
moduleNameMapper mapping for Angular
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');
const moduleNameMapper = Object.keys(compilerOptions.paths).reduce((acc, curr) => {
return {
...acc,
[curr]: '<rootDir>' + compilerOptions.paths[curr]
}
}, {})
@jonathas
jonathas / caesarcipher.ts
Created November 4, 2021 11:27
Caesar Cipher
class CaesarCipher {
private characters = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
private shift = 4;
public decrypt(value: string): string {
return value.toString().split("")
.map(v => this.shiftNumber(Number(v))).join("");
}
private shiftNumber(x: number): number {
@jonathas
jonathas / algorithms.js
Created September 29, 2021 12:11
Palindrome, Fibonacci, First non repeating index
function isPalindrome1(word) {
const len = word.length;
for (let i = 0; i < len / 2; i++) {
if (word[i] !== word[len-1-i]) {
return false;
}
}
return true;
}
@jonathas
jonathas / user.php
Created September 2, 2021 10:58
Simplify/fix the code below by knowing that you can use php 7.3-7.4
<?php
/**
* Simplify/fix the code below by knowing that you can use php 7.3-7.4:
*/
class User {
public $name;
public $lastName;
protected $age;
public function __construct($name, $lastName, $age)
@jonathas
jonathas / dirs.txt
Created August 27, 2021 09:34
Parse text and extract only the recup_dir directory names generated by PhotoRec
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.10 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.100 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1000 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1001 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1002 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1003 to /run/media/jonathas/Elements/recovered_photos
==> Copying images from: /run/media/jonathas/Elements/Recovery/recup_dir.1004 to /run/media/jonathas/Elements/recovered_photos
==> Cop
@jonathas
jonathas / repo_migration.sh
Created May 19, 2021 12:25
Migrating repositories
#!/bin/bash
for branch in `git branch -r|grep -v ' -> '|cut -d"/" -f2,3`; do git checkout $branch; git fetch; done;
for branch in `git branch`; do git push -u github $branch; done;
git push --tags github