We're growing into something new. Read More
AzizLight

Aziz Light  Pro


Discussion

Features for an agile development tool

Hi everybody, Today, I decided that my final project will be an alternative, minimalistic agile project management tool, a-la JIRA but without the bloat. As I won't have a lot of time to develop the project, I need to set to myself some goals. What kind of essential features does an Agile project management tool have?

Shitty: a shitty admin template

Hi everybody, I am a backend rails developer and I needed an admin template for a project I am working on. I went on ThemeForest and I couldn't find anything remotely reasonable. Everything is either awful or overly complicated. So I (tried) to create what I was looking for; I didn't quite reach my goal because my design skills are just ... well look at the title of the post... I designed the elements that I use in my admin area on my project, but I'm sure I missed a lot of elements (ones that I will use ultimately). On the technical side, I tried to be as reasonable as I could, I didn't use tables (obviously!), I used HTML5, CSS3 (via SASS + Compass). The whole source code is available to download on Github here I am looking for feedback, but please don't be too harsh, it's my birthday today...

Discussion

TaskList: code tags parser and lister

Yesterday I created a post on Forrst with a link to a gist. That code was ugly! I hate ugly code. So I rewrote the whole thing into a class, made it a gem and created a Github repository for it. The link is in the title. I took advantage of the situation and added a couple features and something every project should have: a README file. Let me first define the term "code tag" (definition taken from the README file): Code tasks are constructive comments in the code that are prefixed with a tag. I gave examples of code tags in my previous post, but for the sake of clarity I will post examples again here: # TODO: Add some documentation to that method! # OPTIMIZE: Reduce the amount of SQL queries in that block of code. # BUG: If x equals 0 the division fails miserably Raw Code » As for the features that I added: More code tags supported. Some files and folders are ignored (e.g. images, log folder, sqlite database, etc.), reducing the time it takes to parse a list of files. Multiple files/folders can be parsed at the same time (an example of that is below). I tried to add a spinner or a progress bar to the command line script but I did not manage to get any satisfactory result; I do not want to install any libraries, I don't like dependencies. You can install the gem with the following command: % [sudo] gem install task-list Raw Code » And you can use it with the help of the tl command: % tl [folder_name] % tl . % tl rails/ % tl app/ spec/ Raw Code » Voila :) I just wanted to share my progress with you.

Discussion

Tasks list from the command line

When you press Control+Shift+T in Textmate, you get a list of tasks. Tasks are usually comments of the following form: # TODO: This is a task # FIXME: This code needs to be fixed # NOTE: This is a constructive note! Raw Code » Until now, there was no way to get a list of tasks in a project from the command-line, so I hacked a little script together last night. It takes as input a file or folder. If a file was passed the file is parsed; if a folder was passed all the files under that folder are parsed, recursively. Then a list of Tasks appears. If you use tasks you should try it. The question is, why would you use this if you use Textmate. The answer: you wouldn't. I use this because I use MacVim; and a lot of editors don't do tasks lists. So how to use it? First you need to be on a Unix-based system. The script might work on windows but I haven't tested it. Then you need to put that script in a file under your $PATH. I have put mine in $HOME/bin. Then you just type tl . or tl [foldername] (or whatever you called the script). Now my question is: How can I improve the script. The code is pretty disgusting, but then I hacked it together as I mentioned before. Please feel free to give me some advice on how to make the script better looking and/or more efficient (faster) or feel free to fork the gist on github. If you have any questions, leave a comment :)

Discussion

jQuery + Sinatra: Number Converter

I took this whole week to create a number converter. The idea is that the converter takes a number, detects its base (binary, decimal or hexadecimal) and convert it to binary, decimal and hexadecimal. I am an ubber-noob when it comes to javascript/jQuery but I managed to do some stuff. Namely, some validation and some ajax. The whole javascript side can really be improved though, and that's where I mostly need your help. On the server-side, I used pure ruby to create the converter and Sinatra to create an API. It's the first time I create an API so don't be too harsh please, I did my best. The API can really be improved too. I kept the design as simple as possible. I intend to add some colors to the whole thing too but I haven't had the time to do it yet, all my energy went into the API and jQuery. All in all, it would be great if I could get some general feedback, but I am particularly interested in jQuery advice and how to improve the site in general using javascript. Also the whole codebase can be found here: github.com/AzizLight/number_converter/

