Skip to content

Instantly share code, notes, and snippets.

@gregersrygg
gregersrygg / README.md
Last active July 28, 2020 17:01
Use a Raspberry Pi as a baby monitor

What you need:

  • Raspberry Pi RevB
  • Raspberry Pi NoIR camera

Download raspbian and install to SD-card. Here is a good guide on how to install the .img file to the card: https://www.andrewmunsell.com/blog/getting-started-raspberry-pi-install-raspbian

Connect ethernet or wifi, then boot the Raspberry Pi and follow configuration options. Make sure you enable the camera option.

When you get to the command-line:

@gregersrygg
gregersrygg / notify-install.sh
Last active August 29, 2015 14:00
Removed shebang to make it less than 140 bytes
echo -e 'S=${*:-`cat`}\n/usr/bin/osascript -e "display notification \"$S\""'|sudo -s "cd /usr/local/bin;tee notify&&chmod +x notify"
@gregersrygg
gregersrygg / deparam.js
Created October 30, 2012 15:38
Array reduce example to convert a query-string to parameter object (requires EcmaScript 5)
var queryString = "foo=bar&a=b%C3%B8";
var decode = decodeURIComponent;
var paramObj = queryString.split("&").reduce(function (obj, pair) {
var keyVal = pair.split("=");
var key = keyVal[0];
var val = keyVal[1];
obj[ decode(key) ] = decode(val);
return obj;
@gregersrygg
gregersrygg / gist:3899381
Created October 16, 2012 13:45
One-liner to random pick a meetup.com attendee from the RSVP list
// copy-paste into console
alert(Array.prototype.slice.call(document.querySelectorAll("#rsvp-list h5 a"),0).sort(function () { return Math.random() -0.5; })[0].innerText);
@gregersrygg
gregersrygg / gist:3892494
Created October 15, 2012 13:35
Detect MacBook Pro Retina display manufacturer. LP = LG, LSN = Samsung.
# Code from http://www.macrumors.com/2012/09/17/retina-macbook-pro-users-still-complaining-of-image-persistence/
ioreg -lw0 | grep \"EDID\" | sed "/[^<]*</s///" | xxd -p -r | strings -6
@gregersrygg
gregersrygg / fixTouch.js
Created October 3, 2012 17:52
Fix touch event bug in iOS 4 and Android 4.0 when page is scrolled
/* Fix touch event bug in iOS 4 and Android 4.0 when page is scrolled.
* This function will take a touch object (evt.touches[x]) and return
* an object litteral with corrected values for clientX and clientY.
*/
function fixTouch (touch) {
var winPageX = window.pageXOffset,
winPageY = window.pageYOffset,
x = touch.clientX,
y = touch.clientY;
@gregersrygg
gregersrygg / meetup-announce.js
Created October 27, 2011 15:42
Announce new meetup bookmarklet. Create a new bookmark, and use this as the url. Click on the bookmark when you're on the description page of the meetup you want to announce.
javascript:(function(){var%20l=location,p=l.pathname.split("/"),g=p[1],e=p[3],u="http://"+l.host+"/"+g+"/messages/send/?event_success=event_new&eventId="+e+"&action=edit&returnUri="+l.href;l.href=u;})();
@gregersrygg
gregersrygg / finn-extreme-startup.js
Created October 20, 2011 13:40
Unfinished nasty code for extreme startup
// My nasty code for extreme startup
// https://github.com/magnars/norsk-extreme-startup
var http = require('http');
var ip = "192.168.42.56";
var products = {
"epler": {
price: 5
},
"bananer": {
@gregersrygg
gregersrygg / fullscreen.html
Created July 18, 2011 22:13
Scroll away addressbar for fullscreen webapps
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
@gregersrygg
gregersrygg / fb-init-bug.html
Created June 20, 2011 20:50
Example to reproduce bug in FB.init
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style>
body {
margin: 0px;
}