Skip to content

Instantly share code, notes, and snippets.

View xen's full-sized avatar
🔥
Light My Fire!

Mikhail Kashkin xen

🔥
Light My Fire!
View GitHub Profile
@xen
xen / isretina.py
Last active June 22, 2016 00:36
isretina.py
from objc_util import *
us = ObjCClass('UIScreen')
if us.mainScreen().scale() == 2.0:
print('Retina')
elif us.mainScreen().scale() == 3.0:
print('iPhone 6 Plus')
else:
print('Non retina')
# cat ~/.pip/pip.conf
[global]
default-timeout = 60
respect-virtualenv = true
#download-cache = /home/xen/.pip/cache
log-file = /home/xen/.pip/pip.log
use-wheel = yes
find-links = /home/xen/.pip/wheels
[wheel]
@xen
xen / 1-usage.txt
Last active September 12, 2018 07:49
i18njson translate using Google Translate
$ python i18njson-translate.py --help
Usage: i18njson-translate.py [OPTIONS] INPUTFILE OUTPUT
Process and translate .po or JSON files and generate translated .po file
in result. Can work with exist .po files and if in initial file msgid
dissapear then mark translaed string as obsolete. Try to play nice with
version control systems and follow initial file order format, you will get
predicteable diffs.
Options:
@xen
xen / .gitconfig
Last active August 29, 2015 14:01
Git config
[user]
name = XX
email = X@X.X
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
@xen
xen / example.py
Last active June 18, 2021 08:43
HTTP cache headers decorator for Flask
# example
from flask import json
from .utils import docache
@api.route('/jsonmethod', defaults={'count': 10})
@docache(hours=48, content_type='application/json')
def get_count(count):
# can be useable with JSON APIs
@xen
xen / pyft-vertical-metrics.py
Last active August 29, 2015 13:56
Font ascents/descents fixes
#!/usr/bin/python
# -*- coding: utf-8 -*-
from fontTools import ttLib
def writeFont(font, filename):
font.save(filename)
print "Wrote font to", filename
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
import pytils
import datetime
import time
from selenium import webdriver
@xen
xen / test.py
Created December 26, 2013 03:25
def test_metadata_family(self):
""" Font and METADATA.json have the same name """
self.assertEqual(self.font.familyname, self.metadata.get('name', None))
def test_em_is_1000(self):
""" Font em should be equal 1000 """
self.assertEqual(self.font.em, 1000,
msg="Font em value is %s, required 1000" % self.font.em)
tell application "iPhoto"
set curPhotos to selection
set theCount to 0
repeat with thisPhoto in curPhotos
set theCount to theCount + 1
get theCount
if theCount = 1 then
set lastPhoto to thisPhoto
else
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.