Skip to content

Instantly share code, notes, and snippets.

@espio999
espio999 / MP4toGIF-MoviePy-simple.py
Created April 7, 2023 04:05
Convert MP4 to GIF with MoviePy - simple style
from moviepy.editor import *
folder_path = '/content/drive/MyDrive/20230404/'
movie_name = 'screen-20230331-142030.mp4'
gif_name = '20230404.gif'
source_path = folder_path + movie_name
target_path_ffmpeg = folder_path + 'ffmpeg' + gif_name
target_path_imageio = folder_path + 'imageio' + gif_name
@espio999
espio999 / MP4toGIF-MoviePy.py
Created April 7, 2023 04:02
Convert MP4 to GIF with MoviePy
from moviepy.editor import *
def getCroppedFrames(movie, crop_size, resize_size):
cropped_movie = movie.crop(x1=0, y1=0, width=crop_size["w"], height=crop_size["h"])
resized_movie = cropped_movie.resize(height=resize_size["h"])
return resized_movie
def makeGIF(path, movie, fps, program):
@espio999
espio999 / MP4toGIF-OpenCV.py
Created April 7, 2023 03:48
Convert MP4 to GIF with OpenCV and Pillow
import cv2
from PIL import Image
def getCroppedFrames(movie, crop_size, resize_size):
ret_images = []
while True:
ret, bgr_images = movie.read()
@espio999
espio999 / DRM-SecurityLevelCheck-MainActivity.kt
Last active November 27, 2022 11:18
output DRM security level properties at protection system level and content level - Widevine and others
package com.example.testrun20221122
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.example.testrun20221122.databinding.ActivityMainBinding
import java.util.Date
import android.media.MediaDrm
import java.util.UUID
@espio999
espio999 / container_generics.kt
Created October 3, 2022 00:56
defining container with generics type, it doesn't require type cast.
//ジェネリクス
//どのような型でも受け取るコンテナ
class Container<T>(val value: T)
//どのような型でも受け取る関数
fun <T> packer(value: T): Container<T>{
return Container(value)
}
//コンテナの中身を確認する
@espio999
espio999 / container_any.kt
Created October 3, 2022 00:56
defining container with Any type, it sometime requires type cast.
//any型
//どのような型でも受け取るコンテナ
class Container(var value: Any)
//どのような型でも受取、コンテナに詰める
fun packer(value: Any): Container{
return Container(value)
}
//コンテナの中身を確認する
@espio999
espio999 / Roto.kt
Last active October 2, 2022 15:35
Abstract class and Interface, inheritance and override in Kotlin
abstract class BasicRole(name:String){
var name = name
fun attack(){
println("${name}は攻撃した")
}
open fun guard(){
println("${name}は身を守っている")
}
@espio999
espio999 / 42sv2017d01e09.sh
Last active April 30, 2022 01:28
42 SILICON VALLEY Piscine 2017 Day01 Exercise 09
echo $FT_NBR1 + $FT_NBR2 | sed "s/'/0/g" | tr '\\"?!' 1234 | tr mrdoc 01234 | xargs echo 'obase=13; ibase=5;' | bc | tr 0123456789ABC 'gtaio luSnemf'
@espio999
espio999 / 42sv2017d01e07.sh
Last active April 30, 2022 00:15
42 SILICON VALLEY Piscine 2017 Day01 Exercise 07
cat /etc/passwd | cut -d ":" -f 1,2,3,4,6,7 | sed -n 2~2p | cut -d":" -f 1 | rev | sort -r | tr [:cntrl:] "," | sed 's/,/, /g' | rev | cut -c 3- | sed 's/^/./' | rev | tr -d [:cntrl:]
@espio999
espio999 / 42sv2017d01e06.sh
Created April 29, 2022 14:07
42 SILICON VALLEY Piscine 2017 Day01 Exercise 06
ls -l | sed -n 1~2p