Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Friday, November 29, 2024

Doing a git clone within a LAN without Internet

On the laptop where the repo to be clone is hosted, we run the command git daemon from the terminal.

Sample command on the HOST:

 $ git daemon --base-path=<path_to_folder_containing_project_folder> --export-all --verbose  

<path_to_folder_containing_project> is the folder containing your projects folders, it will provide all projects under that folder. You're basically looking for the project folder containing the .git folder.

The client:

 $ git clone git://<local ip>/<project name>  

It's that easy but do note that the cloned repo's origin will be pointing to the HOST IP, so you need to use git remote set-url origin to point it to a different IP or origin. 

We might want to run git daemon with the --verbose option to get more details in case we run into problems.

If we are getting connection problems, you might have to check Firewall settings to allow the connection.


Reference

* https://stackoverflow.com/questions/5200181/how-to-git-clone-a-repo-in-windows-from-other-pc-within-the-lan


Wednesday, December 21, 2022

Dumping and Restoring a DB from host into a Docker container or back

Assuming you have the sql (ie. backup.sql) file on hand:

To create a backup of a mysql DB (ie. dumping it):

$ docker exec CONTAINER_NAME /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

To restore a mysql dump (for example):

$ cat backup.sql | docker exec -i CONTAINER_NAME /usr/bin/mysql -u root --password=root DATABASE 

Add the --force or -f flag to ignore errors

$ cat backup.sql | docker exec -i CONTAINER_NAME /usr/bin/mysql -u root --password=root  --force DATABASE 

I tested this using the mysql 8.0 image. 


ref: https://stackoverflow.com/questions/46579381/how-to-restore-mysql-dump-from-host-to-docker-container


Tuesday, June 21, 2022

A guide to better google-fu in 8 forms

Google is a powerful tool but 98% of the people on the Internet suck at it. Google search can do more than just typing in a word and pressing enter.

Here's the 8 tips:

  1. "Quotation Marks"

    Put quotes around search terms to let you search exactly for that word.

    Example: "Sara Duterte"

    Gives you all Sarah Duterte search results without just "Sarah" or just "Duterte".

  2. - Dashes

    Use dashes to exclude a term from your search results. The word before the dash will be included.

    Example: multithreading -java

    You want to know about multithreading but exclude anything with java. 

  3. OR

    Put "OR" between each term to combine search results. A vertical bar | also works.

    Example: marathon OR race, marathon | race

  4. site:

    Use "site:" to search within a specific website or domain.

    Example: Nuclear Energy site:en.wikipedia.com

    Would give you results about Nuclear Energy but limited to en.wikipedia.com.

  5. $

    If you are searching for a price.

    Example: Video card $600

  6. .. (two periods)

    Search within a range of numbers. 

    Example: SUV 2010..2012, motherboard $100..$140

  7. location:

    Use "location:" to get results related to a particular location

    Example: Sara Duterte location:cebu



  8. Use @ in front of a word to search social media. 

    Example: @pythonconf

    Similarly, you can also use "#" in front of the word to search hashtags in social media. 

    Example: #pyconph