Skip to content

Instantly share code, notes, and snippets.

View vickonrails's full-sized avatar
🖥️
writing code

Victor Ofoegbu vickonrails

🖥️
writing code
View GitHub Profile
@vickonrails
vickonrails / KMP.js
Last active April 5, 2020 20:42
Implementation of Knuth-Morris-Pratt string search algorithm in JavaScript
// See notes at vickon.netlify.com/notes/algorithms-and-data-structures-day-3
let = longestPrefixSuffix => {
let table = new Array(pattern.length)
let pointer = 0
table[0] = 0
for (let i = 1; i < pattern.length; i++) {
while (pointer > 0 && pattern.charAt(i) !== pattern.charAt(pointer)) {
pointer = table[pointer - 1]
}
[
{
"code": 1,
"customerID": "5e6b803dc1a35b1ac6a7f855",
"businessName": "Utara",
"priceListCode": "PriceLevel2",
"status": "Active",
"emailAddress": "garrisonclarke@utara.com%",
"phoneNumber": "(988) 401-3964",
"category": "Goods",
@vickonrails
vickonrails / note-taking-styled.tsx
Last active September 17, 2019 20:05
A little note taking app in ReactJs, styled components and TypeScript
import React, { useState } from "react";
import styled from "styled-components";
import "./App.css";
// Styled components definitions for all components
const Header = styled.header`
// padding: 0.5em 1em;
`;
import React, { useState } from "react";
import styled from "styled-components";
import "./App.css";
// Styled components definitions for all components
const Header = styled.header``;
const Nav = styled.nav``;
const MainContent = styled.main``;
const Container = styled.div``;
@vickonrails
vickonrails / offline-indicator.html
Created August 20, 2019 13:46
An example of an app that notifies the user of offline and online states
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Offline/Online Demo</title>
<style>
//server.js
const http = require('http'),
url = require('url'),
makeServer = function (request,response){
let path = url.parse(request.url).pathname;
console.log(path);
if(path === '/'){
response.writeHead(200,{'Content-Type':'text/plain'});
response.write('Hello world');
const express = require('express'),
app = express();
//requiring the basic_router.js
app.use('/users',require('.react-router/basic_router'));
//routes
app.get('/posts/newpost',(request,response)=>{
response.send('new post');
});
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title> {{title}} </title>
<link rel='stylesheet' href='css/style.css'/>
</head>
<body>
Hello world
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<!-- the {{home}} got replaced-->
<title> HOME </title>
<link rel='stylesheet' href='css/style.css'/>
</head>
<body>