Skip to content

Instantly share code, notes, and snippets.

View brianmugweru's full-sized avatar
🏠
Working from home

Brian Mugweru brianmugweru

🏠
Working from home
  • Nairobi Kenya
  • 04:02 (UTC +03:00)
View GitHub Profile
@brianmugweru
brianmugweru / gist:1cae2726c2b5e0e7cfd9f39dfe5dc210
Last active March 3, 2023 12:59
gql todolist setup and resolves
// DB DATA SOURCE
/** START OF DB DATA SOURCE **/
const { DataSource } = require("apollo-datasource");
const sqlite = require("sqlite3");
const createDatabase = () => {
return new Promise((resolve, reject) => {
const db = new sqlite.Database(process.env.DB_FILE_PATH, (err) => {
import { useState } from 'react';
export default function TodoList () {
const [todo, setTodo] = useState('')
const [todoList, setTodoList] = useState([])
const addTodo = () => {
if(!todo) return
setTodoList([...todoList, { text: todo, completed:false}])
setTodo('')
function WordSplit(strArr) {
const firstComparisonString = strArr[0]
const dictionaryItems = strArr[1].split(',')
let result = 'not possible'
for (let i = 0; i <= firstComparisonString.length; i++) {
const firstMatch = firstComparisonString.substring(0, i)
const lastMatch = firstComparisonString.substring(i, firstComparisonString.length)
if (dictionaryItems.includes(firstMatch) && dictionaryItems.includes(lastMatch)) {
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
@brianmugweru
brianmugweru / .vimrc
Created February 10, 2018 16:44 — forked from JeffreyWay/.vimrc
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15