shortest Python timezones example

assuming we import datetime and pytz, just for a little bit of brevity ….

print datetime.datetime.utcnow().replace(tzinfo=pytz.utc).\
   astimezone(pytz.timezone("US/Eastern")).strftime("%Y-%m-%d %H:%M")

Whoa Nelly, Break it down bro! Below is an example of getting a ‘Naive’ time. I.E. it will be the time of the computer you are using, but have no associated timezone designation. This example also will get an error if you can’t import datetime.

import datetime
nowVariable = datetime.datetime.now()
print nowVariable

But a naive time object is unaware of the timezone, and the pytz object library is a great addition to datetime, but again, the next example will make your time object timezone aware, but first it will test that your computer can import the pytz object library.

import datetime, pytz
nowVariable = datetime.datetime.now()
laTimeVariable = nowVariable.replace(tzinfo=pytz.timezone("US/Pacific"))
print laTimeVariable

Other timezones could be US/Mountain, US/Central, Europe/Rome, Australia/Perth, Asia/Hong_Kong, etc.

Now, if we want to print the ‘aware’ date object in a pretty format, we can say;

print laTimeVariable.strftime("%Y-%m-%d %H:%M %Z")

This is great to populate the display variable when the date and time are sent to the screen. But with many different timezones and everything happening on the world wide dub dub dub all over the world at all hours, internally to my python code, I might want to always store and calculate the time in one single standard timezone, only converting as the last step to display it to a local user.

To get the current universal time, naive and aware;

utcNaiveVariable = datetime.datetime.utcnow()
utcAwareVariable = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)

What is ERP

Enterprise Resource Planning

Accounting and Operations

Bookkeeping, but more comprehensive

ERP = Enterprise Resource Planning. A comprehensive suite of applications to manage planning and operational functions requiring massive information processing in the business environment

MSInc fills a broad set of IS and IT needs from network support for small businesses with Quickbooks™, Peachtree™, or MS200/500™ accounting modules, as well as customized solutions. We provide network planning, tuning, and connectivity as well as email, web design, PC repair, PC support, and custom MySQL customer service databases. We also provide our own ERP Solution using Thoroughbred™, PVX™, and Basis BBX™ BB8 based accounting and operations systems. Our solutions support a full ERP backbone for manufacturing clients with up to 500 employees. For SaaS or “Software as a Service”, see our new Vehicle Dispatch system, available in lease and purchase license forms. Our lease model leads the way in SOA, or Service Oriented Architecture. Also available for standardized and custom ERP, MRP, CRM, and Financials models in fully normalized designs. Because of our breadth of services, from highly secure financial information, to password accessible customer service portals, through to highly visible and optimized web-sites, we are highly skilled at managing the various security requirements of your company.

Outsourcing, Eastern metro Atlanta. Small and Medium Sized Business.

Purchase Price Variance

Standard costing techniques in ERP

In absorption accounting, the measurement of the inflation or deflation of prices on raw material is measured with purchase price variance. A unit of raw material is assigned a standard cost for the year and the variation in landed cost for deliveries is tracked not with a complicated scheme of tracking on a lifo or fifo basis where each molecule of raw material can be allocated to a product that reaches the consumer, but a standard periodic cost is assigned to a unit of purchased goods. For example, if we choose to fix the cost of a #8-32 1/2″ Stainless round slotted head machine screw at $.15 for the year, the portion of the final cost of a product that uses this purchased item need not change just because the landed price for one million screws that week was $.149900 each.

We freeze the standard cost for the screw at $.15 and book a purchase price variance, favorable, of a hundred bucks. The mechanics require an accounting discipline and business logic in the purchasing and accounts payable departments of recording the landed price vs the standard. When an invoice is received from a vendor on the raw material account, the first thing we want to ascertain is that the material was received and that our vendor deserves to be paid for goods that were delivered and accepted for inventory. This means that a given purchase order receipt, which was a debit to inventory on hand for a given part number should be matched up with the invoice. This receipt is marked then as paid and the accounts payable can be processed with no shoe leather put to waste by either the purchasing or accounting departments.

A register of vouchers accepted for a given day then can be generated with the landed cost put against the standard cost to determine the favorable or unfavorable purchase price variance for raw material acquisition.

Celery

sudo apt install python-celery-common

all configuration to run the celery process is put in a python file sometimes called tasks.py

celery -A tasks worker –loglevel=info

But you might have multiple workers named worker1.py and worker2.py so you would start them in two separate shells using

celery -A worker1 worker –loglevel=info
celery -A worker2 worker –loglevel=info

The “functions” you are going to background will be in worker1 or worker2.

Curling, just not Canadian Style Python 2.6.6 and the urllib2 library

In bash, getting a web page

curl https://www.web-atlanta.com/ >html.html

The bash curl command has nothing to do with Canadian Curling, which is like shuffleboard on ice amidst the tension garnered tolerating a joke about the Queen or the national health care system from a surfboard riding processed cheese eating upper Mexican from south of the barbarian line. In bash, curl is short for client url, a simple http request of a web address.

In Python

x = urllib2.urlopen("https://www.web-atlanta.com")
w = x.read()

