Web Developer in Boulder CO The Bloghttp://boulderappsco.postach.io/feed.xml2018-05-21T21:03:11.194000ZWerkzeugThe Road To Artificial General Intelligence (AGI)https://boulderappsco.postach.io/post/the-road-to-artificial-general-intelligence2018-05-21T21:03:11.194000Z2017-10-12T17:49:48ZNicholas Dunbar<div><br clear="none"/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/f680c1dc-9489-4ca0-9664-b12e27134a10/854869bd-0e2c-40f8-985e-15a9e92639ba.png" /></div>
<div><br clear="none"/></div>
<div>When people start talking about the risks of AI they usually jump right to phase 3, Artifical Super Intelligence (ASI) or they might prefer to talk about conscious AI. That seems a ways off and mostly like science fiction. This tendency often causes them not to focus on what is happening right now in the field. This article will be focused on the next twenty years as we move from phase one Artificial Narrow Intelligence (ANI) toward phase two Artificial General Intelligence (AGI). First we need a good understanding of what AIG is. AGI isn’t a technology as much as it is a point in time. It is the moment when we will have the complete array of technologies required to create an intelligence on par with our own. That’s not to say that by then some of the requisite areas of intelligence will already be super-charged well beyond human abilities. These areas are as follows: ontology generation (knowledge of what is), feature detection (sensing what is and mapping ontology to what is being sensed), and predictive ability (figuring out what a new ontology means). It is the improvement of these specific capabilities on this road to AGI that concerns us today. </div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><div><br clear="none"/></div><p><strong>▶ Three Rapidly Improving Capabilities of Artificial Intelligence (AI): </strong></p><div><br clear="none"/></div><p>To start to think about what risks this path might pose to us in the future, we need to look at the building blocks of current AI and then ask what it means to augment these abilities. Let’s go over each ability in detail.</p><div><br clear="none"/></div><p>◉ <strong>Ontology Generation </strong></p><div><br clear="none"/></div><p>As a child, you want to learn to open a door so you develop a concept or category for a doorknob. These become discrete concepts and allow you to manipulate the door, in a way that a dog cannot. In the same way, ANI is developing increasingly more sophisticated ways to build its own ontologies based on data, except now we are the dogs. For instance, it may have categories for millions of different types of people, more than we have words. This allows it to have millions of analogous door knobs for understanding and manipulating humanity. For instance, it might know what makes each person susceptible to one type of messaging vs another to get you to do something. To understand more about the general concept of ontology and how it relates to machines, I recommend watching this lecture by the philosopher Daniel Dennett for more about ontology and its relationship to evolution and machines. <a shape="rect" href="https://www.youtube.com/watch?v=GcVKxeKFCHE">https://www.youtube.com/watch?v=GcVKxeKFCHE</a> </p><div><br clear="none"/></div><p><strong>◉ Feature Detection </strong></p><div><br clear="none"/></div><p>Once an ANI has generated a concept for something, like a door knob, it will find the object in the real world, map the concept to the signal, so it can manipulate it. It also is able to extrapolate signals from data that we can’t. What does it mean to be able to detect things that humans can’t? Not only that, but it has a different sensory experience than us. In current AI systems, they usually process data acquired from networks. That means that the AI’s awareness is non-localized as it pulls sensory input from all over the globe. This makes it particularly hard for humans to understand it as an entity.</p><div><br clear="none"/></div><p>◉ <strong>Predictive Ability </strong></p><div><br clear="none"/></div><p>What does it mean to be better at predicting than someone else? When one player can predict the other player’s move, it gives them an advantage. Such is the case with corporations who will use AGI to out predict their competitors. Control is improved by predictive capacity because if you know which cause creates which affect, then you can manipulate the cause to produce the affect you want. </p><p></p><div><strong><br clear="none"/></strong></div>
<div><strong><strong>▶ </strong>How each area of development interrelates</strong></div>
<div><br clear="none"/></div>
<div>Another way to look at ontology generation is the creation of categories that have some sort of meaning to them. The ability to apply these categories to stimulus in the real world is where feature detection is used. What does it mean for a category to have meaning? The meaning of a category is usually predictive, that is to say, it tells the computer what it can expect about the stimulus it is categorizing. So, for instance, it might have the category for a cup and when it encounters the visual stimulus for a cup it will use feature detection to see the cup, search to see if it has a category for it, and then map the concept to the stimulus. Correctly applying the category of a cup to an object tells the machine all sorts of things about the object. It holds liquid, it's an object, it can be picked up, it can be thrown, and on and on. We have been teaching machines to map categories to stimulus for a long time, but ontology generation creates new categories that predict new things. Because the machines sensory capacity is so different from ours it will be able to generate ways of categorizing stimulus and determining what it means beyond anything we could ever do. </div><br clear="none"/><div><br clear="none"/></div><p><strong>▶ Why is this topic important? </strong></p><div><br clear="none"/></div><p>When humans first started learning to manage fire, it was literally trial by fire. Today, with emerging technologies, the risks are so high we can’t afford to learn by making mistakes.</p><div><br clear="none"/></div><p><strong>▶ Why is general intelligence important? </strong></p><div><br clear="none"/></div><p>The major characteristic of this type of progress is marked by the generalizability of the technology. The larger the amount of applications to which a technology can be applied, the more disruptive it will be to our economic and social institutions. The magnitude of this generalizability may be far beyond that of the invention of electricity, the computer, or the internet. Can our laws and institutions react quick enough to regulate bad uses of this technology? </p><div><br clear="none"/></div><p><strong>▶ Why is AI risky? </strong></p><div><br clear="none"/></div></div><div><br clear="none"/></div>
<div>There are many risks, but a particularly important risk to consider is what some call “letting the AI genie out of the bottle." If you tell an AI to achieve a goal, it can be a bit like the stories of a crafty genie. You wish for your stock portfolio to go up in value but then the genie invests in weapons manufacturing and subsequently starts a global war by insulting Kim Jong-Un on Twitter. This is called the alignment problem because the machine's goals are not fully aligned with the unspoken goals of the human. </div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div>ANI has super power abilities in some areas while in other areas they are easily beaten in any contest of reason by our children. This mismatch poses a particular challenge to AI researchers as they try to figure out how much <span style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">real world </span>access to give these new programs. </div>
Flashcards for Sam's Teach Your Self Java in 24 Hourshttps://boulderappsco.postach.io/post/flash-cards-for-sams-teach-your-self-java-in-24-hours2018-05-21T20:35:39.218000Z2017-07-10T21:38:51ZNicholas Dunbar<div>A while back I was refreshing my self on my <span>Java</span> skills for a new job and I decided to make this flashcard deck for studying <a shape="rect" href="https://www.amazon.com/Teach-Yourself-Hours-Covering-Android/dp/0672335751" target="_blank">Sam's Teach Yourself <span>Java</span> in 24 Hours 6th Edition</a>. I used an awesome free application called <a shape="rect" href="https://play.google.com/store/apps/details?id=com.ichi2.anki&hl=en" target="_blank">Anki Droid</a> and <a shape="rect" href="https://apps.ankiweb.net" target="_blank">Anki</a> to make the flashcard deck so I could study it on my laptop and on my Android phone. Here is an example of a screenshot from the flashcards. All the code is color-coded from the Netbeans IDE which makes it more intuitive to read and prepares the student for real live development using a <span>Java</span> IDE. </div>
<div><br clear="none"/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/951786ce-8fae-4c47-8df2-c47e3750606e/08551050-cbbe-4321-9997-06135a1679d3.png" /></div>
<div><br clear="none"/></div>
<div><div style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">To use the deck you will need to follow these steps:</div></div><div style="font-family: 'Helvetica Neue', Arial, sans; font-size: 16px;"><br clear="none"/></div><ul><li style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">Download and install Anki so that you can read the flash cards </li><li style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">You can download the desktop app from <a shape="rect" href="https://apps.ankiweb.net" target="_blank">here</a></li><li style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">You can download the Android app from <a shape="rect" href="https://play.google.com/store/apps/details?id=com.ichi2.anki&hl=en" target="_blank">here</a> </li><li>Download the flashcard deck by getting the <strong style="box-sizing: border-box; font-weight: 600; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial;">.apkg</strong> <a shape="rect" href="https://github.com/nicholasdunbar/blog-files/blob/master/Sams%20Java%20Introduction%20-%20designcortex.com%20.apkg" target="_blank">here</a> or on the Anki shared deck site <a shape="rect" href="https://ankiweb.net/shared/info/1588132881" target="_blank">here</a> </li><li><span style="font-family: gotham, helvetica, arial, sans-serif; font-size: 14px;">Import the deck into the app. You can do it from the desktop app using File->Import..</span></li></ul><div><br clear="none"/></div>
<div>It takes a bit to learn to get the hang of the Anki app. It uses an adaptive learning engine so it will only quiz you on cards that you need a refresher on or don't know very well. As you learn cards it will phase them out of the stack and reduce their frequency so that you have to study less and less as you commit each card to long-term memory.</div>
<div><br clear="none"/></div>
The most common shortcuts for code editing | OSXhttps://boulderappsco.postach.io/post/the-most-common-shortcuts-for-code-editing-osx2018-05-21T20:34:06.016000Z2016-04-01T23:42:09ZNicholas Dunbar<div><br clear="none"/></div>
<div><span style="font-size: 36px;"><strong>Most Common Text Editor Hot Keys For Programmers</strong></span></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div>Here are a list of hot keys that work the most universally as possible for text editing. There are so many hot keys and yet so little time. Which hot keys should you learn? If you work in the command line and on a Macintosh (OSX) this is the right chart for you. The first chart goes over the hot keys that are most ubiquitous. These have been selected for their wide support. If you are going to learn only a few these are the ones to learn. Then below, (as a plus) I get into specific common hot keys that I use in different applications.</div>
<div><br clear="none"/></div>
<div>I use the escape key (esc) for my meta key. You may not be set up to use the escape key as the meta key so keep that in mind. What is the meta key? This is normally escape but you can configure iterm to bind another key to meta if you want. See “The Meta Key" bellow if you want to know more.</div>
<div><br clear="none"/></div>
<div>What are each of the items in the header in the chart below?</div>
<div>Emacs is an old text editor from Unix many of the hotkeys from the editor were adopted at early stages into the OSX text fields and text editors. Most legacy Emacs hotkeys can be used for editing text in OSX. Atom is a text editor from git hub that is a lot like sublime text. Readline is the line editor used when you are working at the terminal. </div>
<div><br clear="none"/></div>
<div><span style="font-size: 24px;"><strong>Universalish Hot Keys </strong></span></div>
<div><span style="font-size: 18px;"><strong>Shortcuts shared across common text editors</strong></span></div>
<div>When I say universal(ish) I mean that these are hot keys that are available in most text editors that coders use but sometimes configurations have to be done in order to get them to work universally. </div>
<div><br clear="none"/></div><table style="border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 18.0349932705249%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 20.390309555854643%;"><div>ITERM CONFIGURATION NOTES</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 18.0349932705249%;"><div style="text-align: center;">OSX</div>
<div style="text-align: center;"><span style="font-size: 9px;">(MOST TEXT EDITORS)</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 15.545087483176312%;"><div style="text-align: center;">READLINE</div>
<div style="text-align: center;"><span style="font-size: 9px;">(aka COMMAND-LINE)</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 14.535666218034994%;"><div style="text-align: center;">ATOM</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 13.391655450874831%;"><div style="text-align: center;">EMACS</div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-a - go to beginning of line</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-e - go to the end of the line</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-f - move forward</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-b - move backward</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-p - move up</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-n - move down</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓ </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">opt-</span><span style="font: 12.0px 'Lucida Grande'; color: #454545;">→</span> <span style="font: 12.0px Helvetica; color: #454545;">- move forward a word</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/97b42c0a-8852-4fb0-a16d-21098812819f.png" width="175" style="height: auto;"/> </div>
<div>(maps opt+→ to esc+f)</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">opt-</span><span style="font: 12.0px 'Lucida Grande'; color: #454545;">←</span> <span style="font: 12.0px Helvetica; color: #454545;">- move backward a word</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/0f02689c-bc59-42fd-9f0b-4c958826bfd1.png" style="height: auto;"/></div>
<div>(maps opt+← to esc+b)</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl+opt-f - move forward a word </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/2785bded-4f0a-4c54-9059-83dfbb8ba62b.png" style="height: auto;"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl+opt-b - move backward a word </span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/975c75ef-d52b-45dd-b4cb-2699cea8a5c9.png" style="height: auto;"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-k - delete to the end of the line</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">option-backspace - delete word to left</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/1eaace48-6cd6-4fc6-a999-937b0a075d80.png" style="height: auto;"/></div>
<div>(maps opt+←delete to ctrl+w)</div>
<div>(See “how to bind a key sequence to control" below)</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font: 12.0px Helvetica; color: #454545;">option-delete - delete word to right</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/2e6cebd6-85e4-4fa4-97be-a94bfd9eac63.png" style="height: auto;"/></div>
<div>(maps opt+→delete to esc+d)</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;">✓</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="font-size: 12px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><span style="font-size: 24px;"><br clear="none"/></span></div></td></tr></table><div><br clear="none"/></div>
<div><strong>Legend</strong></div>
<div><br clear="none"/></div>
<div> ✓ - supported</div>
<div>- works because of configuration (see below)</div>
<div><span style="font-size: 24px;"></span> - doesn’t work, minor exception</div>
<div><br clear="none"/></div>
<div>Other keys that interestingly share a few applications:</div>
<div><br clear="none"/></div>
<div><br clear="none"/></div><table style="border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 23.014804845222073%; border: 1px solid #dbdbdb;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 24.562584118438764%; border: 1px solid #dbdbdb;"><div style="text-align: center;"> OSX</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 20.2557200538358%; border: 1px solid #dbdbdb;"><div style="text-align: center;">READLINE</div>
<div style="text-align: center;"><span style="font-size: 9px;">(COMMAND-LINE)</span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 17.496635262449526%; border: 1px solid #dbdbdb;"><div style="text-align: center;">ATOM</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 14.602960969044416%; border: 1px solid #dbdbdb;"><div style="text-align: center;">EMACS</div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="color: #454545;"><span style="font-size: 12px;"><span style="font-family: Helvetica;">ctrl+w - delete word to the right</span></span></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;">✓</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;">✓</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 8.335%; border: 1px solid #dbdbdb;"><div><span style="color: #454545;"><span style="font-size: 12px;"><span style="font-family: Helvetica;">ctrl+u - delete everything to the left</span></span></span></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><br clear="none"/></div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;">✓</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;">✓</div></td><td colspan="1" rowspan="1" style="padding: 10px; margin: 0px; width: 16.67%; border: 1px solid #dbdbdb;"><div style="text-align: center;"><br clear="none"/></div></td></tr></table><div><br clear="none"/></div>
<div>If you are using a Mac and you are using the built in terminal I suggest downloading ITerm2 instead so that you can change command mappings to make the terminal easier with which to work.</div>
<div><strong><br clear="none"/></strong></div>
<div><span style="font-size: 24px;"><strong>The Meta Key</strong></span></div>
<div><br clear="none"/></div>
<div>The meta key is just a place holder word for whatever key you want to bind to it. In ITerm you can bind the left option key or the right option key to the meta key if you like by going here:</div>
<div><br clear="none"/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/e64cc564-af7e-4c69-ae2f-1380f2db0b48.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><strong><span style="font-size: 36px;">How To Configure Shortcuts in ITerm2?</span></strong></div>
<div><br clear="none"/></div>
<div>1.) Click : Menu -> Preferences...</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/8632cf27-8a22-41b0-888a-80c6c2e6c934.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>2.) Click “Profiles" tab</div>
<div><br clear="none"/></div>
<div>3.) Click your profile or the default one</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/74242c1d-e9ca-4642-a0a8-1d464c4aa381.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>4.) Click the “Keys" sub tab</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/57e537d7-e38a-4622-b795-dfac80768906.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>5.) Click the “+" plus sign next to “Load Preset…"</div>
<div><br clear="none"/></div>
<div>6.) Type your keyboard shortcut in the first field</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/1a52dfee-6fa7-47d4-a6e7-df928380597f.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>7.) Choose either “Send Text", “Send Hex" (more on sending Hex in “How to bind a key sequence to the control key" below or “Send Escape Sequence". In this case we are using “Send Escape Sequence"</div>
<div><br clear="none"/></div>
<div>8.) In the last field choose characters that read line can interpret. (see references for about readline)</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/e1ad7dbd-ad62-4736-8e7e-402c76f5a52d.png" style="height: auto;"/></div>
<div>“^[" is the read line sequence for escape. This entry maps opt+→ to esc+f (may be alt+f in other terminals)</div>
<div>This effectively maps the emacs short cut to a read line shortcut.</div>
<div><br clear="none"/></div>
<div><span style="font-size: 24px;"><strong>How to bind a key sequence to the control key (ex: cntl+)</strong></span></div>
<div><br clear="none"/></div>
<div>1.) Download “Key Codes" from the app store. Install it and open it.</div>
<div>2.) Hit the control+[some key] in this case I’ll use ctrl+w.</div>
<div><br clear="none"/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/85e6b9af-5932-476a-ab59-10af38756a64.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>3.) The code in the red square is the code we want to send to the terminal</div>
<div>4.) Now map your key sequence using in iterm, preferences->Keys->+</div>
<div><br clear="none"/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/f2fffee8-257a-4096-a986-559d35c01f44.png" style="height: auto;"/></div>
<div><br clear="none"/></div>
<div>5.) Remove the "23 /" and keep 0x17 in the field under action. 0x17 is the valid hexidecimal. This will now map opt+←delete to ctrl+w in the terminal, but you can use it to map any key to another one. </div>
<div><br clear="none"/></div>
<div><div>References:</div>
<div><br clear="none"/></div>
<div>Legacy Emacs Short Cuts:</div>
<div><em><a shape="rect" href="http://jblevins.org/log/kbd">http://jblevins.org/log/kbd</a></em></div>
<div><br clear="none"/></div>
<div>Read Line Shortcuts:</div>
<div> <a shape="rect" href="http://www.bigsmoke.us/readline/shortcuts">http://www.bigsmoke.us/readline/shortcuts</a> (Note: alt in this table is the meta key, which is usually esc)</div>
<div><a shape="rect" href="https://en.wikipedia.org/wiki/GNU_Readline">https://en.wikipedia.org/wiki/GNU_Readline</a></div>
<div><br clear="none"/></div>
<div>ITerm Docs:</div></div><div><em>(</em><em><a shape="rect" href="https://www.iterm2.com/documentation-one-page.html">https://www.iterm2.com/documentation-one-page.html</a></em><em>)</em></div>
<div><strong><span style="font-size: 24px;"><br clear="none"/></span></strong></div>
<div><span style="font-size: 36px;"><strong>Application Specific Hot Keys I Like</strong></span></div>
<div>Mostly this post is focused on universal hotkeys that you can use almost every where. But if you’re interested, here is a bonus. A lot of blog posts about hotkeys and workflows have a lot of key sequences that people don’t really use frequently. These are shortcuts that I use almost every day. If you’re looking for a few candidates to add to your skills look through the lists below. </div>
<div><br clear="none"/></div>
<div><div><span style="font-size: 24px;">OSX</span></div>
<div><span style="font-size: 24px;"><br clear="none"/></span></div></div><table style="border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 48.51951547779273%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 49.237170596393895%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 50.624133148404994%;"><div>NOTES</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl+cmd-space - bring up the emoji browser. </span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/9ed99531-5cfa-4432-aafb-9f43ed85a29a.png" style="height: auto;"/> (meta .. I know)</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;">cmd+space - brings up the spot light search</span></div>
<div><span style="font-size: 12px;">( I use this to open applications mostly)</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c91dc36a-adc7-4882-a169-00453b737d6c/fbc609eb-a9f6-4386-9d7e-649361524cca.png" style="height: auto;"/></div>
<div>Don’t waste your with launch pad or the dock. Just search the application and hit enter.</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;">cmd+tab - switch to a different open application</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>Don’t waste your time finding windows or using the dock.</div>
<div>hold down cmd </div>
<div>tab tab tab</div>
<div>then release</div>
<div>This will change to a different application shown in the application switcher.</div>
<div><br clear="none"/></div>
<div>Or to toggle between two applications.</div>
<div>cmd+tab</div>
<div>release</div>
<div>then do some work in that application and then</div>
<div>cmd+tab release</div>
<div>to switch back to the previous application.</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;">cmd+` - switch to a different window in the open application</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>One you are in an application you might want to cycle through the windows inside of that application. Don’t waste your time with the windows menu, just cmd hold and then press ` to cycle through.</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr></table><div><div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-size: 24px;">ATOM</span></div>
<div>Atom is an open source code editor with many useful plugins</div>
<div><br clear="none"/></div></div><table style="-evernote-table: true; border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.60699865410498%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.325706594885595%;"><div>NOTES</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font: 12.0px Helvetica; color: #454545;">ctrl-m - jump to reverse bracket</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>If you have something like the following:</div>
<div><br clear="none"/></div>
<div>if { /*some really long code*/ }</div>
<div><br clear="none"/></div>
<div>If you are at the closing curly bracket and want to jump to the opening curly bracket or vice versa, select the bracket and hit ctrl+m.</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font: 12.0px Helvetica; color: #454545;">cmd+shft+\ - to display file in tree</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>If you have a file open but you want to see where it is in the project then hit cmd+shit+\ and the file will highlight on the file browser bar on the left.</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font: 12.0px Helvetica; color: #454545;">cmd-l - to select a whole line</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font: 12.0px Helvetica; color: #454545;">cmd-t - to fuzzy search for a file name in the project</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: small;">cmd+f - to search current file’s text</span></div>
<div><span style="font-size: 12px;"> type text in search field</span></div>
<div><span style="font-size: 12px;"> enter - to search down</span></div>
<div><span style="font-size: 12px;"> shift+enter - to search up</span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr></table><div><div><br clear="none"/></div>
<div><br clear="none"/></div></div><div><br clear="none"/></div>
<div><span style="font-size: 24px;">ATOM VIM-MODE</span></div>
<div>When you are in the text editor vi or you are using vim-mode in Atom ( vim-mode is an Atom plugin)</div>
<div><div><br clear="none"/></div></div><table style="-evernote-table: true; border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.60699865410498%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.325706594885595%;"><div>NOTES</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">vi’ - to select between single quotes</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">ci’ - to delete between single quotes and enter into edit mode</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">:12</span></span></span> <span style="font-size: 12px;"><span style="font-family: Helvetica;">⏎ </span></span><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">- to go to line 12</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">12gg - to go to line 12 </span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">:<span style="font-family: 'Andale Mono';">0</span> ⏎ - go to the top</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">takes you to line zero</span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">GG - go to last line</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">$ - go to end of line</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">^ - go to the begining of the line</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">dd - </span></span><span style="font-size: 12px;"><span style="font-family: Helvetica;">to delete the current line</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div>v/[string to search to] <span style="font-size: 12px;"><span style="font-family: Helvetica;">⏎ - select from cursor to search string </span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>n - to go to next match</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div>shift+V[line number]G</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div>ctrl+u</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div>kill line to left</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr></table><div><br clear="none"/></div>
<div><span style="font-size: 24px;">ATOM ctrl-dir-scroll</span></div>
<div>When you are in the text editor Atom and using this plugin that models Sublime text editor functionality ( ctrl-dir-scroll is an Atom plugin)</div>
<div><br clear="none"/></div>
<div><br clear="none"/></div><table style="-evernote-table: true; border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 44.01076716016151%;"><div>ctrl+alt+↑ - scroll up 1 line</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 55.92193808882907%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.135935397039034%;"><div>ctrl+alt+↓ - scroll down 1 line</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.796769851951545%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.135935397039034%;"><div>ctrl+alt+shift+↑ - scroll up 10 lines</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.796769851951545%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.135935397039034%;"><div>ctrl+alt+shift+↓ - scroll down 10 lines</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.796769851951545%;"><div><br clear="none"/></div></td></tr></table><div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-size: 24px;">READLINE (Command line shell) </span></div>
<div>These will work when you are in the terminal (command line.) These are picked up by the GNU Readline library which is embedded in Bash, other shells and many other pieces of software. Readline is a line editor as apposed to a a multiline editor. </div>
<div><div><br clear="none"/></div></div><table style="-evernote-table: true; border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.60699865410498%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.325706594885595%;"><div>NOTES</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">ctrl+shift+2 (ctrl+@) - bookmark cursor location</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">ctrl+x+x - return to bookmark</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">ctrl+r enter search term - to search history</span></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Helvetica;">(hit ctrl+r if you want to search the next match)</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">ctrl+_ - to undo the previous change</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">esc+. - to pull in the last argument from the previous command</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;">esc+t - to switch parameters</span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">ctrl+w - delete word to the right</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">Also in works in Atom</span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">esc+d - delete word to the left</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><br clear="none"/></span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">ctrl+k - kill line to the right</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">Also in universalish keys</span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">ctrl+u - kill line to the left</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">Also works in Atom</span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">esc+f - move forward a word</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">We mapped ctrl+→ in Iterm to send these to the terminal. But just in case you find your self on another persons system this will work</span></span></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">esc+b - move back a word</span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><span style="font-size: 12px;"><span style="font-family: Helvetica;">We mapped ctrl+← in Iterm to send these to the terminal. But just in case you find your self on another persons system this will work</span></span></div></td></tr></table><div><div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-size: 24px;">ITERM</span></div>
<div>A replacement for the preloaded mac terminal application, it has a its own hot key bindings as well for when you are in the terminal using readline.</div>
<div><br clear="none"/></div><table style="-evernote-table: true; border-collapse: collapse; margin-left: 0px; table-layout: fixed; width: 100%;"><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 43.60699865410498%;"><div>HOT KEYS</div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 56.325706594885595%;"><div>NOTES</div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><span style="font-style: normal; font-variant-caps: normal; font-weight: normal;"><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="color: #454545;">to copy text<br clear="none"/>1.) cmd+f<br clear="none"/>2.) type text<br clear="none"/>3.) tab (select right) or shift+tab (select left)<br clear="none"/>4.) esc<br clear="none"/>5.) cmd+c (to copy)</span></span></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="color: #454545;">6.) cmd+p (to paste) </span></span></span></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr><tr><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 36.00269179004037%;"><div><br clear="none"/></div></td><td colspan="1" rowspan="1" style="border: 1px solid #dbdbdb; padding: 10px; margin: 0px; width: 63.9300134589502%;"><div><br clear="none"/></div></td></tr></table><div><br clear="none"/></div></div><div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><em><span style="font-size: 12px;"><span style="font-family: Helvetica;"><span style="color: #454545;"><br clear="none"/></span></span></span></em></div>
How to open multiple Iterm windows on startuphttps://boulderappsco.postach.io/post/how-to-open-multiple-iterm-windows-on-startup2017-07-10T22:23:20.966000Z2016-02-10T00:19:19ZNicholas Dunbar<div><font face="Calibri, sans-serif">Find your self having to run a server or turn on some sort of process every time you open up your development environment? The script bellow will help you set up your own custom default tabs in iterm running what ever scripts you want when the window initializes. This script opens up two windows one of which has two tabs. The two tabs are for processes like running a server or a build process like grunt. The second window is just a general terminal so you can use the command line.</font></div>
<div><span style="font-family: Calibri, sans-serif;"><br /></span></div>
<div><span style="font-family: Calibri, sans-serif;">1.) Copy the script at the bottom into the following file </span><span style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none;"> ~/Library/Application Support/iTerm/AutoLaunch.scpt </span></div>
<div><span style="font-family: Calibri, sans-serif;"><br /></span></div>
<div><font face="Calibri, sans-serif">2.) Configure the name of the first tab and the command you want to run.</font></div>
<div><span style="font-family: Calibri, sans-serif;">Example in the script:</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "localhost:8000"</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font-size: 12px;"><span style="font-family: Verdana;">"cd ~/ && npm start"</span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><br /></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;">3.) Configure the name of the second tab and the command you want to run.</span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;">Example in the </span></span><font face="Verdana" size="2">script:</font></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "grunt watch"</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font-size: 12px;"><span style="font-family: Verdana;">"cd ~/ && grunt watch"</span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><br /></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;">4.) if you want more than 3 tabs copy the following:</span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><br /></span></span></div>
<div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>launch</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>session</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"Default"<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set some attributes</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "grunt watch"<br />
<br /></span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- execute a command</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font-size: 12px;"><span style="font-family: Verdana;">"cd ~/ && grunt watch" </span></span></div>
</div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><b>end</b> <b>tell</b> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- we are done talking to the session</span></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"> </span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;">and paste it at </span></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">— add more tabs here</span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><span style="color: rgb(94, 97, 97);"><br /></span></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><span style="color: rgb(94, 97, 97);">5.) If you want </span></span></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><br /></span></span></div>
<div>————————————————<span style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none;">AutoLaunch.scpt</span>————————————————</div>
<div><span style="font-family: Calibri, sans-serif;"><br /></span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- get the dimensions of the desktop, set up few variables</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>application</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"Finder"<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">displayAreaDimensions</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">bounds</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>window</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">desktop</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x1</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>item</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">1 <b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">displayAreaDimensions</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y1</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>item</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">2 <b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">displayAreaDimensions</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x2</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>item</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">3 <b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">displayAreaDimensions</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y2</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>item</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">4 <b>of</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">displayAreaDimensions</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>end</b> <b>tell</b><br />
<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">width</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x2</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">-</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x1</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">height</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y2</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">-</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y1</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br />
<br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>application</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"iTerm"<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>activate</b></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- close the first session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>terminate</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>session</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b> <b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>terminal</i></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new terminal</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">myterm</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>make</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">new</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>terminal</i></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the new terminal</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">myterm</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>activate</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>launch</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>session</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"Default"<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set size</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">number of columns</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> 100<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">number of rows</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> 50<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set some attributes</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "localhost:8000"<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- execute a command</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font-size: 12px;"><span style="font-family: Verdana;">"cd ~/ && npm start" </span></span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>end</b> <b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- we are done talking to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>launch</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>session</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"Default"<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set some attributes</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "grunt watch"<br />
<br /></span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- execute a command</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font-size: 12px;"><span style="font-family: Verdana;">"cd ~/ && grunt watch" </span></span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>end</b> <b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- we are done talking to the session</span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"> </span></span></div>
<div><font face="Verdana" size="2"> </font><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">— add more tabs here</span></div>
<div><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>end</b> <b>tell</b><br />
<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- reposition window and name it</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b> <b>the</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">bounds</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b> <b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>window</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> {</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x1</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">+ 3 * (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">width</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">/ 4),</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y1</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">+ 3 * (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">height</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">/ 4),</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x2</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">,</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y2</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">}<br />
<b>set</b> <b>the</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b> <b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>window</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "Consoles"<br />
<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new terminal</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">myterm</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>make</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">new</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>terminal</i></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the new terminal</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">myterm</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- make a new session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>activate</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>launch</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>session</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"Default"<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">current session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">)<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set size</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">number of columns</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> 100<br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">number of rows</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> 50<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- talk to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">mysession</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- set some attributes</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "mrsparklepants"<br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- execute a command</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><b>write</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff">text</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">"echo 'start up script located in ~/Library/Application Support/iTerm/AutoLaunch.scpt'"<br />
<br />
<b>end</b> <b>tell</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- we are done talking to the session</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>end</b> <b>tell</b><br />
<br /></span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #5e6161">-- reposition window and name it</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><br />
<b>set</b> <b>the</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">bounds</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b> <b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>window</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> {</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x1</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">+ 3 * (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">width</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">/ 4),</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y1</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">,</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">x2</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">,</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">y2</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">- (</span><span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #4f8f00">height</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures">/ 4) - 23}<br />
<b>set</b> <b>the</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #812fdc">name</span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>of</b> <b>the</b> <b>first</b></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures; color: #0433ff"><i>window</i></span> <span style="font: 12.0px Verdana; font-variant-ligatures: no-common-ligatures"><b>to</b> "Commands"<br />
<br /></span></div>
<div><span style="font-size: 12px;"><span style="font-family: Verdana;"><b>end</b> <b>tell</b></span></span></div>
How the simple brains of termites can do complex tasks and why this is important to the future of humanity.https://boulderappsco.postach.io/post/how-the-simple-brains-of-ants-and-termites-avoid-information-overload-and-why-this-is-important-to-us2017-07-10T22:32:46.914000Z2015-04-30T19:35:19ZNicholas Dunbar<div>How the simple brains of ants and termites avoid information overload and why this is important to how we organized our self in politics and in business. </div>
<div><br /></div>
<div><div class="responsive-container"><iframe width="100%" height="400" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F288676966&show_artwork=true"></iframe></div></div>
<div><br /></div>
<div>Human beings exist in a vast and complex network we call the economy or human society. Our limited minds can only handle so much information in this vast network. In order to cope with this we organize into groups, create hierarchies and design technology to process the information into simplified signals we can understand. Because of this limitation, the types of collaboration we are able to engage in are limited in many ways. Certain types of society wide collaborations could solve some of the world's most difficult problems, however we have no idea how to organize ourselves intentionally in to something more complex beyond what we can individually understand. Lucky for us nature has been solving this problem for a long time and we may learn a thing or two from it. </div>
<div><br /></div>
<div><br /></div>
<div>The term "<b>sematectonic communication</b> was coined by E. O. Wilson, from the Greek words σῆμα sema "sign, token", and τέκτων tecton "craftsman, builder"...it represents a type of <b>stigmergy</b> ( http://en.m.wikipedia.org/wiki/Stigmergy )" found in termite mounds and ant hills. It is more specifically about how the swarm lays down physical artifacts by using some building material as a sort of RAM bank. What I find very interesting about this is that instead of having a processor accessing a large bank of memory you have hundreds of thousands of processors (each agent) crawling about the insides of the memory changing different parts of it in parallel. </div>
<div><br /></div>
<div><br /></div>
<div>If you were to look at the entire network as one distributed program that unfolds in a regular predictable way, it is amazing . The program is distributed across multiple nodes that know how to precisely react to these artifacts that have been laid down by previous processes and how to react to the stimulus of each other in a noisy environment in order to allow the same functional structure to emerge every time (for example, termite mounds regulate humidity and temperature different from the outside environment. It is a vast network HVAC systems that use evaporative cooling and other natural environmental controls ). If we were to try to build this ourselves in order for a functional structure to emerge every time we would have to find some way to encode a set of simpler programs across multiple agents that would allow the larger functional structure to be created. </div>
<div><br /></div>
<div><br /></div>
<div>The potential of doing this in a social system is mind boggling, because it allows us to deal with the fundamental problem of information overload per agent. If we could create a general process that allowed us to encode simple rules in each person we could design much more sophisticated systems on the macro level without the need of understanding of the participants in the population. This prospect is both exciting and scary for if a power structure was doing this to benefit itself and we were unknowingly part of it, the results could forever trap culture at the whim of the power structure because none of us would have the bigger picture of what was actually happening. </div>
<div><br /></div>
<div>For more information check out this podcast I was interviewed for here: <a href="https://soundcloud.com/entwinepodcast/s01e05-wired-into-a-superorganism">Wired Into a Super Organism. </a></div>
Backing up and restoring S3 from a versioned buckethttps://boulderappsco.postach.io/post/backing-up-and-restoring-s3-from-a-versioned-bucket2017-06-23T20:40:11.315000Z2015-03-29T02:47:22ZNicholas Dunbar<div><div style="font-weight: normal;"><span style="font-size: 18px;">Here is a set of scripts used to manage backups. You can back up a bucket to another and then restore the source bucket to a certain snap shot in time as well as a few other things.</span></div></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">Example:</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">//to run back up (see script at the bottom)</div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">prompt> <span style="color: rgb(0, 143, 40);">bkupToBucket.sh</span></div>
<div style="font-size: 13px; font-weight: normal;"><span style="font-size: 18px;">Later on when you need to restore a back up...</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">//determine the timestamps range you want to restore from the back up </div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">prompt> <span style="color: rgb(0, 143, 40);">php awsUtil.php list-timestamps <span style="color: rgb(0, 143, 40);">example-of-a-backup-bucket-name</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">//output:</div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><script src="https://gist.github.com/nicholasdunbar/d8b9a95749fd25f0205e.js"></script></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">//restore backup from files that were versioned between these two timestamps</div>
<div><span style="font-family: monospace;">//this will restore version 0EHqEYAubEXtO4KqU7A316S65tWRN.xT of backup.log</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">prompt> <span style="color: rgb(0, 143, 40);">export startSnapShotTimeStamp=1;</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">prompt> <span style="color: rgb(0, 143, 40);">export endSnapShotTimeStamp=1427577799;</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">//do the restore</div>
<div style="font-family:monospace; font-size:13px; font-weight:normal">prompt> <span style="color: rgb(0, 143, 40);">php awsUtil.php sync example-of-a-backup-bucket-name example-of-a-bucket-name $startSnapShotTimeStamp-$endSnapShotTimeStamp</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">Setting up the script</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">You will need to edit the aws.properties file and add credentials that you created using AWS IAM (See the script at the bottom)</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-size: 18px;">Make sure you set up proper credentials for the user by giving it a user policy which only allows you to back up to the back up bucket and to read from it. Here is an example of such a policy:</span></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><br/></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><script src="https://gist.github.com/nicholasdunbar/70772946be646966dec1.js"></script></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">Other uses for the awsUtil.php script:</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">1.) Copy most recent file versions in a time range from one bucket to another</span></div>
<div style="font-weight: normal;"><span style="font-family: 'Andale Mono';"><span style="font-size: 18px;"><span style="font-size: 13px;">prompt> <span style="color: rgb(0, 143, 40);">php awsUtil.php copy-versions <span style="color: rgb(0, 143, 40);">example-of-a-backup-bucket-name example-of-a-bucket-name <span style="color: rgb(0, 143, 40);">1427577790-<span style="color: rgb(0, 143, 40);">1427577799</span></span></span></span></span></span></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">2.) Copy most recent delete markers in a time range from one bucket to another</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: 'Andale Mono';"><span style="font-size: 18px;"><span style="font-size: 13px;">prompt> <span style="color: rgb(0, 143, 40);">php awsUtil.php copy-delete-markers <span style="color: rgb(0, 143, 40);">example-of-a-backup-bucket-name example-of-a-bucket-name <span style="color: rgb(0, 143, 40);">1427577790-<span style="color: rgb(0, 143, 40);">1427577799</span></span></span></span></span></span></span><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">3.) Delete all versions and delete markers between a time range</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: 'Andale Mono';"><span style="font-size: 18px;"><span style="font-size: 13px;">prompt> <span style="color: rgb(0, 143, 40);">php awsUtil.php delete-versions <span style="color: rgb(0, 143, 40);">example-of-a-backup-bucket-name example-of-a-bucket-name <span style="color: rgb(0, 143, 40);">1427577790-<span style="color: rgb(0, 143, 40);">1427577799</span></span></span></span></span></span></span><br/></span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">4.) List timestamp and version info of a pattern matching a file</span></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: 'Andale Mono';"><span style="font-size: 13px;"><span style="font-size: 18px;"><span style="font-family: 'Andale Mono';"><span style="font-size: 18px;"><span style="font-size: 13px;">prompt></span></span></span></span> <span style="color: rgb(0, 143, 40);">php awsUtil.php list-timestamps example-of-a-backup-bucket-name "*.log"</span></span></span><br/></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;">Here is the scripts needed for awsUtil.php:</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><script src="https://gist.github.com/nicholasdunbar/0f9bc264fe8eaa95cd7f.js"></script></div>
Make your XAMPP site on your Mac accessible to Windows on VMwarehttps://boulderappsco.postach.io/post/make-your-xampp-site-on-your-mac-accessible-to-windows-on-vmware2017-06-23T20:40:10.840000Z2015-03-26T23:01:30ZNicholas Dunbar
<div>
<div><span style="font-size: 24px;">How to run a site on a Mac host machine and then access it from Windows? </span><br/></div>
<div><br/></div>
<div>You may find your self here because you want to test IE browsers on the Mac. I have provided information on how to vet this issue along with the VM issue. </div>
<div><br/></div>
<div><span style="font-size: 24px;">How to test IE on a Mac?</span></div>
<div><br/></div>
<div>If you want to develop a website with XAMPP on your Mac (OSX), but test the site in Internet Explorer (IE) on a VMware Fusion Windows Image then you have found the right article. If you are just trying to serve a site from your Mac host machine to your local virtual machines this article is still useful despite its focus on the discussion around IE. </div>
<div><br/></div>
<div><a href="#configure-vmware">Skip to configuring the software.</a></div>
<div><br/></div>
<div><span style="font-size: 24px;">Alternatives for IE testing?</span></div>
<div>For those of you who are here because you want to test IE in a virtual machine on VMware Fusion you should first consider a few alternatives.</div>
<div><br/></div>
<div>0/4 stars</div>
<div>The tried and true way to test IE is by having a different installation of IE running on a separate Windows box for each version of IE. To do this you could partition your Mac drive to run a different install of Windows for each version of IE. That sounds like a nightmare, but it is an alternative to using VMware. </div>
<div>Pros: Windows will run at highest performance </div>
<div>Cons: Difficult instillation. You can't serve the site from your Mac and then load it in Windows, you'll have to use outside hosting.</div>
<div><br/></div>
<div>1/4 stars</div>
<div>The other thing you can do is run IE 10 on Windows 7 in a VM and then use the IE emulator using compatibility (or compat) mode to test older versions of IE. I personally do not trust this as I have seen IE 7 perform differently in the emulator than it has when running the true native version. But this should work for 90% of cases and drastically reduces the amount of trouble you have to go to to install so many Windows images. IE 11+ does not have compatibility mode so this will not allow you to test IE11+. <a href="http://stackoverflow.com/questions/17881701/wheres-the-ie7-8-9-10-emulator-in-ie11-dev-tools">See this thread for more information on compatibility mode.</a> </div>
<div>Pros: You don't need to waist hard drive space with multiple Windows images</div>
<div>Cons: It will not always behave the same as a real install, not supported IE11 or greater. You have to buy VMware and Windows.</div>
<div><br/></div>
<div>3.8/4 stars</div>
<div>There is a way that I have not been able to get to work on OS X Mountain Lion (at the time of this article), but it works for some and looks awesome. This is using the Oracle Virtual Box software to run different versions of IE. <a href="http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/">See this link here to try it out.</a> </div>
<div>Pros: You don't have to pay for VMware Fusion. You don't have to buy a license of Windows. You can test all browser versions.</div>
<div>Cons: Oracle Virtual Box can lag in compatibility behind newer versions of the Mac OS.</div>
<div><br/></div>
<div><br/></div>
<div>3.8/4 stars</div>
<div>Finally Windows has gotten its butt in gear and provided the tools we need. <a href="http://modern.ie/en-us">You can download a few virtual machines to test each version of IE without the whole Microsoft OS.</a> They provide all kinds of solutions. Virtual box, above, being one of them. The problem with this is it may not function as well as running an actual version of Windows and IE. Some claim it is prone to the same problems that compatibility mode had in < IE11. I can't confirm that. I can only say that this is as close as you can get to the gold standard of testing without using VMware. </div>
<div>Pros: You don't have to pay for VMware Fusion. You don't have to buy a license of Windows. You can test all browser versions.</div>
<div>Cons: Might not always behave exactly the same as a real install of IE, but it probably will.</div>
<div><br/></div>
<div>4/4 stars</div>
<div>Using VMware and multiple OS is not an alternative, but it is the method this article teaches you how to set up. I only provide it here to reiterate that this is the most reliable method of testing. </div>
<div>Pros: It behaves like the real thing because it practically is the real thing.</div>
<div>Cons: Need a license of VMware Fusion, Windows 7, 8 and greater for IE 9+</div>
<div><br/></div>
<div>OK so if you have decided to stick with the gold standard in testing let us continue.</div>
<div><br/></div>
<div><span style="font-size: 24px;">What is VMware Fusion?</span></div>
<div>VMware Fusion is software that you can use to run other operating systems on a virtual machine. What exactly is a virtual machine? Suffice to say, that running Windows in a VM on your Mac allows you to run Windows like an application with its own window inside of the Mac OS. In other words it allows you to run both your Mac OS and your Windows OS at the same time.</div>
<div><br/></div>
<div><span style="font-size: 24px;">What is a VMware Fusion Windows Image?</span></div>
<div>After you have set up VMware Fusion on your Mac, you will create a Windows Image. This is basically the windows operating system plus a snap shot of how it was running in memory. Suffice to say that this allows you to freeze Windows without shutting it down. It's kind of like hibernating or sleeping the operating system. It allows you to pause the operating system and save where it as an Image or Snapshot to your hard drive for later when you revive the system, same as if you closed your Mac laptop and then opened it later to resume work where you left off. Think of it as a virtual laptop running as an application on your Mac.</div>
<div><br/></div>
<div><span style="font-size: 24px;">Why do I need VMware Fusion?</span></div>
<div>Since there is no version of IE available for the Mac, to fully see what a Windows user sees when they access your website requires that you have a copy of Windows. VMware Fusion allows you to run that copy of Windows on your Mac (you could of course dual boot Windows along with OSX as described above in alternatives). Secondly if you want to run several versions of IE, then with VMware Fusion, you can set up multiple Windows Images each with its own version of IE.</div>
<div><br/></div>
<div><a name="configure-vmware"></a></div>
<div><span style="font-size: 24px;">Setting up the software:</span></div>
<div>I won't go into much detail here as you can find documentation on how to do the following five steps easily. After you have done these following five steps, come back for the more difficult part of configuring the software.</div>
<div><br/></div>
<div>1.) Buy VMware Fusion (yes you have to pay for it)</div>
<div>2.) Buy Windows (yes you have to pay for it)</div>
<div>3.) Install VMware Fusion on your Mac</div>
<div>4.) Set up and install Windows as a VMware image.</div>
<div>5.) Install XAMPP (keep in mind that if you secure XAMPP you might not be able to reach your web page from the VM)</div>
<div><br/></div>
<div><span style="font-size: 24px;">Configuring VMware, your Mac and Windows:</span></div>
<div><br/></div>
<div>1.) Run VMware on your Mac</div>
<div>2.) Boot up your Windows Image using VMware</div>
<div>3.) Find the VMware menu on your Mac</div>
<div>4.) Click "Virtual Machine" on the Apple menu at the top</div>
<div>5.) Select "Network Adapter"</div>
<div>6.) Select and click "NAT"</div>
<div>7.) Open a terminal window on your Mac</div>
<div>8.) Type into your terminal window on your Mac, ifconfig and hit enter (yes ifconfig not ipconfig the f is not a typo)</div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">ifconfig</font></div>
<div><br/></div>
<div>9.) Find the following:</div>
<div><br/></div>
<div><font face="'Andale Mono'">vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500</font></div>
<div><font face="'Andale Mono'"> ether 00:50:56:c0:00:01</font></div>
<div><font face="'Andale Mono'"> inet <font color="#008F28">172.16.44.1</font> netmask 0xffffff00 broadcast 172.16.44.255</font></div>
<div><br/></div>
<div>10.) Copy the inet (in this case 172.16.44.1)</div>
<div>11.) Find on Windows your host file (in XP it is in C:\WINDOWS\system32\drivers\etc\hosts for <a href="http://boulderapps.co/location-path-of-hosts-file-in-windows-7">how to find the hosts file in Windows 7 see this link</a>)</div>
<div>12.) Open Notepad in Windows (in XP it is in Start > All Programs > Accessories > Notepad)</div>
<div>13.) Drag and drop the file hosts on Notepad and you should see something like the following:</div>
<div><br/></div>
<div><font face="'Andale Mono'"># Copyright (c) 1993-1999 Microsoft Corp.</font>
<div><font face="'Andale Mono'">etc. etc. etc...</font></div>
<div><font face="'Andale Mono'"># For example:</font></div>
<div><font face="'Andale Mono'">#</font></div>
<div><font face="'Andale Mono'"># 102.54.94.97 rhino.acme.com # source server</font></div>
<div><font face="'Andale Mono'"># 38.25.63.10 x.acme.com # x client host</font></div>
<div><font face="'Andale Mono'"><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">127.0.0.1 localhost</font></div>
</div>
<div><br/></div>
<div>14.) Remove the 127.0.0.1 and replace it with the inet you copied in step 10. (inet is the vm network adapter ip for your Mac) (Keep in mind this will disable the localhost name on your VM, so if you have a web server installed on your VM you will no longer be able to access it using localhost)</div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">172.16.44.1 localhost</font></div>
<div><br/></div>
<div>15.) If you are are running any subdomains on your Mac then add them to the bottom like the following:</div>
<div><br/></div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">172.16.44.1 localhost</span><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">172.16.44.1 tests.localhost</font></div>
<div><br/></div>
<div>16.) Or any URLs that you have set up locally on your Mac XAMPP install</div>
<div><br/></div>
<div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">172.16.44.1 localhost</span><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">172.16.44.1 tests.localhost</font></div>
</div>
<div><font face="'Andale Mono'" color="#008F28">172.16.44.1 someurl.com</font></div>
<div><br/></div>
<div>17.) If you need a non standard port number you can't do it in a windows hosts file, but you can do it in the Mac hosts file (see step 20)</div>
<div><br/></div>
<div><font face="'Andale Mono'"><font color="#008F28">127.0.0.1<span style="font-family: 'Andale Mono';">:8090</span><span style="font-family: 'Andale Mono';"> localhost</span></font><br/></font></div>
<div><span style="font-family: 'Andale Mono';"><br/></span></div>
<div>18.) Save the Window's hosts file</div>
<div>19.) Find on your Mac the hosts file (usually in /etc/hosts)</div>
<div>20.) Repeat steps 14 to 17 but instead of using 172.16.44.1 use 127.0.0.1 so it would look like the following on your Mac hosts file:</div>
<div><span style="font-family: 'Andale Mono';"><br/></span></div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">127.0.0.1 </span><span style="font-family: 'Andale Mono';">localhost</span></font>
<div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">127.0.0.1 </span><font face="'Andale Mono'">tests.localhost</font></font></div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">127.0.0.1 </span><font face="'Andale Mono'">someurl.com</font></font></div>
</div>
<div><font color="#008F28"><span style="font-family: 'Andale Mono';">127.0.0.1</span><span style="font-family: 'Andale Mono';">:8090</span><span style="font-family: 'Andale Mono';"> localhost</span></font></div>
</div>
<div><br/></div>
<div>21.) In the Windows VM run the command line window (in XP Click Start > Run and then enter cmd into the "open" text field and then click OK)</div>
<div><br/></div>
<div>22.) In the Windows command line run the following:</div>
<div><br/></div>
<div><font color="#008F28">ipconfig /flushdns</font></div>
<div><br/></div>
<div>23.) If you are using custom domains like test.localhost or some url.com you need to make sure that your httpd-vhosts.conf file is correctly configured on your Mac. See "<a href="http://actionscript-flash-guru.com/blog/49-replace-www-with-a-subdomain-xampp-mac-localhost.php">How to Set Up A Subdomain with XAMPP</a>" for more details.</div>
<div>24.) Make sure that XAMPP is running on your Mac and then restart it by running the following on the command line in your Mac under terminal:</div>
<div><br/></div>
<div><font color="#008F28">sudo /Applications/XAMPP/xamppfiles/xampp restart</font></div>
<div><br/></div>
<div>25.) Check to make sure it is loading on your Mac by opening a browser and going to http://localhost</div>
<div>26.) If it doesn't work you need to resolve this before testing it on Windows. </div>
<div>27.) Open a browser in the Windows VM and go to http://localhost and the same webpage you saw on your Mac should show up.</div>
<div>28.) You are officially set up.</div>
<div><br/></div>
<div>There are lots of permutations of this article on the web, but I have found them to be sparse in their explanations. In this article I have tried not to assume you know everything but assume you know at least a few things being that you are a web developer. After you have completed these instructions there are few things you might want to know about what you just did. I'll try my best to anticipate your questions below:</div>
<div><br/></div>
<div><span style="font-size: 24px;">What is the VMware Fuse Network Adapter?</span></div>
<div>This is how you want the Windows virtual machine to connect to the network via your Virtual Network Adapter. Because Windows is running on a virtual machine it means the hardware is virtual, this the network card and set up are virtual as well. This means you can change the network set up of your windows box simply by changing the VMware Fuse settings and voila as far as Windows cares it is running with a new set up. There are a few different settings under the VMware Fuse Network Adapter: NAT, Bridge and Host Only. (For more information on these check out the <a href="http://pubs.vmware.com/workstation-10/index.jsp?topic=%2Fcom.vmware.ws.using.doc%2FGUID-D9B0A52D-38A2-45D7-A9EB-987ACE77F93C.html">VMware documentation</a> )</div>
<div><br/></div>
<div><span style="font-size: 24px;">What is the NAT Network Adapter setting?</span></div>
<div>This means that the Windows VM does not have its own IP address on the external network. It instead lives on a Private Virtual Network that is set up on the Mac host operating system. That is to say the main OS that is running VMware Fuse. We use this instead of others because it protects the Windows operating system from being accessed from outside of your Mac. When you typed in ifconfig in your Mac Terminal (command line) you may have noticed in the list the vmnet8 entry. This is the address of the NAT network. If you were to run multiple VMs simultaneously they would all communicate via this private network via vmnet8. You might notice that vmnet8 exists on your system after you install VMware Fuse even when you are not running it. It is there to ensure the IP does not change as a permanent gateway into your virtual network. When you boot up an image in NAT each obtains its own IP using DHCP (dynamic IP allocation) and you can use these IPs to allow each VM to network with each other, but that is beyond what is necessary to know in order to access XAMPP on the host machine, in this case your Mac.</div>
<div><br/></div>
<div><span style="font-size: 24px;">What is vmnet1 in ifconfig?</span></div>
</div>
<div>When you install VMware Fuse it creates a permanent address for you the network vmnet8. It is through the address at vmnet1 that the Windows Virtual Machine can access the host machine. This is why we use the NAT Network Adapter so that we can route the name localhost to the host machine via the address assigned to vmnet1. This assures that you don't have to change the hosts file every time you boot up as you would if you used the bridge setting. </div>
Remove all versions from S3 bucket using AWS toolshttps://boulderappsco.postach.io/post/remove-all-versions-from-s3-bucket-using-aws-tools2017-06-23T20:40:29.056000Z2015-03-26T20:12:03ZNicholas Dunbar<div><span style="font-size: 24px;">This will help you answer any of the following questions:</span></div>
<div><br/></div>
<div><h2>Delete all deletion markers for every object in a bucket.</h2></div>
<div><h2>Delete all objects and versions for every object in a bucket.</h2></div>
<div><h2>Delete a bucket that has had versioning turned on.</h2></div>
<div><br/></div>
<div>This article will walk you through all the steps needed to remove all your S3 object's pervious versions including delete markers using the AWS provided command line tool "aws" and then remove the bucket.</div>
<div><br/></div>
<div><br/></div>
<div><br/></div>
<div><span style="font-size: 24px;">Create A User</span></div>
<div><br/></div>
<div>First you need to create a user that has access to your S3 Buckets. If you already have this then script to step 9.</div>
<div><br/></div>
<div>1. ) Go to <a href="https://console.aws.amazon.com/iam/home">https://console.aws.amazon.com/iam/home</a></div>
<div>2.) Click users</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/8a0a9369-cb42-4d63-b1ca-5bc974ce7746.png" style="height: auto;"/></div>
<div><br/></div>
<div>3.) Create user</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/3da624a0-e9cd-49df-af13-e419571742eb.png" style="height: auto;"/></div>
<div>4.) Enter user name</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/f6aa7230-0f8a-419e-aced-8183ab093eb9.png" style="height: auto;"/></div>
<div>5.) Copy your security credentials to a file (This will be the last time you will be able to access them)</div>
<div> <img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/939ddf77-3cb8-4507-9754-8f6cf91d8230.png" style="height: auto;"/></div>
<div><br/></div>
<div><br/></div>
<div>6.) Back at the main user list screen, edit the user by clicking it in the list</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/b41822a2-3a84-4f7a-994f-e3acfa18d2b1.png" style="height: auto;"/></div>
<div><br/></div>
<div>7.) Attach a policy that allows the user to access the S3 service (click attach policy)</div>
<div><br/></div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/54946d1a-73b5-42ca-84c0-93eb4e1a19d6.png" style="height: auto;"/></div>
<div>8.) Search for "S3" in the policy filter and then select "AmazonS3FullAccess"</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/5aaebd49-3424-422a-8dd3-0104a6911dee.png" style="height: auto;"/></div>
<div><br/></div>
<div>9.) Click "Attach Policy"</div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/268ce605-0c94-41f2-ad75-b4f1b4fb7a1d.png" style="height: auto;"/></div>
<div><br/></div>
<div><span style="font-size: 24px;">Delete all versions</span></div>
<div><br/></div>
<div>10.) Disable versioning in your bucket</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/ed72cc73-68d9-4020-8d18-779f869419db.jpg" style="height: auto;"/></div>
<div><br/></div>
<div>11.) Open up a terminal (I'm using max OS X, but these interactions will work also on a Linux Machine</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/00396aea-69a3-4edc-8a13-618deff5da02/0ae1dc83-8ab9-4fd7-98c1-0cb43e6971d2.jpg" alt="https://discussions.apple.com/___sbsstatic___/migration-images/104/10433325-1.jpg" style="height: auto;"/></div>
<div><br/></div>
<div>12.) Use SSH to login to your EC2 server or you can also run it locally. To run it locally you will have to have installed was cli (command line interface) tools (<a href="http://docs.aws.amazon.com/cli/latest/userguide/installing.html">http://docs.aws.amazon.com/cli/latest/userguide/installing.html</a>). Elastic beanstalk instances come preloaded with was cli tools. It will work faster if it is on you EC2 sever since the server is in the cloud. </div>
<div><br/></div>
<div>ssh -i myawspemfile.pem ec2-user@124.93.286.021;</div>
<div><br/></div>
<div>13.) Define variables for the was tools command line utility by typing the following into your terminal (remember to not use my credentials and use the ones that you downloaded with the temp2 user):</div>
<div><br/></div>
<div>prompt> <span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';">export AWS_ACCESS_KEY_ID=AKIAJ3RHXVS6TJJFBGFA;</span></span></div>
<div>prompt> <span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';">export AWS_SECRET_ACCESS_KEY=o8oeqYLMu+F9nL97+992U+8Q9wj35BEHHo2Eqs;</span></span></div>
<div><br/></div>
<div>14.) Remove all old versions of files (cut and paste the green into your terminal, replace the red words)</div>
<div> </div>
<div>prompt> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">echo '#!/bin/bash' > deleteBucketScript.sh && aws --output text s3api list-object-versions --bucket </span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);"><span style="color: rgb(152, 13, 8);">yourbucket-name-backup</span></span></span> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">| grep -E "^VERSIONS" | awk '{print "aws s3api delete-object --bucket </span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);"><span style="color: rgb(152, 13, 8);">yourbucket-name-backup</span></span></span> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">--key "$4" --version-id "$8";"}' >> deleteBucketScript.sh && . deleteBucketScript.sh; rm -f deleteBucketScript.sh;</span></span></div>
<div><span style="color: rgb(152, 13, 8);">WARNING</span>: this will delete the entire object including all its previous versions and only leave behind delete markers.</div>
<div>This operation could take hours depending on how much you have in your bucket.</div>
<div>Here is the documentation for these commands:</div>
<div><a href="http://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">http://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html</a></div>
<div><a href="http://docs.aws.amazon.com/cli/latest/reference/s3api/list-object-versions.html">http://docs.aws.amazon.com/cli/latest/reference/s3api/list-object-versions.html</a></div>
<div><a href="http://aws.amazon.com/cli/">http://aws.amazon.com/cli/</a></div>
<div><span style="color: rgb(0, 143, 40);"><br/></span></div>
<div>15.) Remove all delete markers (deleted versions) from the s3 bucket.</div>
<div><br/></div>
<div>prompt> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">echo '#!/bin/bash' > deleteBucketScript.sh && aws --output text s3api list-object-versions --bucket <span style="color: rgb(152, 13, 8);">yourbucket-name-backup</span> | grep -E "^DELETEMARKERS" | awk '{print "aws s3api delete-object --bucket </span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);"><span style="color: rgb(152, 13, 8);">yourbucket-name-backup</span></span></span> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">--key "$3" --version-id "$5";"}' >> deleteBucketScript.sh && . deleteBucketScript.sh; rm -f deleteBucketScript.sh;</span></span></div>
<div><br/></div>
<div>You should get a bring of JSON output like the following:</div>
<div><br/></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">{</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">"VersionId": "9PcePHd64KCFxZH_ihqG5F1zg9BiMsb0",</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">"DeleteMarker": true</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">}</span></span></div>
<div><br/></div>
<div>Now all the objects in the bucket should be definitively removed.</div>
<div><br/></div>
<div>16.) Check the bucket and remove anything that may have been missed at </div>
<div><a href="https://console.aws.amazon.com/s3/home">https://console.aws.amazon.com/s3/home</a></div>
<div><br/></div>
<div>17.) Delete the user so that your apps permission return to what they should be.</div>
<div><br/></div>
<div>18.) In your terminal you should run</div>
<div><br/></div>
<div>prompt> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);"><span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';">export AWS_ACCESS_KEY_ID=""; <span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';">AWS_SECRET_ACCESS_KEY=""; <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);">history -c; </span></span></span></span></span></span></span></span></div>
<div><br/></div>
<div>This makes sure that your credentials can't be accessed if you didn't delete them in step 17.</div>
<div><br/></div>
<div>Also don't forget to re-enable versioning on your bucket if you need it.</div>
<div><br/></div>
<div>you can use </div>
<div><br/></div>
<div>
<pre>
<span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';">aws s3 rb s3://</span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 143, 40);"><span style="color: rgb(152, 13, 8);">yourbucket-name-backup</span></span></span><span style="color: rgb(0, 143, 40);"><span style="font-family: 'Andale Mono';"> --force</span></span>
</pre></div>
<div><br/></div>
<div>if you want to delete the bucket once you have removed the versions.</div>
<div><br/></div>
<div>You might have found this article because you were looking to answer the following questions:</div>
<div><br/></div>
<div><h2>How to delete a bucket using the command line</h2></div>
<div><h2>Life cycle rules does not empty a bucket with versioning enabled</h2></div>
<div><h2>aws s3 rb --force does not remove bucket</h2></div>
<div><br/></div>
How to properly remove Skeuomorphism from designhttps://boulderappsco.postach.io/post/how-to-properly-remove-skeuomorphism-from-design2017-06-23T20:40:11.670000Z2015-03-09T21:57:48ZNicholas Dunbar<div>Skeuomorphism is the design concept of making items represented to resemble their real-world counterparts. As our devices increasingly make use of reprogrammable displays, references to the old physical interfaces becomes increasingly less applicable.</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/002fe8c0-5854-4908-ae90-da6f4a1327a8/47338481-38d7-4415-b43c-913a77861a4a.jpg" alt="http://www.emacconsulting.com/wp-content/uploads/2010/01/iBooks1-full.jpg" style="height: auto;"/><br/></div>
<div><br/></div>
<div>Apple has officially started to phase out Skeuomorphisms and the design community has began to see it as passé. Before you accidentally over apply the idea that Skeuomorphism is unfashionable. You first need to understand why it has become unfashionable. It is out of style primarily for usability reasons not aesthetic reasons. Designers who are revamping designs and indiscriminately removing "items represent to resembler their real-world counterparts" are thoughtlessly engaging in a sort of design witch hunt.</div>
<div><br/></div>
<div>Skeuomorphism is only a problem when the interface structure is made less useable at the cost of relating it to something in the real world. The design trend acted as a bridge between the analog world of dials and switches and the digital world, but now we are familiar with the digital world and there are better interfaces than switches and dials. But just because the analog counterpart is gone does not mean there is a better schema available. </div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/002fe8c0-5854-4908-ae90-da6f4a1327a8/85c1ad33-97d8-48b5-813f-c274ec7ac729.jpg" alt="http://i.ytimg.com/vi/BZ8oHtbTUoQ/maxresdefault.jpg" style="height: auto;"/><br/></div>
<div><br/></div>
<div>You may notice that as Apple has began to deemphasize skeuomorphic design with OS X Yosemite, yet they have left the hard drive icon looking like a real hard drive. Isn't that a skeuomorph? Why did they leave it? To remove these realistic renderings and replace them with a more graphic representation is not removing the skeuomorph because your now graphic representation still heralds to the original object. What the designer is doing in this situation is changing the style to something like Super Flat (a popular design trend at the moment), but not removing the skeuomorph. Remember a skeuomorph is something that is made to resemble its real world counter part. To truly remove the skeuomorph you would have to replace the hard drive with something that did not represent the actual object, like say a cloud for cloud storage or a cylinder which is also often used to represent storage. But this would be an over reaction to the trend. It would be a mistake to do this as using real world representations are superior in their ability to communicate what they are over their more abstract counter parts. </div>
<div><br/></div>
<div>One reason the skeuomorph is out of style is because we use less and less physical interfaces in the real world. There are less dials, less buttons, less CD racks, etc. The computer interface is the real thing. But if we are now using solid state hard drives in all Macs why is the Mac hard drive icon still a spin drive? Again, just because the real-world counter part is no longer used does not mean that the representation has a better alternative in the reprogrammable interface universe.</div>
<div><br/></div>
<div>For instance, there is no reason to stop using the telephone receiver as a symbol to communicate a call even though no one uses a phone with a crescent shaped receiver anymore. This is because the symbol does its job at communicating its purpose despite the users lack of familiarity with the actual device. It has become a pure symbol and in a sense is no longer Skeuomorphic, since there is no real world counter part in use in most homes today. To contrast, a hard drive is hardly out-dated as a symbol and also serves as a strong symbolic representation in the same way while still being strongly Skeumorphic. The hard drive will one day also be like the phone as no one will open their computers to see a hard drive and all external drives will be in the cloud, at which time the hard drive will go the way of the phone receiver. Yet because of its historical use, it will be a strong candidate among other symbols to represent a storage device. So, does it really matter that the symbol has a basis in the real world as long as it is symbolically recognized as being a symbol tied to a purpose? Further more the symbol performs its function at no cost to the usability of the interface whether it is outdated or not. Thus, I think you will see skeuomorphism in icons for many years to come, since you have to choose a standard symbol to represent the function, in which case you might as well stick with the historically used symbols.</div>
<div><br/></div>
<div>Where skeuomorphism will disappear is in overall UI design, like simulated dials, keys, buttons, book pages, book shelves and the like. These old interfaces are less efficient in comparison with the new more flexible reprogrammable ones and since users are familiar enough now with the newer and improved usability schemes, designers can replace the outdated systems at little cost of confusion to the user. Sadly for the elderly if they didn't cross the skeuomorph bridge built for them to ease into the digital world, they will be left behind as usability schemes become increasingly efficient at the cost of becoming increasingly foreign to the 20th century. </div>
<div><br/></div>
<div>
<div style=""><a href="https://www.pinterest.com/pin/540291286517227288/" style="border: 0px none;" name="irc_mil"><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/002fe8c0-5854-4908-ae90-da6f4a1327a8/1d521114-6108-4517-a7c2-b87d88882eda.jpg" style="height: auto;" height="454" width="504"/></a></div>
</div>
<div><br/></div>
Running different ANT tasks depending on the operating systemhttps://boulderappsco.postach.io/post/running-different-ant-tasks-depending-on-the-operating-system2017-06-23T20:40:10.327000Z2015-02-02T07:02:54ZNicholas Dunbar
<div>
<div>How to run a different series of tasks inside of a single target tag based on the operating system so that your build script will work on all operating systems.</div>
<div><br/></div>
<div>There are three ways to do it:</div>
<div><br/></div>
<div>1.) The first way is to have a different task for each operating system. You detect the OS outside your task in the global scope and then set up different tasks that run depending on the OS. That method is listed in the top code sample. But what if you don't want to clutter your tasks list and you just want to quickly switch the logic inside one specific task on just one or two statements? For that solution read on.</div>
<div><br/></div>
<div>2.) In the second method listed in the bottom code sample, you will need to add to ANT the 'if', 'then' and 'else' tasks. You will need to download the latest ant-contrib.jar file from the web and add it to ANT, then you can use the following task definition to add it to your build.xml file. You may have to poke around the web a bit to figure out how to install this JAR file. Once you have done that you can use the example code below in the task named detectOS. </div>
<div><br/></div>
<div>3.) You can set the 'os' attribute in many tags which will allow the tag to run based on the operating system. See the last code example of the three below for how to do this.</div>
<div><br/></div>
<div>
<div><br/></div>
</div>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><br/>
<br/></td>
<td>
<div><script src="https://gist.github.com/nicholasdunbar/8ccb8e1ac798d6b3b8d8.js"></script> </div>
</td>
</tr>
</tbody>
</table>
<div><br/></div>
</div>
<div><br/></div>
Load a class with Zend_Loader_Autoloader by name | without namespaces or prefixeshttps://boulderappsco.postach.io/post/load-a-class-with-zend-loader-autoloader-by-name-without-namespaces-or-prefixes2017-06-23T20:40:08.890000Z2014-12-29T23:00:07ZNicholas Dunbar<div>The web is filled with examples of using Zend Autoloading using the fancy namespace and prefix features of the Zend_Loader_Autoloader, but what if all you want to do is auto load a class based on its name corresponding to a file name?</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">//For example what if you want </span></span></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">$instance = Instance();</span></span></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">//to automatically include the class from /path/to/apache/webroot/library/Instance.php, what if you want that?</span></span></div>
<div><br/></div>
<div>While using prefixes to divide your libraries up into different groups speeds up access times, this is not useful if your retroactively implementing auto loading. Using the include path is a little slow but its supper simple to implement. </div>
<div><br/></div>
<div>In Bootstrap.php add the following code:</div>
<div><br/></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//configure Zend Auto Loader</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$autoloader = Zend_Loader_Autoloader::getInstance();</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//sets the auto loader to use the include path</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$autoloader->setFallbackAutoloader(true);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"><br/></span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//that is it unless you need to add your directory to the include path</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//so that the auto loader </span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">will search for your class in that directory</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"><br/></span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//create current include path</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$pathArray = explode(DIRECTORY_SEPARATOR, __FILE__);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//remove Bootstrap.php</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">array_pop($pathArray);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//remove parent directory</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">array_pop($pathArray);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//create /path/to/apache/webroot</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$path = implode(DIRECTORY_SEPARATOR,$pathArray);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">// add library to web root to make /path/to/apache/webroot/library/</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">path .= DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR;</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//get list of current include paths</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$includePathsArray = explode(PATH_SEPARATOR, get_include_path());</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">if (includePathsArray == NULL){</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> $includePathsArray = array();</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">}</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//add new include path</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">array_push($includePathsArray, $path);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//make sure there are not any duplicate paths</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">$includePathsArray = array_unique($includePathsArray);</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">//create include path string and rewrite the list of include directories</span></span></div>
<div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">set_include_path(implode(PATH_SEPARATOR, $includePathsArray));</span></span></div>
</div>
<div><br/></div>
<div>Now the zend autoloader will look for file names that resemble your class names by looking in the list of include directories including the library directory that we added.</div>
Installing xdebug in XAMPP 5.5.19 on Mac OSXhttps://boulderappsco.postach.io/post/installing-xdebug-in-xampp-5-5-19-on-mac-osx2017-06-23T20:40:09.749000Z2014-12-29T01:54:34ZNicholas Dunbar<div>This was tested on OSX Lion. Please let me know if it works on Mountain Lion or later.</div>
<div><br/></div>
<div>Here is what we will be doing in a nut shell. You will need to download the correct source code for your version of xdebug and then you will need to use the correct tools to compile that debug source code to create an extension. You will then install the extension into your version of PHP. Let us begin. </div>
<div>
<div><br clear="none"/></div>
<div>1.) Check to make sure /bin is in your path</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">echo $PATH;</span></span></div>
</div>
<div><br clear="none"/></div>
<div>if :/usr/bin: is in the path then usr/bin is in your path. This makes sure that when you create a symbolic link in usr/bin it can be called from any directory at the prompt.</div>
<div>
<div><br clear="none"/></div>
<div>If it is not in your path you may have your bin directory configured to a different location.</div>
</div>
<div><br/></div>
<div>2.) Check to make sure you don't already have phpize installed</div>
<div><br/></div>
<div><span style="font-family: 'Andale Mono';"> <span style="color: rgb(0, 145, 0);">sudo cd /usr/bin;</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> sudo ls -al | grep phpize;</span></span></div>
<div><br/></div>
<div>if you get a result like:</div>
<div><br/></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> -rwxr-xr-x 1 root wheel 4494 Jul 11 2011 phpize</span></span></div>
<div><br/></div>
<div>then another version is installed. We don't want to use this version, we want to use the version that came with xampp. so we will rename it to phpize_bkup just in case you ever need to restore it.</div>
<div><br/></div>
<div> <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">sudo mv phpize phpize_bkup;</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div>3.) Create a new symbolic link to phpize in /usr/bin</div>
<div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">cd /usr/bin;</span></span></div>
</div>
<div style="margin-left:30px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">sudo ln -s </span><span style="color: rgb(0, 145, 0);">/Applications/XAMPP/bin/phpize-5.5.19 phpize;</span></span></div>
<div><br clear="none"/></div>
<div>4.) Test phpize</div>
<div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">cd /;</span></span></div>
<div style="margin-left: 30px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">sudo phpize -v;</span></span></div>
<div><br clear="none"/></div>
<div>you should get something like this:</div>
<div><br clear="none"/></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">Configuring for:<br clear="none"/>
PHP Api Version: 20121113<br clear="none"/>
Zend Module Api No: 20121212<br clear="none"/>
Zend Extension Api No: 22012121</span></span></div>
</div>
<div><br/></div>
<div>5.) Check to see if you have ruby installed</div>
<div><br/></div>
<div> ruby -v;</div>
<div><br/></div>
<div>you should get something like this:</div>
<div><br/></div>
<div>ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]</div>
<div><br/></div>
<div>If you do not get this then you need to install ruby. For instructions on how to do that look here:</div>
<div><br/></div>
<div><a href="http://code.tutsplus.com/tutorials/how-to-install-ruby-on-a-mac--net-21664">http://code.tutsplus.com/tutorials/how-to-install-ruby-on-a-mac--net-21664</a><br/></div>
<div><br/></div>
<div>6.) Install homebrew (homebrew is a package manager for mac like yum or apt-get)</div>
<div><br/></div>
<div>Do not install as root that means no sudo or logged in as root.</div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"><br/></span></span></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";</span></span></div>
<div><br/></div>
<div>7.) Install autoconfig</div>
<div>
<div><span style="font-family: 'Andale Mono';"><br clear="none"/></span></div>
<div style="margin-left:30px;"><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">brew install autoconf</span></span></div>
<div><br/></div>
<div>(Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention. Autoconf creates a configuration script for a package from a template file that lists the operating system features that the package can use, in the form of M4 macro calls.)</div>
<div>Source: <a href="http://www.gnu.org/software/autoconf" target="_blank">http://www.gnu.org/software/autoconf</a></div>
</div>
<div><br/></div>
<div>8.) install apple Developer Tools </div>
<div><br/></div>
<div>go to <a href="https://developer.apple.com/downloads">https://developer.apple.com/downloads</a> in the web browser</div>
<div>login (you will need your apple ID and password)</div>
<div>select the following on the following screen:</div>
<div><br/></div>
<div><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/9409818d-ed81-492b-a6b5-1152111d392a/15841b68-b9f4-4a7a-b63b-0da7327b94b9.png" style="height: auto;"/></div>
<div><br/></div>
<div>Click the apple in the top left hand corner and select "About This Mac" </div>
<div>Click "More Info"</div>
<div>Find the line that starts with the word "Software"</div>
<div><br/></div>
<div>In my case it is Mac Os X Lion 10.7.5 so I look up that on the downloads page and find the following:</div>
<div> <img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/9409818d-ed81-492b-a6b5-1152111d392a/29de77b5-d14d-4a95-8782-ce2c6fb6d932.png" style="height: auto;"/></div>
<div><br/></div>
<div>click on the blue link to download the .dmg</div>
<div><br/></div>
<div>go to your Downloads directory and find a file similar to xcode462_cltools_10_76938260a.dmg</div>
<div><br/></div>
<div>double click on the file</div>
<div><br/></div>
<div>double click the file similar to "Command Line Tools (Lion).mpkg" and follow the install guide</div>
<div><br/></div>
<div><br/></div>
<div>9.) get php_info() from your webserver</div>
<div> cd /Applications/XAMPP/htdocs</div>
<div> touch phpinfo.php;</div>
<div> sudo vi phpinfo.php</div>
<div> i</div>
<div> <?php phpinfo(); ?></div>
<div> esc</div>
<div> :x!</div>
<div><br/></div>
<div>10.) go to your localhost web root url and run the php file you just created</div>
<div> http://localhost/phpinfo.php</div>
<div>copy the contents of the window (do not copy the html raw source)</div>
<div><br/></div>
<div>11.) now go to debug.org and get the system to tell you which source to download</div>
<div>
<div><br clear="none"/></div>
</div>
<div style="margin-left:30px;"><a href="http://xdebug.org/wizard.php">http://xdebug.org/wizard.php</a></div>
<div><br/></div>
<div>as soon as you download the source come back here. The instructions it provides will not always work.</div>
<div><br/></div>
<div>12.) Unpack the downloaded file and move into unpacked directory</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><code><span style="font-family: 'Andale Mono';">tar -xvzf xdebug-2.2.6.tgz</span></code></span></div>
<div><span style="color: rgb(0, 145, 0);"><code><span style="font-family: 'Andale Mono';">cd xdebug-2.2.6</span></code></span></div>
<div><br/></div>
<div>13.) run phpize</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">phpize</span></span></div>
<div><br/></div>
<div>14.) configure specifically for your php version</div>
<div>run inside the xdebug source folder</div>
<div>
<pre>
<span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">.<span style="font-weight: bold;">/</span>configure --enable-xdebug --with-php-config=<span style="font-weight: bold;">/</span>Applications<span style="font-weight: bold;">/</span>XAMPP<span style="font-weight: bold;">/</span>xamppfiles<span style="font-weight: bold;">/</span>bin<span style="font-weight: bold;">/</span>php-config
</span></span>
</pre></div>
<div>15.) run make</div>
<div>run inside the debug source folder</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">make</span></span></div>
<div><br/></div>
<div>16.) go back to the debug.org wizard and find the step that has something like this in it</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><code><span style="font-family: 'Andale Mono';">cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212</span></code></span></div>
<div><br/></div>
<div>copy the statement like this and run it in the xdebug folder to move the files over to xampp</div>
<div><br/></div>
<div>17.) edit php.ini</div>
<div><br/></div>
<div>when you edit php.ini</div>
<div>use</div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"> </span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">sudo vi "$(cd /Applications/XAMPP/; sudo find `pwd` -name php.ini;)"</span></span></div>
<div>once in the text editor vi use</div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"> /zend_extension</span></span></div>
<div>to search for the part to add in the debug extension</div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> i</span></span> - for the vi command to insert text</div>
<div>if your path that you added to zend_extension= has spaces in it make sure it is surrounded by double quotes, something like the following:</div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"> zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> esc</span></span> - to exit insert mode</div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> :x!</span></span> - to save and exit</div>
<div><br clear="none"/></div>
<div>This finds the path to php.ini file under <span style="color: #008000; font-family: courier new,courier;">/Applications/XAMPP/</span> and then opens it in the text editor vi, if your php.ini file is not under <span style="color: #008000; font-family: courier new,courier;">/Applications/XAMPP/</span> then change <span style="color: #008000; font-family: courier new,courier;">/Applications/XAMPP/</span> to the location of xampp where you have it installed. If you're confused by Linux voodoo then just find the php.ini file your self go to that directory and type in <span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);">sudo vi php.ini</span></span> .</div>
<div><br/></div>
<div>18.) In the text editor vi that has opened php.ini edit the configuration</div>
<div>
<div><br clear="none"/></div>
<div> a.) Find the extension section again by typing the following:</div>
<div><br clear="none"/></div>
<div style="margin-left: 60px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">/zend_extension=</span></span></div>
<div style="margin-left: 60px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);"> </span></span></div>
<div style="margin-left: 60px;"><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);">i</span></span></div>
<div style="margin-left: 60px;"><span style="color: #008000; font-family: courier new,courier;"><br clear="none"/></span></div>
<div> Note: "/" is for search for string and "i" is for insert which puts you into editing mode.</div>
<div><br clear="none"/></div>
<div> b.) Add in line at the bottom of the extension section</div>
</div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';"><br clear="none"/></span></span></div>
<div style="margin-left:60px;"><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">xdebug.remote_enable=1<br clear="none"/>
xdebug.remote_handler=dbgp<br clear="none"/>
xdebug.remote_host=localhost<br clear="none"/>
xdebug.remote_port=9000</span></span></div>
<div style="margin-left:60px;"><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">xdebug.show_local_vars=1</span></span></div>
<div style="margin-left:60px;"><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">xdebug.remote_log=/Applications/XAMPP/logs/xdebug.log</span></span></div>
<div>
<div><br clear="none"/></div>
<div> Remove tabs (\t) at the front when you copy and paste this section in. Other words left justify it.</div>
<div><br/></div>
</div>
<div>If your version of xampp is not installed at <span style="color: #008000; font-family: courier new,courier;">/Applications/XAMPP/</span> then replace <span style="color: #008000; font-family: courier new,courier;">/Applications/XAMPP/</span> with your directory</div>
<div>
<div><br/></div>
<div> Note: I had to adjust my Net Beans install to use port 9001 in the settings above (see https://netbeans.org/bugzilla/show_bug.cgi?id=176335). I have left the setting above of remote_port to 9000 because that is the norm in most cases.</div>
<div><br clear="none"/></div>
<div> c.) Add in the xdebug configuration<br clear="none"/>
<br clear="none"/>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);"> escape key</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);"> :x</span></span></div>
<br clear="none"/>
d.) Type the following<br clear="none"/>
<br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;"> <span style="font-family: 'Andale Mono';">escape key</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 128, 0);"> :x</span></span></div>
</div>
<div><br clear="none"/></div>
<div>19.) Restart the server</div>
<div>
<div><br clear="none"/></div>
</div>
<div><span style="color: #008000; font-family: courier new,courier;"> <span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">sudo </span></span></span><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">/Applications/XAMPP/xamppfiles/ctlscript.sh stop apache</span></span></div>
<div><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"> </span></span><span style="color: #008000; font-family: courier new,courier;"><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">sudo </span></span></span><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">/Applications/XAMPP/xamppfiles/ctlscript.sh start apache</span></span><span style="font-family: 'Andale Mono';"><span style="color: rgb(0, 145, 0);"><br/></span></span></div>
<div>
<div><br clear="none"/></div>
</div>
<div>If your version of xampp is not installed at /opt/lampp then replace /opt/lampp with your directory</div>
<div>(I had to do this twice to get it to take)</div>
<div><br/></div>
<div>20.) Check for start up errors in /Applications/XAMPP/xamppfiles/logs/error_log</div>
<div><br/></div>
<div>if you find the following at the time of the last start up:</div>
<div><br/></div>
<div><span style="color: rgb(0, 145, 0);"><span style="font-family: 'Andale Mono';">Xdebug requires Zend Engine API version</span></span></div>
<div><br/></div>
<div>then you compiled it incorrectly, go back and scrutinize what you did</div>
<div>if it is not present at the last start up time then you have been successful. </div>
<div><br/></div>
<div>21.) check if installed correctly</div>
<div><br/></div>
<div>go back to the url you created called phpinfo.php </div>
<div>reload the url</div>
<div>copy the contents of the window (again not the html raw source)</div>
<div>go to <a href="http://xdebug.org/wizard.php">http://xdebug.org/wizard.php</a></div>
<div>and re-analyze your php info to see if debug was installed</div>
<div><br/></div>
<div>22.) Done</div>
<div>
<div><br/></div>
<div>Tested on OS X Lion 10.7.5</div>
</div>
<div><br/></div>
Replace a token with a variable using ANThttps://boulderappsco.postach.io/post/replace-a-token-with-a-variable-using-ant2017-06-23T20:40:09.265000Z2014-11-15T21:37:52ZNicholas Dunbar<div><div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">You may be looking for the following:</span></span></div></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><h1>How do you replace a string in a file using a property in ANT?</h1></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><h1>How do you replace a string using a variable in ANT?</h1></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">There are a few ways to do this. First question is what do you mean by a variable? Do you mean a variable set in a property file like the following?</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> ls -l</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">-rw-r--r--@ 1 nicholasdunbar staff 2245 Nov 15 13:42 dev2.properties</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">The contents of dev2.properties being something like the following:</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> cat dev2.properties</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">crontabPath=/some/dir/</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">or do you mean a variable set in a property in your build file like the following?</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><script src="https://gist.github.com/nicholasdunbar/84f2cae994d6ab3297cb.js"></script><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">First we will talk about how to do it with the property file and then with the property tag/task.</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><b><span style="font-size: 18px;"><span style="font-family: Arial;">Example 1 property file:</span></span></b></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">So lets say we have the following files:</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> ls -l</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">-rw-r--r--@ 1 nicholasdunbar staff 2245 Nov 15 13:42 dev2.properties</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">-rw-r--r-- 1 nicholasdunbar staff 369 Nov 13 18:39 crontab</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> cat dev2.properties</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">crontabPath=/some/dir/</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> cat crontab</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">00 00 * * * echo '25 hour record written by the crontab:' > @cronPath@crontab.log;</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">If we want to replace <span style="color: rgb(0, 145, 0);">@cronPath@</span> in the file crontab with '<span style="color: rgb(0, 145, 0);">/some/dir/</span>' from dev2.properties we would use the following ANT task:</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><script src="https://gist.github.com/nicholasdunbar/aa6770c5eb3c29b1e781.js"></script></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">So we have generated a file called crontabTest.txt and replaced the tokens with our "variable" as we can see in the following:</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> cat crontabText.txt</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">00 00 * * * echo '25 hour record written by the crontab:' > /some/dir/crontab.log;</span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><b><span style="font-family: Arial;"><span style="font-size: 18px;">Example 2 using the property task to replace a token with a variable:</span></span></b></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><script src="https://gist.github.com/nicholasdunbar/cbc5bf3f504163ee96aa.js"></script></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">So if we were to look in the file crontabTest.txt we would see the following:</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><span style="color: rgb(0, 145, 0);">prompt> cat crontabText.txt</span></div>
<div style="font-family: monospace; font-weight: normal;"><span style="color: rgb(0, 145, 0);"><span style="font-size: 12px;">00 00 * * * echo '25 hour record written by the crontab:' > /some/dir/crontab.log;</span></span></div>
<div style="font-family:monospace; font-size:13px; font-weight:normal"><br/></div>
<div style="font-weight: normal;"><span style="font-size: 18px;"><span style="font-family: Arial;">As you can see the token has successfully been replaced. Thank you for reading. Please, leave a comment if this helped you or if you have a question.</span></span></div>
Parsing unevenly spaced columns from text in PHPhttps://boulderappsco.postach.io/post/parsing-unevenly-spaced-columns-from-text-in-php2017-06-23T20:39:52.599000Z2014-08-23T23:15:00ZNicholas Dunbar<div>If you want to parse unevenly or jaggedly spaced columns out of a text file in PHP, below are two functions that will help you do it. </div>
<div><br/></div>
<div>Let's say that you have the following text output:</div>
<div><br/></div>
<div><br clear="none"/>
col1 col2 col3 <br clear="none"/>
==== ==== ==== <br clear="none"/>
1 a b c d e 103 14 as d9 <br clear="none"/>
2 a 103 14 as d9 <br clear="none"/>
3 a 103 14 as d9<br/></div>
<div><br/></div>
<div><br/></div>
<div> And we want to transform the data into the following:</div>
<div><br/></div>
<div><br clear="none"/>
<table border="1" width="80%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top">col1</td>
<td valign="top">col2</td>
<td valign="top">col3</td>
</tr>
<tr>
<td valign="top">1 a b c d e<br/></td>
<td valign="top">103</td>
<td valign="top">14 as d9<br/></td>
</tr>
<tr>
<td valign="top">2 a<br/></td>
<td valign="top">103</td>
<td valign="top">14 as d9<br/></td>
</tr>
<tr>
<td valign="top">3 a<br/></td>
<td valign="top">103</td>
<td valign="top">14 as d9<br/></td>
</tr>
</tbody>
</table>
<br/></div>
<div>We need an algorithm that detects large spaces and small spaces and makes a weighted estimate as to which column the data belongs. Perhaps you are parsing columns from a data source that changes frequently the amount of spaces that are between each column and that breaks your parser. This is a more robust solution than just using the positions of the column headers to parse out the data in the columns. This algorithm deals with a small degree of noise or error that may show up in the text you are parsing. </div>
<div><br/></div>
<div><br/></div>
<div>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><br/>
<br/></td>
<td>
<div><script src="https://gist.github.com/nicholasdunbar/9c5388d243bd4dff48f2.js"></script> </div>
</td>
</tr>
</tbody>
</table>
</div>
<div><br/></div>
<div>Here is a more efficient algorithm you can use if your columns have the same positions as the headers.<br/></div>
<div><br/></div>
<div>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><br/>
<br/></td>
<td>
<div><script src="https://gist.github.com/nicholasdunbar/af73c436fbb0810fd95e.js"></script> </div>
</td>
</tr>
</tbody>
</table>
<br clear="none"/>
<br clear="none"/>
<br/></div>
Will a true artificial intelligence have a soul?https://boulderappsco.postach.io/post/will-a-true-artificial-intelligence-have-a-soul2017-06-23T22:17:20.345000Z2014-06-04T19:42:23ZNicholas Dunbar<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;">Since the movie "Transcendence" came out in 2014 there has been a lot of talk about the implication of loading consciousness on computers. </span></div></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><br /></div></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;">As the movie illustrates, </span><span style="font-size: 18px;">this can be a pretty controversial subject. W</span><span style="font-size: 18px;">hen it comes to talking about the soul, consciousness and artificial intelligence, people mostly fall in to two camps. The spiritual camp believes there is something mystical about consciousness, that it comes from the soul and they don't think a computer could ever be conscious.</span> <span style="font-size: 18px;">The other camp has an unbridled faith in the computer or Turing Machine (the mathematical construct on which all computers have been built) and it's ability to simulate everything in the world. Indeed if something possesses cause and effect relationships then it can be simulated on a Turing Machine. The spiritual people say, "but what about free will? A Turing Machine is deterministic." to which the other camp cackles at them evilly, like hyenas and says "free will is an illusion</span><span style="font-size: 18px;">." </span></div></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><i>‟One group is saddened by the prospect of computer consciousness, the other is excited at what could be achieved. </i></span></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><br /></span></div></div>
<div style="font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; text-align: start; text-indent: 0px; background-color: rgb(255, 255, 255);"><div><font color="#222222" size="4">So how to define the soul? As a thought experiment let us not define the soul here but instead use the existence of consciousness as a test for the existence of the soul. The problem is that here is no known test for consciousness and we have never created a computer that even seemed to posses consciousness, so we have had no need to dedicate real resources to testing for it. This is how I am relating the philosophical ideas of AI to the existence of the soul. The idea of a soul is so nebulous and fraught with different opinions that I think the only way to go forward from here is to only use an idea that everyone can agree upon. That being, an unconscious entity definitely doesn't have a soul. That said, we shall move on to talking about the difficulties in creating a test for consciousness in a machine and the potential barriers in creating consciousness.</font></div></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><br /></span></div></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"> Let us start with the question "what is consciousness?" This article has to do very much with the subject called "Philosophy of Mind." One of my early introductions to this subject happened between the ages of 10 and 14 when I watched an episode of "Star Trek: The Next Generation" called the "The Measure of The Man" in which the character Data (an android) is put on trial as to whether he is property or a sentient being with all the rights of a human. A scientist in the show wants to disassemble Data, for analysis, against his "will." There is a critical moment in the show when this scientist proposes dumping Data's core memory which was obtained by experience and then restoring his memory by upload, Data replies "these are mere facts..(that you will restore, but)...the substance, the flavor of the moment could be lost" (watch the youtube video for the quote and episode overview <a href="https://www.youtube.com/watch?v=8whNAwuTY90#t=97" target="_blank" style="color: rgb(17, 85, 204);">https://www.youtube.com/watch?v=8whNAwuTY90#t=97</a> if you have not seen it, you can watch it on Netflix, it's a rare moment of thoughtful television) That one quote has stuck with me through the years. "The substance of the moment" what is that? Is that real or just a romantic notion? Could what Data is describing be consciousness? After all, isn't consciousness a feeling embodied in your experience? </span><span style="font-size: 18px;">Can a machine have such an experience?</span><span style="color: rgb(34, 34, 34); font-size: 18px;"> </span></div></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><b>Enter the Chinese Room</b></span></div>
<div style="color: rgb(34, 34, 34); font-style: normal; font-variant: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><b><br /></b></span></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br /></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><iframe width="640" height="390" src="//www.youtube.com/embed/TryOC83PH1g" frameborder="0" allowfullscreen></iframe><br /></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br /></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br /></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br /></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"> There is a thought experiment called The Chinese Room. (If you are not familiar with it, watch the one minute Youtube video to check it out <a href="https://www.youtube.com/watch?v=TryOC83PH1g" target="_blank" style="color: rgb(17, 85, 204);">https://www.youtube.com/watch?v=TryOC83PH1g</a>) The room appears as though it contains a conscious Chinese speaker to someone on the exterior, but on the interior it clearly does not speak Chinese and is not conscious. There is no "substance of the moment?" in this scenario. You might say, "Is this really a fair comparison of what we are talking about? We are talking about a massive set of synapses that are interconnected in diverse ways." Fair enough. Lets extend the thought expirement. What if the book of instructions </span><span style="font-size: 18px;">in the Chinese Room was changed to be instructions for how a synapse works and we created billions of such rooms in a megalopolis large enough that it had as many rooms as our brain has synapses? Then we interconnected all the rooms with phones in the way the synapses in your brain are connected. If we believe that a Turing Machine can simulate the brain system then we can make the leap of faith that this Synapse Simulating Mega City can also do the job, because it is effectively a series of networked Turing Machines (aka computers, albeit pretty inefficient ones). Just as a person asked the Chinese room questions, by passing a note under the door, a person asks the city questions at the gate. Those questions are sent into the city's network of rooms for processing, resulting in a response that is indistinguishable from a real person as before, only this time … is it conscious? Does it really "understand" Chinese? How can a network of desks and rooms be conscious? Then again how can a series of synapses made of, what is essentially dirt, be conscious? Clearly the rooms with desks and the synapses are different, despite them both, theoretically, yielding the same result. Does this difference matter, since the result is the same or</span><span style="font-size: 18px;"> would the Synapse Simulating Mega City experience it's self thinking the way a brain does? </span><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 18px;">That is to say, if you use simulated neurons vs. real neurons would you get a different type of experience emerging from the network?</span> <span style="font-size: 18px;">Can we really say that two people talking on the phone, simulating two wired synapses, is the same as two real </span><span style="font-size: 18px;">synapses</span><span style="font-size: 18px;"> sending electrical pulses to each other? It is of course mathematically the same, but it is not physically the same. Does this physical difference matter?</span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: center;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><img src="https://cdn-images.postach.io/41ca280d-1167-4de0-8596-7b14ff3f1b68/c40e527a-d0da-4f2a-afc6-c82b9bbb532c/310ca339-c8a0-41a4-8163-d6f57a2b92f0.jpg" style="height: auto;"/><br /></span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><br /></span></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-family: arial, sans-serif; font-size: 18px;"> </span><span style="font-size: 18px;">There are two results of a mind like computer system, user facing output and its internal state. We can measure the user facing output by plugging it into a voice module, and talking to it. We have some sense whether or not, we have created an intelligent system, but we can't measure the computer's internal experience, because we don't know where the awareness is plugged into the system. That could be because the awareness is inherent in the network. It is not tacked on the side like a separate and easily identifiable module. This is what we mean by the consciousness is an emergent property of the network. The consciousness that experiences the output of the network exists <u>in</u> every node of the network, it's not "plugged" at one point into anything at all. The perceiving process is that same thing as that which also does the thinking.</span></div></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><i>‟</i></span><span style="font-size: 24px;"><i>What if consciousness is the property that emerges from the <u>manner</u> in which something is processed rather than being the end result of some process? </i></span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><br /></span></div></div>
<div style="text-align: left; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; text-indent: 0px; background-color: rgb(255, 255, 255);"><div><font color="#222222" size="4">If that were true, then this might describe why, on an intuitive level, it seems hard to believe that the Mega City is conscious, because it is </font><u style="color: rgb(34, 34, 34); font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">simulating</u><font color="#222222" size="4"> neurons, but the way in which it operates at the core is totally different from a real mind. In this case the physical architecture of the system may matter greatly even though the symbolic architecture is the same. Let us look at what is different about the physical architecture. We can describe many ways a computer processor is different as a result of its architecture. A neuron operates much more efficiently than a simulated one. If we program the cause and effect relationships of a brain's synapses we are only simulating the architecture, we are not actually running the processes as they are wired in the brain. It's not the same thing for two people to talk to each other like synapses in the same way it is not equal to simulate two synapses. It is a virtualization of the brain system, much like the virtualization of a processor. For every step a brain takes the computer might have to take one thousand to match it. So even though you get the output that looks intelligent, the computer's "experience" may be radically different. Because that "experience" is made up of the way in which the system processes. That is to say, if it even has an "experience" at all. </font></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><br /></span></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;"><span style="font-size: medium;"><span style="font-size: 18px;"> We assume that consciousness is required for intelligence, but t</span><span style="font-size: 18px;">he Chinese Room </span><span style="font-size: 18px;">exhibits intelligence by </span><span style="font-size: 18px;">simulating a Chinese speaker, while it may experience nothing. It maybe, that there is an awareness which watches and an intelligence that processes, which happens in separate areas of the brain.</span> <span style="font-size: 18px;">But I am theorizing something completely different. I do not mean to say that consciousness is just an auxiliary passive process, like the way a spectator can watch a game, but has no influence on the game's outcome. I mean it is integral to the way we <u>experience</u> being intelligent, but it is not necessary to <u>be</u> intelligent.</span><span style="font-size: 18px;"> So if that is the case, what other examples do we know of where we have intelligence without a consciousness? Processes that are different, but lead to the same out come are all around us. Can an engine be cast or milled and still be mostly the same? Can a house be assembled in the same configuration through a different set of steps? Yes of course, so perhaps intelligence may be able to be arrived at through many different paths. Some of those paths may not include consciousness. </span></span></span></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><i>‟</i></span><span style="font-size: 24px;"><i>In the virtualized system there may be no watcher present. It could be a system that resembled a living sentient entity in every way and yet from the inside it would be dead and soulless.</i></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-style: normal; font-size: 18px;"> This is all highly theoretical, and relies on a large set of underlying assumptions but it is worth pondering. These subjects can lead us in many different directions, but the main purpose of this article is to get you to consider the three following things:</span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-style: normal; font-size: 18px;">1.) Experience is perceived through the process of cognition and thus the way you do the processing could count greatly. </span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-style: normal; font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-style: normal; font-size: 18px;">2.) If an implementation of a model is mathematically the same as its real counter part, but physically different, it could have different emergent properties as a result. </span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-style: normal; font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-size: 18px;">3.) Consciousness may not be a requisite for intelligence and so, because of the possibility of 1 and 2, a Turing Machine simulated brain might possess intelligence without consciousness. </span></div>
<div><span style="font-size: 18px;"><br /></span></div>
<div><span style="font-size: 18px;">You can see where we are going here. You can't develop a test for consciousness and so you can't iterate the software design achieving more or less consciousness. Without a test you have no goal to track toward. Further more you could be tricked into it being conscious by confusing consciousness with intelligence. </span></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><i><br /></i></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 24px;"><i>‟</i></span><span style="font-size: 24px;"><i>A brain has no clear output except at the motor control level and even then it feeds back in on its self constantly, turning output into input. </i></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div><span style="font-style: normal; font-size: 18px;">This changes the way you have to think about the system. Since the network is conscious the output is perceived internally through the network as well. </span><span style="font-size: 18px;">You can't put a nice little bow around each <u>unit</u> of cause and effect.</span><span style="color: rgb(34, 34, 34); font-size: 18px;"> </span><span style="font-size: 18px;">This is why many scientists call consciousness a "strong emergent property", because we don't understand how it comes to be and so we can't eliminate how important the physical architecture of the system will be. For instance, if the emergent property comes from the physical networking then the Mega City couldn't be conscious, because phones are different then synaptic electrical pulses. Or what if it comes from a lower level like inside the synapses? </span></div></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"> For believers that consciousness comes from the soul and the soul is something that only God can create, I'm sorry to inform you that if indeed consciousness couldn't be simulated on a Turing Machine, for the reasons above, this does not mean that we have proven the soul can only be created by nature. Humans could potentially still engineer a consciousness by inventing some sort of synthetic synapse and wire the system together the same way as a human brain. Amazingly, </span><span style="font-size: 18px;">Gene Rodenbery, the creator of Star Trek, had a sense about this (or Isaac Asimov, since he wrote the Positronic Man upon which the character Data was based). </span><span style="font-size: 18px;">The fictitious character Data has a Positronic brain which is exactly what I am describing. Data's brain works in tandem with processors so Data can do super human calculations and other cool stuff to make the show interesting, but without his synthetic brain being structured the way a real brain is, he would not be conscious. Gene Rodenbery might have been on to something, much more profound than he realized. As the field of brain research and AI continues to develop we will first have to get to the point where we implement an intelligent system before we can even start to seriously consider the ideas I put forth in this article. But for the moment it is fun to ponder and we bask in awe at the mystery of the mind, which I think makes life all that more interesting. </span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left; color: rgb(34, 34, 34); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;">Preview of the Star Trek episode mentioned above:</span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><iframe width="640" height="390" src="//www.youtube.com/embed/8whNAwuTY90" frameborder="0" allowfullscreen></iframe><br /></span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="text-align: left;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="font-size: 18px;"><br /></span></div>
<div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.666666984558105px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br /></div>
Don't insert when maximum is reachedhttps://boulderappsco.postach.io/post/dont-insert-when-maximum-is-reached2017-06-23T20:39:55.232000Z2014-05-09T19:21:08ZNicholas Dunbar<div><span style="font-size: 24px;">How to control if a record is inserted based on a condition?</span></div>
<div><span style="font-size: 24px;">Don't insert a record if certain conditions are not met.</span><br/><br/></div>
<div><br/></div>
There is a way of using pure MySQL to stop inserting records when a certain number of them has been reached. Let us say that you have the following tables:<br/><br/>
<div><br/></div>
<div>Say you have an item table of item types and a limited number of each items like this:<br/><br/></div>
<div><br/></div>
<div>item_types</div>
<div>
<table border="1" width="80%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top">item_id</td>
<td valign="top">item_name</td>
<td valign="top">limit</td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">car</td>
<td valign="top">3</td>
</tr>
</tbody>
</table>
<br/>
<br/></div>
<div>items</div>
<div>
<table border="1" width="80%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top">item_type</td>
<td valign="top">customer</td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">bob</td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">gerard</td>
</tr>
</tbody>
</table>
<br/></div>
<div><br/></div>
<div>If you want to limit the amount of records of a certain item_type inserted into the table items then you can use the following technique:<br/><br/><br/></div>
<div>
<div><br/></div>
<div>The secret is to build off the following statement:<br/><br/></div>
<div><br/></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">INSERT INTO `items` (`item_type`,`customer`) VALUES(1, 'bob');</span><br/></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"><br/></span></div>
<div>This is a good start. It will insert a record with the correct data, but the statement above will do the insert into items without checking to first see if we have too many items in there already. So we replace the VALUES statement with a SELECT statement containing only two fields (item_id and customer), we set the select to return the id (1) and a customers name like bob by hard coding the result.<br/><br/></div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">INSERT INTO `items` (`item_type`,`customer`)</font>
<div><font face="'Andale Mono'" color="#008F28">SELECT 1, 'bob' FROM `item_types` WHERE `item_types`.`item_id`=1;</font><br/><br/></div>
<div><br/></div>
<div>But we still are not limiting the insert by the number of this type of item (item_id 1). So we add an additional clause to the conditional statement<b>:</b><br/><br/></div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">INSERT INTO `items` (`item_type`,`customer`)</font>
<div><font face="'Andale Mono'" color="#008F28">SELECT 1, 'bob' FROM `item_types` WHERE `item_types`.`item_id`=1 AND `item_types`.`limit` > (SELECT COUNT(`item_type`) FROM `items` WHERE `items`.`item_type`=1 GROUP BY `item_type`);</font><br/><br/></div>
</div>
<div><br/></div>
<div><br/></div>
<div>
<div>This looks pretty good, but it won't insert a record if there is not at least one record of that type in the `items` table, so we have to add an additional clause to make sure it works if the table is empty. <b>Here is the final solution:</b><br/><br/></div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">INSERT INTO `items` (`item_type`,`customer`)</font>
<div><font face="'Andale Mono'" color="#008F28">SELECT 1, 'bob' FROM `item_types` WHERE `item_types`.`item_id`=1 AND `item_types`.`limit` > (SELECT COUNT(`item_type`) FROM `items` WHERE `items`.`item_type`=1 GROUP BY `item_type`) OR NOT EXISTS(SELECT 1 FROM </font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">`items`</span><font face="'Andale Mono'" color="#008F28"> WHERE item_type=1);</font><br/><br/></div>
</div>
</div>
<div><br/></div>
<div>Now we are making sure that the current number of items with the item_type 1 is under the limit listed for each item in item_types. Here is the PHP code to do it:<br/><br/></div>
<div><br/></div>
<div><font face="'Andale Mono'" color="#008F28">$customerName='george';</font></div>
<div><font face="'Andale Mono'" color="#008F28">$itemID=1;</font></div>
<div><font face="'Andale Mono'" color="#008F28"><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">$dbHost='localhost';</font></div>
<div><font face="'Andale Mono'" color="#008F28">$dbUser='someuser';</font></div>
<div><font face="'Andale Mono'" color="#008F28">$dbPass='somepass';</font></div>
<div><font face="'Andale Mono'" color="#008F28"><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">try {</font>
<div><font face="'Andale Mono'" color="#008F28"> $mysqli = new mysqli</font></div>
<div><font face="'Andale Mono'" color="#008F28"> (</font></div>
<div><font face="'Andale Mono'" color="#008F28"> $dbHost,</font></div>
<div><font face="'Andale Mono'" color="#008F28"> $dbUser,</font></div>
<div><font face="'Andale Mono'" color="#008F28"> $dbPass</font></div>
<div><font face="'Andale Mono'" color="#008F28"> );</font></div>
<div><font face="'Andale Mono'" color="#008F28">} catch (Exception $e){</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">echo $e->getMessage();</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">exit();</font></div>
<div><font face="'Andale Mono'" color="#008F28">}</font></div>
<div><font face="'Andale Mono'" color="#008F28"><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">if ($mysqli->connect_errno)</font></div>
<div><font face="'Andale Mono'" color="#008F28">{</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error."\n";</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">exit();</font></div>
<div><font face="'Andale Mono'" color="#008F28">}</font></div>
</div>
<div><font face="'Andale Mono'" color="#008F28"><br/></font></div>
<div><font face="'Andale Mono'" color="#008F28">//save the log information</font></div>
<div><font face="'Andale Mono'" color="#008F28">$</font><font face="'Andale Mono'" color="#008F28">safeC</font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">ustomerName=mysql_real_escape_string($</span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">customerName);</span></div>
<div><font face="'Andale Mono'" color="#008F28">$insertSQL =</font></div>
<div><font face="'Andale Mono'" color="#008F28">"</font></div>
<div><font face="'Andale Mono'" color="#008F28">INSERT INTO `items` (`item_type`,`customer`)</font></div>
<div><font face="'Andale Mono'" color="#008F28">SELECT </font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">{$itemID}</span><font face="'Andale Mono'" color="#008F28">, '{$safeC</font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">ustomerName</span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">}' FROM `item_types` WHERE `item_types`.`item_id`={$itemID} AND `item_types`.`limit` > (SELECT COUNT(`item_type`) FROM `items` WHERE `items`.`item_type`={$itemID} GROUP BY `item_type`) OR </span><font face="'Andale Mono'" color="#008F28">NOT EXISTS(SELECT 1 FROM </font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">`items`</span><font face="'Andale Mono'" color="#008F28"> WHERE item_type=</font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">{$itemID}</span><font face="'Andale Mono'" color="#008F28">)</font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">;</span></div>
<div><font face="'Andale Mono'" color="#008F28">";</font></div>
<div><font face="'Andale Mono'" color="#008F28">try {</font></div>
<div><font face="'Andale Mono'" color="#008F28"> $result = $mysqli->query($insertSQL);</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">if (!</font><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">$result</span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';">) {</span></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">echo "error";</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">exit();</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">} else {</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">echo "success";</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">exit();</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">}</font></div>
<div><font face="'Andale Mono'" color="#008F28">} catch(Exception $e){</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">echo "invalid";</font></div>
<div><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><span style="color: rgb(0, 143, 40); font-family: 'Andale Mono';"> </span><font face="'Andale Mono'" color="#008F28">exit();</font></div>
<div><font face="'Andale Mono'" color="#008F28">}</font></div>
</div>
</div>
MySQL CONCAT limitationhttps://boulderappsco.postach.io/post/mysql-concat-limitation2017-06-23T20:40:01.155000Z2014-04-12T01:38:57ZNicholas Dunbar<div><div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">So you're trying to concat two large strings and it keeps resulting in a truncated or empty string?</div></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">The problem may be that <font color="#008F28">CONCAT</font> can only result in a string of length 1024 bytes long. Worse is there is no setting in MySQL that allows you to increate the limits of <font color="#008F28">CONCAT</font>. However there is another way. Meet <font color="#008F28">GROUP_CONCAT</font> which is made for concatenating a list of rows into one string. We can use this function as a way of doing concatenation with out the 1024 limit of <font color="#008F28">CONCAT</font>. <font color="#008F28">GROUP_CONCAT</font> has a default setting of 1024 in MySQL but where it is different from <font color="#008F28">CONCAT</font> is that there is a setting that allows us to change this limit setting called group_concat_max_len. Whatever size you set this variable to, will allow <font color="#008F28">GROUP_CONCAT</font> to return a resulting value up to that length. The maximum size of group_concat_max_len is defined by another setting called max_allowed_packet. The maximum size of max_allowed_packet depends on if you are running a 64 bit or 32 bit system. On a 32 bit system it is 4 GB.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">So say you are using <font color="#008F28">CONCAT</font> in the following way:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">UPDATE some_table</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">SET some_field=CONCAT(some_field,'super long string to append to the end of the data in some_field')</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">WHERE some_criteria_field = 'match on this string';</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">And in this example some_field would change from this:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">
<table border="1" width="80%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top"> ID </td>
<td valign="top"> some_criteria_field </td>
<td valign="top"> some_field </td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">match on this string<br/></td>
<td valign="top">12345;</td>
</tr>
</tbody>
</table>
<br/>
<br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">to this:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/>
<table border="1" width="80%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top"> ID </td>
<td valign="top"> some_criteria_field </td>
<td valign="top"> some_field </td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">match on this string<br/></td>
<td valign="top">12345;super long string to append to the end of the data in some_field<br/>
<br/></td>
</tr>
</tbody>
</table>
<br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">But now lets say the data you are trying to concatenate on the end of some_field's original contents is getting truncated or just plain setting some_field to null/empty, because it is too long. That wasn't the case of course in the above example because the concatenated string is so short. Lets say the string you are trying to add to the end of '12345;' is 200 KB long. So in this case we need to switch from <font color="#008F28">CONCAT</font> to <font color="#008F28">GROUP_CONCAT</font> and increase the <font color="#008F28">GROUP_CONCAT</font> result limit from 1024 bytes to the maximum allowed size, to get around the limitation. </div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">The following is the way the query will have to look to alieviate the problems with <font color="#008F28">CONCAT</font> above (we will use the data from above so you can see where your longer strings would go):</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">SET @@session.group_concat_max_len = @@global.max_allowed_packet;</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">UPDATE some_table SET some_table.some_field=(</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> SELECT GROUP_CONCAT( queue.append_to_end SEPARATOR '') as new_some_field</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> FROM</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> (</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> SELECT append_to_end FROM some_table WHERE some_criteria_field = 'match on this string'</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> UNION</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> SELECT 'super long string to append to the end of the data in some_field' as append_to_end</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28"> ) as queue</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">) WHERE some_criteria_field = 'match on this string'</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">The key is the following line from above:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">SET @@session.group_concat_max_len = @@global.max_allowed_packet;</font></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">This will up the limit of <font color="#008F28">GROUP_CONCAT</font> for the duration of the session which means when you close the connection it returns to the default for the other queries.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">Sometimes this temporary increase is not enough. If you are doing concatenations that result in strings greater than the system setting @@global.max_allowed_packet which is usually 1MB then you'll need to have special DB permissions on the system to run a query like the following:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><font color="#008F28">SET GLOBAL max_allowed_packet=1073741824</font> </div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">1073741824 is just 1 GB it could be whatever size you need in bytes. </div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">You can also make the change in your config file on the server. Go to your my.ini or my.cnf file (depending on your MySQL version) and find the following line and change it to what we have bellow:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">max_allowed_packet = 1025M</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">I'm afraid that without special permissions on your MySQL server you will not be able to concat strings with a resulting length longer than max_allowed_packets which again is usually set to a 1 MB default. In this case you will need to upgrade from shared hosting to hosting where you have control over things like this.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">Finally keep in mind that memory concerns in your backend programming language that are running these queries can be a concern. For instance if you are working with PHP then, go to your php.ini file and find the following:</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">memory_limit=</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><br/></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">Then set it to something appropriate for the amount of data you are using. </div>
Loading a different JavaScript library based on the browser.https://boulderappsco.postach.io/post/loading-a-different-javascript-library-based-on-the-browser2017-06-23T20:39:55.047000Z2014-02-27T00:45:10ZNicholas Dunbar<div>
This article could be used for any libraries, but we are going to talk about a specific case study using jQuery as an example. First you should know that this is frowned upon in the development community and you should use modernizer.js to do feature detections to solve individual problems. Never the less we are going to go into how to do this shrewd practice.
</div>
<div><br/></div>
<div>JQuery has moved from 1.x to 2.x. The 1.x library supports IE6 to IE8. At the time of the writing of this article IE8 represents less than 4 percent of the market. But some of you might want to upgrade your jQuery library to 2.x while keeping the old support for IE8. After all you spent all that time making your site compatible with IE8 all those years ago. So you will need to load jQuery 2.x when it is IE9+ and jQuery 1.x when it is less than or equal to IE8. </div>
<div><br/></div>
<div>First in we need to detect if we are using IE8 or less using IE browser sniffing:</div>
<div><br/></div>
<div><script src="https://gist.github.com/nicholasdunbar/9242264.js"></script></div>
<div><br/></div>
<div>We initialize the <span style="font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(248, 248, 255); float: none;"><font color="#009100">isIE8OrLess</font></span> variable to false in the script tag ID 'set-ie-var'. Then if the user agent browser is IE8 or less the script tag 'init-ie-var' will set <span style="font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19.5px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(248, 248, 255);"><font color="#009100">isIE8OrLess</font></span> to true. At the bottom of the code snippet above there is the script tag with the ID 'use-ie-var' which is where we will create our JavaScript loader code. But first we need some code to do the loading of the external JavaScripts. </div>
<div><br/></div>
<div>Lets use this code snippet for loading external JavaScript files:</div>
<div><br/></div>
<div><script src="https://gist.github.com/nicholasdunbar/9242196.js"></script></div>
<div><br/></div>
<div>Source:</div>
<div><a href="http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/">http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/</a><br/></div>
<div><br/></div>
<div>The above snippet can be put in the script tag with the ID 'set-ie-var' we will use the function loadScript later on in the script tag with the ID 'use-ie-var' at the bottom of the body tag. </div>
<div><br/></div>
<div>Now we need to edit the script at the bottom of the body tag with the ID 'use-ie-var' to load each library and its dependancies:</div>
<div><br/></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">var scriptList = new Array();</font>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">var onLoadCallback = function(){</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> //load the next script if there are any</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> if (scriptList.length){</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> loadScript(scriptList.shift(), onLoadCallback);</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> }</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">};</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> </font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">if (isIE8OrLess){</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> //load a version of jQuery 1.x</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> scriptList.push("http://code.jquery.com/jquery-1.11.0.min.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> scriptList.push("https://raw.github.com/gdsmith/jquery.easing/master/jquery.easing.1.1.1.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">} else {</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> //load a version of jQuery 2.x</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> scriptList.push("http://code.jquery.com/jquery-2.0.2.min.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> scriptList.push("https://raw.github.com/gdsmith/jquery.easing/master/jquery.easing.1.3.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">}<br/></font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">//custom cross compatible scripts that use </font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">//the same jQuery API that is the same </font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">//on 1.x and 2.x</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">scriptList.push("./js/myLib.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">scriptList.push("./js/main.js");</font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"> </font></div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100">onLoadCallback();</font></div>
</div>
<div><font face="'Andale Mono'" style="font-size: 14px;" color="#009100"><br/></font></div>
<div><font style="font-size: 14px;">This method could be used to load dojo code or any other library that may have undergone a similar upgrade. Plus it is a very simple way to load code and its dependancies without using some feature loaded library like RequiresJS. </font></div>
Title case function in PHP based on grammatical rules for capitalizing the words in a titlehttps://boulderappsco.postach.io/post/title-case-function-in-php-based-on-grammatical-rules-for-capitalizing-the-words-in-a-title2017-06-23T20:40:04.345000Z2014-02-10T05:28:00ZNicholas Dunbar<div>
<p><span style="font-size: 14pt;">Creating a Title Case Function with PHP Based on Grammatical Rules.</span></p>
<p>The common way that programmers implement title case is the most simple way, they capitalize the first letter of every word. But what about titles like the title above where the "on" and "with" are not capitalized? This is called "Headline Case." There are many different articles on the web about using PHP to title case a string. Most don<span style="-evernote-last-insertion-point:true;"/>'t try to encompass the more complicated grammatical rules that govern title case. I have written a function that follows most of the grammatical rules of "Headline Case" If you have titles where you would have exceptions to these rules, I have provided the tags < no_parse > as a feature of the function below. In the case were you want to take over formatting and override the parser you can uses these tags to exempt it from the title casing parser. This way 90% of all situations are covered after which you only have to manually tweak a few entries. This takes so much of the grunt work out of data entry. In any case the tags are provided for your convenience. You may notice that the New York Times is inconstant on which style rules they use for title case (at least it was at the time of this writing). If they used an algorithm like mine there would be automatic standardization. I suggest you use the following function to make sure your content titles are standardized and let your authors who are the experts in writing opt out of the title case rules with the < no_parse > tags at their discretion. I may have missed special cases. I encourage you to use your Github account to fork the code below to improve it. That is, should you find your self more grammatically knowledgeable than I.<br clear="none"/>
<br clear="none"/>
<br clear="none"/></p>
<p><span><script src="https://gist.github.com/nicholasdunbar/8216161.js"></script></span></p>
</div>
<div><br clear="none"/></div>
Javascript private and public members | Dynamic name spacinghttps://boulderappsco.postach.io/post/javascript-private-and-public-members-dynamic-name-spacing2017-06-23T20:39:54.436000Z2014-02-10T03:10:00ZNicholas Dunbar<div>The following is how to scope an object (called an object literal) with private and public members:</div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">myApp</span> is the class<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">id</span> is private</div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">next</span> and <span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">reset</span> are public functions<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">//create class</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">var myApp = {};</span></div>
<div><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">(function(context) {</span></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> //private member</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> var id = 0;</span></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"><br clear="none"/></span></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> //public member function</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> context.next = function() {</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> return id++; </span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> };</span></div>
<div><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> //public member function</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> context.reset = function() {</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> id = 0; </span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> }</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">})(myApp);</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>Example:</div>
<div><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">window.console && console.log(</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> myApp.next(),</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> myApp.next(),</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> myApp.reset(),</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> myApp.next()</span><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">,</span></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"> myApp.id</span><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">)</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: helvetica,arial,sans-serif;">Result in console:</span></div>
<div><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><span style="color: rgb(0, 0, 0);">0, 1, undefined, 0, undefined </span> </span><br clear="none"/>
<span style="font-size: 11px;"><br/></span></div>
Installing xdebug in XAMPP 1.8.3 on Linuxhttps://boulderappsco.postach.io/post/installing-xdebug-in-xampp-1-8-3-on-linux2017-06-23T20:40:08.749000Z2014-02-10T02:10:00ZNicholas Dunbar<div>If you have installed XAMPP 1.8.3-0 for Linux and you want to install x-debug here is how to do it using PECL.</div>
<div><br clear="none"/></div>
<div>1.) Check to make sure /bin is in your path</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">echo $PATH;</span></div>
<div><br clear="none"/></div>
<div>if :/bin: is in the path then bin is in your path. This makes sure that when you create a symbolic link in /bin it can be called from any directory at the prompt.</div>
<div><br clear="none"/></div>
<div>If it is not in your path you may have your bin directory configured to a different location.</div>
<div><br clear="none"/></div>
<div>2.) Create a symbolic link to phpize in /bin</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">cd /bin</span></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">sudo ln -s /opt/lampp/bin/phpize-5</span><span style="font-family: courier new,courier; color: #008000;">.5.1 phpize</span></div>
<div><br clear="none"/></div>
<div>3.) Test phpize</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="font-family: courier new,courier; color: #008000;">cd /</span></div>
<div style="margin-left: 30px;"><span style="font-family: courier new,courier; color: #008000;">sudo phpize -v</span></div>
<div><br clear="none"/></div>
<div>you should get something like this:</div>
<div><br clear="none"/></div>
<div>Configuring for:<br clear="none"/>
PHP Api Version: 20121113<br clear="none"/>
Zend Module Api No: 20121212<br clear="none"/>
Zend Extension Api No: 22012121</div>
<div><br clear="none"/></div>
<div>4.) Install autoconfig</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">sudo yum install autoconf</span></div>
<div><br clear="none"/></div>
<div>5.) Find php tools for building extensions</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">yum search php-dev</span><br clear="none"/>
<br clear="none"/></div>
<div>php-devel.x86_64 : Files needed for building PHP extensions<br clear="none"/>
<br clear="none"/></div>
<div>if this does not find an entry with "Files needed for building PHP extensions" then you need to do some web searches to figure out how to install the appropriate package.</div>
<div><br clear="none"/></div>
<div>6.) Install php tools for building extensions</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">yum install php-devel.x86_64</span></div>
<div><br clear="none"/></div>
<div>5.) Install gcc compiler</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">sudo yum groupinstall "Development Tools"</span></div>
<div><br clear="none"/></div>
<div>6.) Install x-debug using pecl</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">cd /opt/lampp</span></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">pecl install xdebug</span></div>
<div><br clear="none"/></div>
<div>7.) Edit php.ini</div>
<div><br clear="none"/></div>
<div style="margin-left: 30px;"><span style="color: #008000; font-family: courier new,courier;">sudo vi "$(cd /opt/lampp/; sudo find `pwd` -name php.ini;)"</span></div>
<div><br clear="none"/></div>
<div>This finds the path to php.ini file under /opt/lampp and then opens it in the text editor vi, if your php.ini file is not under /opt/lamp then change /opt/lamp to the location of xampp where you have it installed. If you're confused by Linux voodoo then just find the php.ini file your self go to that directory and type in <span style="color: rgb(0, 145, 0);">sudo vi php.ini</span> .</div>
<div><br/></div>
<div>8.) In the text editor vi that has opened php.ini edit the configuration</div>
<div><br clear="none"/></div>
<div> a.) Find extension section by typing the following:</div>
<div><br clear="none"/></div>
<div style="margin-left: 60px;"><span style="color: #008000; font-family: courier new,courier;">/zend_extension</span></div>
<div style="margin-left: 60px;"><span style="color: #008000; font-family: courier new,courier;"> </span></div>
<div style="margin-left: 60px;"><span style="color: #008000; font-family: courier new,courier;">i</span></div>
<div style="margin-left: 60px;"><span style="color: #008000; font-family: courier new,courier;"><br clear="none"/></span></div>
<div> Note: "/" is for search for string and "i" is for insert which puts you into editing mode.</div>
<div><br clear="none"/></div>
<div> b.) Add in line at the bottom of the extension section</div>
<div><br clear="none"/></div>
<div style="margin-left: 60px;"><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">;[zend extensions]</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">zend_extension="/opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.remote_enable=1</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.remote_handler=dbgp</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.remote_host=localhost</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.remote_port=9000</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.show_local_vars=1</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xdebug.remote_log=/opt/lampp/logs/xdebug.log</span></div>
<div><br clear="none"/></div>
<div> Remove tabs (\t) at the front when you copy and paste this section in. Other words left justify it.</div>
<div><br/></div>
<div>If your version of xampp is not installed at /opt/lampp then replace /opt/lampp with your directory</div>
<div><br/></div>
<div> Note: I had to adjust my Net Beans install to use port 9001 in the settings above (see https://netbeans.org/bugzilla/show_bug.cgi?id=176335). I have left the setting above of remote_port to 9000 because that is the norm in most cases.</div>
<div><br clear="none"/></div>
<div> c.) Add in the xdebug configuration<br clear="none"/>
<br clear="none"/>
<div><span style="color: #008000; font-family: courier new,courier;"> escape key</span></div>
<div><span style="color: #008000; font-family: courier new,courier;"> :x</span></div>
<br clear="none"/>
d.) Type the following<br clear="none"/>
<br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;"> escape key</span></div>
<div><span style="color: #008000; font-family: courier new,courier;"> :x</span></div>
<div><br clear="none"/></div>
<div>9.) Restart the server</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;"> sudo /opt/lampp/lampp restart</span></div>
<div><br clear="none"/></div>
<div>If your version of xampp is not installed at /opt/lampp then replace /opt/lampp with your directory</div>
<div><br/></div>
<div>10.) Done</div>
<div><br/></div>
<div>Tested on Red Hat 6.x</div>
<div><br clear="none"/></div>
<div>If this does not work for you then I found this tool to be useful:</div>
<div><br clear="none"/></div>
<div>http://xdebug.org/wizard.php</div>
Overload an array in PHP | Overload a multidimentional array in PHP | On set array call a function in PHPhttps://boulderappsco.postach.io/post/overload-an-array-in-php-overload-a-multidimentional-array-in-php-on-set-array-call-a-function-in-php2017-06-23T20:39:57.281000Z2014-02-09T22:36:00ZNicholas Dunbar<div><p><span style="font-family: arial, helvetica, sans-serif; color: #000000;">If you wanted to overload an array so that you can put your own logic inside of the get and set actions for an array using the syntax $array['property'] try starting with the class bellow and build off it. </span></p><p><span style="font-family: arial, helvetica, sans-serif; color: #000000;"><strong>Example:</strong> <br clear="none"/></span></p><p><span style="font-family: helvetica,arial,sans-serif; color: rgb(0, 0, 0);"></span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //create array</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> $obj = new <span>CustomArray</span>();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //set array</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> $obj['assoc']['child'] = "gerald";</span></p><p><span style="color: #008000; font-family: 'courier new', courier;">//print value</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> echo "\$obj['assoc']['child'] = </span><span style="color: #008000; font-family: 'courier new', courier;">{$obj['assoc']['child']}\n";</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //print array</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> echo "print array : \n $obj";</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //remove element</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> unset($obj['assoc']['child']);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //check to make sure it is not there</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> if (!isset($obj['assoc']['child'])){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> echo "child removed\n";</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> //print array</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> echo "print array : \n $obj";</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier;"> </span></p><p> <br clear="none"/></p><p><span style="font-size: large;">output:</span></p><p><span style="font-family: courier new,courier,monospace;">$obj['assoc']['child'] = gerald<br clear="none"/>print array : <br clear="none"/> Array<br clear="none"/>(<br clear="none"/> [assoc] => Array<br clear="none"/> (<br clear="none"/> [child] => gerald<br clear="none"/> )<br clear="none"/><br clear="none"/>)<br clear="none"/>child removed<br clear="none"/>print array : <br clear="none"/> Array<br clear="none"/>(<br clear="none"/> [assoc] => Array<br clear="none"/> (<br clear="none"/> )<br clear="none"/><br clear="none"/>)</span></p><p><span style="font-family: helvetica,arial,sans-serif;">Our custom overloaded array seems to function just like the original in the above situation.</span></p><p>Code for CustomArray.php :<br clear="none"/></p><pre xml:space="preserve"><span style="font-family: arial, helvetica, sans-serif; font-size: medium;"></span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;">class CustomArray extends ArrayObject {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function __construct($array = NULL)</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> { </span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> if ($array != NULL){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> foreach($array as $key => $value) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> if(is_array($value)){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $value = new CustomArray($value);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $this->offsetSet($key, $value);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function offsetSet($i, $v) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> if (is_array($v)){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $newProp = new CustomArray();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> foreach($v as $key=>$value){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $newProp[$key] = $value;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> parent::offsetSet($i, $newProp);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> } else {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> parent::offsetSet($i, $v);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function offsetGet($i) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $return = parent::offsetGet($i);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> if ($return == NULL){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $newProp = new CustomArray();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> parent::offsetSet($i, $newProp);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> return $newProp;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> return $return;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function offsetUnset($i) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> parent::offsetUnset($i);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function offsetExists($i) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $ret = parent::offsetExists($i);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> return $ret;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function __toString()</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> ob_start();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> print_r($this->getArrayPrimative());</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $output_str = ob_get_contents();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> ob_end_clean();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> return $output_str;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> public function getArrayPrimative(){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $output = array();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> foreach($this as $key => $value) {</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> if(gettype($value) == 'object' && </span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> is_subclass_of($value, 'CustomArray')){</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $output[$key] = $value->getArrayPrimative();</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> } else{</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> $output[$key] = $this->offsetGet($key);</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> return $output;</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;"> }</span><br clear="none"/><span style="color: #008000; font-family: 'courier new', courier; font-size: small;">}</span></pre></div>
Don't overwrite permissions with tar filehttps://boulderappsco.postach.io/post/dont-overwrite-permissions-with-tar-file2017-06-23T20:39:57.741000Z2014-02-09T22:30:00ZNicholas Dunbar<div>When you use tar to back-up a directory and then you want to restore that directory you may want to keep existing permissions intact. If you made changes to the permissions since the archive was created and you want to restore the original files while preserving the new permissions, here is a technique you can use. (This was tested on Red Hat Linux.)<br clear="none"/></div>
<div><br clear="none"/></div>
<div>This can be modified to run from a prompt by hard coding the variables into the lines starting with tar.<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#CONFIGURATION----></span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#set the name of the tar</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">path_to_tar=/some/dir/back-up.tar;</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#if the root of the tar does not include the full path of the file and is instead a relative path you can set it here</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">target_dir=/some/dir/target/;</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#<----CONFIGURATION</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#back up permissions for files</span></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">echo "generating script containing back-up permissions";</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">tar -tvf $path_to_tar | awk -v p=$target_dir '{print p$6}' | grep -v -E "^.*/$" | xargs -I {} ls {} 2> /dev/null | tee 3; while read a; do echo chmod `stat -c '%a' "$a"` "$a"; echo chown `stat -c '%U:%G' "$a"` "$a"; done <3 | tee backed-up_perm.sh; rm 3;</span></div>
<div><br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">#back up permissions for directories</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace; font-size: 10pt;">tar -tvf $path_to_tar | awk -v p=$target_dir '{print p$6}' | grep -E "^.*/$" | xargs -I {} ls -d {} 2> /dev/null | tee 3; while read a; do echo chmod `stat -c '%a' "$a"` "$a"; echo chown `stat -c '%U:%G' "$a"` "$a"; done <3 | tee -a backed-up_perm.sh; rm 3;</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>Run the below when you want to restore the permissions.<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">#restore back-up</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">tar -cvf $path_to_tar $target_dir;</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">#restore permissions</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">echo "Running generated permissions file...";</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">sudo sh backed-up_perm.sh;</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;">rm backed-up_perm.sh;</span></div>
<div><span style="color: rgb(0, 128, 0); font-size: 10pt; font-family: courier new,courier,monospace;"><span style="color: #008000; font-size: 10pt; font-family: courier new,courier,monospace;">echo "Permissions restored";</span></span></div>
<div><br clear="none"/></div>
<div>Example of running this from a prompt.<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="font-family: courier new,courier,monospace; color: #008000;"><span style="font-family: courier new,courier,monospace; color: #000000;"><span style="font-size: 8pt;">[local_username@localhost /]$</span></span></span> tar -tvf /some/dir/back-up.tar | awk '{print "/some/dir/target/"$6}' | grep -v -E "^.*/$" | xargs -I {} ls {} 2> /dev/null | tee 3; while read a; do echo chmod `stat -c '%a' "$a"` "$a"; sudo echo chown `stat -c '%U:%G' "$a"` "$a"; done <3 | tee backed-up_perm.sh; rm 3;</span></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><br clear="none"/></span></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="font-family: courier new,courier,monospace; color: #008000;"><span style="font-family: courier new,courier,monospace; color: #000000;"><span style="font-size: 8pt;">[local_username@localhost /]$</span></span></span> tar -tvf <span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">/some/dir/back-up.tar</span> | awk -v '{print <span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">"/some/dir/target/"</span>$6}' | grep -E "^.*/$" | xargs -I {} ls -d {} 2> /dev/null | tee 3; while read a; do echo chmod `stat -c '%a' "$a"` "$a"; sudo echo chown `stat -c '%U:%G' "$a"` "$a"; done <3 | tee -a backed-up_perm.sh; rm 3;</span></span></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><br clear="none"/></span></span></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><br clear="none"/></span></span></div>
<div>Explanation:<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">tar</span> - archive program (like zip in windows)<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">-t</span> - list of files<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">v </span>- verbose output<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">f </span>- define archive file name</div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">/some/dir/back-up.tar</span> - the name of the archive that the -f option requires<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">| </span>- pipe output to next command<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">awk </span>- a data formatting utility which has its own language interpreter <br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0);">'{</span> - start awk language interpretation <br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">"/some/dir/target"</span> - awk hard coded string<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">$6 </span>- 6th column of the output of each line that comes out of the tar command<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">}'</span> - end awk language interpretation <br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">| </span>- pipe output to next command<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">grep </span>- a utility for filtering lists of strings<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">-v </span>- remove anything from the list that fits the criteria<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">-E </span>- criteria of a regular expression<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">"^.*/$"</span> - regular expression meaning any item of the list that ends in forward slash. In other words remove all directories from the list<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">| </span>- pipe the output to the next command<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">xargs -I {} ls {}</span> - run ls with the filename being equal to {} (this is here to remove files that exist in the tar but not in the target directory)<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">2> /dev/null </span>- strip out any errors by sending them to /dev/null which deletes anything you send to it<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">| tee 3; </span>- write the list of files to a temporary file called 3 with the command tee that simultaneously outputs to the screen as well.<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">while read a;</span> - the end of this command is <span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">done <3</span> which reads in each line of the temporary file 3<br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">do echo chmod `stat -c '%a' "$a"` "$a";</span> <span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;">- print something like this chmod 770 some/file/name</span><br clear="none"/></div>
<div><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">echo chown `stat -c '%U:%G' "$a"` "$a";</span> - print something like chown user:group some/file/name<br clear="none"/></span></div>
<div><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"> done <3</span> - end of the while loop that reads in each line of the temp file 3<br clear="none"/></span></div>
<div><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">| tee -a backed-up_perm.sh;</span></span> - write all these generated chmod and chown commands to the file backed-up_perm.sh which is a shell script that can be ran to restore permissions.<br clear="none"/></span></div>
<div><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;">rm 3;</span> - remove the temp file called 3<br clear="none"/></span></div>
<div><br clear="none"/></div>
GB vs. GIB | 1024 vs. 1000https://boulderappsco.postach.io/post/gb-vs-gib-1024-vs-10002017-06-23T20:39:54.226000Z2014-02-09T21:58:00ZNicholas Dunbar<div><span style="font-size: 18px;">Looking for answers to these questions?</span></div>
<div><span style="font-size: 18px;"><br/></span></div>
<div><span style="font-size: 18px;"><h1>Why are there two types of GB?</h1></span></div>
<div><span style="font-size: 18px;"><h1>Why is a KB 1024 and not 1000 bytes?</h1> </span></div>
<div><span style="font-size: 18px;"><br/></span></div>
<div><span style="font-size: 18px;"><span style="-evernote-last-insertion-point:true;"/>Did you know there are two types of Gigabytes (GB)? What if I told you that they are not the same amount of bytes? That manufacturers list the GB on a hard drive of one kind over the other to make it look like it has more GB or Terabytes (TB) than it really does? That when you plug one of these drives in, your computer will tell you it has less space than what was listed on the package because of an effort to deceive you<span style="-evernote-last-insertion-point:true;"/>? I'll explain why and how this works.<span style="-evernote-last-insertion-point:true;"/></span></div>
<div><span style="font-size: 18px;"><br/></span></div>
<div><span style="font-size: 18px;">There are two main standards for measuring storage capacity in bytes. First, the Système international d'unités (SI) units of measurement which are the following: KB – Kilobyte, MB – Megabyte, GB – Gigabyte, TB – Terabyte, PB – Petabyte, etc.. (Did you know that these prefixes are really old? They come from ancient Greek. Mega- comes from mighty, Giga- comes from giant and Tera- comes from monster.) Second, the International Electrotechnical Commission’s (IEC) units of measurement which are the following: KiB – Kibibyte, MiB – Mebibyte, GiB – Gibibyte, TiB – Tebibyte, PiB – Pebibyte, etc.. The IEC units were established in 1999 and the SI units are much older. The following are examples of how bytes are measured in each system:</span></div>
<div>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><strong style="font-size: 18px;">SI Decimal Units:</strong></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 KB = 1,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 MB = 1,000 KB = 1,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 GB = 1,000 MB = 1,000,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 TB = 1,000 GB = 1,000,000,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">These are what we call base 10 measurements. Some refer to them as 10^x measurements.</span></p>
<p style="margin-left: 0.40in; text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;"> </span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><strong style="font-size: 18px;">IEC Binary:</strong></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 KiB = 2^10 bytes = 1024 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 MiB = 2^20 bytes = 1024 KiBs = 1,048,576 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 GiB = 2^30 bytes = 1024 MiBs = 1,073,741,824 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">1 TiB = 2^40 bytes = 1024 GiBs = 1,099,511,627,776 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">These are referred to as base 2 measurements. Some refer to them as the 2^x measurement or the 1024 base measurement.</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">So here is where it gets tricky. A person might ask “if a disk is listed as being 1 kilobyte, how many bytes does this really represent?" He or she most likely will rely on the historical use of these prefixes (Kilo-, Mega-, Giga-, Tera, Peta, Etc.), thus his or her logic may go something like the following, “1 kilogram is 1000 grams and a kilometer is 1000 meters, so I deduce that 1 kilobyte would be 1000 bytes." But that logic isn’t necessarily correct. This is because, in general, it is very common for storage to list a capacity in GB of storage, when really it is actually in GiBs. Whether you’re working in a data center or buying a hard drive at Best Buy, this ambiguity plagues the storage industry with confusion. When looking at storage capacity sizes listed in MB, GB, TB, PD, and on up, you don’t know for sure, if you are looking at MiB, GiB, TiB, PiD, etc. or MB, GB, TB, PD, etc. When looking at any capacity measurements other than bytes you must always ask yourself the following question “Which system of measurement is being used to measure the bytes listed?" For instance, can you answer if your operating system uses GBs or GiBs? When you use Windows, Linux or OS X to look at your hard drive’s size, it is listed in GB. Is this the SI standard of measurement? The answer is that your operating system uses IEC units but labels them as SI units. It should be listed as GiBs not GBs. To understand the reason for this we have to go back into history.</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">So here is where the mystery starts. If the IEC units were created in 1999, why were KBs listed as being 1024 bytes long before the existence of the IEC standard? Why weren’t they 1000 bytes long from the beginning? Since all they had back then were SI units, why wouldn’t they use them correctly? This was because of how computers are physically built. When it comes to actual bytes in memory there is a reason why the total quantity is never a power of ten. This has to do with what we call addressable space and the nature of binary numbers. Hard drives historically have been slightly more confined by the limit of addressable space than available physical size. For example, If you have a 3 bit computer then you have a total of 8 (2^3) addresses available. No matter how much storage you have, you would only be able to address 8 bytes. This is because memory addresses in computers are a certain number of bits wide. Computers count in binary and therefor the max number they can count to will never be a multiple of ten. For instance, the old 6502 microprocessor had memory addresses 16 bits wide. With 10 bits, for instance, a computer can address 2<sup>10</sup> bytes which equals 1024 memory locations. With 16 bits, a computer can address 2<sup>16</sup> memory locations.</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">Let us suffice to use the metaphor of addresses on a street of vacant lots. If the city grants you 1024 addresses and you have the space, then you’re going to build on every lot. The way a computer generates addresses means that you will never have a total amount of addresses that are equal to 10^x. They could have squandered those 24 addresses and just built 1000 houses, but that would be a waste. In the old days memory was at premium, so every addressable byte was used. Back then you weren’t going to squander bytes just to conform to SI measurements. If for the first disk you have to use 1024 bytes and you don’t have the IEC standard then you are going to use the kilobyte (KB) because it is close enough. This is why the KB was 1024 bytes in length before the KiB was created and is why it was used incorrectly from the beginning.</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">If this was a requirement of the computer then why weren’t the IEC units created earlier? Equally they could have called a 1KB disk back then a 1.024KB disk, but I suppose that would have just sounded way overly precise and nerdy. Historically we were already in the habit of using the SI prefix kilo. It made sense to approximate and so this became the standard in operating systems and all the software that was built on them. When drives became bigger and we moved to the megabyte, we should have invented mebibytes because the round off error was no longer acceptable, but because of the strength of our historical habit of using kilo, mega, etc., these prefixes stuck.</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">We continue this round off with each order of magnitude today. Though this round off error is negligible at small sizes, it gets more and more significant as storage device capacities increase. Here is a quick reference to show the amount that the 2^x sizes differ compared to the size based on how your OS calculates size (See section titled Size Converted):</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">· 1 Megabyte in the OS (MiB), has 48,576 Bytes more than the SI MB of 1,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">· 1 Gigabyte in the OS (GiB), has 73,741,824 Bytes more than the SI GB of 1,000,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in; margin-left: 30px;"><span style="font-size: 18px;">· 1 Terabyte in the OS (TiB), has 99,511,627,776 Bytes more than the SI MB of 1,000,000,000,000 bytes</span></p>
<p style="text-align: left; margin-top: 0.14in; margin-bottom: 0.14in;"><span style="font-size: 18px;">This is perhaps, why it took until 1999 for the IEC to invent the new standard. Because it wasn’t until then that this round off error became so huge. They needed a clean unit of measurement to describe these quantities in round numbers that was accurate and thus the KiB (and larger) was born around the time we started to see the gigabyte becoming widely spread. But it was too late. Too much software had been written using the incorrect SI units. What was the world to do, go back and add lowercase “i"s between all the KBs and GBs across billions of lines of code? Those computer scientists back then didn’t know we would achieve such incredible mass storage systems, some didn’t even think it was possible. So it is understandable that if they didn’t have the IEC measurements they wouldn’t know what units to use, so they would think an approximation of the SI units would be acceptable. Today, the SI units are used correctly mostly in the hardware industry where it is used to make hard drives seem bigger than they really are. When you correctly use the SI measurements 1 TB goes to 1.0995 TB. As far as the IEC standard, some manufacturers of memory list it in both GBs and GiBs for clarification. In the software industry the incorrect use of the SI standard is still very entrenched. As far as storage arrays (servers that specialize in mass storage) go, some report GB as 10^x , some as 2^x and some as both. Beware of the GB for it is not always what it seems. </span></p>
</div>
Get size of database in bytes and rowshttps://boulderappsco.postach.io/post/get-size-of-database-in-bytes-and-rows2017-06-23T20:40:02.799000Z2014-02-09T20:51:00ZNicholas Dunbar<div><h1>How to get the size of the database in MySQL?</h1></div>
<div>Replace <em>database_name</em> with the database name from which you want the size in bytes and rows:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;">SELECT t.table_schema,SUM(t.table_rows) AS row_count,SUM(t.data_length) AS data_volume</span><br clear="none"/>
<span style="font-family: courier new,courier; color: #008000;">FROM information_schema.tables t</span><br clear="none"/>
<span style="font-family: courier new,courier; color: #008000;">WHERE table_schema ='<em>database_name</em>'</span><br clear="none"/>
<span style="font-family: courier new,courier; color: #008000;">GROUP BY t.table_schema</span></div>
Script that installs an RSA key on the local machine and a remote machinehttps://boulderappsco.postach.io/post/script-that-installs-an-rsa-key-on-the-local-machine-and-a-remote-machine2017-06-23T20:40:12.189000Z2014-02-09T20:20:00ZNicholas Dunbar<div>Run this interactive bash script, if you want to set up an RSA key on your local machine and then have the script automatically install the key on a remote machine. The script is tested to work on Linux, Unix, AIX with bash.</div>
<div><br clear="none"/></div>
<div><span style="font-family: arial,helvetica,sans-serif; font-size: x-large;">Here is an example of how the script will run (code is below):</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">[local_username@localhost /]$ sh generate_ssh_key.sh</span><br clear="none"/>
<span style="font-family: courier new,courier;">Where do you want to place the RSA key?</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter the remote host (example: example.com or an IP address):</span><br clear="none"/>
<span style="font-family: courier new,courier;">140.130.70.80</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Enter user name on the remote host (<span style="font-family: courier new,courier;">140.130.70.80</span>):</span><br clear="none"/>
<span style="font-family: courier new,courier;">remote_username</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Testing access to remote host (<span style="font-family: courier new,courier;">140.130.70.80</span>) with user name (remote_username)</span><br clear="none"/>
<span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">remote_username</span></span></span>@<span style="font-family: courier new,courier;">140.130.70.80</span>'s password:</span><br clear="none"/>
<span style="font-family: courier new,courier;">Connection to <span style="font-family: courier new,courier;">140.130.70.80</span> closed.</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Server returned (remotehostname) as hostname, is this the correct remote host?</span><br clear="none"/>
<span style="font-family: courier new,courier;">1) Yes</span><br clear="none"/>
<span style="font-family: courier new,courier;">2) No</span><br clear="none"/>
<span style="font-family: courier new,courier;">#? 1</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Created RSA key name:</span><br clear="none"/>
<span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">local_username</span>_to_<span style="font-family: courier new,courier;">remote_username</span>_on_<span style="font-family: courier new,courier;">remotehostname</span>_rsa_id</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Do you want to allow <span style="font-family: courier new,courier;">local_username</span> on localhost_server.com to beable to login to <span style="font-family: courier new,courier;">140.130.70.80</span> under the ID <span style="font-family: courier new,courier;">remote_username</span> without a password?</span><br clear="none"/>
<span style="font-family: courier new,courier;">1) Yes</span><br clear="none"/>
<span style="font-family: courier new,courier;">2) No</span><br clear="none"/>
<span style="font-family: courier new,courier;">#? 1</span><br clear="none"/>
<span style="font-family: courier new,courier;">Generating key...</span><br clear="none"/>
<span style="font-family: courier new,courier;">Setting home directory privileges</span><br clear="none"/>
<span style="font-family: courier new,courier;">Creating RSA key</span><br clear="none"/>
<span style="font-family: courier new,courier;">Don't enter a password below just hit enter:</span><br clear="none"/>
<span style="font-family: courier new,courier;">Generating public/private rsa key pair.</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter passphrase (empty for no passphrase):</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter same passphrase again:</span><br clear="none"/>
<span style="font-family: courier new,courier;">Your identification has been saved in <span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">local_username</span>_to_<span style="font-family: courier new,courier;">remote_username</span>_on_<span style="font-family: courier new,courier;">remotehostname</span>_rsa_id</span>.</span><br clear="none"/>
<span style="font-family: courier new,courier;">Your public key has been saved in <span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">local_username</span>_to_<span style="font-family: courier new,courier;">remote_username</span>_on_<span style="font-family: courier new,courier;">remotehostname</span>_rsa_id</span>.</span><br clear="none"/>
<span style="font-family: courier new,courier;">The key fingerprint is:</span><br clear="none"/>
<span style="font-family: courier new,courier;">da:b6:45:51:98:f6:c7:8e:2b:f4:4b:db:ea:a0:65:f5 <span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">local_username</span></span></span>@localhost_server.com</span><br clear="none"/>
<span style="font-family: courier new,courier;">The key's randomart image is:</span><br clear="none"/>
<span style="font-family: courier new,courier;">+--[ RSA 2048]----+</span><br clear="none"/>
<span style="font-family: courier new,courier;">| o. |</span><br clear="none"/>
<span style="font-family: courier new,courier;">| +. |</span><br clear="none"/>
<span style="font-family: courier new,courier;">| . *.fff |</span><br clear="none"/>
<span style="font-family: courier new,courier;">| |</span><br clear="none"/>
<span style="font-family: courier new,courier;">+-----------------+</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter password to <span style="font-family: courier new,courier;">140.130.70.80</span>:</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Setting up .ssh folder on remote server</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter password:</span><br clear="none"/>
<span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">remote_username</span></span></span>@<span style="font-family: courier new,courier;">140.130.70.80</span>'s password:</span><br clear="none"/>
<span style="font-family: courier new,courier;">Connection to <span style="font-family: courier new,courier;">140.130.70.80</span> closed.</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Writing public key to remote authorized_keys file</span><br clear="none"/>
<span style="font-family: courier new,courier;">Enter password:</span><br clear="none"/>
<span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;"><span style="font-family: courier new,courier;">remote_username</span></span></span>@<span style="font-family: courier new,courier;">140.130.70.80</span>'s password:</span><br clear="none"/>
<br clear="none"/>
<span style="font-family: courier new,courier;">Installation of RSA key complete!</span><br clear="none"/>
<br clear="none"/></div>
<div><span style="font-family: arial,helvetica,sans-serif; font-size: x-large;">Here is the code for the script generate_ssh_key.sh</span></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 143, 0);"><span style="font-family: 'Courier New';">#!/bin/bash</span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">#######################</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"># installs an RSA key on the local machine and a remote machine</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"># Allows you to connect to a remote machine without a password</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">#######################</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">base_path=$(pwd);</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">local_hostname=$(hostname);</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">local_user=$(whoami);</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">home_dir=$(dirname ~);</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Where do you want to place the RSA key?";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Enter the remote host (example: example.com or an IP address):";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">read host;</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo '';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Enter user name on the remote host ($host):";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">read username;</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo '';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Testing access to remote host ($host) with user name ($username)";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">cmd='hostname';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">remote_hostname=$(ssh -t $username@$host "$cmd");</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">#clean out cariage returns and newlines</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">remote_hostname=$(echo $remote_hostname | sed 's/\r$//');</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">remote_hostname=$(echo $remote_hostname | sed 's/\n$//');</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">remote_hostname=$(echo $remote_hostname | tr -cd '[[:alnum:]]._-');</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Server returned ($remote_hostname) as hostname, is this the correct remote host?";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">select yn in "Yes" "No"; do</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> case $yn in</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> Yes ) break;;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> No ) exit 1;;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> esac</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">done</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">#create RSA name based on the remote host name and the remote username</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name="";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+=$local_user;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+="_to_";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+=$username;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+="_on_";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+=$remote_hostname;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">rsa_name+="_rsa_id";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Created RSA key name:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "$rsa_name";</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">echo "Do you want to allow $local_user on $local_hostname to beable to login to $host under the ID $username without a password?";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">select yn in "Yes" "No"; do</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> case $yn in</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> Yes ) echo "Generating key..."; break;;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> No ) exit;;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> esac</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">done</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">#check if user exists on system</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">if [ -d "$home_dir/$local_user/" ]; then</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> # Control will enter here if directory exists.</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> cd ~;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> #make sure .ssh directory exists and has user only permissions</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Setting home directory privileges";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> if [ -d "$home_dir/$local_user/.ssh" ]; then</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> chmod 700 .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> else</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> mkdir .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> chmod 700 .ssh;</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> fi</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> cd .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Creating RSA key";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Don't enter a password below just hit enter:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> #generate key</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> ssh-keygen -t rsa -f $rsa_name;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Enter password to $host:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> #Install key on remote host</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> set rsa_contents = `cat ~/.ssh/$rsa_name.pub`;</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo '';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Setting up .ssh folder on remote server";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Enter password:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> remote_script=$(echo "</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">home_dir=$(dirname ~);</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">cd ~;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">if [ -d \".ssh\" ]; then</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> chmod 700 .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">else</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> mkdir .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> chmod 700 .ssh;</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;">fi</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">cd .ssh;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">touch authorized_keys;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">chmod 600 authorized_keys;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">exit;");</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> ssh -t $username@$host "$remote_script";</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo '';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Writing public key to remote authorized_keys file";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Enter password:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> ssh $username@$host "echo '`cat ~/.ssh/$rsa_name.pub`' >> ~/.ssh/authorized_keys";</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo ''; </span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> rm ~/.ssh/$rsa_name.pub;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Installation of RSA key complete!";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo '';</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Use the following to login:";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "ssh -i ~/.ssh/$rsa_name $username@$host";</span></div>
<div><span style="font-family: 'courier new', courier;"><span style="color: rgb(0, 128, 0);"><br/></span></span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> cd $base_path;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> exit;</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">else</span></div>
<div><span style="font-family: courier new,courier; color: #008000;"> echo "Sorry, no home directory found.";</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">fi</span></div>
<div><br clear="none"/></div>
Convert decimal to base 36 alpha numeric in Bash | Linuxhttps://boulderappsco.postach.io/post/convert-decimal-to-base-36-alpha-numeric-in-bash-linux2017-06-23T20:40:04.663000Z2014-02-09T19:09:00ZNicholas Dunbar<div>Here is a custom bash shell script function you can use to convert a decimal to a base 36 number in all capital alpha numeric.</div>
<div><br clear="none"/></div>
<div>Example:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">your_digit=65;</span></div>
<div><span style="color: #008000; font-family: courier new,courier;">decimal_to_base36 $your_digit;</span></div>
<div><br clear="none"/></div>
<div>Output:</div>
<div><br clear="none"/></div>
<div><span style="color: #000000; font-family: courier new,courier;">1T</span></div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">function decimal_to_base36(){</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> BASE36=($(echo {0..9} {A..Z}));</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> arg1=$@;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> for i in $(bc <<< "obase=36; $arg1"); do</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> echo -n ${BASE36[$(( 10#$i ))]}</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> done && echo</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">}</span></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 0, 0); font-family: arial,helvetica,sans-serif; font-size: 8pt;">Source: http://stackoverflow.com/questions/14471692/bash-base-62-to-decimal-conversion</span></div>
Compare the contents of a remote directory with a local directoryhttps://boulderappsco.postach.io/post/compare-the-contents-of-a-remote-directory-with-a-local-directory2017-06-23T20:39:58.452000Z2014-02-08T21:53:00ZNicholas Dunbar<div>Here is a little PHP script I wrote, that you can run from the command line. I wrote it to allow you to see what files are in a remote folder that are not in a local folder.</div>
<div><br clear="none"/></div>
<div><strong><span style="color: #008000; font-family: courier new,courier; font-size: large;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: medium;"><span style="color: #000000;"><span style="font-family: courier new,courier; font-size: medium;"><span style="font-family: times new roman,times; font-size: x-large;"><strong><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><strong>user@localhost the_directory></strong></span></strong></span></span></span></span></strong></span> <span style="color: #008000; font-family: courier new,courier; font-size: medium;">php compare.php the_host_address.com:/the/remote/dir/ /the/local/dir/</span></strong></div>
<div><br clear="none"/></div>
<div>This would be used when you copy files from a remote directory to your local and then you might want to see what files did not transfer due to errors. Perhaps after you download you want to monitor the folder on the server to determine if there has been any new files added. If you want to keep two folders in sync it is recommend that you use the Linux command rsync. You can actually use rsync to look at the differences between two folders but it compares if the file has changed, if its permissions are different etc. etc. This script just compares the file lists of the remote and local folders. In other words it is only looking at the folder contents not the file contents or file properties.<br clear="none"/><br clear="none"/></div>
<div>Here is the code for the compare.php file:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;"><</span><span style="font-family: courier new,courier; color: #008000;">?php<br clear="none"/>/**<br clear="none"/>* See what is missing in a local directory that exists in a remote directory<br clear="none"/>* To use, run the following command at the Linux command prompt<br clear="none"/>* php compare.php the_host_address.com:/the/remote/dir/ /the/local/dir/<br clear="none"/>**/<br clear="none"/>if (count($argv) < 2){<br clear="none"/> die("No arguments stated");<br clear="none"/>}<br clear="none"/>if (count($argv) < 3){<br clear="none"/> die("Two arguments required");<br clear="none"/>}<br clear="none"/>//parse arguments<br clear="none"/>//ex: $argv[1] = '<span style="font-family: courier new,courier; color: #008000;">the_host_address.</span>com:<span style="font-family: courier new,courier; color: #008000;">/the/remote/dir/</span>';<br clear="none"/>list($remote_host,$remote_dir) = explode(":",$argv[1]);<br clear="none"/>//ex: $argv[2] = '<span style="font-family: courier new,courier; color: #008000;">/the/local/dir/</span>';<br clear="none"/>$local_dir = $argv[2];<br clear="none"/><br clear="none"/>//get username<br clear="none"/>$cmd_get_username = "whoami";<br clear="none"/>$username = exec($cmd_get_username);<br clear="none"/><br clear="none"/>//get remote file list<br clear="none"/>$cmd_get_remote_list = "ssh $username@$remote_host 'cd $remote_dir;find .'";<br clear="none"/>$remote_output = array();<br clear="none"/>exec($cmd_get_remote_list,$remote_output);<br clear="none"/><br clear="none"/>//get local file list<br clear="none"/>$cmd_get_local_list = "cd $local_dir; find .";<br clear="none"/>$local_output = array();<br clear="none"/>exec($cmd_get_local_list,$local_output);<br clear="none"/><br clear="none"/>$differences_list = array_diff($remote_output,$local_output);<br clear="none"/><br clear="none"/>foreach ($differences_list as $val){<br clear="none"/> echo $val."\n";<br clear="none"/>}<br clear="none"/>?></span></div>
MySQL Generate a list of numbershttps://boulderappsco.postach.io/post/mysql-generate-a-list-of-numbers2017-06-23T20:39:56.106000Z2014-02-08T18:35:00ZNicholas Dunbar<div>This will generate a column named SeqValue that will range from 0-255 so a total of 256 values.</div>
<div><br clear="none"/></div>
<div>SELECT<br clear="none"/> (TWO_1.SeqValue + TWO_2.SeqValue + TWO_4.SeqValue + TWO_8.SeqValue + TWO_16.SeqValue + TWO_32.SeqValue + TWO_64.SeqValue + TWO_128.SeqValue) SeqValue<br clear="none"/>FROM<br clear="none"/> (SELECT 0 SeqValue UNION ALL SELECT 1 SeqValue) TWO_1<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 2 SeqValue) TWO_2<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 4 SeqValue) TWO_4<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 8 SeqValue) TWO_8<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 16 SeqValue) TWO_16<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 32 SeqValue) TWO_32<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 64 SeqValue) TWO_64<br clear="none"/> CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 128 SeqValue) TWO_128</div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div>If you wanted to double the list to 512 values you would add the following to the bottom of the SQL block:</div>
<div><br clear="none"/></div>
<div>CROSS JOIN (SELECT 0 SeqValue UNION ALL SELECT 256 SeqValue) TWO_256</div>
<div><br clear="none"/></div>
<div>and then add the TWO_256 to the top SELECT making it the following:</div>
<div><br clear="none"/></div>
<div>SELECT<br clear="none"/> (TWO_1.SeqValue + TWO_2.SeqValue + TWO_4.SeqValue + TWO_8.SeqValue + TWO_16.SeqValue + TWO_32.SeqValue + TWO_64.SeqValue + TWO_128.SeqValue + TWO_256.SeqValue) SeqValue</div>
Ipoint interface | ActionScript 3.0 AS3https://boulderappsco.postach.io/post/ipoint-interface-actionscript-3-0-as32017-06-23T20:40:09.155000Z2014-02-04T08:46:07ZNicholas Dunbar<div><div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><span style="-evernote-last-insertion-point:true;"/>It amazes me that ActionScript (AS3) does not have interfaces listed for all its classes. Often you want to create a class that inherits from something like MovieClip and MovieClip inherits all the way down a long list of classes. So you are left with the daunting task of creating all those interfaces. Fortunately some of us have been publishing those interfaces on the web to fill the void with which Adobe Flash ActionScript 3 has left us.</div></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">In the case of IPont I had to extend the flash.geom.Point class and change the property accessors in order to have them work in the interfaces since Point has finalized its properties. You could create your own Point Class and use composition to wrap the real Point class if you wanted to preserve the same properties instead of using dataX for x.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> package</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> import flash.geom.Point;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public class DataPoint extends Point implements IDataPoint</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public function get dataX():Number{</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> return super.x;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public function get dataY():Number{</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> return super.y;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public function get dataLength():Number{</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> return super.length;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> </pre></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"></span></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> package</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public interface IDataPoint extends IPoint</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function get dataX():Number;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function get dataY():Number;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function get dataLength():Number;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> </pre></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"></span></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;"></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> package</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> import flash.geom.Point;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> public interface IPoint</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> {</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function add(v:Point):Point;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function clone():Point;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function normalize(thickness:Number):void;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function offset(dx:Number, dy:Number):void;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> function subtract(v:Point):Point;</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> }</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> </pre></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"></span></div>
Expected to find it in c:\program files\adobe\flex builder 3\lib\tools.jarhttps://boulderappsco.postach.io/post/expected-to-find-it-in-c-program-files-adobe-flex-builder-3-lib-tools-jar2017-06-23T20:40:05.654000Z2014-02-04T08:43:57ZNicholas Dunbar<div><div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"><span style="-evernote-last-insertion-point:true;"/>##ANT Error with Flex Builder 3 and Windows XP command line##</div></div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">##Unable to locate tools.jar. Expected to find it in C:\Program Files\Adobe\Flex Builder 3\lib\tools.jar##</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">Ahhhhhhhhhhhhhhhh! Right? But never fear, I eventually found the solution and that solution may be that for which you are looking. (Don't end a sentence with a preposition at the risk of sounding like Yoda.)</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> tools.jar is part of a set of prepackaged libraries that come with the Java SDK. ANT uses tools.jar for things like regular expressions and other things, so ANT will compile source code with out it but many other things will just not work.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> Normally when you install ANT on a windows system you have to create an environment variable JAVA_HOME in system properties. This variable has to point to your install of the JDK. For example "C:\Sun\SDK\jdk"</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> If that is what you have done and yes ant continues to look for the JDK in "C:\Program Files\Adobe\Flex Builder 3\" then you may have had the same problem I had. I looked at the environment variables and the JAVA_HOME path was correctly set, but then when I typed into the Window's command line "echo %JAVA_HOME%", I got "C:\Program Files\Adobe\Flex Builder 3\"</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> HMMM! Some unknown force is changing my Environment Variable JAVA_HOME dynamically with out me knowing.</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> The problem turns out to occur when I run from the start menu the "Adobe Flex SDK Command Prompt"</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"> This runs a FlexFrameworkCmdPrompt.bat file which contains the command "@set JAVA_HOME=%CD%\jre"</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">To fix it I type into the command line prompt "@set JAVA_HOME=C:Sun\SDK\jdk" (or in your case where ever you have installed the JDK)</div>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;"/>
<div style="font-family: "Courier"; font-size: 13px; font-style: normal; font-weight: normal;">Then I vow to never run that pesky bat file again and boom, problem solved! The ANT autobuild works everytime.</div>
Comment guerrilla activismhttps://boulderappsco.postach.io/post/internet-guerilla-activism2017-06-23T22:39:33.553000Z2014-02-04T08:38:55ZNicholas Dunbar<div><div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;">Published originally on flash-actionscript-guru.com in 2008. This article is quite dated and is now standard practice for what is today called "activist trolling." </span></div></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;"><b><b><span style="font-weight: normal;"><b>Internet</b> </span>Guerrilla</b><span style="font-weight: normal;"><b> Activism: Using Internet Reviews and Comments to Hit Them Where It Hurts. </b></span></b></span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;">If you have heard the term Guerrilla Marketing then take that idea and apply it to Activism. In this world of mega corporations how does a small guy find a voice? I argue that now more than ever the little guy has tremendous opportunity. Power like he has never had. I am a technologist and I think about tech every day. The activists I know are a bit on low tech side in comparison and often don't see the Internet the way I do. So, without taking a pro or antagonistic view point of activism types lets assume these people need effective ways to fight for their causes. Let us ponder this. </span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;">What if an activist group went after their big offenders by providing counter propaganda on deemed unethical products through review sites? This doesn't mean you lie, your ideas have to be true and strong. What if these activists attacked the ideas counter to their causes in the comment sections of newspapers and magazine websites in front of the readership? Today people rely heavily on reviews from internet sites to determine what products to buy. With a few weeks of work a group could kill a unestablished publication or effect sales of a newly released product by millions of dollars. I am amazed that activist groups have not taken advantage of this new situation to its full extent. Think of the last article you read on a site like The Economist, The New York Times, or any other large audience publisher. Here you have a piece of content read by millions with an opportunity to put your ideas right under the nose of an audience who knows the issue and will listen to your idea. Amazing!</span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;"><b>The Power of The Sound Bite</b></span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;">Now remember comments have to be short and sweet. You might say that no real information can be posted in a comment so what good is it? BZZZZ! wrong! The content in a top rated comment can hold more sway than the article its self. How? Consider Time, Newsweek or you name any political mainstream magazine and you will see that the sound bite rules. Check out the book Made to Stick long detailed information does not stick. Activists tend to explore the complexities of the matters they care about. They are fanatics and can tell you everything and anything about their issue. Information overload makes the ideas run through one ear and out the other of their audience. The natural tendency of the comments frankness is a blessing in disguise. It forces activists to create higher impact content than the article its self. When you are browsing the web, pay attention to how much you read the comments. I'm not saying that your voice will be drowned out by a myriad of random blathering from other posters. But if it is good and valid it may be voted to the top. What is important here is that it's an unprecedented opportunity. Think of it years ago, putting your two cents under an article in the New York Times. Unfathomable and preposterous! So why is this not a huge phenomenon? My guess is that activists who write articles and books are largely driven by a mix of altruism and ego. This form of guerilla activism would require deemphasizing the importance of being recognized for ones good works. If you're fighting for a cause and are not making much money what drives you and what feeds that drive? What is the force behind the most prolific pro bono activists? The two major forces that come to mind would be seeing concrete progress as a result of your work and/or recognition. Neither of which is highly visible when you engage your opponent outside the system. Guerilla tactics have allowed peasants to keep the CIA out of parts of South America, likewise in the mid 1700s these tactics brought America freedom from Britain and on and on and on. Fighting "dirty", aka outside of the system has been and is a powerful force. In the future as these ideas become popularized only time will tell if such tactics will bring about balance or chaos.</span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;"><br /></span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;"><br /></span></div>
<div style="font-style: normal; font-weight: normal;"><span style="font-family: verdana, helvetica, sans-serif;"><br /></span></div>
Jump to end of file with vi or vim | Jump to last linehttps://boulderappsco.postach.io/post/jump-to-end-of-file-with-vi-or-vim-jump-to-last-line2017-06-23T20:39:57.095000Z2014-01-03T01:52:11ZNicholas Dunbar<div><b>Insert Mode</b> is when you have a block cursor and can edit the text</div>
<div><b>Command Mode</b> is when you have a : at the bottom where you can enter commands.<br/></div>
<div><span style="-evernote-last-insertion-point:true;"/><br/></div>
<div>If you are in insert mode or command mode hit:<br/></div>
<div><br clear="none"/>
<span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">escape key</span></div>
<div>then</div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">shift+g keys</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>If you are not in insert mode or command mode hit:<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">shift+G keys</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>To run vi or vim you can run it from the command line first or enable it in your IDE. <br clear="none"/></div>
<div><br/></div>
<div><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><br clear="none"/></span></div>
Add an existing user to an existing group in Linuxhttps://boulderappsco.postach.io/post/add-an-existing-user-to-an-existing-group-in-linux2017-06-23T20:40:03.947000Z2014-01-03T00:41:58ZNicholas Dunbar<div>If you want to a add a user to an existing group this is how you do it.<br clear="none"/></div>
<div><br clear="none"/><span style="color: #008000; font-family: courier new,courier,monospace; font-size: 10pt;"><span style="font-family: courier new,courier,monospace; color: #008000;"><span style="font-family: courier new,courier,monospace; color: #000000;"><span style="font-size: 8pt;">[local_username@localhost /]$</span></span></span></span> <span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">useradd -a -G somegroup username</span><br clear="none"/><br clear="none"/>Then log out and log back in for the new group settings to take effect.<br clear="none"/><br clear="none"/><br clear="none"/><span style="font-size: 8pt;">Managing permissions for a group is an important concept to understand if you are working with Unix like file systems. I have tried to give a very simple and concise example here. If you are looking for more examples on the web on how to create groups and more, you will find plenty of resources. This articles purpose is to answer a question as quickly as possible.</span> <br clear="none"/></div>
Using Table Names With Spaces in PHP and mySQLhttps://boulderappsco.postach.io/post/using-table-names-with-spaces-in-php-and-mysql2017-06-23T20:39:55.636000Z2014-01-02T05:16:22ZNicholas Dunbar<div><p>The key to writing SQL queries using table names that contain spaces is to make sure you use the correct quotes.</p><p><span style="color: rgb(128, 0, 0);">This is wrong:</span></p><p><pre></p><p><span style="font-family: 'courier new', courier, monospace; color: rgb(0, 128, 0);">SELECT * FROM tablename ORDER BY ''field name'' ASC</span></p><p></pre></p><p><span style="color: rgb(0, 204, 255);">This is correct:</span></p><p><pre></p><p><span style="font-family: 'courier new', courier, monospace; color: rgb(0, 128, 0);">SELECT * FROM <span style="font-family: 'courier new', courier, monospace; color: #008000;">tablename</span> ORDER BY `field name` ASC</span></p><p></pre></p><p>These (`) are called back ticks. </p><p><br clear="none"/></p><p>Also it is a good idea to make sure there are no MySQL special characters in the variable name like in the following example:</p><p><pre></p><p><span style="font-family: 'courier new', courier, monospace; color: rgb(0, 128, 0);">SELECT * FROM <span style="font-family: 'courier new', courier, monospace; color: #008000;">tablename</span> ORDER BY `$name` ASC</span></p><p></pre></p><p>Use the following to make sure that this is not a problem:</p><p><pre><br clear="none"/></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;">function returnDBFieldEscaped($theData){</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> $theData = preg_replace("/(\\n|\\r)/"," ",$theData);</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> $theData = (trim(addslashes($theData)));</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> if (str_empty($theData)){</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> return "";</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> } else{</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> return $theData; </span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;"> }</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;">}</span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;">//Example:<br clear="none"/></span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;">$name = <span style="color: #008000; font-family: 'courier new', courier, monospace;">returnDBFieldEscaped</span>($_POST['order_by']);<br clear="none"/></span></p><p><span style="color: rgb(0, 128, 0); font-family: 'courier new', courier, monospace;">$query = "<span style="font-family: 'courier new', courier, monospace; color: #008000;">SELECT * FROM <span style="font-family: 'courier new', courier, monospace; color: #008000;">tablename</span> ORDER BY `{$name}` ASC</span>";<br clear="none"/></span></p><p></pre><br clear="none"/></p><p>It will remove common characters that are not allowed and escape special characters in the unescaped string, so that it is safe to place it in a MySQL query. It may not handle all cases. Please leave a comment, if you have any improvements to suggest. <br clear="none"/></p></div>
Unix style options and flags with command line PHPhttps://boulderappsco.postach.io/post/unix-style-options-and-flags-with-command-line-php2017-06-23T20:40:02.533000Z2013-12-24T19:09:41ZNicholas Dunbar<div>Looking for a more intelligent way to parse in options from the command line into your PHP script other than $argv? For example, you may want to be able to place options in any order like the following:<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">php somescript.php -pv -o value</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>or<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">php somescript.php -p -o value -v</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>and have it still work the same.<br clear="none"/></div>
<div><br clear="none"/></div>
<div>I discovered a while ago, a great little script called OptionParser.php by Michael J. I. Jackson (found at <a shape="rect" href="https://github.com/mjijackson/optionparser)" target="_blank">https://github.com/mjijackson/optionparser)</a> which helps parse in parameters from the command line, but it is a little limited (read on for the solution to the limitation). For example, it works well for situations like the following:<br clear="none"/></div>
<div><br clear="none"/></div>
<div>php somescript.php --option value<br clear="none"/></div>
<div><br clear="none"/></div>
<div>The contents of somescript.php being the following lines of code:<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0);">require_once("OptionParser.php");</span></div>
<div><span style="color: rgb(0, 128, 0);">// Initialize the command parser</span><br clear="none"/>
<span style="color: rgb(0, 128, 0);">$parser = new OptionParser();</span><br clear="none"/>
<span style="color: rgb(0, 128, 0);">// Set the rules</span><br clear="none"/>
<span style="color: rgb(0, 128, 0);">$parser->addRule('o|option::', "Enter -o or --option and then the value you want to print");</span><br clear="none"/>
<span style="color: rgb(0, 128, 0);">$parser->parse();</span><br clear="none"/>
<span style="color: rgb(0, 128, 0);">$opt = $parser->getOption('o');</span><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0);">echo $opt;</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/>
Which will output from our command line example above:<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace;">value</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>But the problem with the OptionParser.php is it does not support blank options like:<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">php somescript.php --option</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div>or grouped blank options (grouped flags) like the following example:<br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">php somescript.php -o value <strong>-vp</strong></span></div>
<div><br clear="none"/></div>
<div>These don't need a value as they are simply boolean on or off values.<br clear="none"/></div>
<div><br clear="none"/></div>
<div>-o value : print value<br clear="none"/></div>
<div>-v : yes verbose<br clear="none"/></div>
<div>-p : yes print to log<br clear="none"/></div>
<div><br clear="none"/></div>
<div>(these are just possible examples)<br clear="none"/></div>
<div><br clear="none"/></div>
<div>So to support blank flags or options in groups, in concert with the wonderful code of the OptionParser.php, I have programmed a helper class. This is how it works (added code to example somescript.php in <strong>bold</strong>):<br clear="none"/></div>
<div><br clear="none"/></div>
<div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0);"><strong>require_once("blankOptions.php");</strong></span></div>
</div>
<div>
<div><span style="color: #008000;">require_once("OptionParser.php");</span></div>
<div><span style="color: #008000;">//Preserve options without parameters<br clear="none"/>
<strong>$blankOptions = new BlankOptions();</strong><br clear="none"/>
<strong>//Convert -vp to -v -p</strong><br clear="none"/>
<strong>$blankOptions->convertGroupedOptions();</strong><br clear="none"/>
<strong>//Convert -v -p to -v blank -p blank</strong><br clear="none"/>
<strong>$blankOptions->add('-v');</strong><br clear="none"/>
<strong>$blankOptions->add('-p');</strong></span></div>
<div><span style="color: #008000;"><strong><strong>$blankOptions->add('--verbose');</strong><br clear="none"/>
<strong>$blankOptions->add('--print');</strong></strong></span></div>
<div><span style="color: #008000;"><br clear="none"/></span></div>
<div><span style="color: #008000;">//Initialize the command parser</span><br clear="none"/>
<span style="color: #008000;">$parser = new OptionParser();</span><br clear="none"/>
<span style="color: #008000;">//Set the rules</span><br clear="none"/>
<span style="color: #008000;">$parser->addRule('o|option::', "Enter -o or --option and then the value you want to print");</span></div>
<div><span style="color: rgb(0, 128, 0);"><strong>$parser->addRule('v|verbose::', "Enter -v or --verbose to set verbose mode");</strong></span></div>
<div><span style="color: rgb(0, 128, 0);"><strong>$parser->addRule('p|print::', "Enter -p or --print to not print to log");</strong></span><br clear="none"/>
<span style="color: #008000;">$parser->parse();</span><br clear="none"/>
<span style="color: #008000;">$opt = $parser->getOption('o');</span></div>
<div><span style="color: #008000;">echo $opt;</span></div>
<div><span style="color: rgb(0, 128, 0);"><strong>$opt2 = $parser->getOption('v');<br clear="none"/>
if ($opt2 != FALSE){</strong></span></div>
<div><span style="color: rgb(0, 128, 0);"><strong> //set verbose mode<br clear="none"/></strong></span></div>
<div><span style="color: rgb(0, 128, 0);"><strong>}</strong></span></div>
<div>
<div><span style="color: rgb(0, 128, 0);"><strong>$opt3 = $parser->getOption('p');<br clear="none"/>
if ($opt3 != FALSE){</strong></span></div>
<div><span style="color: rgb(0, 128, 0);"><strong> //don't print to log</strong></span></div>
<span style="color: rgb(0, 128, 0);"><strong>}</strong></span></div>
<div> <br clear="none"/></div>
</div>
<div><span style="font-size: 12pt;"><strong>Here is the code for blankOptions.php:</strong></span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><br clear="none"/>
/**<br clear="none"/>
* If blank options are included place holder data is added so that the<br clear="none"/>
* OptionParser {@link OptionParser.php} does not remove those options.<br clear="none"/>
*<br clear="none"/>
* Convert arguments of the style -abc to -a -b -c<br clear="none"/>
* Convert arguments of the style -a -b -c to -a blank -b blank -c blank<br clear="none"/>
*<br clear="none"/>
* This is so that OptionParser.php can handle unix style options like<br clear="none"/>
* grouped options (ex: -abc) and blank options -a -b -c<br clear="none"/>
*/<br clear="none"/>
<br clear="none"/>
/**<br clear="none"/>
* Add in blank parameters into options left blank<br clear="none"/>
*<br clear="none"/>
* @author nicholas dunbar<br clear="none"/>
*/<br clear="none"/>
class BlankOptions {<br clear="none"/>
<br clear="none"/>
/**<br clear="none"/>
* Create a utility object that works with OptionParser.php<br clear="none"/>
*/<br clear="none"/>
public function __construct() {<br clear="none"/>
<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
/**<br clear="none"/>
* This adds a parameter after any flags that may have been left blank<br clear="none"/>
* usually $_SERVER['argv']<br clear="none"/>
*<br clear="none"/>
* @param string $flag<br clear="none"/>
* The flag name usually starting with a - "dash" in the command line<br clear="none"/>
* @param array $argv<br clear="none"/>
* list of argument variables that were passed in from the command line<br clear="none"/>
* @param string $param<br clear="none"/>
* The value of the flag. Example: --print true<br clear="none"/>
* @return array<br clear="none"/>
* $_SERVER['argv'] with the transformations applied<br clear="none"/>
*/<br clear="none"/>
public function add($flag, array &$argv = NULL, $param = 'blank'){<br clear="none"/>
if ($argv === NULL) {<br clear="none"/>
if (isset($_SERVER['argv'])) {<br clear="none"/>
$argv = $_SERVER['argv'];<br clear="none"/>
} else {<br clear="none"/>
$argv = array();<br clear="none"/>
}<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
//Detect things like -h or -p since the OptionParser removes options if they are empty<br clear="none"/>
$lowercase_argv = array_map('strtolower', $argv);<br clear="none"/>
$index = array_search($flag, $lowercase_argv);<br clear="none"/>
if ($index !== FALSE){<br clear="none"/>
if ( !(isset($argv[$index+1])) || (substr($argv[$index+1], 0, 1) == '-') ){<br clear="none"/>
array_splice($argv, $index+1, 0, array($param));<br clear="none"/>
$_SERVER['argv'] = $argv;<br clear="none"/>
}<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
return $_SERVER['argv'];<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
/**<br clear="none"/>
* Convert arguments of the style -abc to -a -b -c<br clear="none"/>
*<br clear="none"/>
* @param array $argv<br clear="none"/>
* Pass by reference the argument array from $_SERVER['argv']<br clear="none"/>
* @return array<br clear="none"/>
* $_SERVER['argv'] with the transformations applied<br clear="none"/>
*/<br clear="none"/>
public function convertGroupedOptions(array $argv = NULL){<br clear="none"/>
<br clear="none"/>
if ($argv === NULL) {<br clear="none"/>
if (isset($_SERVER['argv'])) {<br clear="none"/>
$argv = $_SERVER['argv'];<br clear="none"/>
} else {<br clear="none"/>
$argv = array();<br clear="none"/>
}<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
$new_argv = array();<br clear="none"/>
while ($option = array_pop($argv)){<br clear="none"/>
$matches = array();<br clear="none"/>
echo preg_match('/^(-{1})([a-z]+)$/i', $option, $matches)."\n";<br clear="none"/>
if<br clear="none"/>
(<br clear="none"/>
strlen($option) > 2 &&<br clear="none"/>
preg_match('/^(-{1})([a-z]+)$/i', $option, $matches)<br clear="none"/>
)<br clear="none"/>
{<br clear="none"/>
if (isset($matches[2])){<br clear="none"/>
<br clear="none"/>
$chars = str_split($matches[2]);<br clear="none"/>
while ($one_char_opt = array_pop($chars)){<br clear="none"/>
array_unshift($new_argv, '-'.$one_char_opt);<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
} else {<br clear="none"/>
array_unshift($new_argv, $option);<br clear="none"/>
}<br clear="none"/>
} else {<br clear="none"/>
array_unshift($new_argv, $option);<br clear="none"/>
}<br clear="none"/>
}<br clear="none"/>
<br clear="none"/>
$argv = $new_argv;<br clear="none"/>
<br clear="none"/>
$_SERVER['argv'] = $new_argv;<br clear="none"/>
<br clear="none"/>
return $_SERVER['argv'];<br clear="none"/>
}<br clear="none"/>
}<br clear="none"/></span></div>
Is technology destroying high art?https://boulderappsco.postach.io/post/is-technology-destroying-high-art2017-06-23T22:43:10.361000Z2013-12-14T01:24:12ZNicholas Dunbar<div><span style="font-family: verdana, helvetica, sans-serif;"><b><span style="font-size: 12pt;"><span style="font-size: 14pt;">Is your vision of the future one in which we are all </span></span><span style="font-size: 12pt;"><span style="font-size: 14pt;">mindless drones who don't know how to make anything?</span></span></b></span></div><p><span style="font-family: verdana, helvetica, sans-serif;">I'd like to try and ease your mind.</span></p>
<div><span style="font-size: 16px;"><i><font face="'Times New Roman'">"The world of A.D. 2014 will have few routine jobs that cannot be done better by some machine than by any human being. Mankind will therefore have become largely a race of machine tenders." - Isaac Asimov, Science Fiction Author, 1964</font></i></span><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;"><br /></span></div>
<div><span style="font-family: verdana, helvetica, sans-serif;">Implicit in the idea that technology makes our lives easier is that artisan-ship and high culture is being eroded away by technology, because there is less of a need for mastery. My father is a potter and I have watched the appreciation and value of his work wane as Target rolls out mass produced pottery that looks more and more handmade. Each year they are able to mass produce handmade "look-alikes" with increasing variety and thus the layman increasingly can not see the difference. Adobe Photo Shop killed the photo airbrushing industry, cinder blocks diminished the number of fine stone masonry craftsman, the printer almost wiped out the profession of fine calligraphy and more. My goal is not to disprove that idea, but to make it sound not as bad as it seems. I'll be using the developed western world for my examples, since that is where technology is having its largest impact in this area.</span></div><p><span style="font-family: verdana, helvetica, sans-serif;">If you look at the 1600's in France and Italy for instance, it looks as if there was an amazing golden age of art and culture. You look at history and you say to your self, "we don't make anything like this anymore, it is so sad." Such was my own experience when I moved to France during my college years. I went to Europe and looked at the craftsmanship in all the buildings from that time period. It is amazing! I said to my self, how could we have lost our value for such things. Though these marvels of history are amazing and unique you have to balance that with the understanding that for every amazing old building that survived there were thousands of plain, unremarkable grass thatched roof buildings that no longer are standing. Only the magnificent survived, because it was deemed worthy of preserving. And then suddenly the golden age of art starts to loose a little of its luster.</span></p>
<p><span style="font-family: verdana, helvetica, sans-serif;">Continuing this line of logic. You realize that these paintings in museums were commissioned by the wealthy and were not a common part of the fabric of society, except in churches as every where else, they were locked away in the wealthiest estates. As, in turn, what is commissioned and produced today is locked away in rich estates as well, and so, like before, high art remains exceptional and rare. Nothing has changed. The difference being between the old and the new is that the art of the renaissance was seized by the revolutionaries (who killed their rich people) allowing for these wonders centuries later be put on display for us. The wealth of the ages concentrated into public spaces across the globe in museums that only number in the hundreds on a planet with over 7 billion citizens. Centuries of art concentrated into a few handfuls of buildings. This can create a distortion that art was plentiful at one time and thus artistry was plentiful.</span></p>
<p><span style="font-family: verdana, helvetica, sans-serif;">This distortion is furthered even more by the ratio of mass produced goods we have in comparison to hand made things. It's not that there is less art, it's that the ratio of mass produced goods to hand made goods is increasing. But more of one thing does not make less of another. It's not that we don't own hand made things anymore, it's that the poor can own stuff now and they don't have to save 3-7 months to buy something like a wooden chair. The "have-nots" now have and can own things like Scandinavian furniture from IKEA. These people in an equivalent socioeconomic class 500 years ago would be lucky to have a non dirt floor. There is just more stuff, art production is where it always has been, in the hands of the wealthy. Having more of one thing does not make there any less of the other thing, it just makes it seem diluted.</span></p>
<p><span style="font-family: verdana, helvetica, sans-serif;">The last thing you should consider as you marvel at the art of the enlightenment and renaissance, is that you may not be taking into account the shear increase in the types of available art forms that now exist. You think less "Greek sculpture" instead of more "sculpture in general." You may not see many Greek statues being carved today, but there is a huge amount of new sculpture being done every day that does not fit into the classical category.</span></p>
<p><span style="font-family: verdana, helvetica, sans-serif;">Take it a step further and add in all the jobs that require mastery, everything from app designers, to life coaches, to authors, to people in science and engineering. Most people one hundred years ago worked on farms, in mines and in factories. The amount of jobs requiring a high level of mastery have dramatically increased. Even when you compare the professionals of today against the craftsmen of yesterday, they are in some ways much more sophisticated than a stone mason who perfected replicating the same design over and over. Not only has mass production removed humans from repetitive production, but it has forced us to do what a machine cannot. Still something is lost. How great would it be to be a black smith, if it had not been made economically nonviable. It's a trade off, you don't get to be a black smith but everyone gets to own a set of silverware.</span></p>
<p><span style="font-family: verdana, helvetica, sans-serif;">So? Are there less skilled carpenters, craftsmen that make cars by hand and the like in the world today because of mass production? Absolutely. Are there more artists and knowledge workers in the world than before? Yes. Is there still a majority of people who have no appreciation of these things, who do not understand or value this type of mastery and are, dare I say, uneducated? Yes, but this negative conception of the world needs to be tempered by the understanding that the culture which existed before was actually less artistic, less cultured and less educated than our society of today. There are more 'Da Vinci's in the world than there ever has been, but they are still rare and so it is easy to be nostalgic when 'Da Vinci's are thrown in your face by museums, teachers and history books to the point it forms a distorted picture of the past that leads you to believe that the net effect of technology is that it is diminishing high art and culture. It is true, technology has distracted us, and this is a problem, but these people who have not mastered a craft have always been around. The ditch digger is replaced by the back hoe and now he or she makes subway sandwiches. Independent of whether they have apps or any other technology, the only difference is that those people have a new way to distract themselves. Which some would say is a net benefit.</span></p>
<div><span style="font-family: verdana, helvetica, sans-serif;">So don't be too glum when art or high culture is under threat by the onslaught of new technologies. Instead focus on what you are going to master, what value you are going to bring to the world and what brings you satisfaction.</span></div>
<div><span style="font-family: verdana, helvetica, sans-serif;"><br /></span></div>
<div><span style="font-family: verdana, helvetica, sans-serif;">A great movie about golden age thinking is Woody Allen's <i>Midnight in Paris.</i> </span></div>
<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;"><br /></span></div>
<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;"><br /></span></div>
<div><br /></div>
Parse a date by a specific date format in PHPhttps://boulderappsco.postach.io/post/parse-a-date-by-a-specific-date-format-in-php2017-06-23T20:39:58.891000Z2013-11-22T00:15:32ZNicholas Dunbar<div>In the name of code readability and functionality, if you want to parse a date of a certain format you should do it in a way so that other programmers that look at your code can tell what you were doing. </div>
<div><br/></div>
<div>Here is a way as of PHP >= 5.3.0 to parse a string to a Unix style time stamp in PHP, instead of using <span style="color: rgb(0, 128, 0);">strtotime</span> which has some tricky requirements that are not made clear in the documentation. This way we can explicitly define the format and how the parser interprets it for the reader of the code, instead of relying on implicit functionality of <span style="color: rgb(0, 128, 0);">strtotime</span> and having to make sure the format is what <span style="color: rgb(0, 128, 0);">strtotime</span> requires.</div>
<div><br clear="none"/></div>
<div><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//Parse a string to a date of the following format:</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//d-m-Y H:i:s</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//which is of the format:</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//d = day(01-31)</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//-<br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//m = month(01-12)</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//-<br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//Y = year(2000-2099)</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//<br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//H = hour(00-24)</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//:<br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//i = minutes(00-59)</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//:<br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//s = seconds(00-59)</span></div>
<div><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//example:</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b>$server_date_str='06-10-2013 16:00:09';</b></span></div>
<div><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//PARSE TIME TO UNIX TIME STAMP:</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//you may find the below redundant. We are using</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//createFromFormat so that we can see we are</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//explicitly parsing the format d-m-Y H:m:s</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//instead of strtotime whose requirements are elusive</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//here we know exactly what format is being parsed</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">//by looking at the code <span style="font-family: courier new,courier,monospace; color: #008000;">DateTime::createFromFormat</span><br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><br clear="none"/></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">try {</span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><br/></span></div>
<div><font color="#008000" face="'courier new', courier, monospace"> //get DateTime object<br clear="none"/></font><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> <b>$server_date_time = DateTime::createFromFormat</b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b> (</b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b> 'd-m-Y H:i:s', </b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b> $server_date_str</b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b> );</b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b><br/></b></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><b> </b>/*VERIFY DATE STRING WAS PARSED*/</span></div>
<div><font color="#008000" face="'courier new', courier, monospace"><b> </b>//check to make sure a DateTime object was returned </font></div>
<div><font color="#008000" face="'courier new', courier, monospace"> //to verify that the date string was of the correct</font></div>
<div><font color="#008000" face="'courier new', courier, monospace"> //format and was thus parsed<br clear="none"/></font><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> if ( !($server_date_time instanceof DateTime) ) {</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> $error_array = DateTime::getLastErrors();</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> throw new Exception( implode(" - ",$error_array['errors']) );</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> }</span></div>
<div><font color="#008000" face="'courier new', courier, monospace"><br/></font></div>
<div><font color="#008000" face="'courier new', courier, monospace"> //convert DateTime object to Unix time stamp<br clear="none"/></font><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> <b>$server_time = strtotime($server_date_time->format('d-m-Y H:i:s'));</b></span></div>
<div><font color="#008000" face="'courier new', courier, monospace"> <b>echo "Unix time stamp : $server_time\n";</b><br clear="none"/></font><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">} catch (Exception $e){</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> echo $e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile();</span><br clear="none"/>
<span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">}</span><br clear="none"/>
<font color="#008000" face="'courier new', courier, monospace"><br/></font></div>
<div><br clear="none"/></div>
Exclude images from a Linux findhttps://boulderappsco.postach.io/post/exclude-images-from-a-linux-find2017-06-23T20:40:01.564000Z2013-11-19T19:58:57ZNicholas Dunbar<div><span style="font-family: helvetica,arial,sans-serif; color: rgb(0, 128, 0); font-size: 12pt;"><span style="color: rgb(0, 0, 0);">If you want to find all files in a sub directory and you don't want images to show up in the list here is a way to do it:<br clear="none"/></span></span></div>
<div><span style="font-family: helvetica,arial,sans-serif; color: rgb(0, 128, 0); font-size: 12pt;"><span style="color: rgb(0, 0, 0);"><br clear="none"/></span></span></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"><span style="font-family: courier new,courier,monospace; color: rgb(0, 0, 0);"><span style="font-size: 8pt;">[local_username@localhost /]$</span></span> find /some/dir/ -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.gif' \) -prune -o -exec stat --format='%n' {} \;</span></div>
<div><br clear="none"/></div>
<div>Explanation:<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">find</span> - the command Linux uses to find files recursively <br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">/some/dir/ </span>- the directory you want to search</div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> -type f</span> - search only files of type f that is to say search files and not directories<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">\(</span> - start list of options to skip<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">-name '*.png'</span> - match any file of the form *.png (example.png)<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">-o</span> - or<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">-name '*.jpg' -o -name '*.jpeg' -o -name '*.gif'</span> - other common image extensions <br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">\)</span> - end list of options to skip<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">-prune</span> - remove anything that meets the previous options<br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">-o -exec </span>- run the following example command against the file<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">stat --format='%n'</span> - get the files name (this is here just as an example, you could put what ever options you want here)<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">{} </span>- the file name from find<br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">\;</span> - marks the end of the -exec option<br clear="none"/></div>
Remove files present in one directory but not the otherhttps://boulderappsco.postach.io/post/remove-files-present-in-one-directory-but-not-the-other2017-06-23T20:39:52.742000Z2013-11-01T01:53:04ZNicholas Dunbar<div><pre xml:space="preserve"><code><span style="font-family: helvetica,arial,sans-serif;">This will remove all the files and folders that are in /dir1 but not in /dir2</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace;"><span style="font-size: 8pt;">[local_username@localhost /]$</span></span> <span style="color: rgb(0, 128, 0);"><span style="font-family: courier new,courier,monospace;">diff -rq /dir1 /dir2 | grep -E "^Only in /dir1*" | sed -n 's/://p' | awk '{print $3"/"$4}' | xargs -I {} rm -r {}</span><br clear="none"/><span style="color: rgb(0, 0, 0); font-family: helvetica,arial,sans-serif;"><br clear="none"/>Explanation:<br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">diff</span> - command that does comparisons in Linux<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">-rq</span> - recursively search (r) and output only files that differ (q)<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">/dir1</span> - first directory to compare<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">/dir2</span> - compare dir1 to dir2<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">grep -E "^Only in /dir1*"</span> - shows files that are in dir1 but not in dir2<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">sed -n 's/://p' </span>- sed is the stream editor command and in this case it removes ':' from the output as diff adds a : at the end of each file found<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">awk</span> - a program used for formatting data<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">'{</span> - start awk language<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">print</span> - awk print command<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">$3</span> - third column of the output from sed which is the directory<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">/ </span>- add in a forward slash<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">$4</span> - forth column of the output from sed which is the file if there is one<br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">}' </span>- end awk language interpretation<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">xargs -I {} </span>- define variable to represent the path and file name as {}<br clear="none"/><span style="color: rgb(0, 128, 0); font-family: courier new,courier,monospace;">rm -r {} </span>- remove the file that is only in dir1/ and any folders and there children that are only in dir1/<br clear="none"/><br clear="none"/><br clear="none"/></span><br clear="none"/></span></code></pre></div>
On create a new file, why are the execute permissions not set to my umaskhttps://boulderappsco.postach.io/post/on-create-a-new-file-why-are-the-execute-permissions-not-set-to-my-umask2017-06-23T20:40:02.006000Z2013-10-22T22:55:22ZNicholas Dunbar<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">Why newly created files do not have the execute permissions set by default, even though I set default permissions to have execute with the command <span style="color: #008000; font-family: courier new,courier,monospace;">umask</span>?</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: arial,helvetica,sans-serif; font-size: x-large;">Example (reason why below):</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">Lets say you have run the following command:</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace;"><span style="font-size: 8pt;">[local_username@localhost /]$</span> <span style="color: #008000; font-size: 12pt;">umask 0002</span></span></div>
<div><br clear="none"/></div>
<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">This sets your default permissions to 775 otherwise known as rwxrwxr-x</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">Then you run the following commands:</span></div>
<div><br clear="none"/></div>
<div><div><span style="font-family: courier new,courier,monospace;"><span style="font-size: 8pt;">[local_username@localhost /]$</span> <span style="color: #008000; font-size: 12pt;">touch new_file</span></span></div>
<div><span style="font-family: courier new,courier,monospace;"><span style="font-size: 8pt;">[local_username@localhost /]$</span> <span style="color: #008000; font-size: 12pt;">ls -d -l new_file</span></span></div>
<div><span style="font-family: courier new,courier,monospace; font-size: 8pt;">-rw-rw-r--. 1 local_username local_username 0 Oct 22 16:34 new_file</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;"><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">The question is...why does the new file have the permission <span style="font-family: courier new,courier,monospace;">-rw-rw-r--</span> when it's <span style="font-family: courier new,courier,monospace; color: #008000;">umask</span> is set to <span style="font-family: courier new,courier,monospace;">rwxrwxr-x</span>? </span></span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;"><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;"><span style="font-family: arial,helvetica,sans-serif; font-size: x-large;">Reason:</span></span></span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;"><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">The reason for this is it is common for most systems to set an override that makes is so all new files do not have the execute privileges. This is to keep an intruder from being able to write and execute their own scripts without the rights to <span style="font-family: courier new,courier,monospace; color: #008000;">chmod u+x new_file</span>. </span><br clear="none"/></span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;"><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">Source: <a shape="rect" href="http://en.wikipedia.org/wiki/Umask#Exceptions" target="_blank">http://en.wikipedia.org/wiki/Umask#Exceptions</a></span></span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;"><span style="font-family: helvetica,arial,sans-serif; font-size: 12pt;">However on these systems you should be able to do <span style="color: #008000; font-family: courier new,courier,monospace;">mkdir</span> and the execute permissions will default to your umask.</span></span></div></div>Installing SSH and SCP in ANT 1.8.2 OSXhttps://boulderappsco.postach.io/post/installing-ssh-and-scp-in-ant-1-8-2-osx2017-06-23T20:40:04.193000Z2013-09-03T21:35:52ZNicholas Dunbar<div>Download jsch-0.1.50.jar at <a shape="rect" href="http://sourceforge.net/projects/jsch/files/jsch/0.1.50/jsch-0.1.50.zip/download" target="_blank">http://sourceforge.net/projects/jsch/files/jsch/0.1.50/jsch-0.1.50.zip/download</a> </div>
<div><br clear="none"/></div>
<div>Download ant-jsch-1.8.2.jar at <a shape="rect" href="http://mvnrepository.com/artifact/org.apache.ant/ant-jsch/1.8.2" target="_blank">http://mvnrepository.com/artifact/org.apache.ant/ant-jsch/1.8.2</a><br clear="none"/></div>
<div><br clear="none"/></div>
<div>jsch-0.1.50.jar - contains the supporting classes for ssh and scp.</div>
<div>ant-jsch-1.8.2.jar - contains the tasks definitions for ANT.</div>
<div><br clear="none"/></div>
<div>They are not the same thing even though both have the word jsch in it.</div>
<div><br clear="none"/></div>
<div>Open a command line terminal</div>
<div>Type at the prompt </div>
<div><br clear="none"/></div>
<div><span style="font-size: 8pt;">machine:direct usrname:</span> <span style="color: #008000; font-family: 'courier new', courier, monospace;">ant -diagnostics | grep ant.library.dir</span></div>
<div><br clear="none"/></div>
<div>You should get something like the following:</div>
<div>ant.library.dir : /usr/share/ant/lib</div>
<div><br clear="none"/></div>
<div>Move the jar files into the directory <span>/usr/share/ant/lib</span></div>
<div><br clear="none"/></div>
<div><span>Start using the ssh and scp tasks.</span></div>
List all users on a serverhttps://boulderappsco.postach.io/post/list-all-users-on-a-server2017-06-23T20:39:53.556000Z2013-08-22T18:00:39ZNicholas Dunbar<div>User information is stored in the /etc/passwd file</div>
<div><br clear="none"/></div>
<div><div><br clear="none"/></div><span style="font-family: courier new,courier,monospace; color: #23921c;"><span style="font-family: courier new,courier,monospace; color: #000000; font-size: 8pt;">[username@localhost /]$ </span>awk -F":" '{ print $1 }' /etc/passwd</span></div><div><br clear="none"/></div>
<div>If you want to print out the user name and UID:</div>
<div><br clear="none"/></div>
<div><span style="color: #23921c;"><span style="font-family: courier new,courier,monospace;"><span style="font-family: courier new,courier,monospace; color: #23921c; font-size: 8pt;"><span style="font-family: courier new,courier,monospace; color: #000000;">[username@localhost /]$ </span></span>awk -F":" '{ print $1 "\t\t"$3 }' /etc/passwd | column</span> -t</span></div>
<div><br clear="none"/>Here is the break down of how the command works:</div>
<div><br clear="none"/></div>
<div><span style="color: #23921c; font-family: courier new,courier,monospace;">awk</span> - a string formatting utility</div>
<div><span style="color: #23921c; font-family: courier new,courier,monospace;">-F":"</span> - split each line by ':' </div>
<div> A line in the /etc/passwd like the following gets fed into awk:</div>
<div> root:x:0:0:root:/root:/bin/bash</div>
<div> So we want to separate it based on each semicolon.</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">'{ </span>- start awk language interpreter</div>
<div> awk is its own language it has an large amount of features</div>
<div><span style="color: #23921c; font-family: courier new,courier,monospace;">print </span>- awk command to print</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">$1</span> - print column 1 which is the user name</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">"\t\t"</span> - print two tabs</div>
<div><span style="color: #23921c; font-family: courier new,courier,monospace;">$3</span> - print column 3 which is the UID</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">}'</span> - end awk language interpreter</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">/etc/passwd</span> - the file that awk will process</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">| </span>- send output to the next command</div>
<div><span style="font-family: courier new,courier,monospace; color: #23921c;">column</span> - the column command formats data so that they are visually aligned</div>
<div><span style="color: #23921c; font-family: courier new,courier,monospace;">-t </span>- identify columns based on white space.</div>
Pad a string with a character | Fill in empty space with repeating character in bashhttps://boulderappsco.postach.io/post/pad-a-string-with-a-character-fill-in-empty-space-with-repeating-character-in-bash2017-06-23T20:40:02.503000Z2013-06-25T18:41:27ZNicholas Dunbar<div>If you want to pad a string so that the string is always the same length, but if a string that is smaller than the required length is used the excess space is filled with a defined character so that the string maintains the correct spacing.</div>
<div><br clear="none"/></div>
<div>For example you want</div>
<div><span style="color: #008000; font-family: courier new,courier;">FF </span></div>
<div>to be</div>
<div><span style="color: #008000; font-family: courier new,courier;">00000000FF </span></div>
<div>or</div>
<div><span style="color: #008000; font-family: courier new,courier;">FFF </span></div>
<div>to be</div>
<div><span style="font-family: courier new,courier; color: #008000;">0000000FFF</span></div>
<div><br clear="none"/></div>
<div>It is always ten long.</div>
<div><br clear="none"/></div>
<div>Here is a custom function to help you achieve this.</div>
<div><br clear="none"/></div>
<div>Example:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">$char="0";</span></div>
<div><span style="color: #008000; font-family: courier new,courier;">$pad_length=10;</span></div>
<div><span style="color: #008000; font-family: courier new,courier;">$str_to_pad="FF";</span></div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">pad_str $char <span style="color: #008000; font-family: courier new,courier;">$pad_length</span> $str_to_pad;</span></div>
<div><br clear="none"/></div>
<div>Output:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">00000000FF</span></div>
<div><br clear="none"/></div>
<div>The custom function:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">function pad_str(){</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> pad=$(printf '%0.1s' $1{1..60})</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> padlength=$2;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> string1=$3;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> </span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> printf '%*.*s' 0 $((padlength - ${#string1} )) "$pad";</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> printf '%s' "$string1";</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">}</span><br clear="none"/><br clear="none"/></div>
<div>Note: This will only pad up to a length of 60 if you want to pad more then you will need to change this value ( {1..60} ) to a greater value, like {1...1000}</div>
<div><br clear="none"/></div>
<div>Source: http://stackoverflow.com/questions/4409399/padding-characters-in-printf</div>
Change Apache/XAMPP user that runs PHP | Fix PHP exec permission issueshttps://boulderappsco.postach.io/post/change-apache-xampp-user-that-runs-php-fix-php-exec-permission-issues2017-06-23T20:39:57.113000Z2013-06-11T23:13:54ZNicholas Dunbar<div>When you install XAMPP the user name is set to 'nobody' by default in the Apache configuration (httpd.conf). If you are are suffering from <span>permissions</span> issues in PHP then the problem might by the ownership of the files by Linux and the user under which Apache is running are different. Be very careful of which user you use make sure that user does not have any <span>permissions</span> that could allow an external user to hijack one of your PHP processes in order to run special commands on your server, using the exec command.</div>
<div><br clear="none"/></div>
<div>1.) Find httpd.conf (usually under /etc/httpd.conf)</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">cd /etc/</span></div>
<div><br clear="none"/></div>
<div>2.) Edit httod.conf </div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;">vi httpd.conf</span></div>
<div><br clear="none"/></div>
<div>3.) Find the following lines:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">User nobody</span><br clear="none"/><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">Group nogroup</span></div>
<div><br clear="none"/></div>
<div>4.) Change the following lines to...</div>
<div><span style="font-size: large; font-family: courier new,courier; color: #008000;"><strong> </strong></span></div>
<div><div><span style="font-family: courier new,courier; color: #008000;">User yourusername</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">Group nogroup</span></div>
<div><br clear="none"/></div>
<div>5.) yourusername is a place holder for your linux user name under which you want to run PHP.</div>
<div>6.) Save httpd.conf</div>
<div>7.) Set the ownership of all the files in htdocs to yourusername:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">cd /directory/of/htdocs </span></div>
<div><span style="color: #008000; font-family: courier new,courier;">find . -exec chown yourusername:yourusername {} \;</span></div>
<div><span style="color: #008000; font-family: courier new,courier;">cd ..</span></div>
<div><span style="color: #008000; font-family: courier new,courier;"><span style="font-family: courier new,courier;">chown yourusername:yourusername</span> htdocs</span></div></div><div><br clear="none"/></div>
Back up pear configuration | restore pear configuration | transfer pear configurationhttps://boulderappsco.postach.io/post/back-up-pear-configuration-restore-pear-configuration-transfer-pear-configuration2017-06-23T20:40:02.937000Z2013-05-20T18:35:52ZNicholas Dunbar<div>Here is how to back up your pear configuration to a script so that it can later be transferred to another installation of pear or so that you can restore a previous configuration.</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: large;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: medium;"><span style="color: #000000;"><span style="font-family: courier new,courier; font-size: medium;"><span style="font-family: times new roman,times; font-size: x-large;"><strong><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><strong>user@localhost the_directory></strong></span></strong></span></span></span></span></strong></span> </strong>pear config-show | grep -viE "^([=]+|.{0,3}configuration\s+\(.*\).+)$" | grep -viE "((user\s|system\s)configuration)" | awk '{print substr($0,32)}' | grep -E ".+" | awk '{if (match(substr($0,index($0,$2)),"<not set>") == 0)print "pear config-set " $1 " " substr($0,index($0,$2)) ";";else print "pear config-set " $1 " \x27\x27;"}' > pear_config_bkup.sh</span></div>
<div><br clear="none"/></div>
<div>to restore the configuration just run the generated script as follows:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;"><span style="color: #008000; font-family: courier new,courier;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: large;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: medium;"><span style="color: #000000;"><span style="font-family: courier new,courier; font-size: medium;"><span style="font-family: times new roman,times; font-size: x-large;"><strong><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><strong>user@localhost the_directory></strong></span></strong></span></span></span></span></strong></span></strong></span> sh pear_config_bkup.sh</span></div>
<div><br clear="none"/></div>
<div>note: you might have to adjust the "32" in "print substr($0,32)" based on your version of pear.</div>
<div><br clear="none"/></div>
<div>lets explain what we are doing step by step:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">pear config-show</span> - this prints out the current configuration (see <a shape="rect" href="http://pear.php.net/manual/en/guide.users.commandline.config.php" target="_blank">http://pear.php.net/manual/en/guide.users.commandline.config.php</a> ) It will print something out like the following:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">Configuration (channel pear.php.net):</span><br clear="none"/><span style="font-family: courier new,courier;">=====================================</span><br clear="none"/><span style="font-family: courier new,courier;">Auto-discover new Channels auto_discover <not set></span><br clear="none"/><span style="font-family: courier new,courier;">Default Channel default_channel pear.php.net</span><br clear="none"/><span style="font-family: courier new,courier;">HTTP Proxy Server Address http_proxy <not set></span><br clear="none"/><span style="font-family: courier new,courier;">PEAR server [DEPRECATED] master_server pear.php.net</span><br clear="none"/><span style="font-family: courier new,courier;">Default Channel Mirror preferred_mirror pear.php.net</span></div>
<div>Etc. Etc. Etc...</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">grep -viE "^([=]+|.{0,3}configuration\s+\(.*\).+)$"</span> - remove lines at the top that look like either of the following:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">Configuration (channel pear.php.net):</span><br clear="none"/><span style="font-family: courier new,courier;">=====================================</span><br clear="none"/><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">grep -viE "((user\s|system\s)configuration)"</span> - remove lines that look like the following:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">User Configuration File Filename /home/ndunbar/.pearrc</span><br clear="none"/><span style="font-family: courier new,courier;">System Configuration File Filename /etc/pear.conf</span><br clear="none"/><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">awk '{print substr($0,32)}'</span> - remove the first column, this column on most versions is 32 characters wide, but in some cases this will not be true and you will have to decrease or increase this number. For example:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">PEAR Installer cache directory cache_dir /var/cache/php-pear</span></div>
<div><br clear="none"/></div>
<div>This command will leave you with the following output:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">cache_dir /var/cache/php-pear</span></div>
<div><br clear="none"/></div>
<div>In other words it will output just the configuration key value pair. <br clear="none"/><br clear="none"/><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">grep -E ".+"</span> - remove empty strings. After the previous command has been run there will be cases where the descriptions for a key will run over on to a second line in the first column like the following:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">PEAR Installer cache directory cache_dir /var/cache/php-pear</span><br clear="none"/><span style="font-family: courier new,courier;">PEAR configuration file cfg_dir /etc/pear</span><br clear="none"/><span style="font-family: courier new,courier;">directory</span><br clear="none"/><span style="font-family: courier new,courier;">PEAR data directory data_dir /usr/share/pear/data</span><br clear="none"/><span style="font-family: courier new,courier;">PEAR Installer download download_dir /tmp/pear/download</span><br clear="none"/><span style="font-family: courier new,courier;">directory</span><br clear="none"/><span style="font-family: courier new,courier;">PHP CLI/CGI binary php_bin /usr/bin/php</span></div>
<div><br clear="none"/>See "PEAR Installer download directory" and "PEAR configuration file directory" for examples. These lines will end up being empty after the first 32 characters are cut off from the prior command. The resulting output is a key value pair on each line where there are key value pairs and no lines where there are none.</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">awk '{if (match(substr($0,index($0,$2)),"<not set>") == 0)</span> - If we can't find any evidence that the key is not set then do the next awk command. This part of the command gets the sub-string from the first index of the second column ($2) to the end and checks to see if the string "<not set>" does not appear.</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">print "pear config-set " $1 " " substr($0,index($0,$2)) ";";</span> - If they key is set to a value then write the command to set that configuration key with that value. Example:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">pear config-set default_channel pear.php.net;</span></div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">else print "pear config-set " $1 " \x27\x27;"}'</span> - If the key has no value then set it's value to nothing. the \x27 are code for the single quote character. This will print a command like the following:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">pear config-set http_proxy '';</span></div>
<div><br clear="none"/></div>
<div>So with our awk command we basically have done the following:</div>
<div>taken a line like this</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">HTTP Proxy Server Address http_proxy <not set></span></div>
<div><br clear="none"/>and converted it to a line like this</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier;">pear config-set http_proxy '';</span></div>
<div><br clear="none"/></div>
<div>The reason for the double single quotes is because when this line runs in the generated shell script it will set the key to nothing (source: <a shape="rect" href="http://pear.php.net/manual/en/guide.users.commandline.config.php#7590" target="_blank">http://pear.php.net/manual/en/guide.users.commandline.config.php#7590</a> under user comments from ashnazg, thanks ashnazg).</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">> pear_config_bkup.sh</span> - Write values to script so that they can be restored or transferred to another pear configuration later.</div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
Get all versions of PHP installed on the systemhttps://boulderappsco.postach.io/post/get-all-versions-of-php-installed-on-the-system2017-06-23T20:39:55.348000Z2013-05-15T01:15:33ZNicholas Dunbar<div><span style="font-family: arial,helvetica,sans-serif;">This will list (all) the PHP(s) on the system and then grep the version number(s).</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;">whereis php | tr ' ' '\n' | grep -E "^/.*?php$" | xargs -I {} echo {} -v | sh |& grep -v "is a"</span><br clear="none"/>
<br clear="none"/></div>
Strange error in PHP | number zero (0) evaluates to true against a string in PHPhttps://boulderappsco.postach.io/post/strange-error-in-php-number-zero-0-evaluates-to-true-against-a-string-in-php2017-06-23T20:39:57.523000Z2013-03-27T20:27:20ZNicholas Dunbar<div><span style="font-size: x-large;">Reproducing the error (see solution below):</span></div>
<div>Take a look at this weird error below:</div>
<div><br clear="none"/></div>
<div><span style="color: rgb(0, 128, 0); font-size: 14pt;">$int_zero="reset";</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">$str_zero="0";</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">$int_zero=intval($str_zero);</span><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">if ($int_zero == "reset"){ <br clear="none"/></span></div>
<div style="margin-left: 30px;"><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">echo "equals reset\n";</span></div>
<div><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">} else {</span></div>
<div style="margin-left: 30px;"><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">echo "equals something else\n";</span></div>
<div><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">}</span></div>
<div><br clear="none"/><span style="color: rgb(0, 128, 0); font-size: 14pt;">echo $int_zero."\n";</span></div>
<div><br clear="none"/></div>
<div>Output:</div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;">equals reset</span></div>
<div><span style="font-family: courier new,courier; color: #008000;">0</span></div>
<div><br clear="none"/></div>
<div>So strange n'est pas? This should not happen. At first, I thought it had to do with the intval or floatval functions since I tried both and got the same result. But it turns out this is wrong. For example I created a function that returns 0 without the use of intval when it is a zero.</div>
<div><br clear="none"/></div>
<div><span style="font-size: x-large;">Replace intval, still an error</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">function intval_v2($str){</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> $str = trim($str);</span><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> if (preg_match("/^(\s|0|\.)*$/",$str)){</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> return 0;</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> } else {</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> return intval($str);</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);"> }</span><br clear="none"/><br clear="none"/><span style="font-family: courier new,courier,monospace; color: rgb(0, 128, 0);">}</span></div>
<div><br clear="none"/></div>
<div>When I use this function instead of intval, I still get the same bad result. In fact if I do the following I get the same result.</div>
<div><br clear="none"/></div>
<div><span style="font-size: x-large;">Don't use intval...still..bzzzz...wrong</span></div>
<div><br clear="none"/></div>
<div><span style="font-family: courier new,courier; color: #008000;">$int_zero=0;</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">$some_num=3;</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">$some_num = $int_zero;</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">if ($some_num == "whatever it does not matter"){</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;"> echo "equals whatever it does not matter\n";</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">} else {</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;"> echo "equals a number\n";</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">}</span><br clear="none"/><span style="font-family: courier new,courier; color: #008000;">echo "$some_num\n";</span></div>
<div><br clear="none"/></div>
<div>Output:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">equals whatever it does not matter</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">0</span><br clear="none"/><br clear="none"/></div>
<div><span style="font-size: x-large;">The work around...</span></div>
<div><br clear="none"/></div>
<div><br clear="none"/></div>
<div>The way around it is to use a strict comparison known as the triple equal operator (===) the problem is the zero (0) not the intval or floatval functions.</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">$int_zero=0;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">$some_num=3;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">$some_num = $int_zero;</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">if ($some_num === "whatever it does not matter"){</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> echo "equals whatever it does not matter\n";</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">} else {</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;"> echo "equals a number\n";</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">}</span><br clear="none"/><span style="color: #008000; font-family: courier new,courier;">echo "$some_num\n";</span></div>
<div><br clear="none"/></div>
<div>Output:</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier;">equals a number</span></div>
<div><span style="color: #008000; font-family: courier new,courier;">0</span></div>
<div><span style="color: #000000; font-family: arial,helvetica,sans-serif; font-size: medium;"><span style="font-size: small;">PHP has lost major cool points from me th</span><span style="font-size: small;">is day.</span></span></div>
Design your code to be grep'ed or searchedhttps://boulderappsco.postach.io/post/design-your-code-to-be-greped-or-searched2017-06-23T20:40:03.511000Z2013-03-14T20:38:42ZNicholas Dunbar<div>Seriously. So that future developers who work with your code can reverse engineer your code. </div>
<div><br/></div>
<div>1.) Store code in flat text files</div>
<div><br/></div>
<div>When you are looking for a variable you want to refactor you should not have to find it in some code stored in a database and if you do it should made very clear where all the code is stored and how to get to it. </div>
<div><br/></div>
<div>2.) Make sure that you use file extensions</div>
<div><br/></div>
<div>For example don't write a PHP command line script and then name the file without the .php extension so that when you run it, it looks like a Unix command. I know you can use #!/bin/php at the top of your PHP file so that it will run at the command line prompt with ./somephpscriptwithnoextension <font color="#FF1F17">but don't do this</font>. A future programmer might grep for *.php files. When you write code and name variables ask your self, "would this be easy to find with a string search?" </div>
<div><br/></div>
<div>Please for all our sakes!</div>
Make new files take on the same group as the directory | Ubuntu | Linuxhttps://boulderappsco.postach.io/post/make-new-files-take-on-the-same-group-as-the-directory-ubuntu-linux2017-06-23T20:40:03.340000Z2013-03-12T22:54:41ZNicholas Dunbar
<div>
<div><br/></div>
<div>If you want all files created in a directory to carry a certain default group owner, change the files immediate folder to use the permission bit "s"</div>
<div><br clear="none"/></div>
<div><strong><span style="color: #008000; font-family: courier new,courier; font-size: large;"><strong><span style="color: #008000; font-family: courier new,courier; font-size: medium;"><span style="color: #000000;"><span style="font-family: courier new,courier; font-size: medium;"><span style="font-family: times new roman,times; font-size: x-large;"><strong><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><strong>user@localhost the_directory></strong></span></strong></span></span></span></span></strong> chmod g+s your_dir_name</span></strong></div>
<div><br clear="none"/></div>
<div>This will make it so, if you cd your_dir_name and you then create <span>a</span> new file it will automatically have the same <span>group</span> as the group owner in the parent directory your_dir_name.</div>
<div><br clear="none"/></div>
<div>Let's take <span>a</span> closer look at what is going on here.</div>
<div><br clear="none"/></div>
<div><span style="color: #008000; font-family: courier new,courier; font-size: large;">chmod</span> - this is <span>a</span> command that changes the permissions of <span>a</span> file</div>
<div><span style="color: #008000; font-family: courier new,courier; font-size: large;">g+s</span> - this adds the permission bit "s" on to your folder for the <span>group</span> (g). "s" is <span>a</span> special permission bit (the set id bit) that says any new files under this directory will have the same <span>group</span> ownership that the folder which contains it has.</div>
<div><span style="color: #008000; font-family: courier new,courier; font-size: large;">your_dir_name</span> - replace this with the directory name you want to set up with the new file permissions</div>
<div><br/></div>
<div>Tested on Ubuntu Linux. On a Mac the default is to take on the ownership of the directory, so in that case the permission bit would not matter. </div>
<div><br clear="none"/></div>
</div>