Mastercam — Peck Drill Toolpath Verify Problem

If you use a drill toolpath on Mastercam and try to use the peck option, the program uses a subroutine/subprogram for the pecking operation and will NOT show up in verify.

Your verify and backplot will show one swift drilling movement all the way to the specified depth, regardless of your peck settings. It turns out the g-code generated is only a line and has the pecking written in as one of the arguments, so if you’ve made it a habit to verify everything and you’ve stopped dead in your tracks with the drill toolpath, just forget verify and run it on your machine — the pecking will be there.

Find the things in life that make you cry.

I just read “Find the things in life that make you cry” and couldn’t agree more.

Life’s pleasures to me are the things that move me so much I am in tears.

Why do we cry? Sadness is obvious. But what about those times you are deeply moved by something? I seem to be chasing /that/ particular high my whole life.

Sad things make you “feel” but I think it’s the most basic of feeling. You can watch or read sad stories and cry. You’re filled with emotion and it feels good.

I’m not sure what crying is, but it’s definitely not always sadness. It’s appreciation, or something deeply moving. Something that hits your heart. Maybe pure emotion. What’s going on in the brain here? It’s definitely not a “joy”, or a high from a drug. It’s a pure expression of one kind.

A few things move me like that:

Music.

This is the most surprising to me. When music moves me to tears, I think I find myself in two camps for explanation. I’m not married to the first camp, while I know the second explanation has some truths.

  1. Sometimes, the music feels so “good” and I appreciate the complexities or uniqueness of the piece so much that I cry.
  2. Most of the time, I think music is tied to storytelling. Music tells a story, and I can be moved in the same way a story moves me. There are some beautifully melancholy songs that move me to tears probably with a mix of sadness and then appreciation.

For example this: http://www.youtube.com/watch?v=RtPm5GiJ_iM moves me to tebars. I associate it very strongly with the movie it was created for so I can’t get rid of my story bias here, but say minute 1:00, that strange instrument is so powerful. It’s so fluid and the tone so sad that I have a great appreciation for the raw emotion it can pull out of me.

Story.

Stories can move you. I always have this opinion that stories are “real”. There’s this thought that if something is fiction, then you won’t be as moved. Well, in my thought experiments I’ve come to the conclusion that “real” and “fake” mean nothing to a story.

An extremely touching story is touching fake or not. Imagine this: you were moved to tears by some rescue operation on the newspaper. Turns out that was fake. Ooops. It’s fake, but how it touches you is the same.

Sci fi fans have always appreciated this. Sci fi books are often all about philosophy that can only be explored through another world. If the world was like “this”, then what would happen?

What moves you in a story? Well unfortunately this one depends on how you were raised and thus your values. I can’t claim here that there are any universal values that will touch all.

Perhaps a story of a tragic love everybody might relate to, or perhaps not? Human attraction for one another is something we all have, but the values that would make a story tragic, heroic, disgusting or boring depend on the person.

Everything is in the eye of the beholder. Music? Music taste depends on which notes you were grown up with.

I asked this question once and found an answer. The human brain enjoys (as in releases “good feeling” chemicals, like when we eat food) musical combinations where the ratio between the two frequencies is simple, like 1/4, 2,/3, 4/6, etc.

Absolute frequency doesn’t matter (X hz), there is no truth in a specific absolute note, but it will sound appealing to YOU if your culture promotes those sets.  This is something that can be learned, so you can start enjoying music from another culture, it’s just that it is definitely a learned skill, not set by birth.

So, because I’ve been raised with the Japanese base notes (which use the same ABCD frequencies as Western music, but the core of it is a different pattern) I can enjoy that music as well as some crazy combination of my inter cultural tastes.

Anyways, as much as I want to go enjoy the things that make me cry, they don’t make any money for me, so I must keep moving on.

One day though, if I can work with what I am passionate for my life would be complete.

What is my PEM Pass Phrase?

Your PEM pass phrase is something you set when you generated your SSL key.

It turns out you can not ever retrieve it, so if you don’t know it, stop trying to figure it out and re-key your certificate!

Your site is probably down, so disable ssl for now and get your apache or nginx or what have you started, and go on to your SSL authority and re-key your certificate!

Good luck.

Firefox Untrusted SSL Issuer

Firefox error: sec_error_untrusted_issuer

If you are running into this problem with GoDaddy SSL check if you combined your .crt and gd_bundle.crt with the “cat” command if you’re running a linux server.

We renewed our SSL and our site had been unknowingly displaying this error for firefox users for a month, but not to Chrome or Internet Explorer users.

Check every browser folks. Who knows how many people we scared off.

