Skip to content

Instantly share code, notes, and snippets.

View kylemocode's full-sized avatar
📺
Web Dev

Kyle Mo kylemocode

📺
Web Dev
View GitHub Profile
@kylemocode
kylemocode / linked-list.ts
Created March 10, 2020 05:40
Linked List using TS
type LinkedNode = {
value: number,
next: LinkedNode | null
}
class LinkedList {
head: LinkedNode;
tail: LinkedNode;
length: number;
export default class RedisDatabase {
redis: any;
constructor() {
this.redis = require('redis');
}
connectDB() {
const client = this.redis.createClient({
host: '127.0.0.1',
import { Request } from 'express';
export const getClientIp = function (req: Request) {
const ipInfo: any = req.socket.address();
let ipAddress = ipInfo.address;
if (!ipAddress) {
return '';
}
// convert from "::ffff:192.0.0.1" to "192.0.0.1"
if (ipAddress.substr(0, 7) == "::ffff:") {
import { Request, Response, NextFunction } from 'express';
import { getClientIp } from '../utils/getIpAddress';
import RedisDatabase from '../db/redisConnection';
export default (req: Request, res: Response, next: NextFunction) => {
const redis_client = new RedisDatabase().connectDB();
const ipAddress = getClientIp(req);
redis_client
.multi()
import express, { Application, Request, Response, NextFunction } from 'express';
import rateLimiter from './middleware/rateLimiter';
import bodyParser from 'body-parser';
const app: Application = express();
app.use(bodyParser.json());
app.get('/', rateLimiter, (req: Request, res: Response) => {
res.send('test');
interface Draggable {
dragStartHandler(event: DragEvent): void;
dragEndHandler(event: DragEvent): void;
}
interface DragTarget {
dragOverHandler(event: DragEvent): void;
dropHandler(event: DragEvent): void;
dragLeaveHandler(event: DragEvent): void;
}
import LoadingPlaceHolder from './LoadingPlaceHolder';
export default LoadingPlaceHolder;
import styled from 'styled-components';
export const S = {
PlaceHolderContainer: styled.div`
width: 100%;
min-height: 120px;
padding: 5px 10px;
display: flex;
flex-direction: column;
align-items: flex-start;
import { useEffect, useState } from 'react';
import axios from 'axios';
import { DCARD_POPULAR_POSTS_BASE_URL, API_POST_LIMIT } from '../constant/api';
export interface FetchPostHook {
loading: boolean;
error: boolean;
posts: any[];
hasMore: boolean;
export const size = {
mobileS: '320px',
mobileM: '375px',
mobileL: '425px',
mobileXL: '450px',
tablet: '768px',
}
export const device = {
mobileS: `(max-width: ${size.mobileS})`,