Skip to content

Instantly share code, notes, and snippets.

View Apkawa's full-sized avatar
🌴
On vacation

Apkawa Apkawa

🌴
On vacation
View GitHub Profile
@Apkawa
Apkawa / frontend.md
Last active August 17, 2018 18:51
Тестовое задание для Frontend-разработчика (React+Redux)

Создать простое одностраничное веб-приложение (React+Redux, SASS) о погоде

(!) Данные можно взять с сайта openweathermap.org

Приложение должно уметь:

  • Добавлять/удалять города
  • Сохранять локально данные
  • Автоматически запрашивать погоду по координатам пользователя — это город/место по умолчанию.

Last updated: 2015-08-11

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@Apkawa
Apkawa / s3_utils.py
Created April 24, 2015 13:44
S3 Multiregion bucket wrapper
class S3MultiRegionWrapper(object):
DEFAULT_REGION = 'eu-west-1'
BUCKET_REGIONS_MAP = None
def __init__(self, conn_kwargs):
self.region = conn_kwargs.pop("region", None) or self.DEFAULT_REGION
self.conn_kwargs = conn_kwargs
self.conn_kwargs['aws_access_key_id'] = settings.AWS_ACCESS_KEY_ID
self.conn_kwargs['aws_secret_access_key'] = settings.AWS_SECRET_ACCESS_KEY
self.region_connections = {}
@Apkawa
Apkawa / ffmpeg.sh
Created April 22, 2015 14:22
ffmpeg cheatsheets
# Example resize to 480p and deshake video
ffmpeg -i input.mov \
-vcodec libx264 \
-vf "deshake,scale=-1:480,scale=trunc(iw/2)*2:trunc(ih/2)*2" \
-acodec copy \
-y output.mp4 \
# Example convert all MOV files in folder
find . -name "*.MOV" -exec ffmpeg -i '{}' -vcodec libx264 -vf "deshake,scale=-1:480,scale=trunc(iw/2)*2:trunc(ih/2)*2" -an -y '{}.mp4' ';'
@Apkawa
Apkawa / books_ru.rb
Last active January 4, 2018 17:20
Downloader buyed e-books from Books.ru
#!/usr/bin/env ruby
# encoding=utf-8
# = INSTALL =
# sudo apt-get install ruby-mechanize
# sudo gem install vcr
require 'uri'
require 'fileutils'
require 'pathname'
require 'vcr'
@Apkawa
Apkawa / check_host_certificates.sh
Created October 22, 2014 13:38
Проверка ip домена на некорректный сертификат. (бывает, что в cdn забанены несколько адресов)
#!/bin/bash
while true
do
ip_list=$(dig $1 A |grep -E "^${1}."|grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
for ip in $ip_list
do
check=$(echo -n $(echo "123" | openssl s_client -connect ${ip}:443 2>/dev/null |grep "issuer=/C=RU/ST=Moscow/O="|wc -l))
if [ $check -eq 1 ]
@Apkawa
Apkawa / example_use.py
Last active June 8, 2021 16:42
Django patch for join with extra
# -*- coding: utf-8 -*-
from .queryset import ExtraJoinQuerySet
class ModelQuerySet(ExtraJoinQuerySet):
def attach_useful_vote(self, user=None):
return self.extra(select={"field": "joined_table.field"},
join=[
"""
JOIN (SELECT rel_id, field FROM subselect_table) AS joined_table ON table.id = joined_table.rel_id
@Apkawa
Apkawa / style_guide.rst
Created January 14, 2014 09:01
Описание стиля REST api

DataURI.py

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.

Parsing

@Apkawa
Apkawa / make gif
Last active December 22, 2015 12:49
#Do check time
mplayer -noautosub -sid 1000 -ao null \
-ss 00:06:05 -endpos 20 \
video.avi
# Do make frame images from video
mplayer -noautosub -sid 1000 -ao null \
-ss 00:06:05 -endpos 20 \
video.avi \
-vo jpeg:quality=99:outdir=images