Snippets Collections
from random import randint
from PIL import Image
from os import listdir, path, mkdir
from uuid import uuid4
import moviepy.editor as mp

def generate_video(folder):
    if not path.exists(folder):
        mkdir(folder)

    # generate video frames
    for i in range(20):
        img = Image.new(
            mode = 'RGB',
            size = (500, 250),
            color = (0, 0, 0)
        )

        for x in range(img.size[0]):
            for y in range(img.size[1]):
                r, g, b = randint(0, 255), randint(0, 255), randint(0, 255)
                img.putpixel((x, y), value = (r, g, b))

        img.save(f'{folder}/{i}.png')
    
    # create video
    images = [f'{folder}/{img}' for img in listdir(folder)]
    clips = [mp.ImageClip(img).set_duration(0.08) for img in images]
    video = mp.concatenate_videoclips(clips, method = 'compose')
    video.to_videofile(f'{str(uuid4())}.mp4', fps = 24)


generate_video('test')
function el(arr) {
  let i = 0;
  return function gen() {
    if (i < arr.length) {
      let val = arr[i];
      i += 1;
      return val;
    }
  }
}
const myArray = [1, 2, 3];
const myGenerator = el(myArray);

console.log(myGenerator()); // 1
console.log(myGenerator()); // 2
console.log(myGenerator()); // 3
console.log(myGenerator()); // undefined
function el(arr) {
  let i = 0;
  return function gen() {
    if (i < arr.length) {
      let val = arr[i];
      i += 1;
      return val;
    }
  }
}
const myArray = [1, 2, 3];
const myGenerator = el(myArray);

console.log(myGenerator()); // 1
console.log(myGenerator()); // 2
console.log(myGenerator()); // 3
console.log(myGenerator()); // undefined
function el(arr) {
  let i = 0;
  return function gen() {
    if (i < arr.length) {
      let val = arr[i];
      i += 1;
      return val;
    }
  }
}
const myArray = [1, 2, 3];
const myGenerator = el(myArray);

console.log(myGenerator()); // 1
console.log(myGenerator()); // 2
console.log(myGenerator()); // 3
console.log(myGenerator()); // undefined
// js
#!/usr/bin/env php
<?php
foreach (glob('*.js') as $js) {
   echo "wp_enqueue_script('wptheme-{$js}', get_template_directory_uri() . '/js/{$js}', array('jquery'), '1.0', true);";
}

// Css
#!/usr/bin/env php
<?php
foreach (glob('*.css') as $css) {
   echo "wp_enqueue_style('wptheme-{$css}', get_template_directory_uri() . '/css/{$css}', null, '1.0');";
}
// js
#!/usr/bin/env php
<?php
foreach (glob('*.js') as $js) {
   echo "wp_enqueue_script('wptheme-{$js}', get_template_directory_uri() . '/js/{$js}', array('jquery'), '1.0', true);";
}

// Css
#!/usr/bin/env php
<?php
foreach (glob('*.css') as $css) {
   echo "wp_enqueue_style('wptheme-{$css}', get_template_directory_uri() . '/css/{$css}', null, '1.0');";
}
star

Sat Oct 21 2023 04:51:13 GMT+0000 (Coordinated Universal Time) video: https://youtu.be/99Zacm7SsWQ?si=DMjv-7OOlInonYd9&t=1398

#javascript #generator #higher-order-function
star

Sat Oct 21 2023 04:50:25 GMT+0000 (Coordinated Universal Time) video: https://youtu.be/99Zacm7SsWQ?si=DMjv-7OOlInonYd9&t=1398

#javascript #generator #higher-order-function
star

Sat Oct 21 2023 04:50:23 GMT+0000 (Coordinated Universal Time) video: https://youtu.be/99Zacm7SsWQ?si=DMjv-7OOlInonYd9&t=1398

#javascript #generator #higher-order-function
star

Sat May 14 2022 10:28:43 GMT+0000 (Coordinated Universal Time)

#generator #css #js
star

Sat May 14 2022 10:28:41 GMT+0000 (Coordinated Universal Time)

#generator #css #js

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension