query = '''SELECT COALESCE(SUM(imp), 0) AS imps,
COALESCE(SUM(click), 0) AS clicks
FROM logCuDate
WHERE id=%s
AND date >= %s
AND date <= %s'''
res = db.executesql(query, args, as_dict=True)
This file contains hidden or 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
| #!/bin/sh | |
| # | |
| # PROVIDE: myuwsgi | |
| # | |
| . /etc/rc.subr | |
| name=myuwsgi | |
| rcvar=myuwsgi_enable | |
| start_cmd="myuwsgi_start" |
This file contains hidden or 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
| CREATE FUNCTION `lat_lng_distance` (lat1 FLOAT, lng1 FLOAT, lat2 FLOAT, lng2 FLOAT) | |
| RETURNS FLOAT | |
| DETERMINISTIC | |
| BEGIN | |
| RETURN 6371 * 2 * ASIN(SQRT( | |
| POWER(SIN((lat1 - abs(lat2)) * pi()/180 / 2), | |
| 2) + COS(lat1 * pi()/180 ) * COS(abs(lat2) * | |
| pi()/180) * POWER(SIN((lng1 - lng2) * | |
| pi()/180 / 2), 2) )); | |
| END |
This file contains hidden or 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
| # dump all databases once every 24 hours | |
| 45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz | |
| # vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night) | |
| 45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze" | |
| 45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet" | |
| # re-index all databases once a week | |
| 0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"' |
This file contains hidden or 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
| defmodule MyApp.Periodically do | |
| use GenServer | |
| def start_link do | |
| GenServer.start_link(__MODULE__, %{}) | |
| end | |
| def init(state) do | |
| Process.send_after(self(), :work, 2 * 60 * 60 * 1000) # In 2 hours | |
| {:ok, state} |
This file contains hidden or 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/python | |
| # This script help you extract image files from an APK file. | |
| # Author : Daehee Han (https://github.com/booknara, @daniel_booknara) | |
| # Date : August 21 2013 | |
| # Basic Usage | |
| # (1) img_extractor.py --ifile <APK file> --ofile <Destination Directory> | |
| # (2) img_extractor.py --ifile <APK file> --ofile . | |
| # (3) img_extractor.py --ifile <APK file> --ofile .. |
This file contains hidden or 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
| #!/bin/sh | |
| # encode_bitrate_overlay.sh | |
| # | |
| # | |
| # Created by Andrew Sinclair on 11/07/2014. | |
| # | |
| #!/bin/bash | |
| VIDSOURCE=$1 | |
| OUTNAME=$2 |
This file contains hidden or 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/python | |
| # Script to encode HLS and DASH from a multi TS mezzanine file | |
| # Places encoded files in a folder of the same name as the source input | |
| # Steps | |
| # 1. Check file with mediainfo (optional) | |
| # 2. Encode to resolutions as mp4 | |
| # 3. Split into TS segments and create playlists | |
| # 4. Create variant playlist | |
| import subprocess |
#FFmpeg Tips
##Table of Contents
- Convert .mp4 to .webm
- Convert .avi to mp4
- Optimize mp4
- Scalling (Resize)
- Create thumbnail from first video frame
###Convert .mp4 to .webm
This file contains hidden or 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 sqlalchemy import create_engine | |
| engine = create_engine('sqlite:///:memory:', echo=True) | |
| from sqlalchemy.ext.declarative import declarative_base | |
| Base = declarative_base() | |
| from sqlalchemy import Column, Integer, String, Float | |
| class User(Base): | |
| __tablename__ = 'users' |