Skip to content

Instantly share code, notes, and snippets.

nano ~/.bash_profile
# in .bash_profile
export GEM_HOME=/Users/sg/.gem
export PATH="$GEM_HOME/bin:$PATH"

Concat a video with a reversed version of itself (for looping)

# without audio
ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" output.mp4

# with audio
ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][0:a][r] [0:a]concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
@sdgandhi
sdgandhi / codesign.sh
Created May 28, 2020 23:57
Enable virtual webcam support for Zoom
sudo codesign --entitlements zoom_entitlements.xml -f -s - /Applications/zoom.us.app
@sdgandhi
sdgandhi / keys
Last active April 1, 2020 03:22
karabiner mouse keys
{
"title": "Mouse keys SG",
"rules": [
{
"description": "Mouse keys SG",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "w",
@sdgandhi
sdgandhi / wol.py
Created March 28, 2020 04:55
wake on lan
#!/usr/bin/env python
import socket
import sys
if len(sys.argv) < 3:
print "Usage: wakeonlan.py <ADR> <MAC> (example: 192.168.1.255 00:11:22:33:44:55)"
sys.exit(1)
mac = sys.argv[2]
@sdgandhi
sdgandhi / ffmpeg-watermark.md
Created July 22, 2019 22:45 — forked from bennylope/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@sdgandhi
sdgandhi / replace_run_script
Created March 1, 2018 20:08
Only run firebase fabric dsym upload on release configuration
if [ "${CONFIGURATION}" = "Release" ]; then
"${PODS_ROOT}/Fabric/run"
fi
@sdgandhi
sdgandhi / generateAppIcon.sh
Created November 22, 2017 19:17 — forked from roblabs/generateAppIcon.sh
Generate app icons and xcassets file from a single image. To use this, place script in `appname` folder inside your project (i.e. the folder that Xcode generates for you containing your source code, it's named after whatever you called the app). Create folder there called `RawImages`. Source icon should 1024x1024 and be called appIcon.png. If th…
#!/bin/bash -e
# --------------------------------------------------------
# Generate app icons and xcassets file from a single image
# Ben Clayton, Calvium Ltd.
# https://gist.github.com/benvium/2be6d673aa9ac284bb8a
# --------------------------------------------------------
#
# Usage with an input of 1024x1024 PNG file
# generateAppIcon.sh AppIcon.png
@sdgandhi
sdgandhi / gist:7f149f6348a7c203d5b7
Created June 1, 2015 02:04
Apple Watch — Load animated image from sprite sheet
func loadingAnimationImage() -> UIImage? {
let sheet = UIImage(named: "activity-large")
var images = [UIImage]()
if sheet == nil {
return nil
}
for (var currentX = 0; currentX < Int(sheet!.size.width); currentX += 54) {
let splitRef = CGImageCreateWithImageInRect(sheet?.CGImage, CGRect(x: CGFloat(currentX), y: 0.0, width: 54.0, height: sheet!.size.height * 2))
@sdgandhi
sdgandhi / save to photos
Created May 26, 2015 18:23
save photo on iOS using Photos Framework
PHObjectPlaceholder *placeholderAsset;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:<#image#>];
newAssetRequest.creationDate = <#time#>;
newAssetRequest.location = <#location#>;
placeholderAsset = newAssetRequest.placeholderForCreatedAsset;
PHAssetCollectionChangeRequest *addAssetRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:<#asset collection#>];