- Go Concurrency Patterns: Context
- Package context
- Context
- Context is for cancelation
- Context isn’t for cancellation
- Revisiting context and http.Handler for Go 1.7
This file contains 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
FFMPEG=/opt/ffmpeg-live/bin/ffmpeg | |
for((;;)) | |
do | |
sleep 1 | |
FILENAME=stat123_for_eng_$(date +"%H%M%S").mp3 | |
echo "save audio into " $FILENAME | |
$FFMPEG -f avfoundation -i ":0" -vn -acodec mp3 -b:a 96k -ar 44100 $FILENAME | |
done |
This file contains 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
The MIT License (MIT) | |
Copyright (c) 2013 Jamar Parris | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S |
This file contains 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 | |
# A script to backup GitLab repositories. | |
GLAB_BACKUP_DIR=${GLAB_BACKUP_DIR-"gitlab_backup"} # where to place the backup files | |
GLAB_TOKEN=${GLAB_TOKEN-"YOUR_TOKEN"} # the access token of the account | |
GLAB_GITHOST=${GLAB_GITHOST-"gitlab.com"} # the GitLab hostname | |
GLAB_PRUNE_OLD=${GLAB_PRUNE_OLD-true} # when `true`, old backups will be deleted | |
GLAB_PRUNE_AFTER_N_DAYS=${GLAB_PRUNE_AFTER_N_DAYS-7} # the min age (in days) of backup files to delete | |
GLAB_SILENT=${GLAB_SILENT-false} # when `true`, only show error messages | |
GLAB_API=${GLAB_API-"https://gitlab.com/api/v3"} # base URI for the GitLab API |
This file contains 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
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
This file contains 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
] wc -l domains.txt | |
783 domains.txt | |
] time go run domain_lookup_parallel.go | |
real 0m5.743s | |
user 0m0.359s | |
sys 0m0.355s | |
] time go run domain_lookup_sequential.go |
This file contains 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 nginx:alpine | |
# stock verison from php:alpine image | |
# ensure www-data user exists | |
RUN set -x \ | |
&& addgroup -g 82 -S www-data \ | |
&& adduser -u 82 -D -S -G www-data www-data | |
# 82 is the standard uid/gid for "www-data" in Alpine | |
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 |