Skip to content

Instantly share code, notes, and snippets.

View IC-Tech's full-sized avatar
🏠
Working from home

Imesh Chamara IC-Tech

🏠
Working from home
View GitHub Profile
@IC-Tech
IC-Tech / naming_convention.md
Created December 26, 2022 15:04
Naming convention in codes
Example Name
twowords flatcase
TWOWORDS UPPERCASE
twoWords (lower) camelCase, dromedaryCase
TwoWords PascalCase, UpperCamelCase, StudlyCase
two_words snake_case, pothole_case
TWO_WORDS SCREAMING SNAKE CASE, MACRO_CASE, CONSTANT_CASE
two_Words camel_Snake_Case
Two_Words Pascal_Snake_Case, Title_Case
@IC-Tech
IC-Tech / timer.sh
Created April 17, 2022 18:20
simple sleep timer with bash
#!/bin/bash
sec=0
function _t1 {
b="$2"
echo "${@:3}" | grep -oE "[0-9]+$1" | grep -oE '[0-9]+' | while read a ; do
printf "$((a * b)) + "
done
}
if [[ "$(echo "$1" | grep -oE '[HhMmSs]')" ]] ; then
v=`_t1 '[sS]' 1 "$@"`
@IC-Tech
IC-Tech / dillinger.io.css
Created March 8, 2022 12:34
dark theme for dillinger.io
/*
- site: dillinger.io
- type: dark theme
- version: v1.0.0
- update: Tue 08 Mar 2022 12:30:06 PM UTC
- problems
- I chaned the font type as a effect, perview text looks smaller; remove the last style to revert.
- codeblock style with dark theme could be messy
- this is not a full patch, just only changed what I saw.
- little bit bored right now; will fix image buttons later.
@IC-Tech
IC-Tech / print_obj.py
Created February 28, 2022 18:01
python print function for classes/objects (with colors)
def print_obj(obj):
print('\033[36m', end='')
print(obj)
print('\033[0m', end='')
for att in dir(obj):
try:
val = obj.__getattribute__(att)
except AttributeError:
#print(' \033[31m' + att + '\033[0m')
continue
@IC-Tech
IC-Tech / check_webp.js
Created July 22, 2021 00:39
test webp features
async function check_webp(f){const a={lossy:"UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",lossless:"UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==",alpha:"UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",animation:"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"},b=b=>new Promise(c=>{var d=new Image();d.onload=a=>c(d.width>0&&d.height>0);d.onerror=a=>c(!1);d.src="data:image/webp;base64,"+a[b]});if(f){return await b(f)}var c=Object.keys(a);for(var i=0;i<c.length;i+=1){if(!(await b(c[i]))){return!1}}return!0}
@IC-Tech
IC-Tech / translate.google.com.css
Last active October 4, 2021 16:16
Google Translate Stylus
html {
--col0: #2f343f;
--col1: #404552;
--col2: #d3dbe4;
--col3: #262a33;
--col4: #d3dbe4ad;
--col5: #4393f2;
}
body {
color: var(--col2) !important;
@IC-Tech
IC-Tech / pastebin.sh
Created May 5, 2021 16:51
pastebin.sh easy cli uploads
#! /bin/bash
dev_key_file="$HOME/.config/pastebin/developer.key"
user_key_file="$HOME/.config/pastebin/user.key"
warn_file="$HOME/.config/pastebin/no_user_key"
if [[ ! -r $dev_key_file ]]; then
nl=1
echo 'warning developer key is missing, you cannot upload files without a key. run --help'
dev_key=''
@IC-Tech
IC-Tech / enc.sh
Created May 5, 2021 12:22
enc.sh for simply encrypt and decrypt files
#! /bin/bash
c=$1
shift
if [[ $c == 'gen' ]] || [[ $c == 'generate' ]] ; then
openssl rand -hex 16 > enc.key
openssl rand -hex 16 > iv.key
elif [[ $c == 'enc' ]] || [[ $c == 'encrypt' ]] ; then
openssl dgst -md5 "$@" > files.md5
for f in "$@" ; do
echo "encrypting $f"
@IC-Tech
IC-Tech / client.c
Created March 8, 2021 12:32
Simple TCP
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void error(const char *msg)
@IC-Tech
IC-Tech / ease.js
Created October 27, 2020 09:02
Easing functions
const ease = (() => {
const E = Math.pow,
b = Math.sqrt,
A = Math.sin,
w = Math.cos,
I = Math.PI,
O = 1.70158,
T = 1.525 * O,
C = O + 1,
x = 2 * I / 3,