echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
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
######################################################################################################## | |
# This config enables us to: | |
# - Resize | |
# - Rotate | |
# ...the resident images on an upstream server, with Nginx Server in our hand, On the fly! | |
# - Just by using arbitrary Query Parameters | |
# ...and | |
# - Cache the transformed image by address. | |
# | |
# Well, I got the Idea from https://stumbles.id.au/nginx-dynamic-image-resizing-with-caching.html |
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
DROP FUNCTION IF EXISTS fa2EnDigit; | |
DELIMITER $$ | |
CREATE FUNCTION fa2EnDigit(str TEXT) RETURNS TEXT | |
BEGIN | |
DECLARE t TEXT; | |
SET t = str; | |
SET t = REPLACE(t, '۱', '1'); | |
SET t = REPLACE(t, '۲', '2'); | |
SET t = REPLACE(t, '۳', '3'); | |
SET t = REPLACE(t, '۴', '4'); |
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
String.prototype.replaceAll = function(search, replacement) { | |
var target = this; | |
return target.replace(new RegExp(search, 'g'), replacement); | |
}; | |
/** | |
* Example | |
*/ |
To merge exist migration files into one file:
- Remove
django_migration
records table (manually) - Remove all migration files
- run
python manage.py migrate --fake
command - run
python manage.py makemigrations
command - run
python manage.py migrate --fake-initial
command - run
python manage.py migrate contenttypes
command
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
import telegram | |
def main(): | |
bot = telegram.Bot(token="113351444:AAGmDDOkLqvzCESShVAfzwBgLiT1R9UvUK0") | |
lui = bot.getUpdates()[-1].update_id | |
print lui | |
while True: | |
for updates in bot.getUpdates(offset=lui,timeout=10): | |
text = updates.message.text | |
chat_id = updates.message.chat.id | |
update_id = updates.update_id |
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
import base64 | |
from django.core.files.base import ContentFile | |
from rest_framework import serializers | |
class Base64ImageField(serializers.ImageField): | |
def from_native(self, data): | |
if isinstance(data, basestring) and data.startswith('data:image'): | |
# base64 encoded image - decode |
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 django.db import connection | |
from django.conf import settings | |
cursor = connection.cursor() | |
cursor.execute('SHOW TABLES') | |
results=[] | |
for row in cursor.fetchall(): | |
results.append(row) | |
for row in results: | |
cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0])) |
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
#! /usr/bin/env python | |
import os | |
import sys | |
import re | |
import tempfile | |
def getVideoDetails(filepath): | |
tmpf = tempfile.NamedTemporaryFile() | |
os.system("ffmpeg -i \"%s\" 2> %s" % (filepath, tmpf.name)) | |
lines = tmpf.readlines() |
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
$ brew install libmagic | |
$ brew link libmagic (if the link is already created is going to fail, don't worry about that) | |
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/ |
NewerOlder