Skip to content

Instantly share code, notes, and snippets.

View hliyan's full-sized avatar

Hasitha N. Liyanage hliyan

View GitHub Profile
@premek
premek / mv.sh
Last active August 12, 2026 04:28
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much
@tpjnorton
tpjnorton / useLoading.ts
Created October 23, 2020 08:55
useLoading.ts
import { useState } from "react";
const useLoading = (action) => {
const [loading, setLoading] = useState(false);
const doAction = (...args) => {
setLoading(true);
return action(...args).finally(() => setLoading(false));
};
@shishir
shishir / clean_code.md
Last active August 26, 2021 05:50 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@Savinda96
Savinda96 / how-set-up-node-ec2.md
Last active August 12, 2021 03:10
Setting up simple node application in EC2

Deploy NodeJS Application into EC2 with GitHub actions

This is an experience shared on getting a simple node application deployed into EC2 with github actions.

Create a simple node application

  1. Go the project directory and type the following commands mkdir node-hello && cd node-hello
  2. Type npm init in your terminal to initiate a node project (Make sure you have node installed if not follow the guide here)
  3. Create the index.js file (touch index.js)
@paulshen
paulshen / tictactoe.rs
Created August 13, 2021 18:30
egui tictactoe
use super::hyperlink::Hyperlink;
use eframe::{egui, epi};
use egui::{pos2, vec2, Color32, Pos2, Rect, Stroke, Widget};
use rand::seq::SliceRandom;
#[derive(Copy, Clone, Debug, PartialEq)]
enum Player {
User,
Computer,
}
import invariant from "tiny-invariant";
class AmalgoBox extends HTMLElement {
get input() {
return this.querySelector("input") as HTMLInputElement;
}
get button() {
return this.querySelector("button") as HTMLButtonElement;
}