Skip to content

Instantly share code, notes, and snippets.

@tanyuan
tanyuan / inject-360-exif.sh
Last active June 22, 2017 14:06
Make Facebook / Google Photos recognize 360 photo
convert photo.png photo.jpg
# Facebook
exiftool -ProjectionType="equirectangular" photo.jpg
# Google Photos
exiftool -ProjectionType="equirectangular" -UsePanoramaViewer="True" -"PoseHeadingDegrees<$exif:GPSImgDirection" -"CroppedAreaImageWidthPixels<$ImageWidth" -"CroppedAreaImageHeightPixels<$ImageHeight" -"FullPanoWidthPixels<$ImageWidth" -"FullPanoHeightPixels<$ImageHeight" -CroppedAreaLeftPixels="0" -CroppedAreaTopPixels="0" photo.jpg
@tanyuan
tanyuan / rclone.md
Created February 13, 2017 00:43
rsync for Google Drive, Dropbox etc.

rclone

Setup

rclone config

Config file is stored at ~/.rclone.conf

List directories

@tanyuan
tanyuan / samba.md
Last active February 25, 2022 14:55
Access Arch Linux folders from Mac using samba

Access Arch Linux folders from Mac using samba

Tested with Arch Linux and macOS Sierra

First make sure that the two machines can see each other.

On Arch, find out IP of Arch Linux machine by:

ip addr
@tanyuan
tanyuan / example.r
Last active January 23, 2017 16:14
Basic R plotting from a text file
# Read arguments from bash command line, example: Rscript data.txt plot.pdf
args <- commandArgs(trailingOnly = TRUE)
# Read data (space separated), if no header: header = FALSE
data <- read.csv(args[1], sep="")
# Set pdf output filename
pdf(file=args[2])
# Plot line plot
plot(data$time, data$raw, type='l')
# Draw another line on the same plot
@tanyuan
tanyuan / remote-ubuntu.md
Last active January 12, 2017 11:32
Mac connects to remote Ubuntu desktop

Mac connects to remote Ubuntu desktop

Remote: Ubuntu:

Desktop Sharing

  • Allow other users to control your desktop
  • You must confirm each access to this machine
  • Require the user to enter this password: ________
@tanyuan
tanyuan / unityReadWriteFile.cs
Created January 7, 2017 19:40
Unity read & write text files.
using System.IO;
string path = "Assets/file.txt";
// Write to file
File.AppendAllText(path, System.String.Format("{0} {1} {3}\n", var1, var2, var3));
// Read from file
StreamReader sr = new StreamReader(path);
for (int i = 0; !sr.EndOfStream; i++) {
@tanyuan
tanyuan / UnlitInsideTransparentTexture.shader
Created January 7, 2017 08:46
Unity shader for inside visible transparent texture.
Shader "Unlit/UnlitTransparentTexture"
{
Properties {
_Color ("Main Color (A=Opacity)", Color) = (1,1,1,1)
_MainTex ("Base (A=Opacity)", 2D) = ""
}
Category {
Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
Cull front // ADDED BY BERNIE, TO FLIP THE SURFACES
@tanyuan
tanyuan / README.md
Last active February 15, 2018 05:33
Control MakerBot movement using Python
@tanyuan
tanyuan / chromium-local-file
Created October 10, 2016 05:13
Open a Chromium session allowing local file access.
#!/bin/bash
chromium-browser --user-data-dir='/tmp' --allow-file-access-from-files $1 &
@tanyuan
tanyuan / README.md
Created October 10, 2016 04:56
Fix Apple keyboard Caps Lock delay.

Fix Apple keyboard Caps Lock delay.

Useful when remapped to another key.

Compile the code:

    gcc apple-kb-caps.c -o apple-kb-caps

Move the executable apple-kb-caps and script run-apple-kb-caps to ~/bin/.