Skip to content

Instantly share code, notes, and snippets.

View cdarlint's full-sized avatar

cdarlint

  • mathworks.com
  • Beijing, China
  • 00:08 (UTC +08:00)
View GitHub Profile
@InfoSec812
InfoSec812 / ParallelStreamWordCount.java
Created August 7, 2016 13:25
Use Java 8 parallel streams to read a file and tally word counts
package us.juggl.twentysixteen.august;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@pudquick
pudquick / shellista.py
Last active November 12, 2022 16:56
Advanced shell for Pythonista
import os, cmd, sys, re, glob, os.path, shutil, zipfile, tarfile, gzip
# Credits
#
# The python code here was written by pudquick@github
#
# License
#
# This code is released under a standard MIT license.
#
@John07
John07 / HLS_dvr.sh
Last active June 10, 2023 10:40
A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.
# required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier
# you can schedule this with launchd to run e.g. weekly
# Specify in seconds how long the script should record (default here is 1 hour).
seconds=3600
# Date format for the recording file name
DATE=`date "+%d-%m-%y_%H-%M"`
# start ffmpeg recording
@jexchan
jexchan / TeXIt.tex
Last active August 4, 2023 05:55 — forked from arcthur/TeXIt.tex
Latex with Chinese Support
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
% 以上设定默认使用 XeLaTeX 编译,并指定 Unicode 编码,供 TeXShop 自动识别
% XeLaTeX 示例
\documentclass[12pt]{article}
% XeTeX 配合 fontspec 可以非常方便的设置字体
@celoyd
celoyd / hi8-fetch.py
Last active August 8, 2023 05:05
Fetch and untile tiled Himawari-8 images from the http://himawari8.nict.go.jp PNG endpoint
import requests as req
import sys
from dateutil.parser import parse
from PIL import Image
from StringIO import StringIO
# hi8-fetch.py <date> <zoom level> <output>
# E.g.: hi8-fetch.py 2016-01-13T22:10:00 8 2016-01-13T221000-z8.png
# Fetch Himawari-8 full disks at a given zoom level.
# Valid zoom levels seem to be powers of 2, 1..16, and 20.
@agentsim
agentsim / highsierra_bootable.sh
Created June 10, 2017 02:23
Create bootable ISO from HighSierra Installer
# Generate a BaseSystem.dmg with 10.13 Install Packages
hdiutil attach /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -mountpoint /Volumes/highsierra
hdiutil create -o /tmp/HighSierraBase.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierraBase.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source /Applications/Install\ macOS\ 10.13\ Beta.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
cp -R /Volumes/highsierra/Packages /Volumes/OS\ X\ Base\ System/System/Installation
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/highsierra/
mv /tmp/HighSierraBase.cdr.dmg /tmp/BaseSystem.dmg
@kylewlacy
kylewlacy / cartesian_product.scala
Created November 17, 2015 07:38
Cartesian product function in Scala
import scala.reflect.ClassTag
object CartesianProduct {
/**
* Given an array containing a partial Cartesian product, and an array of
* items, return an array adding the list of items to the partial
* Cartesian product.
*
* {{{
* val partialProduct = Array(Array(1, 4), Array(1, 5), Array(2, 4), Array(2, 5))
@sandeepraju
sandeepraju / download-chromium.sh
Last active January 19, 2024 14:00
Download the latest bin of chromium for linux
#!/bin/bash
# source: http://askubuntu.com/a/64396/174460
CHROMIUM_ROOT="http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64"
CHROMIUM_LATEST=`wget -q -O - "$CHROMIUM_ROOT/LAST_CHANGE"`
wget $CHROMIUM_ROOT/$CHROMIUM_LATEST/chrome-linux.zip
@ChALkeR
ChALkeR / npm.stats.2016-08-09.txt
Created August 9, 2016 16:57
npm package downloads per month, as of 2016-08-09
This file has been truncated, but you can view the full file.
34964408 readable-stream
34506401 botfather
33295762 glob
31619819 async
29723143 lodash
29354079 minimatch
27539592 minimist
27118468 qs
26340698 source-map
24962073 isarray

This is a demo of how to talk between programs running on a Mac, and programs running under Docker on a VM on the same Mac as installed by Docker Toolbox.

Just add a route to your containers using the VM as the gateway. Demo:

  • on the mac, run Docker Quickstart Terminal from the latest Docker Toolbox. This launches the virtualbox VM, and configures your shell
  • in that shell, figure out the IP address of the VM:
mak@crab 493 ~ $ docker-machine inspect default -f '{{ .Driver.IPAddress }} '
192.168.99.100