Skip to content

Instantly share code, notes, and snippets.

View kristianpedersen's full-sized avatar

Kristian Pedersen kristianpedersen

View GitHub Profile
@kristianpedersen
kristianpedersen / test.md
Last active September 6, 2021 19:18
JS works, Clojure logs empty list

Hi! Given a chess board position, I want to return all moves that have a distance of (x = 1 and y = 2) or (x = 2 and y = 1).

I have solved this in JavaScript, and I'm trying to implement it in Clojure, but my Clojure function just returns an empty list (). What am I missing?

Also, if you have any comments on readability or making the code more idiomatic, that's of course appreciated.

Here they are - first the JavaScript implementation, and then the Clojure one:

const originalBoard = [
import './App.css'
import { useEffect, useState } from "react"
import axios from "axios"
// In package.json, add:
// "proxy": "http://api.wolframalpha.com/v2",
const BASE = "/query?input=pi&appid="
const APP_ID = "W766VX-QK99987KQ6"
const URL = BASE + APP_ID
import clock from "../img/clock.svg"
import diaphragm from "../img/diaphragm.svg"
import money from "../img/money.svg"
import teamwork from "../img/teamwork.svg"
const cards = [
{ icon: clock, h1Text: "Efficient", pText: "So efficient!" },
{ icon: teamwork, h1Text: "Teamwork", pText: "Such teamwork" },
{ icon: diaphragm, h1Text: "Diaphragm", pText: "Diaphphgraprhagm" },
@kristianpedersen
kristianpedersen / propsWithSameNameAsValue.js
Last active November 11, 2020 21:48
If prop name and value are the same
// Boring :c
{songs.map(song => <LibrarySong setCurrentSong={setCurrentSong} song={song} />)}
// Fun and cool! :D
{songs.map(song => <LibrarySong {...{ setCurrentSong, song }} />)}

sudo nano /etc/hosts

Add this line:

104.16.110.30 registry.npmjs.org npmjs.org registry.npmjs.com npmjs.com

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
width: 100vw;
const httpIP = "http://172.20.66.181"
const app = require('express')()
const axios = require("axios")
const exec = require("child_process").exec
const http = require('http').createServer(app)
const io = require('socket.io')(http)
app.get('/', function serveIndexHtml(_, res) {
res.sendFile(__dirname + '/index.html')
@kristianpedersen
kristianpedersen / Raspberry-Pi-Keep-Screen-On.md
Created April 29, 2020 10:03
Raspberry Pi: Keep screen turned on

sudo apt-get update

sudo apt-get install xscreensaver

xscreensaver

Mode: "Disable screen saver"

@kristianpedersen
kristianpedersen / index.md
Last active April 29, 2020 09:04
Raspberry Pi: Install node.js

sudo apt-get update

sudo apt-get dist-upgrade

curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -

sudo apt-get install -y nodejs

@kristianpedersen
kristianpedersen / index.md
Last active November 10, 2020 07:58
Raspberry Pi: Launch script on startup