Category: Programming

Turbolinks and Vue: JavaScript Managing Memory

Turbolinks is a tool that is included in Rails project that renders each page change without actually changing the page in the browser. This helps to make the browsing feel faster and causes less flashing as you change pages.

Vue.js is a JavaScript framework to help build a user interface.

You could probably just impelment them together and forget about it, but I had a concern about memory leaks. As you move from page to page, normal page browsing destroys anything you’ve stored in a variable in JavaScript, but Turbolinks prevents the browser from deleting any variables (and usually, if you load a library such as jQuery, destroying and parsing the code takes time that is unnecessary). There is a lack of documentation on how to make these 2 libraries work together, and most places just say “disable Turbolinks in order to use Vue.js”.

I’m not sure that this is complete, but it’s probably better than nothing. My JavaScript solution is as follows:

(function() {
  var vue;
  $(document).on("turbolinks:visit", function() {
    // If the instance exists, destroy
    if (vue) vue.$destroy();
    vue = null;
  });

  $(document).on("turbolinks:load", function() {
    el = $("#myVue");
    if (el.length === 0) return
    vue = new Vue({
      el: el[0],
      data: {},
      // ...
  });
})();

If you have comments or tips on how to improve this, leave me a comment!

Posted in Programming | Leave a comment

Hex Slideshow

This is totally and utterly pointless, but in case someone finds it interesting besides me, here’s a page I like to call “Hex Show”.

Hex Show

It does have some pretty neat JavaScript, and it’s not too complicated. Feel free to use, modify, or steal the code, just put my name on it if there’s enough of it to matter.

Posted in Programming, Technology | Tagged | Comments Off on Hex Slideshow

A Website in BASIC

So I’ve gotten a lot done on this website. It feels like I’m hammering nails with my head. What a tool! At least there’s a little bit of information on it out there, but google doesn’t like to actually find stuff about BASIC when I type in the word (it’s basically stuff about simplicity 🙂 ).

Posted in Programming | Tagged , | Comments Off on A Website in BASIC

Programming a Website in BASIC

I’ve been given a new job, to program a website in BASIC. I feel like I’ve gone from using a motorized screw driver back to using a manual one by hand. I don’t even know BASIC, but I’m trying to learn it. Besides that, I have to learn exactly how http works, because I’ll have to do it all manually. It will be good to learn, but it’s going to be a challenge without the shortcuts that PHP has to offer. No cookie, or session handling. The only security will have to be coded by me.

I’m building a website that was previously in COBOL, and even though I don’t think moving to BASIC is a very big step, the previous program only allowed Internet Explorer.

Posted in Programming | Tagged , | Comments Off on Programming a Website in BASIC

Crack Project

So I’ve got a 3rd project now. I’m supposed to see if I can break passwords from a computer. This will be used to email them and let them know that they need to change their passwords. It involves cracking, but for a good cause. It’s going to be a fun project if I can figure out the best way to do so.

Posted in Programming | 2 Comments

Server Move

I’ve moved all of my websites to new servers. It’s on the same service provider, but I’m paying less and I have more bandwidth and space. It was a good 4 hours or so to move everything over, but I only lack one server because of a feature difference, which I hope to get resolved soon.

If anyone else is in the market, I really like site5, and I think they do a good job with their servers and the support.

Posted in Programming | Comments Off on Server Move

Presenter Slowed, Other Work to Continue

There’s just not enough time in my nights. Time in the day is unproductive for me, because I just don’t have the motivation to do it before 5:00. Then I finally get my shows watched and turn off the TV, and I start something up, and before I know it, I’ve messed up tomorrow morning because I stayed up too late working on a project.

I actually got some presentation editing set up in presenter, even though it doesn’t do everything completely right, and it’s not as pretty as I’d like it to be. That’s all I’ve had time to do.

I’ve been working on another project for my job that involves producing graphs in PHP using Image_Graph, but it still says its very much in a testing stage, but it seems to do fine so far. It’s going to replace a current program, but make it a little nicer looking so that it’s worth paying for. I’ve actually gotten it pretty far along in half a weeks time, at least as far as the basic graphing goes. I just wish my boss would answer my emails…

One of these days I’m going to put a few Christian articles having to do with some things I’ve been coming to an understanding with. But, just like with everything else, it’s putting the time in to do it.

Posted in Programming | Tagged | Comments Off on Presenter Slowed, Other Work to Continue

A Good Progammer

I found a pretty good article on the signs of a good programmer. I fit a lot of those, except maybe being in a variety of technologies. I pretty much stick to things that have good documentation (such as programming languages). I do as little hacking as possible, and by hacking I mean things that were never meant to be used. I started programming long before I learned it in a classroom setting though, and it’s never been “just a day job,” in fact, over 75% of the programming I’ve done has been unpaid.

In other news, I should be getting a new video card tomorrow… my computer will be complete, mwahaha (An evil laugh felt appropriate, I don’t know why). I also got talked into adding B-vitamins and calcium into my daily regimen by the guy at GNC, and I haven’t seen anything but positive results.

Posted in Programming | Tagged | Comments Off on A Good Progammer

Linux: Setuid/Setgid

This is good information that all Linux developers should know: setuid/setgid.

Posted in Programming | Tagged | Comments Off on Linux: Setuid/Setgid

Python: Facing the Snake

I’m starting to get back into the learning mode, and the first thing on the TODO list, Python. It’s a lot more impressive than PHP. It’s easier to learn the basics, and yet has so much power from what I’ve seen so far. Maybe I can make use of it in my new job.

I started to try to make a script to print all possible words that a phone number can make, but I found that it was harder than it seemed. I could do it, but I estimate there to be around 729 possible combinations (9 digits, 3 combinations on most keys… if my math is right, that’s 9³), I didn’t want to fool with it and any potential memory problems.

I hate to say it, but I’m ready to go back to school… Well, mainly work. I’m running out of games to take up my time.

Update: Ok, I was wrong. The possible combinations is 39, which turns out to be 19683 possibilities, where each key has 3 letters. That does not account for the letters q or z, or the number 1 or 0. I actually came up with a program that’s only 15 lines long using recursion. For anyone who cares, I’ll put the code here:

#! /usr/bin/env python

digits=['_', '.,!?', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz']

def phoneLetters(phone, r=''):
  if(len(phone) == 0):
    print r
    return
  if(phone[0] >= '0' and phone[0] <= '9'):
    for i in digits[int(phone[0])]:
      phoneLetters(phone[1:], r + i)
  else:
    phoneLetters(phone[1:], r)

import sys
if(sys.argv[1]):
  phoneLetters(sys.argv[1])
Posted in Programming | Tagged | Comments Off on Python: Facing the Snake