Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
...

Charlie ⚡ charliewilco

🔥
...
View GitHub Profile
View checkDuplicates.js
const data = ["a", "b", "c", "d", "e", "e", "c"];
function checkDuplicates(data) {
const n = new Map();
for (let i = 0; i < data.length; i++) {
const element = data[i];
if (n.has(element)) {
return i;
}
View DarkMode.swift
import Cocoa
import SwiftUI
import ServiceManagement
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var statusBarItem: NSStatusItem!
View localstorage-mock.ts
interface StringTMap<T> {
[key: string]: T;
}
export function storageMock() {
let storage: StringTMap<string> = {};
return {
setItem(key: string, value: any) {
storage[key] = value || "";
View apollo-next.tsx
import * as React from "react";
import Head from "next/head";
import { ApolloProvider } from "@apollo/react-hooks";
import { ApolloClient } from "apollo-client";
import { InMemoryCache, NormalizedCacheObject } from "apollo-cache-inmemory";
import { HttpLink } from "apollo-link-http";
import fetch from "isomorphic-unfetch";
import { NextPage } from "next";
let apolloClient = null;
View hacker rank problems.ts
function countingValleys(n, s) {
let seaLevel = 0;
let currLevel = 0;
let valleys = 0;
s = s.split('');
for (let i = 0; i < s.length; i++) {
//update the current level
if (s[i] === 'U') {
currLevel += 1;
View duotone.ganymede.css
/*
Name: Duotone Ganymede
*/
:root {
--keyword: #3274a9;
--tag: #e2a500;
--prev-normal: #4a5f78;
--normal: #143550;
--script: #e56353;
@charliewilco
charliewilco / night-mode.js
Created Oct 12, 2018
Night Mode + Localstorage
View night-mode.js
import React from "react";
const Night = React.createContext({});
export class NightModeProvider extends React.Component {
static defaultProps = {
className: "NightMode"
};
state = {
View Dockerfile
FROM mhart/alpine-node:10
WORKDIR /usr/src/app
COPY package.json ./
# # add files to container
# ADD . /app
# # specify the working directory
View cookies.js
function NodeCookieParser(req) {
let cookies = {};
req.headers.cookie &&
req.headers.cookie.split(";").forEach(function(cookie) {
let parts = cookie.split("=");
cookies[parts[0].trim()] = (parts[1] || "").trim();
});
return cookies
}
View compose.js
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)))