Skip to content

Instantly share code, notes, and snippets.

View attilagyorffy's full-sized avatar
🦜
A UDP packet bar walks a into...

Attila Györffy attilagyorffy

🦜
A UDP packet bar walks a into...
View GitHub Profile
# Free RESTful interface for your Ruby objects with Rackable
# http://github.com/madx/rackable/tree/master
#
# + Free HTTP caching with rack-cache
# http://github.com/rtomayko/rack-cache/tree/master
require 'rackable'
require 'rack/cache'
APP_ROOT = File.dirname(__FILE__)
/* Ismael Celis 2010
Simplified WebSocket events dispatcher (no channels, no users)
var socket = new ServerEventsDispatcher();
// bind to server events
socket.bind('some_event', function(data){
alert(data.name + ' says: ' + data.message)
});
@attilagyorffy
attilagyorffy / ba-ghettotmpl.js
Created June 11, 2011 18:45 — forked from cowboy/ba-ghettotmpl.js
Ghetto fabulous templating system. More ghetto than fabulous.
// Ghetto fabulous template system for replacing values in strings. If {{.foo}}
// or {{.bar[0].baz}} is encountered (leading . or ( or [ char), attempt to
// access properties of data object like `data.foo` or `data.bar[0].baz`.
// Alternately, if {{foo}} or {{bar("baz")}} is encountered (no leading dot),
// simply evaluate `foo` or `bar("baz")`. If an error occurs, return empty
// string. Oh yeah, you have to pass the result of ghettoTmpl to eval. :)
function ghettoTmpl(data, str) {
ghettoTmpl._data = data;
ghettoTmpl._str = str;
@attilagyorffy
attilagyorffy / jquery.support.cssproperty.js
Created July 28, 2011 14:06 — forked from jackfuchs/jquery.support.cssproperty.js
Extends the jQuery.support object to CSS Properties
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported (or any of its browser-specific implementations)
*
* @param string p - css property name
* [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
*
* @Author: Axel Jack Fuchs (Cologne, Germany)
* @Date: 08-29-2010 18:43
*
@attilagyorffy
attilagyorffy / gist:1351966
Created November 9, 2011 16:24 — forked from attaboy/gist:1346280
Destroy the localStorage copy of less.js client-side-generated CSS
// Destroys the localStorage copy of CSS that less.js creates
function destroyLessCache(pathToCss) { // e.g. '/css/' or '/stylesheets/'
if (!window.localStorage || !less || less.env !== 'development') {
return;
}
var host = window.location.host;
var protocol = window.location.protocol;
var keyPrefix = protocol + '//' + host + pathToCss;
@attilagyorffy
attilagyorffy / rmate
Created January 23, 2012 13:48 — forked from leon/rmate
Setup TextMate's ssh rmate function
#!/usr/bin/env ruby
# encoding: UTF-8
$VERBOSE = true # -w
$KCODE = "U" if RUBY_VERSION < "1.9" # -KU
require 'optparse'
require 'socket'
require 'fileutils'
#!/bin/sh
### BEGIN INIT INFO
# Provides: mpd-autoplay
# Required-Start: mpd
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@attilagyorffy
attilagyorffy / gist:9a80aadd7250d6c967ae9e08b5d18400
Created December 11, 2016 19:23 — forked from brandonb927/gist:4149074
Javascript: Async Gist loading
/**
* Shamelessly stolen from http://blog.jeansebtr.com/post/36590722386/async-loading-of-githubs-gists-without-jquery-31-loc
*
* Use like this: <gist data-username="brandonb927" data-id="4138162" data-file="gists2.js"><a href="https://gist.github.com/brandonb927/4138162#file_gists2.js">Gist</a></gist>
* UPDATED 02/06/2013: Github implemented Namespaced Gists a few hours ago, which means gist.github.com/4149074 now redirects to gist.github.com/brandonb927/4149074 and I have updated the gist to reflect this new format
*
*/
(function(){
var gists = document.getElementsByTagName('gist');
@attilagyorffy
attilagyorffy / gist:5def7f6677e027ea421e933380698067
Created September 18, 2017 21:14 — forked from ChickenProp/gist:3183960
Expanding the Raspberry Pi's GPIO capabilities with the MCP23017

Introduction

The MCP23017 is an I/O expander chip. It has 16 GPIO pins which you can control using an I2C interface using two pins from a Raspberry Pi, plus a power source and sink (which can also come from the Pi). It's not quite as simple as directly controlling the Pi's GPIO pins, but it's not complicated, either.

You need to install i2c-tools, which is probably in your distribution's package manager. You also need a kernel with I2C support; you might need to modprobe i2c-dev. It would presumably be possible to do without either of these things, and bitbang the I2C protocol over GPIO, but I don't understand the protocol well enough to try.

On pin numbering: if you like, you can refer to the datasheet for the MCP23017. There's a small dot in one corner of the chip, with a semi-circular cut-out at that end. The pin near

@attilagyorffy
attilagyorffy / gist:66552d48dd6f281b6c3a335f1d184074
Created January 27, 2018 11:40
Connect to Neo Air (or anything really) over serial. On a windows machine.

For Windows:

  • Download and install Putty

  • Connect your USB to UART adapter from your computer to your Nano Pi Neo Air (or any COM device)

  • Make sure you connect TX>RX and RX>TX (Sending/Receiving), otherwise both your devices are talking at the same time and neither one is being heard.

  • On Windows OS, pull up the Device Manager

    • Run Windows (WinKey+R) and type in devmgmt.msc