Skip to content

Instantly share code, notes, and snippets.

@niksudan
niksudan / mc-server-setup.md
Last active May 4, 2024 15:49
How to create a new Minecraft Server with DigitalOcean

Creating a new Minecraft Server

This is a short and simple guide on how to set up a multiplayer server running the latest version of Minecraft.

This guide has been tested on Ubuntu 16.04 and 18.04.

Setup

Create a new Ubuntu droplet on DigitalOcean. Make sure it has at least 2GB of RAM, and you provide it with your SSH key.

@niksudan
niksudan / third-party-react-native-dependencies-xcode.md
Last active July 29, 2019 10:51
Fixing Third Party React Native Dependencies for Xcode

Xcode and React Native love to complain about errors. I've found that with certain projects need this additional configuration step in order for it to actually run.

Here's what to do:

  1. Remove all currently installed node modules and caches, and re-install them.
rm -rf node_modules/ && yarn cache clean && yarn install
rm -rf ~/.rncache
@niksudan
niksudan / send_email.php
Last active February 11, 2019 17:22
Send one or many emails [PHP]
<?php
/**
* Send one or many emails
*
* @param string/array $emails
* @param string fromEmail
* @param string fromName
* @param string subject
* @param string content
* @return void
@niksudan
niksudan / redirect.php
Last active February 11, 2019 17:16
Redirect to another URL [PHP]
<?php
/**
* Redirect to another URL
*
* @param string $url
* @return void
*/
function redirect( $url )
{
echo sprintf( '<META http-equiv="refresh" content="0;URL=%s">', $url );
@niksudan
niksudan / get_directory_files.php
Last active February 11, 2019 17:15
Retrieve a listing of all files of type in a directory [PHP]
<?php
/**
* Retrieve a listing of all files of type in a directory
*
* @param string $directory
* @param array $types Accepted file types
* @param boolean $removeExtension Remove the file type extension?
* @return array file locations
*/
function get_directory_files( $directory, $types, $removeExtension = false )
@niksudan
niksudan / README.md
Last active February 11, 2019 17:13
Locator [PHP]

locator

Get location data from a string in PHP.

Note that you can only make a certain amount of requests, so use sparingly.

Usage

@niksudan
niksudan / query.sql
Created June 26, 2015 14:20
MySQL user export [WordPress]
SELECT u.`user_login` as username, u.`display_name` as name, u.`user_email` as email
FROM wp_users u
INNER JOIN wp_usermeta m ON m.`user_id` = u.`ID`
WHERE m.`meta_key` = 'wp_capabilities'
AND (m.meta_value LIKE '%subscriber%')
ORDER BY u.`user_login`;
@niksudan
niksudan / api.php
Created June 26, 2015 14:36
Database Query Service [AngularJS]
<?php
$tables = array('settings', 'people', 'ratings', 'emails', 'comments', 'accounts');
define('ENTRY_LIMIT', 50);
/**
* method
* The operation you are about to perform
*
* table
@niksudan
niksudan / cors.php
Created June 26, 2015 14:39
Cross Origin Permissions [PHP]
<?php
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // Cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
@niksudan
niksudan / disable-author-login.php
Last active September 6, 2018 12:13
Disable WordPress author accounts from logging in
<?php
/**
* Disable author accounts from logging in
*/
function disable_author_login($user, $password)
{
if ($user) {
$roles = (array) $user->roles;
if ($roles[0] === 'author') {
return new WP_Error('disable_author_login', 'You do not have permission to log in');