Skip to content

Instantly share code, notes, and snippets.

@tored
tored / bing.php
Last active June 17, 2016 09:36
Bing Wallpaper
#!/usr/bin/env php
<?php
function getDownloadPathWindows()
{
$home = getenv('HOMEDRIVE') . getenv('HOMEPATH');
if (!is_dir($home)) {
throw new RuntimeException("No home folder $home");
}
return "$home/Pictures/Bing";
@tored
tored / .nanorc
Last active July 13, 2016 19:19
nanorc
set autoident
set tabsize 4
set tabstospaces
set multibuffer
set smarthome
set whitespace "»·"
set const
set historylog
set mouse
set poslog
@tored
tored / move.sh
Last active October 26, 2015 14:36
Move files between git repos keeping history
# http://stackoverflow.com/a/11426261
cd repository
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > patch
cd ../another_repository
git am < ../repository/patch
@tored
tored / make.sh
Created September 30, 2015 09:31
List make rules
make -qrpn | sed -n -e '/^$/ { n ; /^[^ ]*:/p; }' | sort | egrep --color '^[^ .]*:'
git log --graph --oneline --all --decorate
@tored
tored / tabs2spaces.sh
Last active August 29, 2015 14:28
Convert tabs to spaces on multiple files
find . -name '*.php' ! -type d -exec bash -c 'expand -i -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
@tored
tored / isArray.js
Last active August 29, 2015 14:24
isArray: return true if variable is an array
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
@tored
tored / vscodeinstaller.sh
Last active July 26, 2023 13:09
Installer for Visual Studio Code for Linux (Ubuntu)
#!/usr/bin/env bash
# Taken and modified from
# http://www.thepowerbase.com/2015/04/install-visual-studio-code-ubuntu-14-04-14-10-15-04/
DOWNLOAD_URL=https://az764295.vo.msecnd.net/public/0.10.2/VSCode-linux64.zip
VSCODE_DIR=/opt/VSCode
DESKTOP_FILE_PATH=/usr/share/applications/visualstudiocode.desktop
ICON_FILE_PATH=$VSCODE_DIR/resources/app/resources/linux/vscode.png
TMP_DIR=/tmp/VSCode
@tored
tored / render-php-file.php
Last active August 29, 2015 14:22 — forked from james2doyle/render-php-file.php
Render a PHP file as a template
function renderPhpFile($filename, $vars = null) {
if (is_array($vars) && !empty($vars)) {
extract($vars);
}
ob_start();
include $filename;
return ob_get_clean();
}
// usage
@tored
tored / usedmem.sh
Created March 9, 2015 22:47
Used memory in percentage
free | awk '/buffers\/cache/{print $3/($3+$4) * 100.0;}'