echo 3 | sudo tee /proc/sys/vm/drop_caches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backup | |
# Usage: | |
# backup foo bar will make a backup of foo and bar (foo.2014-03….bak) | |
# backup --rm foo will make a backup of foo and then delete the original file | |
# (useful if you, for example, rewrite a configuration file) | |
# Attention: | |
# This is not meant to be a substitute for VCS, or full backups. This is useful | |
# while editing a sensitive resource such as a configuration file, to have a | |
# fallback copy to return to. | |
backup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
status() | |
{ | |
xset -q | grep 'Monitor is ' | awk '{print $3}' | |
} | |
on() | |
{ | |
xset dpms force on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Regular expressions of the delimiters. | |
* @type {Array<string>} | |
*/ | |
var DELIMS = ['%', '%']; | |
/** | |
* Replaces all occurences of {<key>} with parameters[key]. When an | |
* appropriate property of parameters is not found, omits the substitution. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function Node(value, dependencies) { | |
dependencies = (dependencies || []); | |
this.value = this.valueOf = this.toString = () => value; | |
this.dependencies = () => dependencies; | |
this.standalone = () => dependencies.length === 0; | |
this.equals = node => value === node.value(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:Array.prototype.forEach.call(document.querySelectorAll(".list"),function(e){var t=0,r=0;var l=/(\d+?)\/(\d+?)/;var a=e.querySelector(".list-header");Array.prototype.forEach.call(e.querySelectorAll('.badge[title="Checklist items"] .badge-text'),function(e){var a=l.exec(e.textContent);if(a){t+=parseInt(a[2]);r+=parseInt(a[1])}});var o=a.querySelector(".completness")||document.createElement("span");if(t>0){o.textContent=r+"/"+t+" ("+Math.round(r*100/t)+"%)"}o.className="completness";o.style.opacity=.75;o.style.float="right";a.insertBefore(o,a.querySelector(".list-header-menu-icon"))}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$config = ...; | |
$input = file_get_contents('php://stdin'); | |
$output = $input; | |
$opening = '<%'; | |
$closing = '%>'; | |
for ($offset = strpos($output, $opening); $offset !== false; $offset = strpos($output, $opening)) { | |
$endOffset = strpos($output, $closing, $offset); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Configuration | |
cache_file=$HOME/.updates | |
# function to check updates, must work without root privileges and print | |
# the number of updates to stdout. | |
function update_count { | |
checkupdates | wc -l; return $? | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
class stopwatch(object): | |
def __init__(self, jobname): | |
self.jobname = jobname | |
def __enter__(self): | |
self.starttime = (datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
email=overlord@localhost | |
free_threshold=20 | |
next_reminder=$((60*60*24*3)) | |
disks=(/dev/sda1 ...) | |
for disk in ${disks[*]}; do | |
total=$(df $disk -P | tail -n 1 | awk '{print $2}') | |
free=$(df $disk -P | tail -n 1 | awk '{print $4}') |
OlderNewer