Skip to content

Instantly share code, notes, and snippets.

@donwilson
donwilson / wikimedia_dump_sync.php
Last active August 29, 2015 14:20
An automated Wikipedia data dump downloader written in PHP. This tool checks for the latest complete English Wikipedia data dump and automatically downloads, extracts, and stores articles into individual files for fast reads. Optionally stores relevant info into an 'articles' mysql database table.
<?php
set_time_limit(0);
ini_set('memory_limit', "1024M");
// encoding settings
try {
setlocale(LC_ALL, 'en_US.UTF8');
mb_internal_encoding("UTF-8");
} catch(Exception $e) { die("Unable to set local/internal encoding"); }
@donwilson
donwilson / minecraft
Last active August 29, 2015 14:20
Minecraft service startup script for CentOS/etc with backup command to that can upload .tar.gz of your minecraft folder/world to Amazon S3 through s3cmd.
#!/bin/bash
# /etc/init.d/minecraft
# version 0.5.0 2015-04-20 (YYYY-MM-DD)
#
### BEGIN INIT INFO
# Provides: minecraft
# Required-Start: $local_fs $remote_fs screen-cleanup
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
@donwilson
donwilson / gist:3e863598ce041071be0f
Last active August 29, 2015 14:20
https://twitter.com/Dinnerbone/status/595224755126534144 The following picture is meaningless and is probably not even worth your time clicking on it.
<?php $height = (!empty($_REQUEST['height'])?$_REQUEST['height']:128); ?><style type="text/css">
.image { width: 2px; float: left; background-image: url('http://media.dinnerbone.com/uploads/2015-05/screenshots/04_15-51-30_LLw4sOTM2a.png'); background-position: 0 0; }
</style>
<p><a href="?height=<?=($height-1);?>">Less</a> | <?=$height;?> | <a href="?height=<?=($height+1);?>">More</a></p>
<div style="display: table; width: 100%; height: <?=$height;?>px;"><?php
for($i = 1; $i <= 427; $i++) { ?><div class="image" style="height: <?=$height;?>px; background-position: 0 -<?=($height * ($i - 1));?>px;"></div><?php }
?></div>
#!/bin/bash
SOURCE_FILE=$1
if [[ -z "$SOURCE_FILE" ]]; then
SOURCE_FILE="main"
fi
if [[ ! -f "$SOURCE_FILE.cpp" ]]; then
echo "!! $SOURCE_FILE.cpp not found, exiting..."
#include <SFML/Graphics.hpp>
#include <iostream>
#include <stdlib.h>
int main(int argc, char **argv) {
sf::RenderWindow window(sf::VideoMode(800, 600), "test");
sf::CircleShape circle(100.f);
circle.setFillColor(sf::Color::Green);
@donwilson
donwilson / SFML 2.3.2 on Windows with G++
Last active December 9, 2015 19:49
Setup build batch file for SFML 2.3.2 (GCC 4.9.2 MinGW (DW2) - 32-bit) on Windows 10
1) Download GCC 4.9.2 MinGW (DW2) - 32-bit from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-posix/dwarf/i686-4.9.2-release-posix-dwarf-rt_v3-rev0.7z/download (via http://stackoverflow.com/a/28011978)
- Extract to C:\dev_resources\mingw32-4.9.2
2) Download SFML 2.3.2 for GCC 4.9.2 MinGW (DW2) - 32-bit at http://www.sfml-dev.org/download/sfml/2.3.2/
- Extract to C:\dev_resources\SFML-2.3.2_GCC-4.9.2
3) Save compile.bat from this gist into your source directory where main.cpp is
4) (For now) copy "libstdc++-6.dll" from "C:\dev_resources\mingw32-4.9.2\bin\libstdc++-6.dll" into source directory where compile.bat is
5) Run compile.bat in CMD
@donwilson
donwilson / .bashrc
Created June 2, 2017 18:14
Bash shell colorized
# http://bashrcgenerator.com
export PS1="\[\033[38;5;7m\][\[$(tput sgr0)\]\[\033[38;5;229m\]\u\[$(tput sgr0)\]\[\033[38;5;249m\]@\[$(tput sgr0)\]\[\033[38;5;51m\]\h\[$(tput sgr0)\]\[\033[38;5;7m\]]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;39m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]\n\[$(tput sgr0)\]\[\033[38;5;245m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
@donwilson
donwilson / .bashrc
Created March 16, 2018 20:46
Add git repo and branch names to colorized bash prompt
function parse_git_repo {
local repo_path=$(git rev-parse --show-toplevel 2>/dev/null)
[[ ! -z "$repo_path" ]] && basename $repo_path
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
@donwilson
donwilson / grep_current.sh
Created July 10, 2018 16:26
Grep and ignore _old/ and *CST$ files
#!/bin/bash
CWD=$(pwd)
ARROW="-"
echo ""
echo "===================================="
echo "== Finding: $1"
echo "== - in: $CWD/"
echo "== - skipping paths that match '_old/|CST$'"
@donwilson
donwilson / blurry-background.html
Created August 23, 2018 17:30
Image container with blurry background CSS effect
<!doctype html>
<html>
<head>
<title>Blurred Background Image</title>
<style type="text/css">
body {
overflow: hidden;
}
.blur_background_container {