This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Helpers to transcode images. | |
DEPENDENCIES | |
------------ | |
imagemagick (for converting, already installed) | |
avconv (for transcoding) sudo apt-get install libav-tools | |
libx264 (higher encoding quality) sudo apt-get install libavcodec-extra-53 | |
http://askubuntu.com/questions/266663/ffmpeg-resize-could-not-find-codec-parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
convert_to_jpg | |
Converts image formats that browsers don't commonly support (TIFF, BMP, SGI, RGB, etc.) | |
to JPGs and stores them in the same directory if an output location is not specified. | |
Please ignore the following warning: | |
[swscaler @ 0x7fdabb825e00] deprecated pixel format used, make sure you did set range correctly | |
Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
gif_to_mp4 | |
Converts GIFs from an input directory to MP4s or a single GIF file to an MP4 | |
and stores them in the same directory if an output location is not specified. | |
Also, generates a preview image if desired. | |
Usage: | |
gif_to_mp4.py <input_file_or_directory> [-o=<output_directory>] | |
gif_to_mp4.py prev <input_file_or_directory> [-o=<output_directory>] [-p=<output_directory>] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from typing import Callable, Dict, Iterable, List, Optional | |
T = TypeVar("T") | |
U = TypeVar("U") | |
def group_by( | |
func: Callable[[T], U], | |
coll: Iterable[T], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/54761452/3446870 | |
const {promisify} = require('util'); | |
const readline = require('readline'); | |
async function readlineQuestion(question) { | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
from typing import List, Optional, Tuple, Type, Union | |
from django.contrib.auth.models import AbstractUser | |
from django.db import models | |
from django.db.backends.base.base import BaseDatabaseWrapper | |
from django.db.models.expressions import Expression | |
from django.forms import TypedChoiceField | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
# https://hackernoon.com/lesser-known-git-commands-151a1918a60 | |
# https://gist.github.com/robmiller/6018582 | |
# https://www.atlassian.com/blog/git/advanced-git-aliases | |
# https://bitbucket.org/durdn/cfg/src/master/.gitconfig?at=master | |
# https://softwaredoug.com/blog/2022/11/09/idiot-proof-git-aliases.html | |
# template: "!f() { git ; }; f" | |
st = status --short --branch | |
ls = "!f() { git log --oneline -${1-1}; }; f" | |
la = "!f() { git log -${1-1}; }; f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFromRegexKeys(key, map) { | |
for (let [re, val] of map.entries()) { | |
if (re.test(key)) { | |
return val(key.match(re)); | |
} | |
} | |
} | |
const map = new Map([ | |
[/^foo\/(.+)$/, matchResults => matchResults[1]], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert | |
* | |
* foo: { | |
* bar: ['baz', 'qux'], | |
* } | |
* | |
* to | |
* | |
* foo: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (RCTTextSelection *)selection | |
{ | |
id<RCTBackedTextInputViewProtocol> backedTextInput = self.backedTextInputView; | |
UITextRange *selectedTextRange = backedTextInput.selectedTextRange; | |
return [[RCTTextSelection new] initWithStart:[backedTextInput offsetFromPosition:backedTextInput.beginningOfDocument toPosition:selectedTextRange.start] | |
end:[backedTextInput offsetFromPosition:backedTextInput.beginningOfDocument toPosition:selectedTextRange.end] | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
cursorPosition:[backedTextInput caretRectForPosition:selectedTextRange.start].origin]; | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ |
NewerOlder