Skip to content

Instantly share code, notes, and snippets.

Avatar

Valerio Proietti kamicane

View GitHub Profile
@kamicane
kamicane / psx-controller-xinput.ino
Last active May 23, 2019
[psx-controller-xinput] PSX controller adapter to XInput with Arduino pro micro #arduino
View psx-controller-xinput.ino
// https://bitbucket.org/kamicane/psxpad/src/master/
#include <PSXPad.h>
// https://github.com/dmadison/ArduinoXInput
#include <XInput.h>
const int ATT_PIN = 9;
PSXPad* pad;
void setup() {
@kamicane
kamicane / promicro-sega-joystick.ino
Last active May 23, 2019
[Sega Joystick to DirectInput] #arduino
View promicro-sega-joystick.ino
#include <SegaController.h>
#include <Joystick.h>
#define USE_DEBUG 1
// Controller DB9 pins (looking face-on to the end of the plug):
//
// 5 4 3 2 1
// 9 8 7 6
View observer-component.js
import { Component } from 'react'
import { observe } from '@nx-js/observer-util'
export default class ObserverComponent extends Component {
componentWillMount () {
const render = this.render
const initialRender = (...args) => {
let result
@kamicane
kamicane / camelize.js
Last active May 23, 2019
[Clint 2] a command line parser
View camelize.js
'use strict'
const CAMEL_REGEXP = /[-_]+([A-z])/g
module.exports = function camelize (string) {
return string.replace(CAMEL_REGEXP, (full, match) => match.toUpperCase())
}
@kamicane
kamicane / color-conversion-algorithms.js
Last active Jan 16, 2017 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
View color-conversion-algorithms.js
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@kamicane
kamicane / README.md
Last active May 23, 2019
[async-sequence] a generator runner
View README.md

a generator runner. yield promises. be async.

View .requirebin-equation-stuff
an early version of equation-designer, demoed on requirebin
@kamicane
kamicane / index.js
Created May 14, 2015
requirebin sketch
View index.js
var Scene = require('three.cjs/scenes/Scene').Scene;
var PerspectiveCamera = require('three.cjs/cameras/PerspectiveCamera').PerspectiveCamera;
var BoxGeometry = require('three.cjs/extras/geometries/BoxGeometry').BoxGeometry;
var MeshBasicMaterial = require('three.cjs/materials/MeshBasicMaterial').MeshBasicMaterial;
var Mesh = require('three.cjs/objects/Mesh').Mesh;
var WebGLRenderer = require('three.cjs/renderers/WebGLRenderer').WebGLRenderer;
var scene, camera, renderer;
var geometry, material, mesh;
View gradient-solver.js
"use strict";
var rgb = require("rgb");
var lerp = function(from, to, delta) {
return (to - from) * delta + from;
};
var convertToPct = function(c, i) {
if (i === 3) return c;
View canvas-text.js
"use strict";
var fragmentText = function(ctx, lines, index, maxWidth) {
var line = lines[index];
var nextLine;
var tooLong = true;
while (tooLong) {
var width = ctx.measureText(line.join(" ")).width;