Skip to content

Instantly share code, notes, and snippets.

View kenjinp's full-sized avatar
🏴󠁧󠁢󠁷󠁬󠁳󠁿

Kenneth Pirman kenjinp

🏴󠁧󠁢󠁷󠁬󠁳󠁿
View GitHub Profile
@kenjinp
kenjinp / db32.css
Last active June 17, 2023 16:04
db32 color palette implemented in css variables
:root {
--idx0: #000000;
--idx1: #222034;
--idx2: #45283c;
--idx3: #663931;
--idx4: #8f563b;
--idx5: #df7126;
--idx6: #d9a066;
--idx7: #eec39a;
--idx8: #fbf236;
@kenjinp
kenjinp / rapierHeightfieldsFromImage.ts
Created December 11, 2021 16:46
Create a Rapier Heightfield Collider from an Image (Heightmap)
import getPixels from "get-pixels";
import { max, min } from "lodash";
import { NdArray } from "ndarray";
import { Vector3 } from "three";
// Example, use like:
const makeHeightfieldColliderFromImage = async () => {
const heightMapTexture = "myimage.png";
const xSubdivisions = 200;
const zSubdivisions = 200;
@kenjinp
kenjinp / CapsuleBufferGeometry.ts
Last active October 24, 2021 14:41
A threejs capsule geometry! CapulseBufferGeometry: for creating capsules using threejs and typescript. Especially helpful for games
import * as THREE from "three";
import { BufferGeometry } from "three";
/**
* Capsule Geometry
* especially helpful in 3D games
* original creator:
* @author maximequiblier
*
* Modified for typescript (partially)
@kenjinp
kenjinp / templater.ts
Created November 2, 2020 08:13
Simple Templater Function
import { get } from 'lodash';
// will result in template parsing inside js-like template-string literals: ${ }
// for example ${myObject.name}
const templateStringExpression = /\${([^}]*)}/g;
const templater = (sourceObject: object, templateString: string) => {
return templateString.replace(
templateStringExpression,
@kenjinp
kenjinp / dice breakfthrough.gif
Last active June 22, 2019 13:16
Roll the dice!
dice breakfthrough.gif
@kenjinp
kenjinp / serverless.yml
Created August 24, 2017 14:03
serverless.yml with seed example
service: sg-platform-module-manager
custom:
serviceSlug: module-manager
dynamodb:
start:
seed: true
seed:
domain:
sources:
-
export const UserEdit = (props) => (
<Edit title="Edit User" {...props}>
<SimpleForm>
<DisabledInput source="_id" />
<TextInput source="username" />
<TextInput source="staffNumber" />
</SimpleForm>
</Edit>
);
/**
* Returns if the number is dense or not (averge of digits > 7)
* @param {int} int to test
* @returns {boolean}
*/
function isDenseNumber(int) {
let digitArray = []
let valDigits = 0
while (int) {
let digit = int % 10
@kenjinp
kenjinp / gist:2b7dcff3a21b34b39669cfddc3d44eb1
Created December 9, 2016 12:56
new spinner and overlay
<style>
.fullheight {
height: 200vw;
}
.bg-candy-stripes {
background: repeating-linear-gradient(
45deg,
#bdeaff,
#bdeaff 10px,
#1d9cd8 10px,
@kenjinp
kenjinp / gist:e48530866d6589eb4ac523742492115b
Created December 8, 2016 13:38
fantastic font awesome spins
.fa-spin {
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
.fa-pulse {
-webkit-animation: fa-spin 1s infinite steps(8);
animation: fa-spin 1s infinite steps(8);
}
@-webkit-keyframes fa-spin {
0% {