Skip to content

Instantly share code, notes, and snippets.

View vijinho's full-sized avatar

Vijay vijinho

  • England
View GitHub Profile
@vijinho
vijinho / gist:0bdad1fb2f5b399bc3ca
Last active October 22, 2020 20:19
Kivy - Detect if running on a desktop platform
from kivy.utils import platform
def is_desktop():
"""
Detect if we are running on the desktop or not
:return: boolean True if running on a desktop platform or String platform
"""
if platform in ('linux', 'win', 'macosx'):
return True
else:
@vijinho
vijinho / gist:d7b76af6a765eea0baf0
Last active August 29, 2015 14:07
Debug Kivy Widgets
# DEBUG ALL WIDGETS
<Widget>:
canvas.after:
Line:
rectangle: self.x+1, self.y+1, self.width-1, self.height-1
dash_offset: 5
dash_length: 3
# DEBUG A SINGLE WIDGET
canvas.after:
from kivy.core.text import LabelBase
KIVY_FONTS = [
{
"name": "Ubuntu",
"fn_regular": "assets/fonts/ubuntu/Ubuntu-L.ttf",
"fn_bold": "assets/fonts/ubuntu/Ubuntu-M.ttf",
"fn_italic": "assets/fonts/ubuntu/Ubuntu-LI.ttf",
"fn_bolditalic": "assets/fonts/ubuntu/Ubuntu-MI.ttf"
}
]
@vijinho
vijinho / gist:ff3aca32ebdb6739811d
Last active August 29, 2015 14:08
Determine image orientation from width and height
def orientation(self, width, height):
"""
Determine an image orientation based on width and height
:param w: width
:param h: height
:return: boolean (landscape, portrait, square)
"""
square = False
landscape = False
portrait = False
@vijinho
vijinho / gist:5bad31a16beedb9e02c8
Created October 28, 2014 04:17
Python Kivy: Rescale an image to fit a given viewport size without losing aspect ratio
class MyImage(Image):
def __init__(self, **kwargs):
super(MyImage, self).__init__()
def texture_width(self):
return self.texture.size[0]
def texture_height(self):
return self.texture.size[1]
@vijinho
vijinho / gist:66e200cf3bbec4ff5b7a
Created October 28, 2014 13:32
Kivy Debug Test Script
# -*- coding: utf-8 -*-
import kivy
kivy.require('1.8.0')
from kivy.uix.image import Image
from kivy.uix.behaviors import ButtonBehavior
from kivy.properties import ObjectProperty, StringProperty
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.lang import Builder
from kivy.config import Config
@vijinho
vijinho / gist:a8e2838b5408548ba03c
Created November 1, 2014 16:05
List file extensions in use in current directory tree
# find file extension used in project
find . -type f | cut -d '.' -f 3 | sort | uniq | sort
@vijinho
vijinho / gist:488ebe2ff2ffa8acc87e
Created November 2, 2014 16:33
Ubuntu 13.10 Kivy VM Packages Used
accountsservice install
acl install
acpid install
adduser install
android-platform-headers install
android-src-vendor install
ant install
ant-optional install
apparmor install
apport install
@vijinho
vijinho / gist:2a59d7660ecc0c7d8c2b
Last active April 10, 2024 03:23
MacOS X nginx SSL Proxy Setup

#Installing nginx on OS X

brew install nginx
sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
mkdir -p /usr/local/etc/nginx/logs
mkdir -p /usr/local/etc/nginx/sites-available
mkdir -p /usr/local/etc/nginx/sites-enabled
mkdir -p /usr/local/etc/nginx/conf.d
mkdir -p /usr/local/etc/nginx/ssl
@vijinho
vijinho / startMysql.sh
Last active February 5, 2016 22:23
MAMP Start MySQL with my.cnf configuration file
# /bin/sh
#
# If there is a MySQL configuration file present in the MAMP conf directory,
# use it as the only configuration file processed by MySQL. Otherwise use the
# sequence of MySQL configuration files as defined in the MySQL documentation:
#
# http://dev.mysql.com/doc/refman/5.5/en/option-files.html
/Applications/MAMP/bin/stopMysql.sh