Using ZeroClipboard on your website to Copy text to your clipboard

I've used ZeroClipboard in a couple of my projects which allows me to provide a clickable object which copies text of my choosing into the client's clipboard.  I usually use copy and paste keyboard shortcuts, but there are times when it's nice and more effecient to have a click-to-copy button.

Get the files

wget https://github.com/zeroclipboard/ZeroClipboard/raw/master/ZeroClipboard.swf
wget https://raw.github.com/zeroclipboard/ZeroClipboard/master/ZeroClipboard.min.js

Import the files and create the basic structure

<html>
<head>
</head>
<body>
<div id="copy_initiator">Click me to Copy Text!</div>
<script src="ZeroClipboard.min.js" type="text/javascript"></script>
<script type="text/javascript">

var clip = new ZeroClipboard( document.getElementById("copy_initiator"), {
  moviePath: "ZeroClipboard.swf"
} );

//this event happens upon initiating the copy 
clip.on( 'dataRequested', function ( client, args ) {
    clip.setText( "whatever text you want");
} );

//this event happens upon the copy finishing
clip.on( 'complete', function(client, args) {
  alert("Copied text to clipboard: " + args.text );
} );

</script>
</body>
</html>

And thats it! You should have a div with the id of "copy_initiator" which when clicked will copy "whatever text you want" into the client's clipboard. Using the setText() method you can use any source of text including anything object attributes, html, text via javascript or jquery.

Tagged as copy , js ZeroClipboard
Written by Andrew Konkol on August 1st, 2013 | 0 Comments

Screwing around with JS/CC parser generator

I've been looking to add more functionality to hatch templates and after searching I feel like I've finally gotten somewhere. Js/cc is a parser and lexical analyzer generator. I can use it to create my own "language" and utilize javascript for processing.

Although I've benefited from parsers and lexers for a long time, I've never had to think about how they work. Writing my own token definitions and working through processing patterns has been challenging but ultimately exciting and rewarding. Testing what I write in js/cc is like re-living my first "hello world" in basic. I have a feeling its going to be a long process to develop a fully-cooked (hell, "half-cooked") implementation for all the functionality I want in hatch templates but I've got to start somewhere.

Below is a super simple implementation of an "echo" function and a substring() function which can be tested with the following:

  • say 'some string'
  • say 'some string'.substr(1,3);
/~ creating an echo parsing function 
   to test enter: say 'some_string';
   substring function: say 'some_string'.substr(first_num, last_num);
~/

!     ' |\r|\n|\t|//[^\n]*\n'
      "SAY"
      ';'
      '[A-Za-z_][A-Za-z0-9_]*' Identifier
      '\'([^\']|\'\')*\'' String [* %match = %match.substr( 1,%match.length - 2 );
                                    %match = %match.replace( /''/g,"\'" );
                                 *]
      '\.substr' SUBSTR
      '\(' 
      '\)' 
      '[0-9]+' NUM 
      '\,'  
      ;


##
Program:     Program Stmt     
             |
             ;


Stmt_List:   Stmt_List Stmt
             |
             ;

Stmt:        SAY String ';'    [* alert(%2); *]
             | SAY String SUBSTR '(' NUM ',' NUM ')' ';'   [* alert(%2.substring(%5,%7)); *]
             ;

Tagged as hatch , js/cc jscc , lexer parser
Written by Andrew Konkol on July 16th, 2013 | 0 Comments

Fridge Coffee For a Fiend

I've been drinking iced coffee every morning for the last 6 years, to say I am a morning zombie iced coffee fiend is an understatement.  I drink it so regularly that I know how to translate my order in all the chain languages (iced venti unsweetened iced coffee).  So when my friend Ian told be about his cold brew fridge coffee method, I was ready to hunt down the best process, for the best cup of iced coffee.  I tried Ian's method of mixing water and grounds and leaving it in a jar overnight and found that straining the grounds is a pain in the ass.  I decided to sew a muslin bag to hold my grounds (like a coffee tea bag) and had mixed results.

  • If I pack the muslin bag too tight, that water doesn't penetrate all the grounds.
  • My ratio of grounds to water needed to be double (48 tablespoons for 1 gallon)
  • Although delicious, cafe du monde is a strange coffee to cold brew with (super weak)
  • So far, cafe bustello is king for this method

 

