Skip to content

Instantly share code, notes, and snippets.

Avatar
🍽️
Cooking & Eating

Victor Ofoegbu vickOnRails

🍽️
Cooking & Eating
View GitHub Profile
@vickOnRails
vickOnRails / KMP.js
Last active Apr 5, 2020
Implementation of Knuth-Morris-Pratt string search algorithm in JavaScript
View KMP.js
// 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]
}
View json
[
{
"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 Sep 17, 2019
A little note taking app in ReactJs, styled components and TypeScript
View note-taking-styled.tsx
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;
`;
View app.tsx
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 Aug 20, 2019
An example of an app that notifies the user of offline and online states
View offline-indicator.html
<!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>
View view-without-layout_templating-hbs.hbs
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title> {{title}} </title>
<link rel='stylesheet' href='css/style.css'/>
</head>
<body>
Hello world
View main-layout-with-view_templating-hbs.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<!-- the {{home}} got replaced-->
<title> HOME </title>
<link rel='stylesheet' href='css/style.css'/>
</head>
<body>
View basic-hbs_templating-hbs.js
//requiring express and handlebars
//.create() method configures handlebars. We’ll explain that in a while
const express = require('express'),
  hbs = require('express-handlebars').create({defaultLayout: 'main', extname: 'hbs'});
  app = express();
//set the app engine to handlebars
app.engine('hbs', hbs.engine);
app.set('view engine','hbs');