May 27, 2011 0

Useful crap and things I can never remember.

By in Nothing, SysAdmin

How to get random hex values (color values) in python:
rand_color = "#" + str(random.randint(0, 16777215))

Creating a database user and giving them full rights to a database:

GRANT ALL PRIVILEGES
ON db_name.*
TO 'db_user'@'localhost'
IDENTIFIED BY 'the_password!'
WITH GRANT OPTION;

May 23, 2011 0

“Live, Dynamic” text generation with jQuery using replace()

By in Uncategorized

When you manage a bunch of similar devices, it’s nice to generate consistent configurations quickly. I built a config file generator last week which you embed the variables in plain text such as “$hostname.” Then a web form is generated based off those embedded variables and a find and replace is done on the config text. The app has been up and running for a about a week and has made our deployment of new gear at sites a snap.

I wanted to add some candy to it. So now what happens is when you enter values into form fields the configuration file is generated in “real time” in front of your own two eyeballs.

live_edit_1

live_edit_2

live_edit_3

View Demo

April 18, 2011 1

Banners.

By in Fun, Nothing, SysAdmin

I’ve always put ascii art in the motd of my servers, and I think im going to keep track of them now.


                    ,dPYb,
                    IP'`Yb
                    I8  8I
                    I8  8'
  ,ggg,     ,gggg,  I8 dPgg,     ,ggggg,
 i8" "8i   dP"  "Yb I8dP" "8I   dP"  "Y8ggg
 I8, ,8I  i8'       I8P    I8  i8'    ,8I
 `YbadP' ,d8,_    _,d8     I8,,d8,   ,d8'
888P"Y888P""Y8888PP88P     `Y8P"Y8888P"

                                  $$\
                                  \__|
$$\   $$\  $$$$$$$\  $$$$$$\      $$\  $$$$$$\
$$ |  $$ |$$  _____|$$  __$$\     $$ |$$  __$$\
$$ |  $$ |\$$$$$$\  $$$$$$$$ |    $$ |$$ /  $$ |
$$ |  $$ | \____$$\ $$   ____|    $$ |$$ |  $$ |
\$$$$$$  |$$$$$$$  |\$$$$$$$\ $$\ $$ |\$$$$$$  |
 \______/ \_______/  \_______|\__|\__| \______/

 .d888                  888                    888
d88P"                   888                    888
888                     888                    888
888888 .d88b.  888  888 888888 888d888 .d88b.  888888
888   d88""88b `Y8bd8P' 888    888P"  d88""88b 888
888   888  888   X88K   888    888    888  888 888
888   Y88..88P .d8""8b. Y88b.  888    Y88..88P Y88b.
888    "Y88P"  888  888  "Y888 888     "Y88P"   "Y888 
April 7, 2011 1

Installing Avon MT-CC-86-ANO Hand Grips on a Triumph Speedmaster

By in Fun

Avon Grips

avon_metric_grips

Triumph Speedmaster

triumph_speedmaster

Steps

1. Un-screw hex screws from handlebar endcaps

1_remove_hand_grip_screws

2. Un-screw hex screws from switchgear assembly

2_Remove_switch_gear_cover

3. Twist throttle grip down and remove throttle cables

3_Remove_throttle_cable

4. Un-screw hex screws from master cylinder mounting clamp, be careful to hold onto the assembly

4_Remove_master_cylinder_mounting_bracket

5. Find the “B” throttle gear included with the Avon kit and super glue it to the throttle body according to Avon’s recommendations

5_Glue_B

6. Slide the new throttle side grip over the handlebar, position the right hand assembly where you want it and re-mount the master cylinder mounting clamp by screwing in the two hex screws

7. Twist the throttle grip down and insert the ball ends of the throttle cables into the new throttle cap (the thing you glued onto the new grip)

8. Screw on the switchgear plate

9. Use a razor blade and cut through the clutch side grip and remove the grip

10. Clean off the clutch side handlebar and apply the tape supplied with the Avon kit making sure that there is a 1/4″ hanging over the end of the bar, and remove the backing of the tape so that there is tape adhesive exposed

11. Apply adhesive solution provided in kit evenly over the tape area and inside the clutch grip

12. Slide clutch grip over tape and solution, making sure the ‘Avon’ logo position matches the same ‘Avon’ logo on the throttle side

13. Check to make sure the clutch is securely glued on after 2 hours, once dry screw in the 4 surrounding screws on the grip

14. Adjust the opening cable and closing cable so that the throttle grip returns to idle after accelerating and letting go

14_Remove_throttle_cable

March 11, 2011 0

Rediculously Easy Jquery Accordion

By in Fun

We wanted to write a small “about us” blurb on the website without having to create a whole page. This content would probably be less than 3 paragraphs, but it’s an important 3 paragraphs. I figured out a way to “slide” a div section up over the main content. Jquery makes this super easy, here is a demo and if you want to make some elements a bit “shinier” here is the code:

<html>
<head>
  <script src="jquery.min.js" type="text/javascript"></script>

  <script type="text/javascript">
  $(document).ready(function($) {
         $('#content').hide();
         $('#about_section').click(function(){
                 $('#main_content').slideToggle();
                 $(this).parent().next().slideDown();
                  $('#content').toggle();
                 return false;
         });
  });
</script>
</head>

<body style="width:600px; ">
<div id="main_content">
        <h1>Mary Had a Little Lamb</h1>
        <p>Mary had a little lamb,
           little lamb, little lamb,
           Mary had a little lamb,
           whose fleece was white as snow.
           And everywhere that Mary went,
           Mary went, Mary went,
           and everywhere that Mary went,
           the lamb was sure to go.
        </p>
</div>

  <div id="about_section"  style="background-color:#E7E7DA; border-top:thick solid #000;">

     <b><a href="#">About this story</a></b>
     <div id="content">
        <p>"Mary Had a Little Lamb" is an English language nursery rhyme of nineteenth-century American origin. </p>
     </div>

  </div><!-- colophon -->

</body>
</html>

View Demo