Skip to content

Instantly share code, notes, and snippets.

View itsdonnix's full-sized avatar

DON itsdonnix

View GitHub Profile
@itsdonnix
itsdonnix / random_guid.js
Created November 23, 2022 03:26
Generate random GUID
function CreateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
@itsdonnix
itsdonnix / linux_cheatsheets.md
Last active January 10, 2023 07:51
Linux Cheatsheets

Linux Cheatshets

Storage Management

List of all mounted storages

cat /proc/self/mounts

Networking

@itsdonnix
itsdonnix / docker_cheatsheets.md
Last active February 21, 2023 07:47
Docker Cheatsheets

Docker Cheatsheets

Misc

Exctract a docker run command from running container

docker inspect \
  --format "$(curl -s https://gist.githubusercontent.com/efrecon/8ce9c75d518b6eb863f667442d7bc679/raw/run.tpl)" \
  name_or_id_of_your_running_container
@itsdonnix
itsdonnix / laravel_cheatsheets.md
Last active December 4, 2022 23:09
Laravel Cheatsheets

Laravel Cheatsheets

Laravel Upload file to storage folder (local)

if ($request->hasFile('image')) {
  $image = $request->file('image');
  // Will upload to /storage/public/472385852.jpg for example
  $destination  = 'public/' . time() . "." . $image->getClientOriginalExtension();
 Storage::disk('local')->put($destination, file_get_contents($image->getRealPath()));
@itsdonnix
itsdonnix / hugo_cheatsheets.md
Last active September 9, 2022 05:58
Hugo Cheatsheets

Hugo Cheatsheets

Date/Time

Get Current Date/Time

{{ dateFormat "01 Jan 2006" now }}
@itsdonnix
itsdonnix / css-aspect-ratio-with-fallback.html
Created June 9, 2022 02:01
CSS Aspect Ratio with Fallback
<!--
CSS Aspect Ratio with Fallback by Una Kravets
Source: https://codepen.io/una/pen/BazyaOM
-->
<div>I am always 16x9</div>
<style>
div {
background: lightblue;
@itsdonnix
itsdonnix / css_container_trick.css
Created April 28, 2022 06:44
CSS Container Trick
.container {
--max-width: 60rem;
--padding: 2rem;
max-width: min(100% - var(--padding), var(--max-width));
margin-inline: auto;
}
@itsdonnix
itsdonnix / calculate_age.js
Created February 16, 2022 09:04
Calculate age
function calculateAge(year, month, date) {
const bornDate = new Date(year, month - 1, date);
const nowDate = new Date();
const bornYear = bornDate.getFullYear();
const nowYear = nowDate.getFullYear();
let age = nowYear - bornYear - 1;
if (
nowDate.getMonth() >= bornDate.getMonth() &&
nowDate.getDate() >= bornDate.getDate()
) {
@itsdonnix
itsdonnix / random_date_start_end.js
Created February 16, 2022 03:30
Javascript Random Date from start to end
function randomDate() {
// Start from 01 Jan 2010
const start = new Date(2010, 1, 1);
// End with current date
const end = new Date();
const randomDate = new Date(
start.getTime() + Math.random() * (end.getTime() - start.getTime())
);
return randomDate.toISOString().slice(0, 10);
}
@itsdonnix
itsdonnix / sshfs_load_pem_file.md
Created January 31, 2022 03:58
Use sshfs to mount an AWS EC2 folder using PEM file

Use sshfs to mount an AWS EC2 folder using PEM file

sshfs -o "IdentityFile=path/to/file.pem" ubuntu@EC2_HOST:/path/to/dir /path/to/mount/point