#!/usr/bin/env ruby

# NOTES:
#   - This script only works on OS X.
#   - This script was only tested with ruby 1.9.2 using
#     the aaronh-chronic gem. If the chronic gem is used
#     instead, this script will not work (unless the chronic
#     gem was updated to work with ruby 1.9.2).

require 'rubygems'
require 'chronic'
require 'rainbow'

# ------------------------------------------------------------------------------
actions = ["sleep","wake","poweron","shutdown","wakeorpoweron"]
this_is_a_test = false # Set this to true if you just want to test the script
add_colors_to_output = true

action_color = :green
time_color   = :red
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
def list_actions(actions = ["sleep","wake","poweron","shutdown","wakeorpoweron"])
  puts "List of valid actions:"
  actions[0] = "\t#{actions[0]}"
  puts actions.join("\n\t")
end

def show_help
  puts "Usage: please [action] [time]"
  puts "Example: please sleep in 3 hours"
  puts "\n"
  list_actions
  puts "\nList of valid times:\n\tAnything that chronic can parse\n\t(See https://github.com/mojombo/chronic)"
end
# ------------------------------------------------------------------------------

if ARGV.empty?
  show_help
  exit
end

action = ARGV[0]
if action == "test" && actions.include?(ARGV[1])
  this_is_a_test = true
  ARGV.shift
  action = ARGV[0]
elsif action == "help"
  # TODO: show help for each valid action
  show_help
  exit
elsif !actions.include?(action)
  puts "Unknow action: #{action}"
  list_actions
  exit
end

time_pieces = ARGV[1..-1]
if time_pieces[0] == "at"
  time_pieces.shift
  time_pieces.unshift("tomorrow at") if Chronic.parse(time_pieces.join(" ")) < Time.now
end
time_string = time_pieces.join(" ")
chronic_time = Chronic.parse(time_string)
time = chronic_time.strftime("%m/%d/%Y %H:%M:%S")

if this_is_a_test
  if add_colors_to_output
    puts "OS X would #{action.color(action_color)} #{time_string.color(time_color)} (#{time.color(time_color)})"
  else
    puts "OS X would #{action} #{time_string} (#{time})"
  end
  
  exit
else
  if add_colors_to_output
    exec("sudo pmset schedule #{action} \"#{time}\" && echo 'OS X will #{action.color(action_color)} #{time_string.color(time_color)} (#{time.color(time_color)})'")
  else
    exec("sudo pmset schedule #{action} \"#{time}\" && echo 'OS X will #{action} #{time_string} (#{time})'")
  end
  
  exit
end

Easily schedule OS X to sleep, shutdown, etc.

Hi everybody, It's been a while since I posted to Forrst. I've been learning Ruby slowly. Yesterday I decided to write a small script to schedule OS X to sleep, shutdow or restart (or anything that pmset can schedule) using the command-line. Using pmset directly is a pain because you have to pass a date in the form "mm/dd/yyyy hh:mm:ss". The script that I wrote uses Tom Preston-Werner's Chronic gem which let's the user type stuff like: please sleep in three hours Raw Code » instead of: pmset schedule sleep "12/02/2010 17:04:09" Raw Code » Oh, and I called the script please. Here are a few other usage examples: please sleep at 3am # Sleep the next time it's 3am please shutdown tonight # Shutdown the same day at 10pm please test sleep in 5 minutes # This will tell you when OS X would sleep if the test keywork wasn't there please help # Show some usage help Raw Code » The script as it is works fine; but it's ugly (or as a ruby newb, I suspect it is). For a script this small that does so little, I can't see how I could put that into a class/module, or if I should... Anyway, any feedback and/or critics is welcomed, but please bear in mind that I'm still new to ruby (and I come from php). The code is also available on GitHub in this gist.

Discussion

AzizLight's Generators at master - GitHub

