Skip to content

Instantly share code, notes, and snippets.

View nielvid's full-sized avatar

Nielvid nielvid

View GitHub Profile
@nielvid
nielvid / Setting up a Github and Bitbucket account
Last active December 30, 2024 13:50 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer on Mac OS. Now with a guide for Windows 10.
# Setting up github and bitbucket on the same computer (Windows)
# Guide for Windows
[mix3d](https://gist.github.com/mix3d) asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in **Git Bash** once it's installed.
Github will be the main account and bitbucket the secondary.
## Git for Windows
+ Download and install [Git for Windows](https://gitforwindows.org/)
+ In the installer, select everything but decide if you want a desktop icon (2nd step)

4 Ways to backup mySql database to a csv file

There are several methods to create a CSV backup of your MySQL database. Some third-party database management tools offer additional features for backing up to CSV. If you prefer command-line control, the mysqldump utility is powerful and flexible. If you are familiar with the python programing language, there are packages to help you write python scripts to backup your database. The method you choose depends on your comfort level and technical expertise

In this article, i share 4 different ways to backup your MySQL database to a CSV file.

Using mysqldump and mysql Command-Line Tools

package main
import (
"fmt"
"strings"
)
func ReverseString(s string)string{
var b []string
a := strings.Split(s, "")
@nielvid
nielvid / gist:764ec86c48eceaa21ee45b37b508eb7f
Created July 27, 2023 14:48
Get hour difference between two dated
export const getHoursDifference = (day1: string, day2: string) => {
const dayOne = new Date(day1).getTime();
const dayTwo = new Date(day2).getTime();
if (Number.isNaN(dayOne) || Number.isNaN(dayTwo)) {
throw new Error('invalid date or time format');
}
let hourDifference = (dayTwo - dayOne) / 1000;
hourDifference = hourDifference / (60 * 60);
return hourDifference;
};
@nielvid
nielvid / rsa.js
Created March 10, 2023 15:07 — forked from sohamkamani/rsa.js
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})
@nielvid
nielvid / cheatsheet.ps1
Created February 5, 2023 00:46 — forked from pcgeek86/cheatsheet.ps1
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@nielvid
nielvid / postgres-cheatsheet.md
Created September 29, 2022 17:39 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@nielvid
nielvid / hasMany.go
Created June 7, 2022 05:25 — forked from jtbonhomme/hasMany.go
Gorm example of foreign key definition for a hasMany relation
package main
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
// Customer ...
type Customer struct {
@nielvid
nielvid / docker_nodejs.sh
Last active May 24, 2022 13:59
Install Docker nginx and [email protected] on ubuntu
#!/bin/bash
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
@nielvid
nielvid / cloudSettings
Last active January 4, 2022 15:02 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL
{"lastUpload":"2022-01-04T15:01:55.480Z","extensionVersion":"v3.4.3"}