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 / split_text_to_sentences.php
Created May 10, 2017 19:08
Extract first X sentences from WordPress post content for post excerpt
<?php
/**
* Extract out first X sentences from uncleaned raw text
* @param string $text Raw text
* @param int $num_sentences Optional. Number of sentences
* @return string
*/
function extract_sentences_from_text($raw_text, $num_sentences=3) {
$text = $raw_text;
$text = strip_tags($text);
@donwilson
donwilson / rclone-backup-script.sh
Created May 26, 2017 23:24
Back up WWW, MySQL DB and separate content folder to S3 using rclone
#!/bin/bash
###
# Backup Script
###
# Toggle debug mode for CLI output - "YES" or "NO"
DEBUG="YES"
@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 / server_commands.txt
Last active December 8, 2020 21:10
Server Setup Helper
#################################
# General Program Installations #
#################################
yum -y install htop screen bzip2 unzip parallel wget nano dos2unix nmap iotop
###########################
# Install Git from Source #
###########################