Skip to content

Instantly share code, notes, and snippets.

fn main() -> Result<()> {
let args = Args::parse();
let zipfile = File::open(args.zipfile)?;
let zipfile = CloneableFile::new(zipfile);
let zip = zip::ZipArchive::new(zipfile)?;
let file_count = zip.len();
println!("Zip has {} files", file_count);
(0..file_count).into_par_iter().for_each(|i| {
let mut myzip = zip.clone();
@xiangyuan
xiangyuan / SlicedFilledImage.cs
Created July 27, 2021 02:54 — forked from yasirkula/SlicedFilledImage.cs
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@xiangyuan
xiangyuan / Automated RubyGem Install
Created December 1, 2020 05:24 — forked from wallymathieu/Automated RubyGem Install
How to install RubyGems via an automated ruby script
#!c:/ruby/bin/ruby.exe
require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'
def install(lib)
begin
Gem::GemRunner.new.run ['install', lib]
rescue Gem::SystemExitException => e
end
@xiangyuan
xiangyuan / GravityCamera.cs
Created November 25, 2020 03:23 — forked from BichengLUO/GravityCamera.cs
A Unity3D script for rotating the camera according to the device's accelerometer
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class GravityCamera : MonoBehaviour
{
public GameObject target;
public Vector3 centerOffset;
public float sensitivity = 1000;
@xiangyuan
xiangyuan / p4merge4git.md
Created November 10, 2020 10:59 — forked from tony4d/p4merge4git.md
Setup p4merge as a visual diff and merge tool for git

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@xiangyuan
xiangyuan / PinToSafeArea.cs
Created August 2, 2019 09:25 — forked from SeanMcTex/PinToSafeArea.cs
Restrict Unity UI to an iPhone X or other Mobile Device's Safe Area
using UnityEngine;
/// <summary>
/// Resizes a UI element with a RectTransform to respect the safe areas of the current device.
/// This is particularly useful on an iPhone X, where we have to avoid the notch and the screen
/// corners.
///
/// The easiest way to use it is to create a root Canvas object, attach this to a "SafeAreaContainer"
/// child of that canvas, and then to lay out other UI elements within the SafeAreaContainer, which
/// will adjust size appropriately for the current device.
@xiangyuan
xiangyuan / Circular Circles.shader
Created April 23, 2019 03:02 — forked from FreyaHolmer/Circular Circles.shader
A shader for rendering circles arranged in a circle. Written in CG for use in the Unity engine
Shader "Custom/Circular Circles" {
Properties {
_CircleCount ("Circle Count", Float ) = 8
_CircleRadius ("Circle Radius", Range(0, 1)) = 0.18
_CircleSharpness ("Circle Sharpness", Range(0, 0.999)) = 0.95
_GroupRadius("Group Radius", Range(0, 1)) = 0.6
}
SubShader {
Pass {
CGPROGRAM
@xiangyuan
xiangyuan / XTEA.cs
Created October 29, 2018 06:15 — forked from InfectedBytes/XTEA.cs
XTEA encryption for C#
/*
* Helper class for XTEA en/decryption of arbitrary data.
*
* Copyright (c) 2017, Henrik Heine
*/
using System;
using System.IO;
using System.Text;
@xiangyuan
xiangyuan / CinemachineCameraShaker.cs
Created September 19, 2018 07:12 — forked from reunono/CinemachineCameraShaker.cs
Cinemachine camera shake
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Add this component to your Cinemachine Virtual Camera to have it shake when calling its ShakeCamera methods.
/// </summary>
public class CinemachineCameraShaker : MonoBehaviour
{