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
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:
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"
]
Monday, 13 April 2015

Taking and tweeting a photo with raspberry pi


At first I was going to create a timelapse of my cherry tree while blooming, then I decided to make a tweet once a day with a image.

Timelapse

Based on older post on how to make a Timelapse with Rapberry Pi camera module, I made small change. Rather than do a loop of x images I choose to use cronjob to run the script every 15 minutes. The script is simple and short.
#!/bin/bash

DIR=/home/pi/cherrytree
/usr/bin/raspistill -w 1920 -h 1080 -rot 180 -n -t 1000 -o $DIR/$(date -u +"%Y%m%d-%H%M-%S").jpg

Next add to your cronjob your interval, I use every 15 min.
*/15 * * * * /bin/bash /home/pi/cherry.sh >/dev/null 2>&1

Twitter bot

There's more than one way to cook an egg... There are also many ways to make a twitter bot.
I installed Twitter CLI
sudo apt-get install ruby-dev
gem install t
You will also have to create or have access to an twitter app to authorize the CLI interface.


Here is a simple script I use to take picture and tweet it. Every time I run this script, I just overwrite the image, but you can collect them by naming the file like in the script above.
#!/bin/bash
DIR=/home/pi/autotwitter
DATE=$(date -u +"%A %d %B %Y")
/usr/bin/raspistill -w 800 -h 460 -rot 180 -n -t 1000 -o $DIR/twitter.jpg
/usr/local/bin/t update 'Image of the day, '"${DATE}"'. #CherryBlossoms #raspberrypi #cli ' --file=$DIR/twitter.jpg
Once a day this script runs by cronjob at 12:01
1 12 * * * /bin/bash /home/pi/twitter.sh >/dev/null 2>&1
In addition to that, you can auto follow your followers in the same script by adding following line to the twitter script.
/usr/local/bin/t groupies | xargs /usr/local/bin/t follow

Friday, 6 March 2015

Tag cloud and list layout with css



What I wanted was to style my tags, (labels) which is an unordered list, so the look like the image below.

    Tag list

    This is a simple unordered list, we need to remowe bullets and make it horizontal.
    <ul class="tags">
        <li class="tag">
            <a target="_blank" href="#">css</a>
        </li>
        <li class="tag">
            <a target="_blank" href="#">html</a>
        </li>
        <li class="tag">
            <a target="_blank" href="#">python</a>
        </li>
        <li class="tag">
            <a target="_blank" href="#">Demo</a>
        </li>
    </ul>

    And here we have the css
    ul .tags {
        list-style: none;
    }
    .tags a, .tags a:visited, .tags a:active{
        color: #ddd;
        border:1px solid #ddd;
        border-radius:5px;
        text-decoration:none;
        padding:3px;
        margin:3px;
        text-transform:uppercase;
        font-size: 1em;
        line-height: 1.2em;
    }
    .tags a::before{
        content:'#';
    }
        
    .tags a:hover {
        color: #fff;
        background:#eee;
    }
    
    li.tag {
        display: inline;
        list-style-type: none;
    }
    

    Perhaps I'll change the layout of the labels in this site to.

    --cheers
    Saturday, 28 February 2015

    Six tips to improve your Google calendar usage


    Google Calendar is the favourite up-to-date organization tool. like other Google’s services, Google Calendar has flexibility which lets you work faster and more efficiently. With Gmail, separate calendars for work, school or personal affairs, keep them together in the same view, and share your calendar with colleagues.

    1. Keyboard shortcuts


    Navigating around a calendar should be fast and easy.

    Shortcut KeyAction
    Navigation
    k or pMoves your calendar view to the previous date range
    j or nMoves your calendar view to the next date range
    rRefreshes your calendar
    tMoves you to the current day
    Views
    1 or dDisplays your calendar in the 'Day' view
    2 or wDisplays your calendar in the 'Week' view
    3 or mDisplays your calendar in the 'Month' view
    4 or xDisplays your calendar in the 'Custom' view
    5 or aDisplays your calendar in the 'Agenda' view
    Actions
    cAllows you to create a new event
    eAllows you to view an event's details
    Backspace or DeleteDeletes the event
    ctrl + z / command + z or zUndo last action (if possible)
    ctrl + s / command + sSave event (from event details page)
    EscReturn to calendar grid (from event details page)
    Application
    /Places your cursor in the search box
    shift += or +Focus on 'Add a calendar' text box under 'Other calendars'
    qOpens "Quick Add"
    ctrl + p or command + pPrints the current view
    sBrings you to your Google Calendar settings page
    ctrl + ? / command + ? or ?Brings up a menu of keyboard shortcuts

    2. Receive an email with your agenda


    If your schedule is busy, you can receive your google agenda by mail, share it, modify it or duplicate it. Go to settings, Calendars tab, then click on the “Notifications” of the agenda.

    Receive an email with your agenda

    3. Add a Different Time Zone


    You can get Google Calendar to display multiple timezones. To change this, hit S to head to "Settings" menu. Under the "General" tab you can see "Your current time zone." Click on "Show an additional time zone," and then tick the box "Display all time zones."

    Add a Different Time Zone


    4. Customise view the view of your Google calendar

    Set the view of your calendar, depending on whether you prefer a display of “4 days, 5 days or more”. Choose between 2-7 days and 2-4 weeks.
    Hit s for settings and scroll down to "Custom view"

    5. View your tasks in your Google Calendar

    Google Calendar allows you to view your tasks in your calendar. In the left pane, in "My calendars" check the “Tasks” box. Google Calendar allows you to assign a deadline to a task, which will be displayed in your calendar.

    View your tasks in your Google Calendar

    6. Add public holidays to Google calendar

    Integrate public holidays or special events to your Google Calendar. Depending on countries and cultures, the holidays or public holidays can be very different. In the left pane, click "Other Calendars" and "Browse interesting calendar".

    Add public holidays to Google calendar

    Thursday, 8 January 2015

    How I use VPN on Android

    In the comany I work for we are providing VPN connection to our employees. To set up the VPN connection using pre shared key, I use following settings on my LG G3 phone.
    Settings --> Networks --> Tethering &networks --> VPN --> Add VPN network
    
    VPN field:
    Name: Work
    Type: IPSec Xauth PSK
    Server: VPN  IP.
    IPSec identifier: Connection profile
    IPSec pre-shared-key: Secret key.