Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

smac89

🎯
Focusing
Block or report user

Report or block smac89

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smac89
smac89 / Unbound timer.md
Created May 10, 2020
Create systemd timer from simple command
View Unbound timer.md

To create the timer described here

systemd-run --on-calendar='*-*-01 12:00:00' --description='Update root hints for unbound' --property='After=network.target' --timer-property='Persistent=true' /usr/bin/curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache
@smac89
smac89 / Restoring Sanity.md
Last active May 10, 2020
Linux Desktop User: Sane defaults
View Restoring Sanity.md

Being a Linux desktop user is not easy, but it doesn't have to be difficult.

Enabling persistent journals

This is especially useful for collecting logs of system issues.
@smac89
smac89 / StructuralSearch.md
Last active May 10, 2020
Structural search tips. #IntelliJ #idea
View StructuralSearch.md

Find field references on an instance

In this example, we want to find places where one did:

someClass.someField

Where someClass is of the type fully.qualified.SomeClass

Find and replace field reference with method call
@smac89
smac89 / Instructions.md
Last active Aug 2, 2018
Teamspeak server setup on Linux Ubuntu 16.04. #teamspeak #server #ts3
View Instructions.md

Downloading teamspeak

Since the server will likely not have a UI, so the download must be done with a command

The command to download teamspeak (Find the most recent version and download instead):

wget -O teamspeak-server.tar.bz2 http://dl.4players.de/ts/releases/3.0.13.8/teamspeak3-server_linux_amd64-3.0.13.8.tar.bz2

Setting up teamspeak folder

@smac89
smac89 / SSHServerSetup.md
Last active May 10, 2020
Set up an ssh server with public key encryption. #ssh
View SSHServerSetup.md

Server

Create the user group and add the users you want to be part of this group:

sudo groupadd sshusers
sudo usermod -a -G sshusers <username>

Client

# Generate key and create password
@smac89
smac89 / Main.java
Last active May 10, 2020
Java sliding windows via Streams
View Main.java
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Main {
public static void main(String args[]) {
Stream<List<Integer>> stream = SlidingWindow.pagedStream(StreamableSupplier.fromStream(IntStream.range(1, 10000).boxed()), 5)
.apply(i -> i <= 100);
stream.forEach(System.out::println);
@smac89
smac89 / Main.java
Last active Feb 5, 2018
Read a large json file, but do so lazily so as to not use too much memory. Thanks to Java 8 streams, this is quite possible
View Main.java
import com.google.common.io.Resources;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
@smac89
smac89 / nautilus-raw-preview.md
Last active May 10, 2020 — forked from h4cc/howto.md
Show previews of your image files in nautilus file manager in Ubuntu
View nautilus-raw-preview.md

Howto

Install these packages

sudo apt-get install gnome-raw-thumbnailer ufraw-batch

Check to see if everything works, and your thumbnails show up. If not, try the next part.

@smac89
smac89 / create_self_signed_pem_python.py
Last active Sep 26, 2017
Create a self-signed certificate for SSL encrypted http messaging
View create_self_signed_pem_python.py
def _gen_private_pem_key():
from cryptography.hazmat.backends import default_backend as crypto_default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
key = rsa.generate_private_key(
backend=crypto_default_backend(),
public_exponent=65537,
key_size=2048
)
return key
@smac89
smac89 / gulp-typescript-compile-queue.ts
Last active Jul 6, 2017
Solution to "Error: gulp-typescript: A project cannot be used in two compilations * at the same time. Create multiple projects with createProject instead."
View gulp-typescript-compile-queue.ts
import {Project, CompileStream} from 'gulp-typescript';
import {Duplex, PassThrough, Readable} from 'stream';
import {Reporter} from 'gulp-typescript/release/reporter';
type Callback = () => void;
/**
* This is used to ensure that each project object is not busy when it is to be used
* This prevents the annoying:
* "Error: gulp-typescript: A project cannot be used in two compilations
You can’t perform that action at this time.