Skip to content

Instantly share code, notes, and snippets.

@nickovs
nickovs / stepper.py
Last active November 14, 2023 22:07
A stepper motor driver for MicroPython
# stepper.py
# A micropython driver for 4-phase, unipolar stepper motors such as
# the 28BYJ-48
# Relesed to the Public Domain by Nicko van Someren, 2020
# The constructor for the Stepper class takes as arguments the four
# pins for driving the motor phases, in phase order, and optionally a
# timer. The pins can be passed as pin numbers or machine.Pin objects
@ofZach
ofZach / gist:d67d2ab2a0aa183b7d34f72263d5c5bd
Created November 27, 2017 07:44
looping 1d noise (tiling)
ofPolyline temp;
float ff = ofGetElapsedTimef();
for (int i = 0; i < 100; i++){
float angle = ofMap(i, 0, 100, 0, TWO_PI);
ofPoint pt= ofPoint(400,400);
float radius = 200 + ofSignedNoise(ff*0.1, cos(angle)*0.3, sin(angle)*0.3) * 100;
pt += radius * ofPoint(cos(angle), sin(angle));
temp.addVertex(pt);
}
temp.setClosed(true);
@Hebali
Hebali / GlslSobel.frag
Created January 12, 2017 17:25
GLSL Fragment Shader: Sobel Edge Detection
// Sobel Edge Detection Filter
// GLSL Fragment Shader
// Implementation by Patrick Hebron
uniform sampler2D texture;
uniform float width;
uniform float height;
void make_kernel(inout vec4 n[9], sampler2D tex, vec2 coord)
{
@bendavis78
bendavis78 / svg-template-support.js
Last active April 23, 2022 19:54
Polymer 1.0 suppoert for template inside svg
// Templates inside SVG won't work in polymer-1.0 without some monkeypatching.
(function(){
var doc = document.currentScript.ownerDocument;
var root = doc.querySelector('dom-module > template').content;
var templates = root.querySelectorAll('svg template');
var el, template, attribs, attrib, count, child, content;
for (var i=0; i<templates.length; i++) {
el = templates[i];
template = el.ownerDocument.createElement('template');
el.parentNode.insertBefore(template, el);
@creationix
creationix / init.lua
Last active November 1, 2019 11:13
Websocket server in nodemcu using new crypto module.
wifi.setmode(wifi.STATION)
wifi.sta.config("creationix","noderocks")
wifi.sta.connect()
tmr.alarm(0, 1000, 1, function ()
local ip = wifi.sta.getip()
if ip then
tmr.stop(0)
print(ip)
dofile("websocket.lc")
dofile("main.lc")
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@antiboredom
antiboredom / index.html
Created December 15, 2014 16:36
A simple example showing how to save animated gifs from p5.js sketches, using https://github.com/jnordberg/gif.js
<html>
<head>
<script src="gif.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/p5.js/0.3.11/p5.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/p5.js/0.3.11/addons/p5.dom.js"></script>
<script src="sketch.js"></script>
</head>
<body>
<p>First, allow camera access.<p><p>Then click once to start recording, and another time finish recording and make a gif.</p>
</body>
@paulobarcelos
paulobarcelos / gist:5d9d8c2859f85fc5749a
Created November 18, 2014 18:43
eu sou sou hacker
var sync = function(){console.log('sync')}
var leftPage = false
var t = 0;
var c = function(){
if((Date.now()-t) > 500){
leftPage=true
}
else if(leftPage){
leftPage=false; sync()
};
@murilopolese
murilopolese / yolo
Last active August 29, 2015 14:06
Yolo Deploy
#!/bin/bash
git add -A && git commit -m "yolo" && git push $1 $2
@rtgibbons
rtgibbons / post_test.js
Last active October 1, 2015 19:26
mocha test on Keystone Model
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
require('dotenv').load();
var keystone = require('keystone');
var chai = require('chai');
var dbURI = process.env.MONGO_URL
keystone.init({
'name': 'Post Model Test',
's3 config': {} //has to be set, but isn't used in our models