Python / Django — Combine Querysets and Sort. Sort List of Any Objects.

Assuming it quacks like a duck, you can use operator.attrgetter()

Combine queryset by turning it into a list:
queryset_list = list(queryset1).extend(list(queryset2))

Sort the list by:
queryset_list.sort(key=operator.attrgetter(‘attribute to sort by’))

Update: 4/28/2010

Yeah, I forgot the sort function sorts in place. sort = list.sort would not be good.
Also, for those wondering, you can just import operator. “import operator”

Django — Admin Inline Styling / Widget Attrs / Overriding Widgets

Quickly style all of your inlines with formfield_for_dbfield

class PersonInline(admin.TabularInline):
	model = Person
	extra = 6
	def formfield_for_dbfield(self, db_field, **kwargs):
		attrs = { 'size': 15 }
		if db_field.attname == 'interest_level':
			attrs = { 'size': 2 }
		kwargs['widget'] = forms.TextInput(attrs=attrs)
		return super(PersonInline, self).formfield_for_dbfield(db_field,**kwargs)

I see this used for things like custom widgets, ReadOnlyWidget, ColoredWidget, etc, but I wanted a quick and dirty(?) way to fit more fields on my inlines, since the admin just overflows.

Django — Limit Queryset For ModelAdmin List View

This is documented:

To modify a query based on user, override the ‘queryset’ for ModelAdmin like so. Should give enough ideas:

	def queryset(self, request):
		qs = super(PanelTasting, self).queryset(request)
		if request.user.is_superuser:
			return qs
		return qs.filter(host__user=request.user)

Django — Django Admin Model Name Override / Verbose Name

Since so much admin functionality has moved to AdminSite, I couldn’t find the answer to this very easily on google searches.

Despite the move towards towards ModelAdmin for admin-specific stuff, verbose_name’s are still defined in your Model.

Add the following to your models Meta class.

class Meta:
    verbose_name = "foo"
    verbose_name_plural = "foobars" 

to avoid names like Entrys.

Django / Python — Dynamically Create Queries from a String and the OR operator

Dynamically create queries from strings in django.

My problem: I wanted to make a searchable, sorted list of an arbitrary amount of fields to check against.

Normally, we’d use a  Q object to get to the | “or” operator. Our search might look like the following:

Person.objects.filter( Q(first_name__icontains='Yuji') | Q(last_name__icontains='Tomita')

What if I don’t want to hard code the field names? I want to use dynamic field names so I can use a basic factory on multiple models very easily.

With much needed prodding in the right direction by mattmcc, I figured it out.

The key was how to use keyword arguments as strings.

Person.objects.filter(first_name__icontains='Yuji')
is equal to:
Person.objects.filter( **{'first_name__icontains':'Yuji'})

With this knowledge, and operator.or_, I could do a Q and | lookup via strings.

query_string = "Some Name" # the search string
argument_list = []
fields = ('search_field1','search_field2','search_field3')
for query in query_string.split(' '): # split search words
for field in fields:
argument_list.append( Q(**{field+'__icontains': query} )
query = MyModel.objects.filter(  reduce(operator.or_, argument_list)  ) # join the arguments in the list with the or operator

Python on Windows — Setting PYTHONPATH Environment Variable

What is the PYTHONPATH environment variable?

The PYTHONPATH environment variable is the list of folders that the import statement will look through when attempting to resolve a module name.

A per session Python Path is visible in sys.path (per python shell session)

import sys
print sys.path # returns list of directories

sys.path.append('C:\Foobar') 
# now, we can import pyton modules in C:\Foobar

The above solution requires appending to the python path every session. If we don’t want that, we can edit the PYTHONPATH environment variable.

How to set the PYTHONPATH environment variable on Windows XP, Vista, Windows 7, etc.

For Windows the PYTHONPATH is set in the windows registry.

Run regedit

First, open up “Run” from the start menu (Ctrl + R).

Browse to the PythonPath folder

Browse to HKEY_LOCAL_MACHINE -> SOFTWARE -> Python -> PythonCore -> [ Version Number ] -> PythonPath.

Don’t alter the pythonpath you see here.

Create new key

Right click the PythonPath folder and select New –> Key

Name it what you like.

Select the new folder and right click the one blank value sitting on the right side of the screen and select Modify.

For the value field, add your new paths separated by ” ; ”

Run python and try an import.

If that doesn’t work

Updated 1/2014

There are people in comments below with a ton of different solutions. I know that windows is at 8 now, and I haven’t tested with 8.

An alternative method is described here that doesn’t use REGEX. My gut tells me it may be more reliable method. http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

Done!