Skip to content

Instantly share code, notes, and snippets.

View mazharul's full-sized avatar

Mazharul Anwar mazharul

View GitHub Profile
FROM node:16-alpine
# Set the working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
version: '3.8'
services:
app:
container_name: examplehkbooks_app
build: .
ports:
- "6000:6000"
environment:
- NODE_ENV=production
- DATABASE_URL=mongodb://mongo:27017/hkbooks
@mazharul
mazharul / web-servers.md
Created May 13, 2021 11:21 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mazharul
mazharul / clean_code.md
Created January 25, 2021 04:27 — 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

<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=0.4, maximum-scale=1">
<title>Test HTML form</title>
</head>
@mazharul
mazharul / map.html
Created January 21, 2013 07:15
Sample map code for farhan
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8W_JvhLDsIX_dSiWo91mhGG5jVYA1IIY&sensor=true"></script>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
import sys
import csv
import httplib, urllib, base64
def main():
# set the name of your repository, username and password
username = "test"
password = "test"
repo = "test"
import sys
def shortestpath(graph,start,end,visited=[],distances={},predecessors={}):
"""Find the shortest path between start and end nodes in a graph"""
# we've found our end node, now find the path to it, and return
if start==end:
path=[]
while end != None:
path.append(end)
end=predecessors.get(end,None)
return distances[start], path[::-1]
@mazharul
mazharul / gist:1421582
Created December 2, 2011 03:21
Facebook authentication code
<?php
session_start();
$code = $_GET["code"];
$appId = $common->getAppId(); // your app id
$myUrl = $_SERVER['HTTP_REFERER'];
$appSecret = $common->secret(); //your app secret
if(empty($code)) {
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $appId . "&redirect_uri=" . urlencode($myUrl) . "&state="
@mazharul
mazharul / validEmail.php
Created October 12, 2011 08:24
validate php file regex
<?php
public function validEmailAdd($address){
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? false : true;
}
?>