Graph your pacman activity!

Today I wanted to create a simple script that would graph my pacman activity, and I thought I might as well share it with community. Below you can find a python script that serves that purpose. You will need python2-matplotlib to use it. And here what my version of the graph looks like:
Copyright (C) 2011 Yaşar Arabacı
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import datetime
import time
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from collections import Counter
months = mdates.MonthLocator() # every month
days = mdates.DayLocator() # Every day
monthsFmt = mdates.DateFormatter('%m-%Y')
logfile = "/var/log/pacman.log"
interesting_line = re.compile(
r"\[(?P<datetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2})\] "
"(?P<action>installed|upgraded|removed)")
installs = Counter()
upgrades = Counter()
removes = Counter()
with open(logfile) as logfile:
for line in logfile:
match = interesting_line.search(line)
if match:
struct = time.strptime(match.group("datetime"),"%Y-%m-%d %H:%S")
date = datetime.date(struct.tm_year, struct.tm_mon, struct.tm_mday)
if match.group("action") == "installed":
installs[date] += 1
elif match.group("action") == "upgraded":
upgrades[date] += 1
elif match.group("action") == "removed":
removes[date] += 1
fig = plt.figure()
ax = fig.add_subplot(111)
insdatenumpairs = zip(installs.keys(), installs.values())
insdatenumpairs = sorted(insdatenumpairs, key = lambda pair: pair[0])
upgdatenumpairs = zip(upgrades.keys(), upgrades.values())
upgdatenumpairs = sorted(upgdatenumpairs, key = lambda pair: pair[0])
remdatenumpairs = zip(removes.keys(), removes.values())
remdatenumpairs = sorted(remdatenumpairs, key = lambda pair: pair[0])
ax.plot([pair[0] for pair in insdatenumpairs],[pair[1] for pair in insdatenumpairs],"b")
ax.plot([pair[0] for pair in upgdatenumpairs],[pair[1] for pair in upgdatenumpairs],"g")
ax.plot([pair[0] for pair in remdatenumpairs],[pair[1] for pair in remdatenumpairs],"y")
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
ax.xaxis.set_minor_locator(days)
ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
ax.grid(True)
fig.autofmt_xdate()
plt.legend(("installs","upgrades","removes"))
plt.xlabel("Date")
plt.ylabel("# of packages")
plt.show()
Last edited by yasar11732 (2012-01-08 11:58:35)

Here is a little bit different version, only showing total number of packages over time.
Copyright (C) 2011 Yaşar Arabacı
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import datetime
import time
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from collections import Counter
months = mdates.MonthLocator() # every month
days = mdates.DayLocator() # Every day
monthsFmt = mdates.DateFormatter('%m-%Y')
logfile = "/var/log/pacman.log"
interesting_line = re.compile(
r"\[(?P<datetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2})\] "
"(?P<action>installed|removed)")
total = 0
packs = Counter()
with open(logfile) as logfile:
for line in logfile:
match = interesting_line.search(line)
if match:
struct = time.strptime(match.group("datetime"),"%Y-%m-%d %H:%S")
date = datetime.date(struct.tm_year, struct.tm_mon, struct.tm_mday)
if match.group("action") == "installed":
total += 1
elif match.group("action") == "removed":
total -= 1
packs[date] = total
fig = plt.figure()
ax = fig.add_subplot(111)
datenumpairs = zip(packs.keys(), packs.values())
datenumpairs = sorted(datenumpairs, key = lambda pair: pair[0])
ax.plot([pair[0] for pair in datenumpairs],[pair[1] for pair in datenumpairs])
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
ax.xaxis.set_minor_locator(days)
ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
ax.grid(True)
fig.autofmt_xdate()
plt.xlabel("Date")
plt.ylabel("# of packages")
plt.show()
Last edited by yasar11732 (2012-01-08 11:59:09)

