This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.leadspace.tools; | |
| import spark.Request; | |
| import spark.Response; | |
| import spark.Route; | |
| import spark.Spark; | |
| import java.util.Arrays; | |
| public class HelloWeb { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // given that we already have an instance of shakersProvider | |
| String color = getColor(); | |
| // no if-else, and no switch-case-default, the provider should do the work (aka service locator) | |
| IShaker shaker = shakersProvider.getByColor(color); | |
| shaker.shake(); | |
| // or with reusable constants |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum MyColors { | |
| White, | |
| Green, | |
| Blue, | |
| Brown | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyColors x = getColor(); | |
| if (x == MyColors.Green) { | |
| doSomething(); | |
| } else { | |
| doSomethingElse(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum MyColors { | |
| White, | |
| Green, | |
| Blue | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| localip () { | |
| ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//' | grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | xargs echo | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x = 1 | |
| print (x) | |
| x = "a" + 'b' | |
| print (x) | |
| # Python's null is None | |
| y = None | |
| print y is None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void enableGzipIfNeeded(spark.Request request, spark.Response response) { | |
| String accept = request.headers("Accept-Encoding"); | |
| if (accept == null) { | |
| return; | |
| } | |
| String[] tokens = accept.split(","); | |
| if (Arrays.stream(tokens).map(String::trim).anyMatch(s -> s.equalsIgnoreCase("gzip"))) { | |
| response.header("Content-Encoding", "gzip"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # if you want to change the shell to something else | |
| sudo lwregshell set_value '[HKEY_THIS_MACHINE\Services\lsass\Parameters\Providers\ActiveDirectory]' LoginShellTemplate /usr/local/bin/fish | |
| sudo lwregshell set_value '[HKEY_THIS_MACHINE\Services\lsass\Parameters\Providers\Local]' LoginShellTemplate /usr/local/bin/fish | |
| sudo lwsm refresh lsass | |
| sudo lw-ad-cache --delete-all | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
| from datetime import datetime | |
| import sys | |
| DEFAULT_PORT_NUMBER = 8080 | |
| # noinspection PyPep8Naming | |
| class myHandler(BaseHTTPRequestHandler): | |
| def do_GET(self): |