Skip to content

Instantly share code, notes, and snippets.

View jamwaffles's full-sized avatar
💼
Hireable - Rust full time or part time

James Waples jamwaffles

💼
Hireable - Rust full time or part time
View GitHub Profile
@jamwaffles
jamwaffles / gist:4376dcda7644846543db
Last active August 29, 2015 14:07
tm-react-accordion howto
var React = require('react')
var Accordion = require('tm-react-accordion').Accordion
var Item = require('tm-react-accordion').Item
var AccordionHeader = require('tm-react-accordion').Header
var AccordionContent = require('tm-react-accordion').Content
React.renderComponent(
<Accordion className="custom-accordion-class">
<Item open={true} className="custom-item-class">
Backbone.$ = function(el) {
return {
on: function(eventName, handler) {
el.addEventListener(eventName, handler)
},
off: function() {
console.error("`off` isn't implemented. If you need to use this, implement it or you'll get memory leaks")
}
}
var s3 = require('gulp-s3');
var gzip = require('gulp-gzip')
gulp.task('s3-gzip', function() {
var assetsConf = {
key: "YOURAWSKEYHERE",
secret: "sTuPiDLongS3CretKey",
region: 'eu-west-1',
bucket: 'bucketName'
}
@jamwaffles
jamwaffles / class.rs
Created August 13, 2015 19:51
Rust "class" definition
struct Sprite {
image_data: SomeBinaryType,
width: i16,
height: i16
}
impl Sprite {
pub fn new(filename: str) -> Sprite {
// TOOD: Load image into a Piston/OpenGL texture
SPI1.setup({ baud:3200000, mosi: A7 });
var brightness = 0;
var delta = 1;
var maxBrightness = 250;
var numLeds = 12;
var data = new Uint8ClampedArray(numLeds * 3);
function sendFrame(data) {
/*
* jQuery fade/slide plugin to toggle/show/hide an element by fading then sliding it in/out
* If given new content, it will automatically refit itself, and show it
*
* By James Waples 2013
*
* Usage:
*
* $('.selector').fadeSlide('fast', function() { ... }) // Toggle, fast, run callback anonymous function
* $('.selector').fadeSlide(650, 'hide') // Fade out, slide hide in 650 msec
/* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. Modified by James Waples 2018 */
/*
Library for interfacing to the EspressIF ESP8266. Uses the 'NetworkJS'
library to provide a JS endpoint for HTTP.
For EspressIF ESP8266 firmware 0.25
*/
var at;
var socks = [];
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
app.use('/public', express.static(__dirname + '/public'));
@jamwaffles
jamwaffles / ImgurAPI.php
Created January 8, 2014 14:52
Imgur API class
<?php
namespace Model;
use RedBean_Facade as R;
class ImgurAPI extends \Pliers\Model {
protected $user;
protected $session;
public function __construct() {
//! Interface factory
//!
//! This is the easiest way to create a driver instance. You can set various parameters of the
//! driver and give it an interface to use. The builder will return a
//! [`mode::RawMode`](../mode/raw/struct.RawMode.html) object which you should coerce to a richer
//! display mode, like [mode::Graphics](../mode/graphics/struct.GraphicsMode.html) for drawing
//! primitives and text.
//!
//! # Examples
//!