Skip to content

Instantly share code, notes, and snippets.

@ESWZY
ESWZY / compress_video.py
Last active February 9, 2025 17:05
An example Python code for compressing video file to target size.
# Simplified version and explanation at: https://stackoverflow.com/a/64439347/12866353
import os
import ffmpeg
def compress_video(video_full_path, size_upper_bound, two_pass=True, filename_suffix='cps_'):
"""
Compress video file to max-supported size.
:param video_full_path: the video you want to compress.
:param size_upper_bound: Max video size in KB.
@jamescalam
jamescalam / app.py
Created August 26, 2020 11:38
Simple REST API code example.
from flask import Flask
from flask_restful import Resource, Api, reqparse
import os
app = Flask(__name__)
api = Api(app)
DATA = {
'places':
['rome',
@nrubin29
nrubin29 / balanced_parentheses_one_line.py
Last active April 9, 2021 11:37
The classic balanced parentheses algorithm implemented in one line (one expression) in Python for this video: https://youtu.be/0eeweCiUU4U
print(
(
lambda expr, stack: all(
len(stack) == 0 if char is None else
stack.append(char) or True if char in '([{' else
len(stack) > 0 and {'(': ')', '[': ']', '{': '}'}[stack.pop()] == char if char in ')]}' else
True
for char in expr
)
)(
@felipou
felipou / decrypt_dbeaver.py
Last active February 11, 2025 10:48
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycryptodome lib (pip install pycryptodome)
import sys
import base64
import os
import json
from Crypto.Cipher import AES
@ipepe
ipepe / install-chrome-headless.sh
Last active February 10, 2025 16:14
Installing headless chrome on Ubuntu.
#!/bin/bash
# from https://chromium.woolyss.com/
# and https://gist.github.com/addyosmani/5336747
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox http://example.org/
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active April 23, 2025 02:00
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@thaJeztah
thaJeztah / docker-examples.md
Last active October 11, 2024 12:20
Some docker examples

Commit, clone a container

To 'clone' a container, you'll have to make an image of that container first, you can do so by "committing" the container. Docker will (by default) pause all processes running in the container during commit to preserve data-consistency.

For example;

docker commit --message="Snapshot of my container" my_container my_container_snapshot:yymmdd
@dangtrinhnt
dangtrinhnt / utils.gs
Created November 19, 2014 14:10
Convert row data to dictionary using Google Apps Script
function rowToDict(sheet, rownumber) {
var columns = sheet.getRange(1,1,1, sheet.getMaxColumns()).getValues()[0];
var data = sheet.getDataRange().getValues()[rownumber-1];
var dict_data = {};
for (var keys in columns) {
var key = columns[keys];
dict_data[key] = data[keys];
}
return dict_data;
}
@niksumeiko
niksumeiko / git.migrate
Last active April 10, 2025 01:10
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.