Skip to content

Instantly share code, notes, and snippets.

View synaptiko's full-sized avatar

Jiří Prokop synaptiko

View GitHub Profile
@synaptiko
synaptiko / mount-sshfs.sh
Last active December 11, 2015 06:18
Simple shell script for un/mounting over SSH. Usage: ./mount-sshf <USER> <SERVER> [kill] It uses xclip command to copy and run command "cd <MOUNTED_DIR>" directly in terminal.
#!/bin/sh
if [ $# -ge 2 ]; then
USER=$1
SERVER=$2
DIR=${MOUNT_SSHFS__ROOT_DIR:-/var/tmp/mount-sshfs}/$SERVER
# it's possible to use primary or clip
XCLIP_SEL_MODE=${MOUNT_SSHFS__XCLIP_SEL_MODE:-primary}
if [ -d $DIR ]; then
if [ $# -eq 3 -a "$3" = "kill" ]; then
#!/bin/bash
DATE=`date +"%Y%m%d%H%M%S"`
INSTALL_DIR=node_${DATE}
mkdir $INSTALL_DIR
cd $INSTALL_DIR
curl http://nodejs.org/dist/node-latest.tar.gz | tar xzv --strip-components=1
export JOBS=2
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
@synaptiko
synaptiko / qr-code.html
Last active December 14, 2015 11:59
Simple QR code appender. Adds to QR code to page according to content of div with class qr-code.
<meta http-equiv="content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-Language" content="cs" />
<style>
div.qr-code {
clear: left;
}
img.qr-code {
float: left;
margin-bottom: 50px;
}
@synaptiko
synaptiko / Classes.coffee
Last active December 14, 2015 18:38
Two interesting examples from http://ashkenas.com/dotjs/ which I don't know about
# ... with if/else
class Pirate
if century > 1700
loot: ->
say 'Give me the gold!'
else
loot: ->
say 'Dame el oro!'
@synaptiko
synaptiko / DomainsNode.js
Created March 11, 2013 05:37
Domains in node used for one request error handling from: http://www.youtube.com/watch?v=tgTniHwGPuM
http.createServer(function(req, res) {
var d = domain.create();
d.add(req);
d.add(res);
d.on('error', function(er) {
console.error('Error', er, req.url);
d.dispose();
});
@synaptiko
synaptiko / 8188eu.ko
Last active May 1, 2019 20:23
Useful links related to "hard" linux things when I was experimenting with Raspberry Pi, cross-compilation, emulation etc.
@synaptiko
synaptiko / daemon.sh
Created June 9, 2013 19:33
Bash shell script which let run PROCESS_COMMAND forever until daemon is called with kill parameter.
#!/usr/bin/env bash
SCRIPT_PATH=$(readlink -f $0)
DIR=$(dirname $SCRIPT_PATH)
PID_DIR="${DIR}/pid"
LOG_DIR="${DIR}/log"
DAEMON_PID_FILE="${PID_DIR}/daemon.pid"
DAEMON_LOG_FILE="${LOG_DIR}/daemon.log"
PROCESS_PID_FILE="${PID_DIR}/process.pid"
#!/bin/sh
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@synaptiko
synaptiko / tooHotLed.js
Created June 19, 2013 19:53
Simple program combining temperature sensor and led through GPIO.
#!/usr/bin/env node
var fs = require('fs');
var gpio = require("gpio");
var gpio10 = gpio.export(10, {
direction: "out",
ready: function() {
function readTemperature() {
var data = fs.readFileSync('/sys/bus/w1/devices/28-0000047c275a/w1_slave', { encoding: 'ascii' });
var temperature;