Skip to content

Instantly share code, notes, and snippets.

View dkhd's full-sized avatar
🏖️
Available for Remote Projects

Diky Hadna dkhd

🏖️
Available for Remote Projects
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Simple Group Chat on Node.js</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #fff; padding: 3px; position: fixed; bottom: 0; width: 100%; border-color: #000; border-top-style: solid; border-top-width: 1px;}
form input { border-style: solid; border-width: 1px; padding: 10px; width: 85%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; margin-left: 2%; }
@dkhd
dkhd / index.js
Created February 18, 2019 09:53
Build A Group-Chat App in 30 Lines Using Node.js
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
app.get('/', function(req, res) {
res.render('index.ejs');
});
io.sockets.on('connection', function(socket) {
@dkhd
dkhd / basic index.ejs
Created February 18, 2019 09:15
Building A (Simple) Group Chat Using Node.js
<!DOCTYPE html>
<html>
<head>
<title>Simple Group Chat on Node.js</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #fff; padding: 3px; position: fixed; bottom: 0; width: 100%; border-color: #000; border-top-style: solid; border-top-width: 1px;}
form input { border-style: solid; border-width: 1px; padding: 10px; width: 85%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; margin-left: 2%; }
@dkhd
dkhd / basic index.js
Created February 18, 2019 08:38
Building A (Simple) Group Chat Using Node.js
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
app.get('/', function(req, res) {
res.send('Hello world!');
});
const server = http.listen(8080, function() {
@dkhd
dkhd / import modules
Created February 18, 2019 08:23
Building A (Simple) Group Chat Using Node.js
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
@dkhd
dkhd / telegram-bot.py
Created August 25, 2017 18:34
A Python script that will make our Telegram bot alive!
from telegram.ext import Updater, CommandHandler
from engine import get_random_quote
# Your bot token (from BotFather)
token = "YOUR TOKEN HERE"
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text=("Hi %s. Send me /quote command to get a random quote from "
"me!" %
update.message.from_user.name))
@dkhd
dkhd / engine.py
Created August 25, 2017 18:08
An engine.py file that contains a function to generate random quotes.
from random import randint
quote_file = "quotes.txt"
def get_random_quote():
start_line = None
end_line = None
# Open the quote file
with open(quote_file) as file: