Skip to content

Instantly share code, notes, and snippets.

@daangemist
daangemist / empty.js
Created December 24, 2020 07:43
Empty an AWS DynamoDB table
require('dotenv').config()
const AWS = require('aws-sdk');
AWS.config.update({
credentials: {
accessKeyId: 'xxx',
secretAccessKey: 'xxx'
},
region: 'eu-central-1'
});
@daangemist
daangemist / .bash_aliases
Created December 8, 2018 06:59
Default linux config stuff
alias npm='docker run -v `pwd`:/app --rm -it -w=/app node:10 npm'
# Use NODEV=8 npm to specify a different node version
npm() { docker run -v `pwd`:/app --rm -it -w=/app node:${NODEV-10} npm; }
@daangemist
daangemist / pm2-app.json
Created June 12, 2017 07:55
PM2 configuration for localtunnel-server
{
"name": "localtunnel",
"script": "bin/server",
"args": "--port=1234 --host=example.com",
"cwd": "/opt/localtunnel",
"env": {
"DEBUG": "localtunnel*",
"NODE_ENV": "production"
},
"error_file": "/mnt/usbstick2/logs/lt-error.log",
@daangemist
daangemist / backupper.php
Created July 8, 2014 07:01
Periodically backups a file
<?php
if( $argc === 1 ) {
die('Will periodically backup a file. Usage: php ' . $argv[0] . ' filename' . PHP_EOL);
}
$filename = $argv[1];
if( !file_exists($filename) )
die('File ' . $filename . ' not found.' . PHP_EOL);
$backupEverySeconds = 60*30; //backup every half hour
@daangemist
daangemist / mkrepo.sh
Created January 22, 2014 20:59
Script to easily create Git repo
#!/bin/sh
mkdir $1.git
cd $1.git
git init --bare
cd ..
chown -R git:git $1.git
chmod -R g+w $1.git
echo "Add as remote: git remote add origin user@git.server:$1.git"
@daangemist
daangemist / rtmdash.html
Created April 20, 2013 20:32
A HTML page to easily display three RememberTheMlik lists using the mobile website and an iFrame.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>RTMDash</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(bottom, #FFFFFF 0%, #23A614 100%);
/* Mozilla Firefox */
// ==UserScript==
// @name RockMongo with ACE
// @match http://127.0.0.1/rockmongo/*
// @match https://127.0.0.1/rockmongo/*
// ==/UserScript==
// Stolen from http://stackoverflow.com/a/3550261/360593
function addHeadJS(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//cdnjs.cloudflare.com/ajax/libs/headjs/0.99/head.min.js");
@daangemist
daangemist / openhab.sh
Created February 7, 2013 10:21
Openhab init.d startup script. Copied from Victor.
#! /bin/sh
### BEGIN INIT INFO
# Provides: openhab
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenHAB Daemon
### END INIT INFO
@daangemist
daangemist / gist:4690404
Created February 1, 2013 09:47
Small PHP script to request a page with a different Host: header.
<?php
if( isset($_REQUEST['url']) ) {
$url = $_REQUEST['url'];
$host = $_REQUEST['host'];
/* Borrowed from http://stackoverflow.com/questions/9932636/how-to-set-hostname-using-php-curl-for-a-specific-ip */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $host));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
@daangemist
daangemist / headerlock.js
Created December 20, 2012 21:58
Lock the menu header in place when the page starts scrolling. Taken from www.lesscss.org, the docked CSS class makes the background semi-transparent.
window.onload = function () {
var menu = document.getElementById('menu');
var init = menu.offsetTop;
var docked;
window.onscroll = function () {
if (!docked && (menu.offsetTop - scrollTop() < 0)) {
menu.style.top = 0;
menu.style.position = 'fixed';
menu.className = 'docked';