Skip to content

Instantly share code, notes, and snippets.

@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 / 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');
@niksudan
niksudan / img-preload.js
Created July 23, 2018 14:44
Preload an image without rendering
const image = new Image();
image.src = 'your-image-url-here';
image.onload = () => {
// Your image has loaded
};
@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 / pdfimg.js
Created July 11, 2017 10:13
Convert a PDF document to separate images
const PDFImage = require('pdf-image').PDFImage;
const pdfImage = new PDFImage('./input/document.pdf');
const convert = (page) => {
return pdfImage.convertPage(page);
}
let canConvert = true;
let currentPage = 0;
@niksudan
niksudan / semver-regex
Created April 13, 2017 10:04
Semver Regex
^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-([a-z]+))?(\.(?:0|[1-9]\d*)
@niksudan
niksudan / server.js
Created March 6, 2017 15:28
Host a create-react-app build folder with express
const express = require('express');
const app = express();
// 80 won't work if another process uses this port (apache/nginx)
const SERVER_PORT = 80;
app.get('*', express.static(__dirname + '/build'));
app.get('*', (req, res) => {
res.sendFile(__dirname + '/build/index.html');
@niksudan
niksudan / .hyper.js
Last active March 6, 2017 15:29
Hyperterm config
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'FiraCode-Regular, Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.75)',
@niksudan
niksudan / viewport.html
Created September 16, 2016 14:37
Meta viewport tag [HTML]
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@niksudan
niksudan / n-queens.clj
Created January 22, 2016 14:34
n queens problem [Clojure]
(defn n-queens [n]
(def nList
(case (mod n 6)
2 (concat
(for [i (range 1 (+ (/ n 2) 1))] (* i 2))
(concat
(list 3 1)
(when (> n 6) (for [i (range 4 (+ (/ n 2) 1))] (- (* i 2) 1)))