Similar Messages

  • How to import your MS Active Directory users in an Oracle table

    Hello,
    I first tried to get a Heterogenous Connection to my MS Active Directory to get information on my Active Directory users.
    This doesn't work so I used an alternative solution:
    How to import your MS Active Directory users in an Oracle table
    - a Visual Basic script for export from Active Directory
    - a table in my database
    - a SQL*Loader Control-file
    - a command-file to start the SQL*Loader
    Now I can schedule the vsb-script and the command-file to get my information in an Oracle table. This works fine for me.
    Just to share my scripts:
    I made a Visual Basic script to make an export from my Active Directory to a CSV-file.
    'Export_ActiveDir_users.vbs                              26-10-2006
    'Script to export info from MS Active Directory to a CSV-file
    '     Accountname, employeeid, Name, Function, Department etc.
    '       Richard de Boer - Wetterskip Fryslan, the Nethterlands
    '     samaccountname          Logon Name / Account     
    '     employeeid          Employee ID
    '     name               name     
    '     displayname          Display Name / Full Name     
    '     sn               Last Name     
    '     description          Description / Function
    '     department          Department / Organisation     
    '     physicaldeliveryofficename Office Location     Wetterskip Fryslan
    '     streetaddress          Street Address          Harlingerstraatweg 113
    '     l               City / Location          Leeuwarden
    '     mail               E-mail adress     
    '     wwwhomepage          Web Page Address
    '     distinguishedName     Full unique name with cn, ou's, dc's
    'Global variables
        Dim oContainer
        Dim OutPutFile
        Dim FileSystem
    'Initialize global variables
        Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
        Set OutPutFile = FileSystem.CreateTextFile("ActiveDir_users.csv", True)
        Set oContainer=GetObject("LDAP://OU=WFgebruikers,DC=Wetterskip,DC=Fryslan,DC=Local")
    'Enumerate Container
        EnumerateUsers oContainer
    'Clean up
        OutPutFile.Close
        Set FileSystem = Nothing
        Set oContainer = Nothing
        WScript.Echo "Finished"
        WScript.Quit(0)
    Sub EnumerateUsers(oCont)
        Dim oUser
        For Each oUser In oCont
            Select Case LCase(oUser.Class)
                   Case "user"
                        If Not IsEmpty(oUser.distinguishedName) Then
                            OutPutFile.WriteLine _
                   oUser.samaccountname      & ";" & _
                   oUser.employeeid     & ";" & _
                   oUser.Get ("name")      & ";" & _
                   oUser.displayname      & ";" & _
                   oUser.sn           & ";" & _
                   oUser.description      & ";" & _
                   oUser.department      & ";" & _
                   oUser.physicaldeliveryofficename & ";" & _
                   oUser.streetaddress      & ";" & _
                   oUser.l           & ";" & _
                   oUser.mail           & ";" & _
                   oUser.wwwhomepage      & ";" & _
                   oUser.distinguishedName     & ";"
                        End If
                   Case "organizationalunit", "container"
                        EnumerateUsers oUser
            End Select
        Next
    End SubThis give's output like this:
    rdeboer;2988;Richard de Boer;Richard de Boer;de Boer;Database Administrator;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Richard de Boer,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;
    tbronkhorst;201;Tjitske Bronkhorst;Tjitske Bronkhorst;Bronkhorst;Configuratiebeheerder;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Tjitske Bronkhorst,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;I made a table in my Oracle database:
    CREATE TABLE     PG4WF.ACTD_USERS     
         samaccountname          VARCHAR2(64)
    ,     employeeid          VARCHAR2(16)
    ,     name               VARCHAR2(64)
    ,     displayname          VARCHAR2(64)
    ,     sn               VARCHAR2(64)
    ,     description          VARCHAR2(100)
    ,     department          VARCHAR2(64)
    ,     physicaldeliveryofficename     VARCHAR2(64)
    ,     streetaddress          VARCHAR2(128)
    ,     l               VARCHAR2(64)
    ,     mail               VARCHAR2(100)
    ,     wwwhomepage          VARCHAR2(128)
    ,     distinguishedName     VARCHAR2(256)
    )I made SQL*Loader Control-file:
    LOAD DATA
    INFILE           'ActiveDir_users.csv'
    BADFILE      'ActiveDir_users.bad'
    DISCARDFILE      'ActiveDir_users.dsc'
    TRUNCATE
    INTO TABLE PG4WF.ACTD_USERS
    FIELDS TERMINATED BY ';'
    (     samaccountname
    ,     employeeid
    ,     name
    ,     displayname
    ,     sn
    ,     description
    ,     department
    ,     physicaldeliveryofficename
    ,     streetaddress
    ,     l
    ,     mail
    ,     wwwhomepage
    ,     distinguishedName
    )I made a cmd-file to start SQL*Loader
    : Import the Active Directory users in Oracle by SQL*Loader
    D:\Oracle\ora92\bin\sqlldr userid=pg4wf/<password>@<database> control=sqlldr_ActiveDir_users.ctl log=sqlldr_ActiveDir_users.logI used this for a good list of active directory fields:
    http://www.kouti.com/tables/userattributes.htm
    Greetings,
    Richard de Boer

    I have a table with about 50,000 records in my Oracle database and there is a date column which shows the date that each record get inserted to the table, for example 04-Aug-13.
    Is there any way that I can find out what time each record has been inserted?
    For example: 04-Aug-13 4:20:00 PM. (For my existing records not future ones)
    First you need to clarify what you mean by 'the date that each record get inserted'.  A row is not permanent and visible to other sessions until it has been COMMITTED and that commit may happen seconds, minutes, hours or even days AFTER a user actually creates the row and puts a date in your 'date column'.
    Second - your date column, and ALL date columns, includes a time component. So just query your date column for the time.
    The only way that time value will be incorrect is if you did something silly like TRUNC(myDate) when you inserted the value. That would use a time component of 00:00:00 and destroy the actual time.

  • HT1498 do you have to have your computer active, in order for apple tv to work?

    Do you have to have your computer active, in order for apple tv to work?

    Setting up Home Sharing for Apple TV (2nd generation)
    Troubleshooting Home Sharing with Apple TV (2nd gen)
    Apple TV (2nd and 3rd gen)- How to use AirPlay Mirroring

  • Can I get the circle graphs back in Activity Monitor in Mavericks?

    Can I get the circle graphs back in Activity Monitor in Mavericks?

    No, the Disk Usage and Memory Usage pie charts are gone. Also gone is the Memory Usage Dock icon. (New graphs are much more useful, imo.)

  • Re: Impossible to activate your iPhone, activation server temporarily unavailable.. how long it will take?

    hi there
    just update ios to try beta 6  to our test iphone 3gs  but we got the message
    Impossible to activate your iPhone, activation server temporarily unavailable..
    we try several times to activate it but nothing. we have the dev account and also the provis auth. any idea why this could happen ?
    thanks

    As you are running a beta you must be a developer. You will have to go to the Developer forums for help.
    I suspect there is nothing wrong with the activation server; more likely you hacked the phone to get the beta. Now you are stuck.

  • "Your [Windows] activation period has expired. You must activate Windows."

    Today I received a refurbished P755-S5385 from Amazon.com Warehouse Deals. I turned on the computer per the instructions, and very carefully typed in the Windows product key from the "Windows 7 Home Premium Refurbished PCs" sticker on the bottom of the laptop. I then got the above error that the activation period had expired. I'm not sure what this means. What activation period. I'm sure at least several companies sell refurbished Toshibas. Does anyone (here or at Toshiba) know what to do?  Thanks. -Paul
    Solved!
    Go to Solution.

    Satellite P755-S5385
    1) In the Start/Search box type this.
        slui 4  
    2) Press the Enter key.  
    3) Select your Country from the list.  
    4) Choose the Phone Activation option by calling the number.  
    5) Stay on the phone (do not select or press any options) and simply wait for a person to help you with activation.  
    6) Explain your problem clearly to the support person. 
       How to contact a Microsoft Product Activation Center by phone
    -Jerry

  • HT4623 "could not activate your iPhone" -- activation server cannot be reached.  Any ideas? Waited for 20 minutes now.

    Just keeps saying the activation server cannot be reached.  Am I too impatient or is there something actually wrong?

    Check to see if your antivirus or firewall is blocking access to gs.apple.com. You might also see this message if your phone was jailbroken or if your computer was used to jailbreak in the past.
    If neither of these apply, just keep trying. There's a very heavy load on Apple's data centers right now.

  • Please complete your iPhone activation

    I've upgraded to the 4s for more than a month now and all is well with no trouble. But recenty I've been getting emails telling me to activte my iphone by connecting it to my computer (once 2/17 and one today). I don't know what's causing this and am afriad someone might be trying to use my email address to activate another iphone. Who can I turn to to look into this matter?

    Your best bet is to call Apple and see if your phone is registered with them, since it's obviously not the activation with your carrier since it's working fine.

  • Daily stats required from statspack for graph of month activity

    Hi All,
    I am trying to get a graph of index io on a daily basis, the trouble is the stats are cumulative since database startup and the database is rarely bounced. So what I actually get is a growing value for each day. I expect there is a simple way to correct my code in sqlplus. ( Otherwise PL/SQL beckons)
    Here is my code:
    Select to_char(snap_time, 'YYYY-MON-DD') "Day of Mnth",
    avg(time_waited_micro)/1000 "index wait duration"
    FROM
    perfstat.stats$system_event se,
    Perfstat.stats$snapshot sn
    WHERE se.snap_id = sn.snap_id
    and se.event='db file sequential read'
    and sn.snap_time between (sysdate - 50) and sysdate
    GROUP BY to_char(snap_time, 'YYYY-MON-DD')
    order by to_date(to_char(snap_time, 'YYYY-MON-DD'),'YYYY-MON-DD') ;
    Thanks in Advance

    Hi All,
    I am trying to get a graph of index io on a daily basis, the trouble is the stats are cumulative since database startup and the database is rarely bounced. So what I actually get is a growing value for each day. I expect there is a simple way to correct my code in sqlplus. ( Otherwise PL/SQL beckons)
    Here is my code:
    Select to_char(snap_time, 'YYYY-MON-DD') "Day of Mnth",
    avg(time_waited_micro)/1000 "index wait duration"
    FROM
    perfstat.stats$system_event se,
    Perfstat.stats$snapshot sn
    WHERE se.snap_id = sn.snap_id
    and se.event='db file sequential read'
    and sn.snap_time between (sysdate - 50) and sysdate
    GROUP BY to_char(snap_time, 'YYYY-MON-DD')
    order by to_date(to_char(snap_time, 'YYYY-MON-DD'),'YYYY-MON-DD') ;
    Thanks in Advance

  • Clearcache - another script to selectively clear your pacman cache.

    https://aur.archlinux.org/packages.php?ID=50498
    I learned there are a number of scripts designed to do the same thing after I
    wrote the basic framework, but I went ahead and finished it anyway.
    clearcache has a number of features I haven't seen elsewhere,
    usage: clearcache [options] [targets]
    Options:
      -h, --help          display this help menu
      -d, --dry           dry run, simply list targets instead of removing
      -q, --quiet         only prints filenames for -d/--dry or -l/--list-targets
      -f, --force         force removal of package files
      -i, --ignore <pkg>  specify package(s) to ignore. this can be a comma
                          separated list, or '-' reads a list from stdin, one
                          per line. can be used more than once.
      -k, --keep <num>    specify number of old package files to keep. by default,
                          clearcache will keep the two most recent versions.
      -l, --list-targets  list targets to remove, using PAGER/less, before
                          removing. may not be used with -d/--dry
      -t, --threads <num> use <num> threads. the default value is 5. using a
                          large number will not gain you much, and is not
                          recommended, but there is no hard limit.
      -u, --uninstalled   remove all package files for packages that are not
                          currently installed, while still keeping the
                          specified number of old files for installed packages
      -v, --verbose       output more
      there MUST be a space between the option and its argument.
    Targets:
      targets are package names, as you would specify them to pacman.
      if targets are specified, only package files belonging to them will be
      removed. if no targets are specified, all packages except for thos
      specified to be ignored will be removed.
    It now uses the .PKGINFO file within the package itself, in order to know which
    package it belongs to (Thanks again brisbin).  This eliminates any issues with
    parsing the name from the version info, in the filename.
    Obviously using alpm or such would be faster, but this was a quick project.  I
    wrote a short snippet for myself, and decided to extend it.
    Anyway, hope someone else finds this useful, let me know if you find any bugs,
    or have any feature reqs.
    Potential issues:
      As seems to be the most common issue with scripts like this, it assumes the
      most recent package in the cache is the one installed, or the one you would
      want to keep.  I'm considering parsing pacman output to compare the versions,
      at least as an option.
    EDIT:
      Now with multithreading!  It has taken about 10% off the execution time on a single
      core netbook, and gets faster on better processors.  If nothing else, it was a good
      experiment, but I think it turned out rather well.
    Last edited by freak (2011-07-07 01:56:45)

    https://aur.archlinux.org/packages.php?ID=50498
    I learned there are a number of scripts designed to do the same thing after I
    wrote the basic framework, but I went ahead and finished it anyway.
    clearcache has a number of features I haven't seen elsewhere,
    usage: clearcache [options] [targets]
    Options:
      -h, --help          display this help menu
      -d, --dry           dry run, simply list targets instead of removing
      -q, --quiet         only prints filenames for -d/--dry or -l/--list-targets
      -f, --force         force removal of package files
      -i, --ignore <pkg>  specify package(s) to ignore. this can be a comma
                          separated list, or '-' reads a list from stdin, one
                          per line. can be used more than once.
      -k, --keep <num>    specify number of old package files to keep. by default,
                          clearcache will keep the two most recent versions.
      -l, --list-targets  list targets to remove, using PAGER/less, before
                          removing. may not be used with -d/--dry
      -t, --threads <num> use <num> threads. the default value is 5. using a
                          large number will not gain you much, and is not
                          recommended, but there is no hard limit.
      -u, --uninstalled   remove all package files for packages that are not
                          currently installed, while still keeping the
                          specified number of old files for installed packages
      -v, --verbose       output more
      there MUST be a space between the option and its argument.
    Targets:
      targets are package names, as you would specify them to pacman.
      if targets are specified, only package files belonging to them will be
      removed. if no targets are specified, all packages except for thos
      specified to be ignored will be removed.
    It now uses the .PKGINFO file within the package itself, in order to know which
    package it belongs to (Thanks again brisbin).  This eliminates any issues with
    parsing the name from the version info, in the filename.
    Obviously using alpm or such would be faster, but this was a quick project.  I
    wrote a short snippet for myself, and decided to extend it.
    Anyway, hope someone else finds this useful, let me know if you find any bugs,
    or have any feature reqs.
    Potential issues:
      As seems to be the most common issue with scripts like this, it assumes the
      most recent package in the cache is the one installed, or the one you would
      want to keep.  I'm considering parsing pacman output to compare the versions,
      at least as an option.
    EDIT:
      Now with multithreading!  It has taken about 10% off the execution time on a single
      core netbook, and gets faster on better processors.  If nothing else, it was a good
      experiment, but I think it turned out rather well.
    Last edited by freak (2011-07-07 01:56:45)

  • Pachorizon - Sort your pacman mirrorlist by distance

    I'm behind a stupid firewall, and can't use ping, so can't use tools like rankmirrors.  So I wrote a python script for sorting mirrors with nearest countries.
    Usage:
    Usage: pachorizon.py <country> <mirrorlist>
    pachorizon.py list
    pachorizon.py help
    Example: pachorizon.py "Great Britain" /etc/pacman.d/mirrorlist
    Example output:
    $ ./pachorizon.py "Great Britain" /etc/pacman.d/mirrorlist
    ## Pacman mirrorlist generated for Great Britain
    ## Great Britain
    # Server = http://mirror.lividpenguin.com/pub/archlinux/$repo/os/$arch
    # Server = http://mirror.cinosure.com/archlinux/$repo/os/$arch
    # Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch
    ## Ireland
    # Server = http://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch
    ## Netherlands
    # Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
    # Server = http://ftp.nluug.nl/pub/os/Linux/distr/archlinux/$repo/os/$arch
    ## Belgium
    # Server = http://archlinux.mirror.kangaroot.net/$repo/os/$arch
    ## Luxembourg
    # Server = http://archlinux.mirror.root.lu/$repo/os/$arch
    Script:
    #!/usr/bin/env python3
    import sys
    import math
    import functools
    import collections
    coords= {'Australia': (-27.0, 133.0),
    'Belarus': (53.0, 28.0),
    'Belgium': (50.5, 4.0),
    'Brazil': (-10.0, -55.0),
    'Canada': (60.0, -95.0),
    'Chile': (-30.0, -71.0),
    'China': (35.0, 105.0),
    'Colombia': (4.0, -72.0),
    'Czech Republic': (49.45, 15.3),
    'Denmark': (56.0, 10.0),
    'Estonia': (59.0, 26.0),
    'Finland': (64.0, 26.0),
    'France': (46.0, 2.0),
    'Germany': (51.0, 9.0),
    'Great Britain': (54.0, -2.0),
    'Greece': (39.0, 22.0),
    'Hungary': (47.0, 20.0),
    'India': (20.0, 77.0),
    'Indonesia': (-5.0, 120.0),
    'Ireland': (53.0, -8.0),
    'Israel': (31.3, 34.45),
    'Italy': (42.5, 12.5),
    'Japan': (36.0, 138.0),
    'Kazakhstan': (48.0, 68.0),
    'Korea': (40.0, 127.0),
    'Latvia': (57.0, 25.0),
    'Luxembourg': (49.45, 6.1),
    'Moldova': (47.0, 29.0),
    'Netherlands': (52.3, 5.45),
    'New Caledonia': (-21.3, 165.3),
    'Norway': (62.0, 10.0),
    'Poland': (52.0, 20.0),
    'Portugal': (39.3, -8.0),
    'Romania': (46.0, 25.0),
    'Russia': (60.0, 100.0),
    'Singapore': (1.22, 103.48),
    'South Korea': (40.0, 127.0),
    'Spain': (40.0, -4.0),
    'Sweden': (62.0, 15.0),
    'Switzerland': (47.0, 8.0),
    'Taiwan': (23.3, 121.0),
    'Turkey': (39.0, 35.0),
    'USA': (38.0, -97.0),
    'Ukraine': (49.0, 32.0),
    'United States': (38.0, -97.0),
    'Uzbekistan': (41.0, 64.0)}
    def distance_between_coords(coord1, coord2):
    """Recipe From:
    http://www.johndcook.com/python_longitude_latitude.html"""
    lat1, long1 = coord1
    lat2, long2 = coord2
    # Convert latitude and longitude to
    # spherical coordinates in radians.
    degrees_to_radians = math.pi/180.0
    # phi = 90 - latitude
    phi1 = (90.0 - lat1)*degrees_to_radians
    phi2 = (90.0 - lat2)*degrees_to_radians
    # theta = longitude
    theta1 = long1*degrees_to_radians
    theta2 = long2*degrees_to_radians
    # Compute spherical distance from spherical coordinates.
    # For two locations in spherical coordinates
    # (1, theta, phi) and (1, theta, phi)
    # cosine( arc length ) =
    # sin phi sin phi' cos(theta-theta') + cos phi cos phi'
    # distance = rho * arc length
    cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta1 - theta2) +
    math.cos(phi1)*math.cos(phi2))
    arc = math.acos( cos )
    return arc * 6373 #for kilometers
    def distance_between_countries(c1, c2):
    return distance_between_coords(coords[c1], coords[c2])
    my_location = sys.argv[1]
    if my_location == "help":
    print("Usage: pachorizon.py <country> <mirrorlist>")
    print(" pachorizon.py list")
    print(" pachorizon.py help")
    print("Example: pachorizon.py \"Great Britain\" /etc/pacman.d/mirrorlist")
    exit()
    elif my_location == "list":
    print("Possible countries:" )
    print(", ".join(c for c in coords.keys()))
    exit()
    mirrorlist = open(sys.argv[2]).readlines()
    urls = [("Any", [])]
    for line in mirrorlist:
    line = line.strip("# \n")
    if line in coords.keys():
    urls.append((line, []))
    elif line.startswith("Server ="):
    urls[-1][-1].append(line.split("Server =", 1)[1].strip())
    locationless, *urls = urls
    get_distance = functools.partial(distance_between_countries, my_location)
    sorted_urls = collections.OrderedDict(sorted(
    urls,
    key = lambda i: get_distance(i[0]),
    sorted_urls["Any"] = locationless[1]
    sorted_urls.move_to_end("Any", last=False)
    print("## Pacman mirrorlist generated for " + my_location + "\n")
    for country, servers in sorted_urls.items():
    if not servers:
    continue
    print("## " + country)
    for server in servers:
    print("# Server = " + server)
    print()
    I hope you like it .

    The wiki has https://wiki.archlinux.org/index.php/Mi … _Generator Maybe you can enhance that script?
    If you're not sure if the outcome is correct, post it on the wiki talk page first.

  • Is there an app that can track your network activity?

    My daughter's iPhone has starting chewing up data like water. (iPhone 5) Here are the symptoms:
    --data useage has gone from 2-3 gigs/month to 20+ gigs, .8gb/day
    --the battery will sometimes lose 40% of its power overnight and even 20% in an hour when she isn't using it, and it will get very hot
    She has tried changing various settings in her apps to cut down on useage of the cell network.  (She is in L.A. and is on AT&T where coverate is spotty.)  She discovered that she was downloading the entire Spotify catalogue so turned that feature off but it didn't help.  We think somethine else is trying to upload or download in the background but can't figure out what it is without systematically disabling every app one at a time.  So short of that, is there an app that would help us track down this problem?  I called AT&T and they weren't any help, just wanted to upgrade me to a higher plan.

    another symptom--after doing nothing but some light texting, she sent 30 mb of data in an hour.  That strikes me as being way out of line.

  • Action may be Required to Keep Your 10g Database Certs Active

    If your latest version of Oracle Database certification is 10, you will need to upgrade to a current version of certification by March 1, 2016 to keep your certifications active.
    Read More.
    Brandye Barrington
    Oracle Certification Program

    Gaea,
    We recently deleted out approximately 400K contacts from our database (not using the method described above but using our own process) and have had amazing success. The open and click through rates are going through the roof and our overall impact on the organization is improving greatly. Anyone that hasn't cleaned house recently is really leaving money on the table by diluting their messaging and trying too hard to be too much to too many people.
    Dave

  • Howto: Pacman Updates on your Awesome3 bar

    So in my boredom one day, I decided to add a textbox to my Awesome wibox bar (formerly referred to as a statusbar) that displayed the number of updates available for my system.  I see many users getting this info from Conky, but I wanted to get better acquainted with LUA and the rc.lua awesome syntax.
    This guide assumes the user has a fresh Awesome installation with a default rc.lua file.
    Thanks to Xyne for the pacman perl scripts (Shown later).
    What you will need:
    Awesome 3.4 (pacman version)
    perl
    Files you will need:
    pacman-updates: Necessary to provide the user-readable output to awesome-client
    #! /usr/bin/perl
    ## script by Xyne
    ## output format tweaked slightly
    ## http://bbs.archlinux.org/viewtopic.php?id=57291
    use strict;
    use warnings;
    my $n = (`pacman -Qu | wc -l`);
    chomp ($n);
    if ($n == 0)
    print "\" [ No new packages ] \""
    elsif ($n == 1)
    print "\" [ 1 new package ] \""
    else
    print "\" [ $n new packages ] \""
    pacman-updater: A basic way of keeping your pacman package list refreshed.
    #! /bin/bash
    # Script to update pacman database
    # Will be put in /etc/cron.hourly
    pacman -Sy 1>/dev/null 2>&1
    pacman-widget: Executes the pacman-updates script and passes it to awesome-client for display
    #! /bin/bash
    ## Script to update awesome-client widget with pacman package information
    ## Script belongs in /etc/cron.hourly
    echo mytextbox.text = `perl /path/to/script/pacman-updates` | awesome-client
    Place the files in the script folder of your choice.  Then, ensure all files have adequate permissions so that they can be executed. (chmod)
    Open your rc.lua file with your favorite text editor.  Create a textbox widget by adding the following:
    mytextbox = widget({ type = "textbox", name = "mytextbox" })
    mytextbox.text = " [ Pacman Updates ] "
    Now that the code for created the widget has been added, we need to add the widget to the existing wibox.  Find the section of your rc.lua file that looks like this:
    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
    mylauncher,
    mytaglist[s],
    mypromptbox[s],
    layout = awful.widget.layout.horizontal.leftright
    mylayoutbox[s],
    mytextclock,
    s == 1 and mysystray or nil,
    mytasklist[s],
    layout = awful.widget.layout.horizontal.rightleft
    end
    Add the line "mytextbox," underneath the default textclock widget:
    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
    mylauncher,
    mytaglist[s],
    mypromptbox[s],
    layout = awful.widget.layout.horizontal.leftright
    mylayoutbox[s],
    mytextclock,
    mytextbox,
    s == 1 and mysystray or nil,
    mytasklist[s],
    layout = awful.widget.layout.horizontal.rightleft
    end
    Copy pacman-updater and pacman-widget scripts into your /etc/cron.hourly folder:
    sudo cp pacman-updater /etc/cron.hourly
    If everything went smoothly, you should see package information updated hourly on your wibox in the top right corner, such as:
    I hope this guide has proven useful.  Please post if you see any errors or could suggest improvements, as I will update the guide.
    Thanks
    Last edited by trann (2009-11-05 20:03:45)

    Oh cool, I never realized that vicious was basically an upgraded wicked.  I had an old rc.lua that used wicked, and when they got rid of wicked no sooner than I made a config using it; I just moved on to another WM rather than try to read about and choose between vicious, obvious and bashets.  If I had spent 5 secs learning that my old config would've worked for what I was doing simply by replacing the word 'wicked' with the word 'vicious' everywhere, I might have not been so distraught.
    But yes, thanks for the snippet using vicious.  It works great.  I modified it a little (I didn't feel like being informed when there were 0 updates, only when there were some):
    local pacupdates = widget({type="textbox"})
    vicious.register(pacupdates,vicious.widgets.pacman,
    function (widget, args)
    if args[1] == 0 then
    return ''
    else
    return ' <span color="red">'..args[1]..' Updates</span> '
    end
    end)
    You obviously have to require("vicious") somewhere and put pacupdates in your mywibox[s].widgets (or some other bar, I suppose), but it is quite simple.
    I suppose I could make that better by adding in an 'else if args[1] == 1 then return ' <span color="white">'..args[1]..' Update</span> ' or something, so it doesn't say "Updates" when there is only one.  I suppose there is an else if in lua, but I haven't read that programming in lua thing yet, as I was planning on using xmonad instead of awesome, but seem to be experiencing some difficulties with the multi-screen setup on my tower and xmonad. 
    Right now, I'm thinking maybe I'll use xmonad on the laptop and awesome on the desktop, just so I have a good reason to tinker in both programming languages.
    Works great and doesn't require any weird background stuff or cron.

  • HT201413 We're sorry, we are unable to continue with your activation at this time.

    cant continue to the last

    Hello sirdieehfus,
    The following article provides steps that can help get your iPhone activated.
    iPhone: Troubleshooting activation issues
    http://support.apple.com/kb/TS3424
    Cheers,
    Allen

Maybe you are looking for

  • Computer crashed how do i get my music back

    Computer crashed how do i get my music back

  • Copying Macbook iPhoto '09 library to Macbook Air iPhoto '11

    Good evening, I was hoping somebody might be able to help me with a problem I am having with my new Macbook Air. I initially set up my laptop which automatically created a User Account\. I realise now that I should have used Migration Assistant befor

  • [SOLVED] Is 'epson-inkjet-printer-201212w 1.0.0-7' a safe AUR package?

    Hello, I'm new to Arch Linux. I'm wondering if this package ( https://aur.archlinux.org/packages/epso … r-201212w/ ) is safe to use? I've read the wiki and I was advised to check the PKGBUILD for any malicious/corrupt code. As I'm not a programmer or

  • Query with nulls and multiple columns

    I need help with structuring a query. I have the following table: REGION |     AREA 1     | A 1     |      B 1     |      C 1     |      D 1     |      (null) (null)     | A (null)     |      B (null)     |      C (null)     |      A 2     |      A 2

  • Types Reports

    Hi Could any body send the information regarding Types of reports(How many types of reports is there and what is it ) Anser 'll be rewarded. Regards Satya. Message was edited by:         satya G