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
#!/bin/bash | |
docker inspect $1 | jq -r ".[0].NetworkSettings.Networks.${2:-bridge}.IPAddress" |
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
docker run --name=a-test-mysql --detach \ | |
-e MYSQL_USER='blaser' \ | |
-e MYSQL_PASSWORD='ok' \ | |
-e MYSQL_DATABASE='dratabasss' \ | |
mysql/mysql-server:5.7 |
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
# Some docs imly source can be a directory, but it does not work actually. | |
# Below is a workaround | |
for p in a-source-folder/* | |
do | |
# Note that uppercase JPG suffix is not recognized so adding "jpg" to output file name. | |
darktable-cli --width 3000 --height 3000 --hq true $p $(dirname $p)-export/$(basename ${p%.JPG}.jpg); | |
done |
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
use std::net::TcpListener; | |
use std::net::UdpSocket; | |
use std::net::TcpStream; | |
use std::net::Shutdown; | |
use std::thread; | |
use std::io::BufReader; | |
use std::io::Write; | |
use std::io::BufRead; | |
fn session(mut ios: TcpStream) -> Result<(), std::io::Error> { |
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
rom collections import defaultdict | |
from math import inf | |
def find_closest(dist, unvisited): | |
# Select node with the least distance to source | |
u = None | |
min_du = inf | |
for v in unvisited: | |
if dist[v] < min_du: |
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 collections import defaultdict | |
from math import inf | |
def find_closest(dist, unvisited): | |
# Select node with the least distance to source | |
u = None | |
min_du = inf | |
for v in unvisited: | |
if dist[v] < min_du: |
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 java.util.Random; | |
import java.util.TreeSet; | |
public class MainSr { | |
public static void main(String[] args) { | |
// Run this with assertions enabled | |
assert 1 == countRanges(new int[]{1}); | |
assert 1 == countRanges(new int[]{2, 1}); | |
assert 1 == countRanges(new int[]{3, 2, 1}); |
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 dropbox | |
import dropbox.files | |
CHUNK_SIZE = 4 * 1024 * 1024 | |
def upload_stream(dbx, readable, dest_path): | |
d = readable.read(CHUNK_SIZE) | |
offset = len(d) |
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 boto3 | |
import gzip | |
s3 = boto3.client('s3') | |
# get gz file content | |
content = gzip.decompress( | |
s3.get_object(Bucket='a-bucket-id', | |
Key='a-key')['Body'].read()) |
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
# SPARK_HOME=$HOME/opt/spark-2.2.1-bin-hadoop2.7 ptpython | |
# SPARK_HOME=$HOME/opt/spark-2.2.1-bin-hadoop2.7 pyspark | |
from pyspark.sql import SparkSession | |
spark = SparkSession.builder \ | |
.appName('hello') \ | |
.master('local[3]') \ | |
.config("spark.ui.port", 9100) \ | |
.getOrCreate() |