file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
internal/yaman/network/utils.go | Go | package network
import (
"net"
"strconv"
"strings"
)
// GetRandomPort returns a random (host) port if it finds one.
func GetRandomPort() (int, error) {
l, err := net.Listen("tcp", ":0")
if err != nil {
return 0, err
}
defer l.Close()
parts := strings.Split(l.Addr().String(), ":")
return strconv.Atoi(part... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/network/utils_test.go | Go | package network
import "testing"
func TestGetRandomPort(t *testing.T) {
port, err := GetRandomPort()
if err != nil {
t.Errorf("expected no error, got: %v", err)
}
if port < 1 {
t.Errorf("expected strictly positive port number, got: %d", port)
}
}
| willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/registry/http.go | Go | package registry
import (
"net/http"
)
type httpClient struct {
client *http.Client
token string
}
func newHttpClientWithAuthToken(token string) httpClient {
return httpClient{
client: http.DefaultClient,
token: token,
}
}
func (c *httpClient) Get(url string, headers map[string]string) (resp *http.Respon... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/registry/pull.go | Go | package registry
import (
"errors"
"fmt"
"io"
"io/fs"
"os"
"strings"
"github.com/willdurand/containers/internal/yaman/image"
)
type PullPolicy string
// PullOpts contains options for the pull operation.
type PullOpts struct {
Policy PullPolicy
Output io.Writer
}
const (
// PullAlways means that we always... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/registry/pull_test.go | Go | package registry
import (
"testing"
)
func TestParsePullPolicy(t *testing.T) {
for _, tc := range []struct {
value string
expected PullPolicy
err error
}{
{"always", PullAlways, nil},
{"missing", PullMissing, nil},
{"never", PullNever, nil},
{"", "", ErrInvalidPullPolicy},
{"invalid", "", E... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/registry/registry.go | Go | package registry
import (
"compress/gzip"
"encoding/json"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
"time"
"github.com/artyom/untar"
"github.com/opencontainers/go-digest"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"github.com/willdurand/containers/inter... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/shim/shim.go | Go | package shim
import (
"bufio"
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"io/ioutil"
"net"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
"syscall"
"time"
"github.com/sirupsen/logrus"
"github.com/willdurand/containers/internal/cli"
"g... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
internal/yaman/shim/utils.go | Go | package shim
import (
"bufio"
"fmt"
"io"
"os"
"sync"
)
func copyStd(s *os.File, w io.Writer, wg *sync.WaitGroup) {
defer wg.Done()
reader := bufio.NewReader(s)
for {
line, err := reader.ReadString('\n')
if err != nil {
break
}
fmt.Fprint(w, line)
}
}
| willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
tests/integration/base_helpers.bash | Shell | #!/usr/bin/env bash
load "../helpers/bats-support/load"
load "../helpers/bats-assert/load"
bats_require_minimum_version 1.5.0 | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
tests/integration/yacr/helpers.bash | Shell | #!/usr/bin/env bash
load '../base_helpers'
function run_yacr() {
run yacr "$@"
}
| willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
tests/integration/yacs/helpers.bash | Shell | #!/usr/bin/env bash
load '../base_helpers'
function run_yacs() {
run yacs "$@"
}
function get_state() {
local sock="$1"
run curl -s --unix-socket "$sock" http://shim/
assert_success
echo "$output"
} | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
tests/integration/yaman/helpers.bash | Shell | #!/usr/bin/env bash
load '../base_helpers'
TIMEOUT=30s
DOCKER_ALPINE=docker.io/library/alpine
DOCKER_HELLO_WORLD=docker.io/willdurand/hello-world
DOCKER_REDIS=docker.io/library/redis
QUAY_ALPINE=quay.io/aptible/alpine
function run_yaman() {
run timeout --foreground "$TIMEOUT" yaman "$@"
}
function run_yaman_and_... | willdurand/containers | 9 | 📦 This is a repository with some code I wrote to learn more about containers. | Go | willdurand | William Durand | mozilla |
docs/10.bootstrap.js | JavaScript | "use strict";(self.webpackChunkxpidump_webapp=self.webpackChunkxpidump_webapp||[]).push([[10],{194:(n,t,e)=>{e.a(n,(async(n,r)=>{try{e.d(t,{bi:()=>_.bi});var i=e(238),_=e(537),o=n([i]);i=(o.then?(await o)():o)[0],(0,_.oT)(i),r()}catch(n){r(n)}}))},537:(n,t,e)=>{let r;function i(n){r=n}e.d(t,{CF:()=>S,G2:()=>O,Je:()=>E,... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
docs/bootstrap.js | JavaScript | (()=>{var e,r,t,o,n,a,i={},s={};function p(e){var r=s[e];if(void 0!==r)return r.exports;var t=s[e]={id:e,loaded:!1,exports:{}};return i[e](t,t.exports,p),t.loaded=!0,t.exports}p.m=i,e="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",r="function"==typeof Symbol?Symbol("webpack exports"):"__webpack... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
docs/index.html | HTML | <!doctype html><html lang="en"><head><title>xpidump</title><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="stylesheet" href="https://unpkg.com/terminal.css@0.7.4/dist/terminal.min.css"/><style>pre, pre code {
background-color: var(--code-bg-color);
}
... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/lib.rs | Rust | //! A library to parse XPI files.
//!
//! # Example
//!
//! ```
//! use std::fs;
//! use xpidump::XPI;
//! use zip::ZipArchive;
//!
//! let mut archive = ZipArchive::new(
//! fs::File::open("tests/fixtures/dev-new.xpi").unwrap()
//! ).unwrap();
//! let xpi = XPI::new(&mut archive);
//!
//! println!("Add-on ID in the ... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/main.rs | Rust | use clap::Parser;
use std::{fs::File, path::PathBuf};
use xpidump::XPI;
use zip::ZipArchive;
#[derive(clap::ValueEnum, Clone)]
enum Format {
Text,
Json,
}
/// A simple tool to dump information about XPI files.
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Args {
/// The path to an... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/wasm_bindings.rs | Rust | use crate::{Environment, SignatureKind, XPI as InnerXPI};
use std::io::Cursor;
use wasm_bindgen::prelude::*;
use zip::ZipArchive;
// This file contains a thin layer to expose the `xpidump` information in a WASM environment.
#[wasm_bindgen]
pub struct XPI {
xpi: InnerXPI,
}
#[wasm_bindgen]
impl XPI {
#[wasm_b... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/xpi.rs | Rust | mod cose_ish;
mod manifest;
mod signatures;
use serde::{Deserialize, Serialize};
use std::{fmt, io};
use zip::ZipArchive;
pub use manifest::*;
pub use signatures::*;
#[derive(Debug, PartialEq, Deserialize, Serialize)]
/// Represents the recommendation state values.
pub enum RecommendationState {
#[serde(rename =... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/xpi/cose_ish.rs | Rust | use cms::cert::x509::{der::Decode, Certificate};
use minicbor::data::Int;
use minicbor::decode::Decoder;
use std::convert::From;
const COSE_SIGN_TAG: u64 = 98;
const COSE_ALG: u64 = 1;
const COSE_KID: u64 = 4;
pub enum CoseError {
InvalidTag,
UnexpectedType,
MalformedInput,
}
impl From<minicbor::decode::... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/xpi/manifest.rs | Rust | use json_comments::StripComments;
use serde::Serialize;
use std::{fmt, io};
use zip::ZipArchive;
#[derive(Default, Serialize)]
/// Represents the information contained in the `manifest.json` file.
pub struct Manifest {
present: bool,
/// The add-on ID found in the manifest, if any.
pub id: Option<String>,
... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
src/xpi/signatures.rs | Rust | use super::cose_ish::CoseSign;
use cms::cert::{
x509,
x509::{
attr::AttributeTypeAndValue,
certificate::TbsCertificateInner,
der::{
asn1::{PrintableStringRef, TeletexStringRef, UtcTime, Utf8StringRef},
Decode, Encode, Tag, Tagged,
},
Certificate,
... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
tests/xpi_test.rs | Rust | use std::io::Cursor;
use std::time::Duration;
use xpidump::{Date, Environment, RecommendationState, Signature, SignatureKind, XPI};
use zip::ZipArchive;
fn assert_signature(signature: &Signature, kind: SignatureKind, env: Environment, algorithm: &str) {
assert!(signature.exists());
assert_eq!(kind, signature.k... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
web/bootstrap.js | JavaScript | // A dependency graph that contains any wasm must all be imported
// asynchronously. This `bootstrap.js` file does the single async import, so
// that no one else needs to worry about it again.
import("./index.js").catch((e) =>
console.error("Error importing `index.js`:", e),
);
| willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
web/index.html | HTML | <!DOCTYPE html>
<html lang="en">
<head>
<title>xpidump</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/terminal.css@0.7.4/dist/terminal.min.css" />
<style>
pre, pre code {
background-... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
web/index.js | JavaScript | import * as xpidump from "xpidump";
const updateUI = (xpi) => {
const $outputPretty = document.getElementById("output-pretty");
const $outputRaw = document.getElementById("output-raw");
if (!xpi.has_manifest) {
$outputPretty.textContent = `⚠️ This file doesn't look like an add-on.`;
$outputRaw.textConte... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
web/webpack.config.js | JavaScript | const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const git_hash = require("child_process")
.execSync("git rev-parse HEAD")
.toString()
.trim();
module.exports = {
entry: "./bootstrap.js",
output: {
path: path.resolve(__dirname, "..", "docs"),
filename: "bootstr... | willdurand/xpidump | 8 | A simple tool to dump information about XPI files. | Rust | willdurand | William Durand | mozilla |
.eslintrc.js | JavaScript | module.exports = {
root: true,
env: {
browser: true,
amd: true,
node: true,
es6: true,
},
extends: [
'eslint:recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
'next',
'next/core-web-vitals',
],
rules: {
'prettier/prettier': 'error',
'reac... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Card.js | JavaScript | import Image from './Image'
import Link from './Link'
const Card = ({ title, description, imgSrc, href }) => (
<div className="p-4 md:w-1/2 md" style={{ maxWidth: '544px' }}>
<div className="h-full overflow-hidden border-2 border-gray-200 rounded-md border-opacity-60 dark:border-gray-700">
{href ? (
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Footer.js | JavaScript | import Link from './Link'
import siteMetadata from '@/data/siteMetadata'
import SocialIcon from '@/components/social-icons'
export default function Footer() {
return (
<footer>
<div className="flex flex-col items-center mt-16">
<div className="flex mb-3 space-x-4">
<SocialIcon kind="githu... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Image.js | JavaScript | import NextImage from 'next/image'
// eslint-disable-next-line jsx-a11y/alt-text
const Image = ({ ...rest }) => <NextImage {...rest} />
export default Image
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/LayoutWrapper.js | JavaScript | import siteMetadata from '@/data/siteMetadata'
import headerNavLinks from '@/data/headerNavLinks'
import Logo from '@/data/logo.svg'
import Link from './Link'
import SectionContainer from './SectionContainer'
import Footer from './Footer'
import MobileNav from './MobileNav'
import ThemeSwitch from './ThemeSwitch'
cons... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Link.js | JavaScript | /* eslint-disable jsx-a11y/anchor-has-content */
import Link from 'next/link'
const CustomLink = ({ href, ...rest }) => {
const isInternalLink = href && href.startsWith('/')
const isAnchorLink = href && href.startsWith('#')
if (isInternalLink) {
return (
<Link href={href}>
<a {...rest} />
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/MDXComponents.js | JavaScript | /* eslint-disable react/display-name */
import { useMemo } from 'react'
import { getMDXComponent } from 'mdx-bundler/client'
import Image from './Image'
import CustomLink from './Link'
import TOCInline from './TOCInline'
import Pre from './Pre'
export const MDXComponents = {
Image,
TOCInline,
a: CustomLink,
pr... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/MobileNav.js | JavaScript | import { useState } from 'react'
import Link from './Link'
import headerNavLinks from '@/data/headerNavLinks'
const MobileNav = () => {
const [navShow, setNavShow] = useState(false)
const onToggleNav = () => {
setNavShow((status) => {
if (status) {
document.body.style.overflow = 'auto'
} e... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/PageTitle.js | JavaScript | export default function PageTitle({ children }) {
return (
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-5xl md:leading-14">
{children}
</h1>
)
}
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Pagination.js | JavaScript | import Link from '@/components/Link'
export default function Pagination({ totalPages, currentPage }) {
const prevPage = parseInt(currentPage) - 1 > 0
const nextPage = parseInt(currentPage) + 1 <= parseInt(totalPages)
return (
<div className="pt-6 pb-8 space-y-2 md:space-y-5">
<nav className="flex just... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Pre.js | JavaScript | import { useState, useRef } from 'react'
const Pre = (props) => {
const textInput = useRef(null)
const [hovered, setHovered] = useState(false)
const [copied, setCopied] = useState(false)
const onEnter = () => {
setHovered(true)
}
const onExit = () => {
setHovered(false)
setCopied(false)
}
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/SEO.js | JavaScript | import Head from 'next/head'
import { useRouter } from 'next/router'
import siteMetadata from '@/data/siteMetadata'
export const PageSeo = ({ title, description }) => {
const router = useRouter()
return (
<Head>
<title>{`${title}`}</title>
<meta name="robots" content="follow, index" />
<meta ... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/SectionContainer.js | JavaScript | export default function SectionContainer({ children }) {
return <div className="max-w-3xl px-4 mx-auto sm:px-6 xl:max-w-5xl xl:px-0">{children}</div>
}
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/TOCInline.js | JavaScript | /**
* @typedef TocHeading
* @prop {string} value
* @prop {number} depth
* @prop {string} url
*/
/**
* Generates an inline table of contents
* Exclude titles matching this string (new RegExp('^(' + string + ')$', 'i')).
* If an array is passed the array gets joined with a pipe (new RegExp('^(' + array.join('|')... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/Tag.js | JavaScript | import Link from 'next/link'
import kebabCase from '@/lib/utils/kebabCase'
const Tag = ({ text }) => {
return (
<Link href={`/tags/${kebabCase(text)}`}>
<a className="mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400">
{text.split(' ').join('-')}... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/ThemeSwitch.js | JavaScript | import { useEffect, useState } from 'react'
import { useTheme } from 'next-themes'
const ThemeSwitch = () => {
const [mounted, setMounted] = useState(false)
const { theme, setTheme, resolvedTheme } = useTheme()
// When mounted on client, now we can show the UI
useEffect(() => setMounted(true), [])
return (... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/analytics/GoogleAnalytics.js | JavaScript | import Script from 'next/script'
import siteMetadata from '@/data/siteMetadata'
const GAScript = () => {
return (
<>
<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${siteMetadata.analytics.googleAnalyticsId}`}
/>
<Script strategy="lazyOnload">
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/analytics/Plausible.js | JavaScript | import Script from 'next/script'
import siteMetadata from '@/data/siteMetadata'
const PlausibleScript = () => {
return (
<>
<Script
strategy="lazyOnload"
data-domain={siteMetadata.analytics.plausibleDataDomain}
src="https://plausible.io/js/plausible.js"
/>
<Script strat... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/analytics/SimpleAnalytics.js | JavaScript | import Script from 'next/script'
const SimpleAnalyticsScript = () => {
return (
<>
<Script strategy="lazyOnload">
{`
window.sa_event=window.sa_event||function(){var a=[].slice.call(arguments);window.sa_event.q?window.sa_event.q.push(a):window.sa_event.q=[a]};
`}
</Script>
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/analytics/index.js | JavaScript | import GA from './GoogleAnalytics'
import Plausible from './Plausible'
import SimpleAnalytics from './SimpleAnalytics'
import siteMetadata from '@/data/siteMetadata'
const isProduction = process.env.NODE_ENV === 'production'
const Analytics = () => {
return (
<>
{isProduction && siteMetadata.analytics.pla... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/comments/Disqus.js | JavaScript | import React, { useState } from 'react'
import siteMetadata from '@/data/siteMetadata'
const Disqus = ({ frontMatter }) => {
const [enableLoadComments, setEnabledLoadComments] = useState(true)
const COMMENTS_ID = 'disqus_thread'
function LoadComments() {
setEnabledLoadComments(false)
window.disqus_co... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/comments/Giscus.js | JavaScript | import React, { useState } from 'react'
import { useTheme } from 'next-themes'
import siteMetadata from '@/data/siteMetadata'
const Giscus = ({ mapping }) => {
const [enableLoadComments, setEnabledLoadComments] = useState(true)
const { theme, resolvedTheme } = useTheme()
const commentsTheme =
siteMetadata.c... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/comments/Utterances.js | JavaScript | import React, { useState } from 'react'
import { useTheme } from 'next-themes'
import siteMetadata from '@/data/siteMetadata'
const Utterances = ({ issueTerm }) => {
const [enableLoadComments, setEnabledLoadComments] = useState(true)
const { theme, resolvedTheme } = useTheme()
const commentsTheme =
theme ==... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/comments/index.js | JavaScript | import siteMetadata from '@/data/siteMetadata'
import dynamic from 'next/dynamic'
const UtterancesComponent = dynamic(
() => {
return import('@/components/comments/Utterances')
},
{ ssr: false }
)
const GiscusComponent = dynamic(
() => {
return import('@/components/comments/Giscus')
},
{ ssr: false... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
components/social-icons/index.js | JavaScript | import Mail from './mail.svg'
import Github from './github.svg'
import Facebook from './facebook.svg'
import Youtube from './youtube.svg'
import Linkedin from './linkedin.svg'
import Instagram from './instagram.svg'
import OpenStreetMap from './openstreetmap.svg'
import Rss from './rss.svg'
import Twitter from './twitt... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
css/tailwind.css | CSS | @tailwind base;
@tailwind components;
@tailwind utilities;
.remark-code-title {
@apply px-5 py-3 font-mono text-sm font-bold text-gray-200 bg-gray-700 rounded-t;
}
.remark-code-title + div > pre {
@apply mt-0 rounded-t-none;
}
.task-list-item:before {
@apply hidden;
}
.code-line {
@apply pl-4 -mx-4 border-l... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
data/headerNavLinks.js | JavaScript | const headerNavLinks = [
{ href: '/blog', title: 'Blog' },
// { href: '/tags', title: 'Tags' },
{ href: '/projects', title: 'Projects' },
{ href: '/about', title: 'About' },
]
export default headerNavLinks
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
data/projectsData.js | JavaScript | const projectsData = [
{
title: 'OSMCha',
description: `An OpenStreetMap validation tool. OSMCha registers all changesets
created on OSM, provides a good visualization and run some analysis in order to flag
possibly bad edits. Mapbox, Facebook, Apple and the OSM community uses OSMCha
to keep track... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
data/siteMetadata.js | JavaScript | const siteMetadata = {
title: 'Wille',
author: 'Wille Marcel',
headerTitle: 'Wille',
description: 'Software engineering, maps & other thoughts',
language: 'en-gb',
siteUrl: 'https://wille.me',
siteRepo: 'https://github.com/willemarcel/wille.blog',
image: '/static/images/avatar.jpg',
head: '/static/ima... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
layouts/AuthorLayout.js | JavaScript | import SocialIcon from '@/components/social-icons'
import Image from '@/components/Image'
import { PageSeo } from '@/components/SEO'
export default function AuthorLayout({ children, frontMatter }) {
const {
name,
avatar,
occupation,
company,
instagram,
twitter,
linkedin,
openstreetmap... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
layouts/ListLayout.js | JavaScript | import Link from '@/components/Link'
import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
import { useState } from 'react'
import Pagination from '@/components/Pagination'
import formatDate from '@/lib/utils/formatDate'
export default function ListLayout({ posts, title, initialDisplayPosts... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
layouts/PostLayout.js | JavaScript | import Link from '@/components/Link'
import PageTitle from '@/components/PageTitle'
import SectionContainer from '@/components/SectionContainer'
import { BlogSeo } from '@/components/SEO'
import Image from '@/components/Image'
import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
import Comm... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
layouts/PostSimple.js | JavaScript | import Link from '@/components/Link'
import PageTitle from '@/components/PageTitle'
import SectionContainer from '@/components/SectionContainer'
import { BlogSeo } from '@/components/SEO'
import siteMetadata from '@/data/siteMetadata'
import formatDate from '@/lib/utils/formatDate'
import Comments from '@/components/co... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/generate-rss.js | JavaScript | import { escape } from '@/lib/utils/htmlEscaper'
import siteMetadata from '@/data/siteMetadata'
const generateRssItem = (post) => `
<item>
<guid>${siteMetadata.siteUrl}/blog/${post.slug}</guid>
<title>${escape(post.title)}</title>
<link>${siteMetadata.siteUrl}/blog/${post.slug}</link>
${post.summary... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/img-to-jsx.js | JavaScript | const visit = require('unist-util-visit')
const sizeOf = require('image-size')
const fs = require('fs')
module.exports = (options) => (tree) => {
visit(
tree,
// only visit p tags that contain an img element
(node) => node.type === 'paragraph' && node.children.some((n) => n.type === 'image'),
(node) ... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/mdx.js | JavaScript | import { bundleMDX } from 'mdx-bundler'
import fs from 'fs'
import matter from 'gray-matter'
import path from 'path'
import readingTime from 'reading-time'
import visit from 'unist-util-visit'
import codeTitles from './remark-code-title'
import remarkTocHeadings from './remark-toc-headings'
import imgToJsx from './img-... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/remark-code-title.js | JavaScript | import visit from 'unist-util-visit'
module.exports = function (options) {
return (tree) =>
visit(tree, 'code', (node, index) => {
const nodeLang = node.lang || ''
let language = ''
let title = ''
if (nodeLang.includes(':')) {
language = nodeLang.slice(0, nodeLang.search(':'))
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/remark-toc-headings.js | JavaScript | import visit from 'unist-util-visit'
module.exports = function (options) {
return (tree) =>
visit(tree, 'heading', (node, index, parent) => {
options.exportRef.push({
value: node.children[1].value,
url: node.children[0].url,
depth: node.depth,
})
})
}
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/tags.js | JavaScript | import fs from 'fs'
import matter from 'gray-matter'
import path from 'path'
import { getFiles } from './mdx'
import kebabCase from './utils/kebabCase'
const root = process.cwd()
export async function getAllTags(type) {
const files = await getFiles(type)
let tagCount = {}
// Iterate through each post, putting ... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/utils/files.js | JavaScript | import fs from 'fs'
import path from 'path'
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x)
const flattenArray = (input) =>
input.reduce((acc, item) => [...acc, ...(Array.isArray(item) ? item : [item])], [])
const map = (fn) => (input) => input.map(fn)
const walkDir = (fullPath) => {
return fs.sta... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/utils/formatDate.js | JavaScript | import siteMetadata from '@/data/siteMetadata'
const formatDate = (date) => {
const options = {
year: 'numeric',
month: 'long',
day: 'numeric',
}
const now = new Date(date).toLocaleDateString(siteMetadata.locale, options)
return now
}
export default formatDate
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/utils/htmlEscaper.js | JavaScript | const { replace } = ''
// escape
const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g
const ca = /[&<>'"]/g
const esca = {
'&': '&',
'<': '<',
'>': '>',
"'": ''',
'"': '"',
}
const pe = (m) => esca[m]
/**
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
* @para... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
lib/utils/kebabCase.js | JavaScript | const kebabCase = (str) =>
str &&
str
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
.map((x) => x.toLowerCase())
.join('-')
export default kebabCase
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
next.config.js | JavaScript | const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({
reactStrictMode: true,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
eslint: {
dirs: ['pages', 'components', 'lib', 'layouts', 'scripts'],
},
webpack: (config, {... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/404.js | JavaScript | import Link from '@/components/Link'
export default function FourZeroFour() {
return (
<div className="flex flex-col items-start justify-start md:justify-center md:items-center md:flex-row md:space-x-6 md:mt-24">
<div className="pt-6 pb-8 space-x-2 md:space-y-5">
<h1 className="text-6xl font-extrab... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/_app.js | JavaScript | import '@/css/tailwind.css'
import { ThemeProvider } from 'next-themes'
import Head from 'next/head'
import Analytics from '@/components/analytics'
import LayoutWrapper from '@/components/LayoutWrapper'
export default function App({ Component, pageProps }) {
return (
<ThemeProvider attribute="class">
<He... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/_document.js | JavaScript | import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head>
<link rel="apple-touch-icon" sizes="76x76" href="/static/favicons/apple-touch-icon.png" />
<link
rel="icon"
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/about.js | JavaScript | import { MDXLayoutRenderer } from '@/components/MDXComponents'
import { getFileBySlug } from '@/lib/mdx'
const DEFAULT_LAYOUT = 'AuthorLayout'
export async function getStaticProps() {
const authorDetails = await getFileBySlug('authors', ['default'])
return { props: { authorDetails } }
}
export default function A... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/blog.js | JavaScript | import { getAllFilesFrontMatter } from '@/lib/mdx'
import siteMetadata from '@/data/siteMetadata'
import ListLayout from '@/layouts/ListLayout'
import { PageSeo } from '@/components/SEO'
export const POSTS_PER_PAGE = 5
export async function getStaticProps() {
const posts = await getAllFilesFrontMatter('blog')
con... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/blog/[...slug].js | JavaScript | import fs from 'fs'
import PageTitle from '@/components/PageTitle'
import generateRss from '@/lib/generate-rss'
import { MDXLayoutRenderer } from '@/components/MDXComponents'
import { formatSlug, getAllFilesFrontMatter, getFileBySlug, getFiles } from '@/lib/mdx'
const DEFAULT_LAYOUT = 'PostLayout'
export async functi... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/blog/page/[page].js | JavaScript | import { PageSeo } from '@/components/SEO'
import siteMetadata from '@/data/siteMetadata'
import { getAllFilesFrontMatter } from '@/lib/mdx'
import ListLayout from '@/layouts/ListLayout'
import { POSTS_PER_PAGE } from '../../blog'
export async function getStaticPaths() {
const totalPosts = await getAllFilesFrontMatt... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/index.js | JavaScript | import Link from '@/components/Link'
import { PageSeo } from '@/components/SEO'
import siteMetadata from '@/data/siteMetadata'
import { getAllFilesFrontMatter } from '@/lib/mdx'
import formatDate from '@/lib/utils/formatDate'
const MAX_DISPLAY = 5
export async function getStaticProps() {
const posts = await getAllF... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/projects.js | JavaScript | import siteMetadata from '@/data/siteMetadata'
import projectsData from '@/data/projectsData'
import Card from '@/components/Card'
import { PageSeo } from '@/components/SEO'
export default function Projects() {
return (
<>
<PageSeo title={`Projects - ${siteMetadata.author}`} description={siteMetadata.descr... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/tags.js | JavaScript | import Link from '@/components/Link'
import { PageSeo } from '@/components/SEO'
import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
import { getAllTags } from '@/lib/tags'
import kebabCase from '@/lib/utils/kebabCase'
export async function getStaticProps() {
const tags = await getAllTag... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
pages/tags/[tag].js | JavaScript | import { PageSeo } from '@/components/SEO'
import siteMetadata from '@/data/siteMetadata'
import ListLayout from '@/layouts/ListLayout'
import generateRss from '@/lib/generate-rss'
import { getAllFilesFrontMatter } from '@/lib/mdx'
import { getAllTags } from '@/lib/tags'
import kebabCase from '@/lib/utils/kebabCase'
im... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
postcss.config.js | JavaScript | module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
prettier.config.js | JavaScript | module.exports = {
semi: false,
singleQuote: true,
printWidth: 100,
tabWidth: 2,
useTabs: false,
trailingComma: 'es5',
bracketSpacing: true,
}
| willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
scripts/compose.js | JavaScript | const fs = require('fs')
const path = require('path')
const inquirer = require('inquirer')
const dedent = require('dedent')
const root = process.cwd()
const getAuthors = () => {
const authorPath = path.join(root, 'data', 'authors')
const authorList = fs.readdirSync(authorPath).map((filename) => path.parse(filenam... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
scripts/generate-sitemap.js | JavaScript | const fs = require('fs')
const globby = require('globby')
const prettier = require('prettier')
const siteMetadata = require('../data/siteMetadata')
;(async () => {
const prettierConfig = await prettier.resolveConfig('./.prettierrc.js')
const pages = await globby([
'pages/*.js',
'data/blog/**/*.mdx',
'd... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
tailwind.config.js | JavaScript | const defaultTheme = require('tailwindcss/defaultTheme')
const colors = require('tailwindcss/colors')
module.exports = {
mode: 'jit',
purge: ['./pages/**/*.js', './components/**/*.js', './layouts/**/*.js', './lib/**/*.js'],
darkMode: 'class',
theme: {
extend: {
spacing: {
'9/16': '56.25%',
... | willemarcel/wille.blog | 1 | Personal blog | JavaScript | willemarcel | Wille Marcel | developmentseed |
project/lit_image_classifier.py | Python | from argparse import ArgumentParser
import os
import torch
import pytorch_lightning as pl
from pytorch_lightning.metrics import functional as PLF
from torch.nn import functional as F
from flash.vision import ImageClassificationData
from torchvision import transforms
from torchvision import models
import numpy as np
... | williamFalcon/cifar5 | 5 | Python | williamFalcon | William Falcon | Lightning AI | |
setup.py | Python | #!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='project',
version='0.0.0',
description='Describe Your Cool Project',
author='',
author_email='',
# REPLACE WITH YOUR OWN GITHUB PROJECT LINK
url='https://github.com/PyTorchLightning/pytorch-lightning-conference-... | williamFalcon/cifar5 | 5 | Python | williamFalcon | William Falcon | Lightning AI | |
cifar5.py | Python | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from flash.image import ImageClassificationData, ImageClassifier
import argparse
from pytorch_lightning import seed_everything
from flash import Trainer
from pytorch_lightning.callbacks import LearningRateMonitor
from pytor... | williamFalcon/cifar5-simple | 0 | Python | williamFalcon | William Falcon | Lightning AI | |
image_plotting_callback.py | Python | from matplotlib.pyplot import imshow, figure
import numpy as np
from torchvision.utils import make_grid
from pl_bolts.transforms.dataset_normalizations import cifar10_normalization
import pytorch_lightning as pl
import torch
class ImageSampler(pl.Callback):
def __init__(self):
super().__init__()
s... | williamFalcon/pytorch-lightning-vae | 211 | VAE for color images | Python | williamFalcon | William Falcon | Lightning AI |
vae.py | Python | import pytorch_lightning as pl
pl.seed_everything(1234)
from torch import nn
import torch
from pl_bolts.models.autoencoders.components import (
resnet18_decoder,
resnet18_encoder,
)
from pl_bolts.datamodules import CIFAR10DataModule, ImagenetDataModule
from image_plotting_callback import ImageSampler
from argpa... | williamFalcon/pytorch-lightning-vae | 211 | VAE for color images | Python | williamFalcon | William Falcon | Lightning AI |
babel.config.js | JavaScript | module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
}
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
generators/plopfile.js | JavaScript | module.exports = (plop) => {
plop.setGenerator('kata', {
description: 'Create a kata',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your kata exercise name? Without spaces and symbols.',
},
],
actions: [
{
type: 'add',
path: '../... | willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
jest.config.js | JavaScript | /*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where ... | willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
src/01-square-digits/index.ts | TypeScript | export default function squareDigits(num: number) {
return +num
.toString()
.split('')
.map((n) => Math.pow(+n, 2))
.join('')
}
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
src/01-square-digits/test.ts | TypeScript | import squareDigits from '.'
describe('squareDigits', () => {
it('should square digits and concatenate', () => {
expect(squareDigits(9119)).toBe(811181)
expect(squareDigits(0)).toBe(0)
})
})
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
src/02-smallest-number/index.ts | TypeScript | export default function smallestNumber(numbers: number[]) {
return Math.min(...numbers)
}
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
src/02-smallest-number/test.ts | TypeScript | import smallestNumber from '.'
describe('02-smallest-number', () => {
it('should return the smallest number', () => {
expect(smallestNumber([34, 15, 88, 2])).toBe(2)
expect(smallestNumber([34, -345, -1, 100])).toBe(-345)
})
})
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen | |
src/03-even-or-odd/index.ts | TypeScript | export default function evenOrOdd(n: number): string {
return n % 2 === 0 ? 'Even' : 'Odd'
}
| willianjusten/kata-playground-ts | 22 | A simple playground to create and test your Katas in Typescript. | JavaScript | willianjusten | Willian Justen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.