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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Launch the latest vanilla Java Edition with a local/offline username. | |
| # Supported on Linux and macOS (Intel and Apple Silicon). | |
| # Usage: ./start-client.sh [username] [version] | |
| # Overrides: MC_USERNAME=Player, MC_VERSION=release, MC_MEMORY=4G | |
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | |
| CLIENT_DIR="$SCRIPT_DIR/client" |
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
| import imageio | |
| import cv2 | |
| import numpy as np | |
| # Load GIF | |
| gif = imageio.mimread('calvin.gif') | |
| frames = [cv2.cvtColor(np.array(frame), cv2.COLOR_RGBA2BGR) for frame in gif] | |
| def is_panel(box, w_thresh=200, h_thresh=200): | |
| x, y, w, h = box |
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
| Game { | |
| height: 3; | |
| width: 50%; | |
| } |
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 textual.app import App, ComposeResult | |
| from textual.containers import Container | |
| from textual.reactive import reactive | |
| from textual.widgets import Static | |
| class Thing(Static): | |
| def __init__( self, text ) -> None: | |
| self._text = text | |
| super().__init__() |
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
| # determines whether a GPU is available in your instance and starts an appropriate Dask Cluster | |
| from dask.distributed import Client, LocalCluster | |
| from dask_cuda import LocalCUDACluster | |
| from dask_sql import Context | |
| from pyngrok import ngrok | |
| import dask | |
| import time | |
| import warnings | |
| from IPython.core.magic import needs_local_scope, register_cell_magic |
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 IPython.core.magic import register_cell_magic, needs_local_scope | |
| from sql_formatter.core import format_sql | |
| import time, warnings | |
| warnings.filterwarnings("ignore") | |
| @register_cell_magic | |
| @needs_local_scope | |
| def sql(line, cell, local_ns): | |
| sql_statement = cell.format(**local_ns) |
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
| df = spark.createDataFrame( | |
| [ | |
| (1, 'foo'), # create your data here, be consistent in the types. | |
| (2, 'bar'), | |
| ], | |
| ['id', 'txt'] # add your columns label here | |
| ) | |
| df.write.csv('test') | |
| spark.read.csv('test').collect() |
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
| import sys, os, cgi, _thread | |
| from http.server import SimpleHTTPRequestHandler, HTTPServer | |
| class MyServer(SimpleHTTPRequestHandler): | |
| #Custom POST handler that saves POSTed file content to local disk | |
| def do_POST(self): | |
| post_env = { | |
| 'REQUEST_METHOD': 'POST', | |
| 'CONTENT_TYPE': self.headers['Content-Type'], | |
| } |
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
| # Generate all substrings of string recursively | |
| def substrings(string): | |
| #base case | |
| if len(string) == 0: return '' | |
| else: | |
| ret = [string] | |
| #Slide from left | |
| for x in range(0, len(string)): | |
| sub = string[x:-1] | |
| ret.append(sub) |
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 org.apache.commons.io import IOUtils | |
| from java.nio.charset import StandardCharsets | |
| from org.apache.nifi.processor.io import StreamCallback | |
| import os, sys, imp, traceback, time | |
| from urlparse import urlparse | |
| parser_path = '/home/dev/projects/scripts/parsers/' | |
| class PyStreamCallback(StreamCallback): |
NewerOlder