Skip to content

Instantly share code, notes, and snippets.

View chaojian-zhang's full-sized avatar
🏯
When I am doing programming: I want to be God.

Charles Zhang chaojian-zhang

🏯
When I am doing programming: I want to be God.
View GitHub Profile
  • Convert images to video: ffmpeg -framerate 4 -start_number 51 -i _DSC12%d.jpg -c:v libx264 -r 4 output.mp4 (Recommendataion) Use Screen2Gif's editor instead.
  • Convert video into gif
  • Convert video into image sequence:
  • Crop video: ffmpeg -i in.mp4 -vf crop=w:h:x:y out.mp4
  • Change video frame rate:
  • Scale video resolution: ffmpeg -i input.avi -vf scale=320:240 output.avi
  • Scaleing while keeping aspect ratio: ffmpeg -i input.jpg -vf scale=320:-1 output_320.png
  • Scale images: ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png
  • Multiple filters (separate using comma): ffmpeg -i 1.mp4 -vf "crop=720:720:264:0, scale=320:-1" 1.gif
  • Trim/Cut video: ffmpeg -i input.mp4 -ss 00:05:20 -t 00:10:00 -c:v copy -c:a copy output1.mp4
@chaojian-zhang
chaojian-zhang / BinaryData.cs
Last active March 1, 2023 13:29
Quick C# bin Data. #C#, #LZ4
// <PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.3.5" />
public abstract class BaseNotifyPropertyChanged: INotifyPropertyChanged
{
#region Data Binding
public event PropertyChangedEventHandler PropertyChanged;
public virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected bool SetField<TType>(ref TType field, TType value, [CallerMemberName] string propertyName = null)
{
@chaojian-zhang
chaojian-zhang / DockerUsageNotes.md
Last active February 10, 2023 21:44
Docker Usages Notes

Basics

  • docker run --name <your_container_name> alpine/git <git_command>
  • docker run -it --name <your_container_name> alpine/git <git_command>: Run with tty interactive
  • docker run -d --name couch -p 8091-8094:8091-8094 -p 11210:11210 couchbase: Run (e.g. a server) unattached
  • docker cp container_name:/git/getting-started .: Copy files/folders between a container and the local filesystem
  • docker start <your_container_name>: Start a stopped container
  • docker attach <your_container_name>: Attach to running container
@chaojian-zhang
chaojian-zhang / gerstner_wave.cpp
Created February 8, 2023 04:04 — forked from yorung/gerstner_wave.cpp
Calc gerstner wave in C++.
struct Wave
{
Vec2 dir;
float amplitude;
float waveLength;
};
struct ImmutableCB
{
float waveSteepness;
@chaojian-zhang
chaojian-zhang / Perlin.cs
Created February 6, 2023 19:03 — forked from Kakusakov/Perlin.cs
Improved Perlin Noise Implementation in C#
// Clone of https://gist.github.com/Flafla2/1a0b9ebef678bbce3215 with more dimensions and seed generation.
public class PerlinGen
{
private readonly int[] p; // Randomly shuffled array of values from 0 to 255.
// Values are repeated up to size of 512 to avoid using modulo operator.
public PerlinGen(int seed)
{
// Generate p.
@chaojian-zhang
chaojian-zhang / Blazor Bizarre.md
Last active January 11, 2023 18:53
Blazor bizarre. #Blazor #C# #.Net Core

Blazor Bizarre

Blazor is NOT procedural. And you cannot define "functional components" - so all the shitty little layouts need to become a seperate component, which quickly makes project messy because each component needs some naming.

Blazor is entirely FUNCTIONAL despite what it looks like, and things like the below can happen that blew your mind:

// The code below depends on Blazorized for <Row> and <Column> definitions

// ProductGalerry.blazor
@chaojian-zhang
chaojian-zhang / CursorPos.cs
Created December 29, 2022 19:21
CursorPos #C#
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows; // Or use whatever point class you like for the implicit cast operator
namespace CursorPos
{
class Program
{
/// <summary>
@chaojian-zhang
chaojian-zhang / (Reference) VS Shortcuts.md
Last active November 23, 2022 14:11
Visual Studio very common shortcuts that's used and forgotten by us.

Visual Studio Shortcuts

Navigation

  • Ctrl+-: Go to last cursor location (navigate back); Same effect if one has "Navigate back" mouse button;
  • Alt+F12: Peek definition; Press again to peek declaration;
  • Ctrl+K, O: Switch between header and cpp file;
  • Ctrl+K, R: Find all references;
  • Alt+*: Go (back to) current debug line;
  • F9: Toggle breakpoint
@chaojian-zhang
chaojian-zhang / get-pip.py
Last active November 22, 2022 22:04 — forked from rgl/python-embedded.md
notes about python embedded in windows #Python
This file has been truncated, but you can view the full file.
#!/usr/bin/env python
#
# Hi There!
#
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip (version 22.3.1).
#
# Pip is a thing that installs packages, pip itself is a package that someone
@chaojian-zhang
chaojian-zhang / StringHelper.cs
Last active November 5, 2022 18:58
Useful stuff borrowed from [The Matrix](https://github.com/Charles-Zhang-Project-Nine/TheMatrix) project. #C#, #CSharp, #Utility
/*Dependency: Csv by Steven Hansen*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Utility