Skip to content

Instantly share code, notes, and snippets.

@mjvo
mjvo / Input2p5js.ino
Last active March 7, 2019 12:13
Serial Input to P5.js - Arduino and p5js code
void setup() {
Serial.begin(9600); // initialize serial communications @ 9600
}
void loop() {
int potentiometer = analogRead(A0); // read the input pin
int mappedPot = map(potentiometer, 0, 1023, 0, 255); // remap the pot value to fit in 1 byte
//Serial.write(mappedPot); // write mappedPot value to the serial port (1 byte)
Serial.println(potentiometer); // *or* use println to print out raw potentiometer value with newline as data separator
delay(1); // slight delay to stabilize the ADC
@xmon
xmon / lg-editartgroup.js
Created December 21, 2016 20:56
Custom plugin for sachinchoolur/lightGallery
(function () {
'use strict';
var defaults = {
editArtGroup: true
};
var EditArtGroup = function (element) {
@gncgnc
gncgnc / resizeNN.js
Last active June 7, 2023 01:52
Extends p5.Image to handle nearest neighbor resizing for scaling small images (e.g. pixel art) without blurring. You can also make regular images into pixelated images by shrinking then growing them with this method (a la MS Paint.)
/**
* Resize the image to a new width and height using nearest neigbor algorithm. To make the image scale
* proportionally, use 0 as the value for the wide or high parameter.
* For instance, to make the width of an image 150 pixels, and change
* the height using the same proportion, use resize(150, 0).
* Otherwise same usage as the regular resize().
*
* Note: Disproportionate resizing squashes the "pixels" from squares to rectangles.
* This works about 10 times slower than the regular resize. Any suggestions for performance increase are welcome.
*/
@GoToLoop
GoToLoop / resizeNN.js
Last active June 6, 2023 18:11 — forked from gncgnc/resizeNN.js
Extends p5.Image to handle nearest neighbor resizing for scaling images w/o blurring.
/**
* Resize the image to a new width and height using nearest neighbor algorithm.
* To make the image scale proportionally,
* use 0 as the value for the wide or high parameters.
* For instance, to make the width of an image 150 pixels,
* and change the height using the same proportion, use resize(150, 0).
* Otherwise same usage as the regular resize().
*
* Note: Disproportionate resizing squashes "pixels" from squares to rectangles.
* This works about 10 times slower than the regular resize.
@arcanoix
arcanoix / index.html
Created October 27, 2017 17:59
VueJS Personality Quiz
<div id="app" v-cloak>
<div class="row">
<div class="large-12 columns">
<h1>{{ quiz.title }}</h1>
<div class="callout">
<div v-for="(question, index) in quiz.questions">
<!-- Hide all questions, show only the one with index === to current question index -->
@ditzel
ditzel / KdTree.cs
Last active March 11, 2025 12:50
k-d Tree
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Profiling;
public class KdTree<T> : IEnumerable<T>, IEnumerable where T : Component
{
protected KdNode _root;
protected KdNode _last;
@marufshidiq
marufshidiq / HOWTO.md
Created April 12, 2020 07:03
Backup and Restore mongodb inside docker-compose container

How to backup

docker-compose exec -T <mongodb_service_name> mongodump --archive --gzip --db <mongodb_database> > dump.gz

How to restore

docker-compose exec -T  mongorestore --archive --gzip &lt; dump.gz