Skip to content

Instantly share code, notes, and snippets.

View ComradeCat24's full-sized avatar

Sym ComradeCat24

View GitHub Profile
@ComradeCat24
ComradeCat24 / Rfor.js
Created January 22, 2021 08:58
For-loop in JSX
import React from "react";
const RFor = ({ data, renderItem }) => {
return data.map((item) => renderItem(item));
};
const data = ["i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10"];
const Box = ({ item }) => (
<div>
@ComradeCat24
ComradeCat24 / Loop.js
Created January 26, 2021 07:33
For-loop in JSX with id
const Loop = () => {
const animals = [
{ id: 1, animal: "Dog" },
{ id: 2, animal: "Bird" },
{ id: 3, animal: "Cat" },
{ id: 4, animal: "Mouse" },
{ id: 5, animal: "Horse" },
];
return (
@ComradeCat24
ComradeCat24 / install-docker.sh
Last active January 31, 2021 07:11
Docker installation for linux mint 20 ulyana
#!/bin/bash
sudo apt-get update
echo "# install dependencies"
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
echo "# add the gpg key for docker"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@ComradeCat24
ComradeCat24 / redux.js
Created March 10, 2021 18:11
A project to understand "redux" lib
console.clear();
// People dropping off a form (Action Creators)
const createPolicy = (name, amount) => {
return { // Action (a form in our analogy)
type: 'CREATE_POLICY',
payload: {
name: name,
amount: amount
}
@ComradeCat24
ComradeCat24 / Battery.vbs
Created March 11, 2021 06:21
Battery Warning when charged upto a Limit {here 80%}
set oLocator = CreateObject("WbemScripting.SWbemLocator")
set oServices = oLocator.ConnectServer(".","root\wmi")
set oResults = oServices.ExecQuery("select * from batteryfullchargedcapacity")
for each oResult in oResults
iFull = oResult.FullChargedCapacity
next
while (1)
set oResults = oServices.ExecQuery("select * from batterystatus")
for each oResult in oResults
class SinglyLinkedListNode {
constructor(data, next = null) {
this.data = data; // piece of data
this.next = next; //reference to next node
}
}
class SinglyLinkedList {
constructor() {
this.head = null;
@ComradeCat24
ComradeCat24 / battery-status.sh
Last active February 3, 2022 18:27
Get Battery notification on Linux
#!/bin/bash
while true
do
export DISPLAY=:0.0
battery_level=`cat /sys/class/power_supply/BAT0/capacity`
if [ $(cat /sys/class/power_supply/BAT0/status) = 'Charging' ]; then
if [ $battery_level -ge 80 ]; then
notify-send -t 10000 "Battery Full" "Level: ${battery_level}%"
fi
else
@ComradeCat24
ComradeCat24 / FormRepeater.js
Last active May 20, 2021 16:50
Add your own Label and Value to create a Form
import React from "react";
import { Label, FormGroup, Input, Row, Col } from "reactstrap";
import { Delete, Plus } from "react-feather";
export default class FormRepeater extends React.Component {
constructor(props) {
super(props);
this.state = {
value: "",
@ComradeCat24
ComradeCat24 / JPGtoPNGconverter.py
Created September 8, 2021 07:47
image convertion jpg to png using PILLOW fork
import sys
import os
from PIL import Image
path = sys.argv[1]
directory = sys.argv[2]
if not os.path.exists(directory):
os.makedirs(directory)
@ComradeCat24
ComradeCat24 / pdf_combiner.py
Last active September 9, 2021 18:07
combine multiple pdf into a single pdf
import sys
from PyPDF2 import PdfFileMerger
inputs = sys.argv[1:]
def pdf_combiner(pdf_list):
merger = PdfFileMerger()
for pdf in pdf_list:
print(pdf)