Skip to content

Instantly share code, notes, and snippets.

View mengstr's full-sized avatar

Mats Engstrom mengstr

View GitHub Profile
@mengstr
mengstr / install-nginx.sh
Created November 10, 2010 05:50
Install and start nginx on $0.99 VpsTree.com Debian VPS
#!/bin/bash
##
## This script installs and start nginx with ssh & php support
##
## 2010-11-10 v1.0 Mats Engstrom - mats@smallroomlabs.com
## 2010-11-10 v1.1 Mats Engstrom - Fixed www-path
## 2010-11-10 v1.2 Mats Engstrom - Added ssl support & self signed cert
## 2010-11-10 v1.3 Mats Engstrom - Added delay before testing
##
@mengstr
mengstr / gitsetup.sh
Created January 21, 2011 04:04
Install git & gitosis on $0.99 VpsTree.com on Debian VPS
#!/bin/bash
##
## This script installs git/gitosis with mailed backups on a $0.99 Debian 5.0 server
##
## 2011-01-20 v1.0 Mats Engstrom (mats@smallroomlabs.com)
## 2011-01-25 v1.1 Mats - Added automated nightly backups
## 2011-01-26 v1.2 Mats - Removed some unnecessary services
##
#include <avr/pgmspace.h>
#include <Wire.h>
void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
int rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.send((int)(eeaddress >> 8)); // MSB
Wire.send((int)(eeaddress & 0xFF)); // LSB
Wire.send(rdata);
#include <avr/pgmspace.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#define ENDOFWORDLIST '~'
#define WORDDELIMITER ','
#define MAXWORDS 2284
#define EEDEVICE 0x50
@mengstr
mengstr / gist:976006
Created May 17, 2011 05:35
Chrome search engine for Element14
http://my.element14.com/jsp/search/browse.jsp?N=541&Ntk=gensearch_001&Ntt=%s&Ntx=mode+matchallpartial&suggestions=false&ref=globalsearch
@mengstr
mengstr / fanten.php
Created May 22, 2011 07:44
Generates an Eagle CAD script to place led's & resistors on a Fanten PCB
<?php
$size=10;
$step=2.54;
$leds=1;
echo "#Label aligment grid\r\n";
echo "\r\n";
@mengstr
mengstr / tm.sh
Created August 23, 2011 04:44
Open some tmux windows/panes and start apps in them
#!/bin/bash
SESSION=$USER
# if the session is already running, just attach to it.
tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
tmux attach -t $SESSION
exit 0;
fi
--
-- Prevent execution of the entrire script by mistake
--
raiserror('(MATS) This script must be run in separate parts...',20,-1) with log
set noexec on
go
------------------------------------------------------------------------------
@mengstr
mengstr / gist:7873791
Last active December 30, 2015 19:19
Pushed data doesn't show up until RPUSH XYZ "foo" is done from redis-cli
// https://github.com/mranney/node_redis 0.9.1
var redis=require("redis");
var rclient=redis.createClient();
// This RPUSH doesn't get available until I've RPUSH'ed
// something from the redis-cli
setInterval(function() {
rclient.rpush('XYZ','Interval',function(err,data) {
console.log('RPUSH');
if (err)console.dir(err);
@mengstr
mengstr / OpenSSHtunnel
Created January 9, 2014 05:03
Open a ssh tunnel from a machine behind a firewall to a ec2 server and make port 19999 on the ec2 server connected to port 22 on the firewalled machine.
status=$(netstat -a -W | grep ec2 | grep ap-southeast | grep ESTABLISHED)
if [ "$?" != "0" ]; then
ssh -f -N -R 19999:localhost:22 root@THE_SERVER_TO_CONNECT_TO
fi