Skip to content

Instantly share code, notes, and snippets.

View carlbennett's full-sized avatar
💙
Fedora Linux

Carl Bennett carlbennett

💙
Fedora Linux
View GitHub Profile
@carlbennett
carlbennett / game.cpp
Created November 17, 2011 01:45
Make error
/*
Copyright (c) 2011, The Mineserver Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
diff --git a/src/app.cpp b/src/app.cpp
index a6adf14..1c82aa3 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -38,6 +38,7 @@
#include <mineserver/network/protocol/notch/protocol.h>
#include <mineserver/network/server.h>
+#include <mineserver/watcher/keepalive.h>
#include <mineserver/watcher/login.h>
@carlbennett
carlbennett / login.h
Created November 18, 2011 05:36
Pointer problem most likely
namespace Mineserver
{
struct Watcher_Login
{
void operator()(Mineserver::Game::pointer_t game, Mineserver::Network_Client::pointer_t client, Mineserver::Network_Message::pointer_t message) const
{
std::cout << "Login watcher called!" << std::endl;
const Mineserver::Network_Message_Login* msg = (Mineserver::Network_Message_Login*)&message;
Mineserver::Game_Player::pointer_t player(new Mineserver::Game_Player);
@carlbennett
carlbennett / lunch.sh
Last active July 10, 2017 16:28
Lunch Location Randomizer
#!/bin/bash
TODAY=$(date +%Y-%m-%d)
LIST=$(sed -e 's/$/\r/g' lunch.txt | perl -MURI::Escape -ne 'print uri_escape($_)')
curl -s \
-d "list=${LIST}" \
-d "format=plain" \
-d "rnd=date.${TODAY}" \
"https://www.random.org/lists/?mode=advanced"
@carlbennett
carlbennett / motd.sh
Last active March 5, 2020 05:29
Prints a dynamic message of the day upon login. To install, copy the file to the `/etc/profile.d/` directory.
#!/bin/bash
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
# Only display motd if tty and not sudoing as root
[ "$PS1" ] && [ "$EUID" -ne 0 ] || return 0
# Run the entire function in its own subshell.
#
# The local keyword in functions prevents inheriting values.
# The subshell prevents exporting them.
@carlbennett
carlbennett / linux-cheatsheet.sh
Last active June 2, 2024 14:41
Cheatsheet for Fedora, CentOS, and RedHat family members of Linux
# Fix user and directory permissions:
find . -type f -print0 | sudo xargs -0 chmod 664
find . -type d -print0 | sudo xargs -0 chmod 775
# Copy user permissions to group permissions:
chmod -R g=u .
# Make new files inherit the group of the container directory
chmod g+s <directory>
@carlbennett
carlbennett / serialize_test.php
Created October 12, 2015 22:15
Tests serializing a class with custom serialize functions
#!/usr/bin/php
<?php
class Test implements Serializable {
public function __tostring() {
return "asdf";
}
public function serialize() {
@carlbennett
carlbennett / sshd_config
Created October 19, 2015 03:03
Customized SSH configuration
Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
KeyRegenerationInterval 1h
ServerKeyBits 4096 # Legacy Protocol 1, meaningless on Protocol 2
SyslogFacility AUTHPRIV
# Enhanced Network Hosts File
# Authored by Carl Bennett <https://carlbennett.me>
#
# How To <https://support.rackspace.com/how-to/modify-your-hosts-file/>
# (I do not endorse Rackspace, the document is simply of decent quality.)
#
# This file is hereby released under the MIT license. A copy of the license can
# be found at: <https://opensource.org/licenses/MIT>
#
#!/usr/bin/php
<?php
function closure_test(&$foobar) {
// Repeat for some arbitrary number of executions
$x = mt_rand(3, 10);
while ($x > 0) {
$foobar[] = $x;
--$x;