Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
Available for Remote Projects

Diky Hadna dkhd

🏖️
Available for Remote Projects
View GitHub Profile
View index.ejs
<!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 Feb 18, 2019
Build A Group-Chat App in 30 Lines Using Node.js
View index.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 Feb 18, 2019
Building A (Simple) Group Chat Using Node.js
View basic index.ejs
<!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 Feb 18, 2019
Building A (Simple) Group Chat Using Node.js
View basic index.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 Feb 18, 2019
Building A (Simple) Group Chat Using Node.js
View import modules
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 Aug 25, 2017
A Python script that will make our Telegram bot alive!
View telegram-bot.py
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 Aug 25, 2017
An engine.py file that contains a function to generate random quotes.
View engine.py
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: