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
/*
* 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
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() {
@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">
@jamwaffles
jamwaffles / MergeGUI.md
Last active June 23, 2022 15:59
Graphical merge tool for resolving Git merge conflicts

Diff screenshot

Installation

  1. Download DiffMerge from here. It's not the prettiest merge tool but it works.

  2. Install it as usual

  3. Open up a console and run the following commands:

     git config --global merge.tool diffmerge
     git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
    
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) {
/* 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 = [];