I have see a lot of different password generators in PHP. There is also a bunch of implementations on Forrst. None of the generators I found produced quality passwords, so I created my own. Generators is more than a password generator. I first created it to be a collection of password tools, including password "enhancers" (ie: Convert some letters to numbers in a plain text password to make it a bit stronger) and password strength testers. Right now, I only created Marvin, a password generator. The most important difference between Marvin and the other password generators is the fact that it takes into account character repetition. With Marvin, you can create a password with the following "features": No character repetition. Every character will only appear once. The same letter in uppercase and lowercase is considered two different characters. The same letter in uppercase and lowercase will not appear one after the other. ie: You will not see "oO" or "Ff" in generated passwords. Characters of the same type will not appear one after the other. ie: You will not see sequences like "12", "ABD", "%^&" in generated passwords. I also created Marvin to make the password generation process as customizable as possible. So if you want to generate passwords with a lot of duplicated characters in it, you can. The reason I post this here is because I really want ANY feedback that I can get. Is this little app completely useless? How can I improve it in any way? etc. The current state of the application is pretty rudimentary, a lot of things can and will be improved in the future, and a lot of features will be added. Creating Generators was also a great learning experience. Note that the contents of index.php is just a bunch of basic implementations. I created Generators so that it can be used as a web app as well as anything else (ie: a CLI Shell script). Here is the contents of index.php as an implementation example, as well as it's output: <?php // ------------------------------------------------------------------------ // Bootstrap // ------------------------------------------------------------------------ // CONSTANTS define( 'APPPATH', dirname( __FILE__ ) . '/' ); define( 'CONFIGFILE', APPPATH . 'config.ini' ); define( 'ALGODIR', APPPATH . 'algorithms/' ); require_once './passwordTool.php'; // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // Implementation examples // ------------------------------------------------------------------------ // Simplest implementation $password = new Marvin(); $p = $password->generate(); var_dump($p); // ------------------------------------------------------------------------ $conf = array( 'length' => 25, 'max_numbers_count' => 2, // <- 2 numbers maximum in each password 'symbols_count' => 0, // <- Disable symbols ); $password1 = new Marvin($conf); $p1a = $password1->generate(); $p1b = $password1->generate(3); // <- generate 3 passwords var_dump($p1a); var_dump($p1b); // ------------------------------------------------------------------------ $password2 = new Marvin(8); // <- set password length to 8 characters $p2 = $password2->generate(10); // <- generate 10 passwords var_dump($p2); var_dump($password2->password); // The password instance variable contains the first password generated var_dump($password2->passwords); // This is the same as $p2 // ------------------------------------------------------------------------ // The implementation in this exemple is not fully functional; there might be a lot of repeting characters... $conf = array( 'chars' => array( '_override_', // <- this chars array will override the default one '1234567890', ), 'length' => 5 ); $password3 = new Marvin($conf); $p3 = $password3->generate(); var_dump($p3); Output: string 'DnUtWgKsOvXqJaPoZlRmSxCzQpAkYrGcMiNhFdLfTu' (length=42) string 'TsL3jO9NiEgSwKzHkQuPoYnXy' (length=25) array 0 => string 'TsL3jO9NiEgSwKzHkQuPoYnXy' (length=25) 1 => string 'ZqGhUbMdXgJpNcYjDtHiFnOsI' (length=25) 2 => string 'OrItHdLuEsPnSqWjFgCyUhJvQ' (length=25) 3 => string 'CeYiGxBaHtJhEmPwVzKuRbQoU' (length=25) array 0 => string 'i$6G#Uq(' (length=8) 1 => string '0)uM6T@7' (length=8) 2 => string '3e#Zy{N!' (length=8) 3 => string '9@z~o)eX' (length=8) 4 => string 'xCl6jG4D' (length=8) 5 => string 'K#DaI2^e' (length=8) 6 => string 'RgJ*iO3b' (length=8) 7 => string 'tU+V4z*m' (length=8) 8 => string 'C)4V2lG$' (length=8) 9 => string 'H%I&Kv3W' (length=8) string 'i$6G#Uq(' (length=8) array 0 => string 'i$6G#Uq(' (length=8) 1 => string '0)uM6T@7' (length=8) 2 => string '3e#Zy{N!' (length=8) 3 => string '9@z~o)eX' (length=8) 4 => string 'xCl6jG4D' (length=8) 5 => string 'K#DaI2^e' (length=8) 6 => string 'RgJ*iO3b' (length=8) 7 => string 'tU+V4z*m' (length=8) 8 => string 'C)4V2lG$' (length=8) 9 => string 'H%I&Kv3W' (length=8) string '47712' (length=5) Note: I use XDebug, hence the output of the var_dump calls