Tagged as cafe bustello , fridge coffee
Written by Andrew Konkol on September 10th, 2012 | 0 Comments

Craft and Function

Finding a pair of jeans that fit well and look well has been a challenge of mine for quite some time.  Easily put, I am big & tall, not one or the other, both.  Through the years I've worn poor fitting Old Navy Jeans and then got a breath of fresh air when Indi Denim came out.  It now seems that Indi Denim is out of business, therefore I can't find good looking custom jeans over the internet.  A couple of weeks ago I visited Nashville and went to Imogene + Willie.  Great looking denim jeans weren't the only thing I vibed with, it was the ethics, principles, and passion that goes into everything they produce.  Easily put: they make simple, high quality products.

 

When I buy something, I want it to be awesome and last forever.  The checklist I use to buy tools pretty much gets applied to everything I purchase.

  • How long will this last me?
  • Does it function well?
  • How flexible is it?

 

From an early age I've followed a pretty simple mantra "if it doesn't exist, make it."  I've got a big frame, off-the-rack shirts suck.  I decided to go all in and start making button-down shirts, creating patterns from already owned shirts.  I spent a few nights doing this and finally got to the point of sewing a shirt together when I realized that I cut the patterns wrong, 3 yards of fabric out the window.  This kind of trial and error went on for a few weeks and I ultimately got frustrated and gave up.

 

A couple of months ago I took a leather workshop class at the Chicago School of Shoe Making which re-sparked some motivation to create garments again.  Since my trip to Imogene + Willie I took a sewing class at The Needle Shop in Chicago, my girlfriend has also taken up leather purse making.  Through all these events I've been inspired to make jeans.  But this time it's going to be different! I'm going to go slow, steady, and focus.

 

Whenever I get into a project I do a shit-ton of research, planning, and come up with a bill of materials.  I torture myself with details because I want to know EVERYTHING about EVERYTHING.  So here is what I have found out so far:

  • I should use raw indigo selvedge denim (because its traditional and cool) Cone Mills produces this in USA
  • I should use rivets
  • I should get awesome top stitching thread
  • I should make a pant block pattern (sloper)
  • I should then  make a pattern using the sloper as the baseline and adjust based on how I want the jeans to fit
  • I want to do a button fly

 

References:

 

I ordered a copy of the book mentioned above and the next step is creating a pant sloper for my measurements, then creating a mock-up pair of jeans using cheaper material and seeing how they fit.

Tagged as jeans , sewing
Written by Andrew Konkol on August 20th, 2012 | 0 Comments

Spur Network Configuration Manager Has been released

Spur is a web based network configuration manager. It allows you to ssh or telnet to any device and run commands through a web front-end.The results of these commands are stored and can be diff'd. You can get alerted whenever a diff is found.  You can extend Spur's capabilities by writing your own modules for different types of equipment.

Spur is comprised of:

  • Tratto - a ssh/telenet framework built on-top of pexpect
  • A custom written "cron" which allows you to create and schedule repetitive tasks
  • Customized django skin
  • Cisco syntax highlighting via syntax-highlighter
This project is in beta, I need people to help test.  I have not used spur to configure any network equipment as of right now.

System Requirements

  • Python
  • Django 1.4+
  • Sqlite, mysql, posgres
which python # find out if you have python installed

#django installation
wget http://www.djangoproject.com/m/releases/1.4/Django-1.4.1.tar.gz
tar xzvf Django-1.4.1.tar.gz
cd Django-1.4.1
sudo python setup.py install

#sqlite installation
sudo apt-get install sqlite

Python Requirements

  • django-mptt
  • pexpect
  • croniter
  • pytz
sudo easy_install django-mptt
sudo easy_install pexpect
sudo easy_install croniter
sudo easy_install pytz

Spur Installation

git clone https://github.com/akonkol/spur.git
cd spur

#edit this file to match your enviornment
vi spur/spur_settings.py 

#create an admin user
python manage.py syncdb 
python manage.py runserver 0.0.0.0:8000

#Create a cronjob for spur
crontab -e
* * * * * /path/to/spur/manage.py spur-cron

Browse to spur http://your_fqdn_or_ip:8000

Thanks for checking it out.

Tagged as cisco , django ncm , spur tratto
Written by Andrew Konkol on August 2nd, 2012 | 1 Comments