Skip to content

Instantly share code, notes, and snippets.

Avatar

Nik Sudan niksudan

View GitHub Profile
@niksudan
niksudan / third-party-react-native-dependencies-xcode.md
Last active Jul 29, 2019
Fixing Third Party React Native Dependencies for Xcode
View third-party-react-native-dependencies-xcode.md

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 Sep 6, 2018
Disable WordPress author accounts from logging in
View disable-author-login.php
<?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 Jul 23, 2018
Preload an image without rendering
View img-preload.js
const image = new Image();
image.src = 'your-image-url-here';
image.onload = () => {
// Your image has loaded
};
@niksudan
niksudan / mc-server-setup.md
Last active Feb 13, 2021
How to create a new Minecraft Server with DigitalOcean
View mc-server-setup.md

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 Jul 11, 2017
Convert a PDF document to separate images
View pdfimg.js
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;
View 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 Mar 6, 2017
Host a create-react-app build folder with express
View server.js
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 Mar 6, 2017
Hyperterm config
View .hyper.js
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 Sep 16, 2016
Meta viewport tag [HTML]
View viewport.html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@niksudan
niksudan / n-queens.clj
Created Jan 22, 2016
n queens problem [Clojure]
View n-queens.clj
(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)))