And as a part of a class init

  def __init__(self,TableName,filename,url):
    self.sqhandle=sqlite3.connect(filename) # empty if noexist
    self.sq1cursor = self.sqhandle.cursor()
    self.filename = filename
    try:
      self.sq1cursor.execute('''CREATE TABLE '''
         +TableName+''' (somenum real, somestring text)''')
      self.sqhandle.commit()
    except:
      print TableName,"table already exists"
    self.samples = 0
    x = urllib2.urlopen(url)
    self.pagedata = x.read()

So if we instantiate a class we now have the html as classname.pagedata and sqlite3 handle and cursor as classname.sqhandle and sq1cursor

We need to do some things with sql like

    command = 'INSERT INTO '+table+' VALUES (' + x +', "'+ y +'")'
    try:
      classname.sq1cursor.execute(command)
      classname.sqhandle.commit()
    except:
      print command

sqlite3 insert a row

  def sqlinsert(sqhandle,sq1cursor,table,x,y):
    command = 'INSERT INTO '+table+' VALUES (' + x +', "'+ y +'")'
    try:
      sq1cursor.execute(command)
      sqhandle.commit()
    except:
      print "failed to ", command

Perl MySql Example

Perl with DBI, Perl Database access

!/usr/bin/perl -w

#

script to add up some table data

use DBI;
use CGI::Carp qw(fatalsToBrowser);

print “Content-type: text/html\n\n”;
my $dbh = DBI->connect(’dbi:mysql:database=DATABASE_NAME;host=localhost’, ‘USERNAME’, ‘PASSWORD’)
or die “Couldn’t connect to database: ” . DBI->errstr;

my ( $k, $id, $book_date, $svc_type, $cust_id, $time_pref, $a_sched,$a_eight);
my $t_date=”20080115″;

$sqlquery = qq( SELECT id, book_date, svc_type, cust_id, time_pref, FROM orders WHERE  move_date = $t_date );
$sth = $dbh->prepare ( $sqlquery );
$sth->execute() || die “Couldn’t execute query: ” . DBI->errstr;

$k = 0;
$sth->bind_columns( \$id, \$book_date, \$svc_type, \$cust_id, \$move_date, \$time_pref, \$est_men, \$est_trks );
while ( $sth->fetch() ) {
$a_sched  += 1;
if ( $time_pref eq “8-9A.M.” ) { $a_eight  +=1; }
}

Now $a_sched contains the number of records $a_eight contains the number of 8-9A.M. record for that date.

atlanta custom database design   vehicle dispatch ERP

Google Places Best Practices

Places uses different heuristics from organic search results pages and say that inclusion in Google Places is not influenced by your Google advertising budget.

Whether you are creating your listing or engaging in Google Places Listing Optimization, we need to take advantage of as many features as possible without abusing any areas and thus risking a lengthy period of invisibility on the Google search results pages. Remember that Google is not a consulting firm, does not charge for your local listing, and like the IRS, relies on you to either hire a CPA or figure it out, preferably a little of both. Google Places uses different heuristics from organic search results pages and say that inclusion in Google Places is not influenced by your Google advertising budget. There are a lot of lies and hype about Google Places, partly because of Google’s lack of support but also greatly due to the ignorance and naivety of business owners when it comes to understanding search engine results.

  • Business Name: Use precisely your legal business name, or risk a penalty.
  • Do Not stuff keywords or geographic terms here.
  • Categories: Use all five categories to not just tell consumers what you do, but to influence search results.You must use the first category for a Google approved category.
  • Images & Video: Load 10 images and at least 1-3 videos to ensure the listing is 100% complete. See our section on Youtube optimization.
  • Citations. These are like links, but they don’t require a hyperlink with the url as much as they depend on the exact same business name and phone number, possibly address for things like yp.com, citysearch or angieslist.
  • Have your business address prominent on your web-site, and enter the URL on your Google Places listing.

The last practice is a real problem for small business, many of which are run out of our homes. But once we grow to open an office location, use this key to maximize results. Reviews also help, as well as people searching for your exact business name and town, and even asking directions. All these activities are recorded by google and make your listing more important.

What is the difference between parenthesis and brackets in Python

Tuples and lists

Both are arrays, but tuples are immutable. This means that once you define a tuple, you cannot add elements, pop, append, remove an element, etc. You need to create a new tuple out of the old one every time you make a change.

  • Tuples (1,2,3,4,5,6) are great for static definition. They are hashable, lean and unequivocal.
  • Lists [1,2,3,4,5,6] are great for computation. They are mutable and queueable.

Both are addressed with integers in brackets.

Whether it is a list or a tuple, addressing one element is the same.

create a tuple with y = (“a”,”b”,”c”) and do this;

y = ("a","b","c")
print (y[0])
for i in y:
    print (i)

For lists and tuples, know this too;

for i in range(0,len(y)):
    print (i,y,y[i])

Now redefine y as a list and try it again. Same results?

Shortest Postfix sudo mail queue command list

Commands

mailq # note the message id – ten (10) alpha key to emails in queue

postcat -vq nnnnnnnnnn

postsuper -d nnnnnnnnnn

cd /etc/postfix; vi virtual; postmap virtual # forwarding

cd /etc/postfix; vi rbl_override; postmap rbl_override #whitelist

Postfix queues: pending and deferred.

Deferred queue is for messages that have soft-failed. Postfix will retry sending deferred emails.