Skip to content

Instantly share code, notes, and snippets.

View Rahmanism's full-sized avatar
💻
I'm coding!

Rahmani Rahmanism

💻
I'm coding!
View GitHub Profile
@Rahmanism
Rahmanism / dockerfile-apache-centos7
Created August 15, 2024 11:32
Dockerfile for Apache on CentOS 7
FROM centos:7
LABEL Remarks="This is a dockerfile example for Centos system"
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum -y update && yum -y install httpd && yum clean all
# ADD ./site/html.tar.gz /var/www/html/
EXPOSE 80
CMD ["apachectl", "-D", "FOREGROUND"]
@Rahmanism
Rahmanism / encoding.py
Created April 16, 2023 09:24
Find the encoding of a file
import sys, chardet
with open(sys.argv[1], 'rb') as f:
result = chardet.detect(f.read())
print(result['encoding'])
@Rahmanism
Rahmanism / file-listing-web.py
Last active April 17, 2023 05:27
File listing using Python for web
# -*- coding: utf-8 -*-
import os, sys
print('Content-Type: text/html; charset=utf-8')
print('')
print('<!DOCTYPE html>')
print('<html>')
print('<head>')
print('<meta charset="utf-8" />')
print('<meta name="viewport" content="width=device-width, initial-scale=1.0">')
@Rahmanism
Rahmanism / upload.py
Last active April 17, 2023 06:33
Upload file Python CGI
import os, cgi, shutil
from sys import exit
print('Content-Type: text/html')
print('')
print('<html><body>')
# Define the HTML form to upload the file
form = cgi.FieldStorage()
@Rahmanism
Rahmanism / extract-srt.sh
Created February 18, 2023 15:59
Extract subtitle from a movie using `ffmpeg`
ffmpeg -i movie.mkv -map 0:s:0 sub.srt
@Rahmanism
Rahmanism / html-expandable-list.html
Created January 29, 2023 07:47
HTML Expandable UL - Custom element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Custom Element - Expandable List</title>
</head>
@Rahmanism
Rahmanism / html-custom-element.html
Created January 29, 2023 07:45
HTML Custom elements
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Element</title>
<style>
h3 {
@Rahmanism
Rahmanism / currency-fetch.html
Created January 22, 2023 07:23
A sample code to use fetch in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currency</title>
</head>
@Rahmanism
Rahmanism / promise-allsettled.js
Created January 21, 2023 09:46
Using Promise.allSettled instead of Promise.all for concurrency in JavaScript
async function getData() {
const results = await Promise.allSettled({
fetchUser(),
fetchProduct()
})
const [user, product] = handle(results)
}
@Rahmanism
Rahmanism / vscode-indentation-active.json
Created January 21, 2023 09:43
To change indentation vertical line color in VSCode, set this in json settings
"workbench.colorCustomizations":{
"editorIndentGuide.activeBackground":"#06a"
}