Wednesday, 25 May 2016
Restoring applications after minimizing to Mac OS X dock
When you click the yellow pill button in the upper left corner of a window to minimize that window in Mac OS X or if you use ⌘ Cmd + M you might want to bring the application back. When cycling through running applications, including the minimised applications, using ⌘ Cmd + Tab you might expect to retrieve the application back.
This sequence on the other hand will bring wour application window.
1. Use ⌘ Cmd + Tab untill you find your application.
2. Before releasing ⌘ Cmd, press and hold ⌥ Alt
Other method is to hide application using ⌘ Cmd + H, then you can restore your window with ⌘ Cmd + Tab
Thursday, 12 May 2016
Using Python, MySQL and UTF-8
I have been spending way to long time figuring out how I can encode my data to utf8 when fetching records from MySQL database. All the time I was focusing on encoding the output, resulting in error like this one.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 1:
ordinal not in range(128)
The solution I finally found is to set the character set when I prepare the MySQL connection
con.set_character_set('utf8')
Ending up in my code like this.!/usr/bin/env python
# -*- coding: utf-8 -*-
import MySQLdb as mdb
def getname(p):
con = mdb.connect('hostname', 'username', ' password', 'databasname')
con.set_character_set('utf8')
sql = "SELECT cellname1 from tablename where cellname2='%s'"%(str(p))
cur = con.cursor()
cur.execute(sql)
row = cur.fetchone()
if not row:
return 'n/a'
else:
return str(row[0])
cur.close()
Now everything works like a charm.
Tuesday, 15 December 2015
How To Allow Usb To Serial Adapters In Osx “el Capitan
In my line of work I use serial port on some devices frequently and most new computers do not have serialport. In Linux I found out that it’s easy to connect using usb to serial and screen, but now when I’ve got mac it looks like there is no driver for the usb to serial by default.
I bought PL-2303 Driver (€6.17/$7.36) and all my problems are solved. It'a easy and fast installation.
After I connect the USB serial converter I simply type in:
screen /dev/tty.Repleo-PL2303-00001014
-cheers
Monday, 23 November 2015
Windows is blocking random websites
My gf is running Windows and some time after she got Windows 8 some DNS issue occurred and random webpages started to get blocked. After update to Windows 10 this problem was still ongoing. To "fix" this she had to use
ipconfig /flushdns
But that was just a temporary fix because later same day you could need to do this again.I did multiple web searches and in the end I found this method that seems to fix this issue.
Run CMD as admininstrator.
In the command line type:
netsh winsock reset
Press Enter then restart your PC.Netsh winsock reset is a helpful command that you can use in Windows to reset the winsock catalog back to default setting or clean state.
In computing, the Windows Sockets API (WSA), later shortened to Winsock, is a technical specification that defines how Windows network software should access network services, especially TCP/IP.
Tuesday, 9 June 2015
Terminal won't launch after upgrade to Ubuntu 15.04
After upgrade to Ubuntu 15.04 there is know bug where you can't get the terminal to open with Ctrl+Alt+T
Apparently the problem has to do with custom locale. You can fix this by changing the locale /etc/default/locale
Apparently the problem has to do with custom locale. You can fix this by changing the locale /etc/default/locale
LANG="en_US.UTF-8
"LANGUAGE="en_US"
Or you can add the LANG=en_US.utf8 to your ~/.bashrc file by adding following line to it
export LANG=en_US.utf8
If you have any improvement to this or a better method, please feel free to share it here in the comments.
Monday, 8 June 2015
How to embed a Google Calendar in a responsive site
I'm using embedded google calendar on a responsive website and in my opinion it works quite well on a mobile device. Well it works on my LG G3 with Android 5.0 Lollipop.
But there seems to be a problem as I had some complaints from some iPhone users where the calendar would display fine but not populate any actual events.
So, what to do. One solution was brought to my attention where two versions of the calender code is used in two div's. One div for normal view and one div for mobile view and some css to hide or show based on the width of the screen. Yes, it works. But the calender view in this solution looses part of it's functions like the week view. I think it is a bad solution where you "fix" one thing by making it worse for those where it works.
My solution might not be the best in the world, but I'm trying to fix only what is broken. The iPhone view. That's why I use php to find out what device or browser is viewing the page and then I select which calender code I use. And I use a bit from fhe CSS from the other solution.
The main difference is the URL to the calender is "embed" vs. "htmlembed"
Original:
The web page has a Wordpress cms and to use php code on a page or a post we need to install some plugin for that, I choose PHP Code for posts for this job, but you can use anything that works for you.
Here is the code I use to select how I display the calendar
But there seems to be a problem as I had some complaints from some iPhone users where the calendar would display fine but not populate any actual events.
So, what to do. One solution was brought to my attention where two versions of the calender code is used in two div's. One div for normal view and one div for mobile view and some css to hide or show based on the width of the screen. Yes, it works. But the calender view in this solution looses part of it's functions like the week view. I think it is a bad solution where you "fix" one thing by making it worse for those where it works.
My solution might not be the best in the world, but I'm trying to fix only what is broken. The iPhone view. That's why I use php to find out what device or browser is viewing the page and then I select which calender code I use. And I use a bit from fhe CSS from the other solution.
The main difference is the URL to the calender is "embed" vs. "htmlembed"
Original:
https://www.google.com/calendar/embed?
The fixed version:
https://www.google.com/calendar/htmlembed?
The web page has a Wordpress cms and to use php code on a page or a post we need to install some plugin for that, I choose PHP Code for posts for this job, but you can use anything that works for you.
Here is the code I use to select how I display the calendar
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'ipod'))
{
?>
<div class="responsive-iframe-container">
<iframe style="border-width: 0;" src="https://www.google.com/calendar/htmlembed?***"></iframe>
</div>
<?
}else {
?>
<div class="responsive-iframe-container-normal">
<iframe src="https://www.google.com/calendar/embed?***"></iframe>
</div>
<?
}
?>
Here is the CSS I added, it might need some adjustments..responsive-iframe-container-normal iframe,
.vresponsive-iframe-container-normal object,
.vresponsive-iframe-container-normal embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.responsive-iframe-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 400px;
overflow: hidden;
}
.responsive-iframe-container iframe,
.vresponsive-iframe-container object,
.vresponsive-iframe-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
If you have any improvement to this or a better method, please feel free to share it here in the comments.
Sunday, 26 April 2015
Sublime text in "command mode"
I really love Sublime Text 3, it's very easy to use and powerful tool at the same time. One of the things that recently started to bother me is "command mode". Some how doing things I have done many times before like selecting word or string multiple times CRTL + D, edit them and quit the selection with ESC which is enabling "command mode". Something has changed in my setup I think, because I'm pretty sure that this did not happen before and for some time I just closed the file and reopened to get back in "insert mode". But after all, the solution was quite simple. i takes you back to "insert mode".
Even better, at least in my case where I'm not using this "command mode", simply go to preferences -> settings-user and add following.
"ignored_packages":
[
"Vintage"
]
Subscribe to:
Posts
(
Atom
)






