Skip to content

Instantly share code, notes, and snippets.

@mojothejojo
mojothejojo / install_java_scala_sbt.sh
Created April 15, 2021 16:30 — forked from patmandenver/install_java_scala_sbt.sh
Script to install Oracle Java 1.8, Scala 2.11.7 and sbt 0.13.9 on Ubuntu 14.04
#!/bin/bash
#
# Script to Install
# Oracle Java 1.8
# Scala 2.11.7
# sbt 0.13.9
#
##############################
#Script must be run as root/sudo
@mojothejojo
mojothejojo / spark_s3a_instructions.sh
Created March 28, 2021 14:17 — forked from thekensta/spark_s3a_instructions.sh
Set up Apache Spark 1.5+ with Hadoop 2.6+ s3a
# For a local environment
# Install hadoop and apache-spark via homebrew
# Apache Spark conf file
# libexec/conf/spark-defaults.conf
# Make the AWS jars available to Spark
spark.executor.extraClassPath /usr/local/Cellar/hadoop/2.7.1/libexec/share/hadoop/tools/lib/aws-java-sdk-1.7.4.jar:/usr/local/Cellar/hadoop/2.7.1/libexec/share/hadoop/tools/lib/hadoop-aws-2.7.1.jar
spark.driver.extraClassPath /usr/local/Cellar/hadoop/2.7.1/libexec/share/hadoop/tools/lib/aws-java-sdk-1.7.4.jar:/usr/local/Cellar/hadoop/2.7.1/libexec/share/hadoop/tools/lib/hadoop-aws-2.7.1.jar
# Add file
@mojothejojo
mojothejojo / gist:a7b003dd731db7ff3cc0791970959a50
Created November 15, 2020 07:18 — forked from Daeinar/gist:4383663
Install pip packages with homebrew
Install pip packages with homebrew:
1. Install Homebrew
http://mxcl.github.com/homebrew/
2. Install the brew-pip package
brew install brew-pip
3. Add Homebrew's pip path to your PYTHONPATH environment variable (you probably should add this to some sort of shell initialization file like ~/.bashrc or ~/.zshrc)
export PYTHONPATH=$(brew --prefix)/lib/python2.7/site-packages
3. Now install any pip pacakges with Homebrew!
brew pip Glances
@mojothejojo
mojothejojo / fish_greeting.fish
Created May 29, 2020 19:54 — forked from angstbear/fish_greeting.fish
fortune + cowsay (random animal) + lolcat Fish-Shell prompt greeting
function fish_greeting
if not which fortune > /dev/null ^ /dev/null
switch (uname)
case Darwin
echo Installing fortune and cowsay
brew install fortune
sudo gem install lolcat
case Linux
echo Installing fortune and cowsay
if which apt-get > /dev/null ^ /dev/null
@mojothejojo
mojothejojo / fix-osx-wifi-battery-drain.md
Created May 14, 2020 08:17 — forked from ziadoz/fix-osx-wifi-battery-drain.md
Fix OSX battery draining on sleep due to wifi activity

Fix OSX battery draining on sleep due to wifi activity

Install SleepWatcher using Homebrew:

sudo chown -R $(whoami) /usr/local
brew update
brew install sleepwatcher

Start the SleepWatcher service:

#!/bin/sh
# default commands for osx to make it nicer to work with
##########################
# General UI?UX settings #
##########################
# Set hostname (hex of MVB9APPS)
sudo scutil --set ComputerName "0x4d56423941505053"
sudo scutil --set HostName "0x4d56423941505053"
@mojothejojo
mojothejojo / print256colours.sh
Created January 4, 2020 10:46 — forked from HaleTom/print256colours.sh
Print a 256-colour test pattern in the terminal
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256
@mojothejojo
mojothejojo / limitConcurrentGoroutines.go
Created December 23, 2019 05:02 — forked from AntoineAugusti/limitConcurrentGoroutines.go
Limit the maximum number of goroutines running at the same time
package main
import (
"flag"
"fmt"
"time"
)
// Fake a long and difficult work.
func DoWork() {
@mojothejojo
mojothejojo / simpleRestfulHttpServerInPython
Created December 3, 2019 12:28 — forked from mafayaz/simpleRestfulHttpServerInPython
Writing Simple HTTP Server in Python (With REST and JSON)
There are many already existing powerful http servers that can be used in python e.g. gevent, twisted web server. However, they are a bit complex to use and you cannot start them in a thread other than the main thread.
Here is a sample of basic http server using "BaseHTTPRequestHandler". The example exposed two rest interfaces:
To ingest records into the web server
To retrieve already ingested records from the web server
The records are assumed to be JSON based, however, any type of records can be ingested.
[sourcecode language="python" wraplines="false" collapse="false"]
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
@mojothejojo
mojothejojo / README.md
Created December 3, 2019 12:28 — forked from fahadysf/README.md
A multiprocess task broker which accepts and provides status reports for tasks using JSON REST API calls.

Multiprocess Task Broker with REST API

This gist shows and example or an asynchronous multiprocess task broker which can take job requests and report on running jobs via a minimal REST API.

Adapted from https://gist.github.com/nitaku/10d0662536f37a087e1b

All of the caveats from the original author still apply.