Skip to content

Instantly share code, notes, and snippets.

@heyfluke
heyfluke / ffmpeg-commands.sh
Created April 2, 2022 06:03 — forked from 44213/ffmpeg-commands.sh
ffmpeg commands.
# To extract the sound from a video and save it as MP3:
ffmpeg -i <video.mp4> -vn <sound>.mp3
# To convert frames from a video or GIF into individual numbered images:
ffmpeg -i <video.mpg|video.gif> <frame_%d.png>
# To combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:
ffmpeg -i <frame_%d.jpg> -f image2 <video.mpg|video.gif>
# To quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image:
@heyfluke
heyfluke / remap_docker_user_to_host_user.md
Last active March 5, 2024 15:57
remap docker user to host user.

Problem

When I use docker to work with the shared workspace with host under Ubuntu, I find that files created by docker user is owned by root. This is not the same with macOS.

Maybe this is becuase docker is run by root user and the default user mapping mechanism is to map container-root to host-user or host-root. So can I map the container-root or container-any-user to host-current-user?

Fortunately the latest docker supports the re-map the container user to any host user via Linux namespace. Refer to this.

Linux namespace

#!/usr/local/python/bin
# coding=utf-8
'''Implements a simple log library.
This module is a simple encapsulation of logging module to provide a more
convenient interface to write log. The log will both print to stdout and
write to log file. It provides a more flexible way to set the log actions,
and also very simple. See examples showed below:
@heyfluke
heyfluke / renderview2snapshot
Created October 5, 2013 09:12
take snapshot.
. + (UIImage *)renderView:(UIView *)view {
. UIGraphicsBeginImageContext(view.bounds.size);
.
. CGContextRef ctx = UIGraphicsGetCurrentContext();
. [view.layer renderInContext:ctx];
.
. UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
.
. UIGraphicsEndImageContext();
.
@heyfluke
heyfluke / SmoothedSmoothedBIView.mm
Created September 28, 2013 13:43
Smoothed drawing in a scrollview.
#import "ScrolledSmoothedBIView.h"
#import "SmoothedBIView.h"
@implementation ScrolledSmoothedBIView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
@heyfluke
heyfluke / SmoothedBIView.mm
Created September 28, 2013 13:42
Smoothed drawing.
#import "SmoothedBIView.h"
#import "TouchProfiler.h"
@implementation SmoothedBIView
{
UIBezierPath *path;
UIImage *incrementalImage;
CGPoint pts[5]; // we now need to keep track of the four points of a Bezier segment and the first control point of the next segment
uint ctr;
TouchProfiler *_profiler;
@heyfluke
heyfluke / TouchProfiler.mm
Created September 28, 2013 13:34
record touch-event times and show reports.
/// start TouchProfiler.h
#ifndef __MySketchPad__TouchProfiler__
#define __MySketchPad__TouchProfiler__
#include <deque>
using namespace std;
class TouchProfiler
{
public:

Raspberry Pi general optimization

  • Use a class 10 SD card for best speed. The USB bus can't come much higher than 30MB/s so you don't have to buy any extremely fast ones though. Not all cards are compatible, check the compatibility list: http://elinux.org/RPi_SD_cards
  • Use the HardFloat version of Raspbian instead of the SoftFloat. HF has much faster floating point operations - however SF is required for running Java. So it's either Java or performance, like normal.
  • The official Raspbian image gives low network speeds: http://elinux.org/RPi_Performance#NIC
  • A graphics driver by Simon / teh_orph is using hardware acceleration for some instructions: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=28294 installation instructions: http://elinux.org/RPi_Xorg_rpi_Driver
  • The firmware can be upgraded which gives, among other things, better GPU performance.