<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Kedare's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 22:52:05 GMT</pubDate>
    <description>DZone Snippets: Kedare's Code Snippets</description>
    <item>
      <title>Simple base64 encoder/decoder in command-line with D</title>
      <link>http://snippets.dzone.com/posts/show/5780</link>
      <description>&lt;code&gt;&lt;br /&gt;import std.base64;&lt;br /&gt;import std.stdio;&lt;br /&gt;import std.array;&lt;br /&gt;void main(string[] args)&lt;br /&gt; {&lt;br /&gt;	try {&lt;br /&gt;		string action = args[1];&lt;br /&gt;		string source = args[2];&lt;br /&gt;		string dest;&lt;br /&gt;		if(action == "encode") {&lt;br /&gt;			dest = std.base64.encode(source);&lt;br /&gt;		}&lt;br /&gt;		else if(action == "decode") {&lt;br /&gt;			dest = std.base64.decode(source);&lt;br /&gt;		}&lt;br /&gt;		else {&lt;br /&gt;			writeln("Error: Bad Action");&lt;br /&gt;			return 1;&lt;br /&gt;		}&lt;br /&gt;		writeln(dest);&lt;br /&gt;		return 0;&lt;br /&gt;	}&lt;br /&gt;	catch(ArrayBoundsError err) {&lt;br /&gt;		writefln("Error: Missing argument (%s action string)", args[0]);&lt;br /&gt;	}&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Usage: b64utils [de/en]code mytext</description>
      <pubDate>Thu, 17 Jul 2008 19:16:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5780</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
    <item>
      <title>Unix Console Styler</title>
      <link>http://snippets.dzone.com/posts/show/4822</link>
      <description>This modue can be used to apply many style on Unix* terminals&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Unix Console Style&lt;br /&gt;# You can use this module to apply a style on the terminal&lt;br /&gt;#&lt;br /&gt;# &lt;b&gt;DON'T WORK ON WINDOWS (Only on *nix Terminal)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;module UnixConsoleStyler&lt;br /&gt;  class StyleNotFoundException &lt; Exception; end&lt;br /&gt;  &lt;br /&gt;  # Availables Styles&lt;br /&gt;  STYLE = {&lt;br /&gt;      :default    =&gt;    "\033[0m",&lt;br /&gt;    	# styles&lt;br /&gt;    	:bold       =&gt;    "\033[1m",&lt;br /&gt;    	:underline  =&gt;    "\033[4m",&lt;br /&gt;    	:blink      =&gt;    "\033[5m",&lt;br /&gt;    	:reverse    =&gt;    "\033[7m",&lt;br /&gt;    	:concealed  =&gt;    "\033[8m",&lt;br /&gt;    	# font colors&lt;br /&gt;    	:black      =&gt;    "\033[30m", &lt;br /&gt;    	:red        =&gt;    "\033[31m",&lt;br /&gt;    	:green      =&gt;    "\033[32m",&lt;br /&gt;    	:yellow     =&gt;    "\033[33m",&lt;br /&gt;    	:blue       =&gt;    "\033[34m",&lt;br /&gt;    	:magenta    =&gt;    "\033[35m",&lt;br /&gt;    	:cyan       =&gt;    "\033[36m",&lt;br /&gt;    	:white      =&gt;    "\033[37m",&lt;br /&gt;    	# background colors&lt;br /&gt;    	:on_black   =&gt;    "\033[40m", &lt;br /&gt;    	:on_red     =&gt;    "\033[41m",&lt;br /&gt;    	:on_green   =&gt;    "\033[42m",&lt;br /&gt;    	:on_yellow  =&gt;    "\033[43m",&lt;br /&gt;    	:on_blue    =&gt;    "\033[44m",&lt;br /&gt;    	:on_magenta =&gt;    "\033[45m",&lt;br /&gt;    	:on_cyan    =&gt;    "\033[46m",&lt;br /&gt;    	:on_white   =&gt;    "\033[47m" }&lt;br /&gt;  &lt;br /&gt;  # Methods to use if you want to apply a style&lt;br /&gt;  def UnixConsoleStyler::apply_style(style)&lt;br /&gt;    if STYLE.has_key? style&lt;br /&gt;      STDOUT.write STYLE[style]&lt;br /&gt;    else&lt;br /&gt;      raise StyleNotFoundException, "Style #{style} not found"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 Nov 2007 19:21:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4822</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
    <item>
      <title>Gradient in an applet</title>
      <link>http://snippets.dzone.com/posts/show/3903</link>
      <description>&lt;code&gt;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.applet.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class JavaAppDe extends JApplet {&lt;br /&gt;	&lt;br /&gt;    public void init() {&lt;br /&gt;    }&lt;br /&gt;	&lt;br /&gt;    public void paint (Graphics g) {&lt;br /&gt;        super.paint(g);&lt;br /&gt;	int base = 0;&lt;br /&gt;	while(base&lt;255) {&lt;br /&gt;		g.setColor(new Color(base,base,base));&lt;br /&gt;		g.drawLine(0,base,255,base);&lt;br /&gt;		base++;&lt;br /&gt;	}&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 25 Apr 2007 20:54:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3903</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
    <item>
      <title>Avatar Resizer</title>
      <link>http://snippets.dzone.com/posts/show/3860</link>
      <description>I go on a lot of Bulletin Board, every has its own limits of size for the avatars, instead of the resize manually I created a script which does it for me with RMagick&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;require "RMagick"&lt;br /&gt;$SIZES = [80 , 100 , 110 , 128]&lt;br /&gt;&lt;br /&gt;if !ARGV[0]&lt;br /&gt;  puts "Usage: mk_avatars.rb SourceAvatarPath"&lt;br /&gt;  exit&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;image = Magick::Image.read(ARGV[0]).first&lt;br /&gt;$SIZES.each do |sz|&lt;br /&gt;  puts "Generating Avatar : #{sz}"&lt;br /&gt;  out = image.thumbnail(sz,sz)&lt;br /&gt;  file = "out_#{sz}.#{image.format}"&lt;br /&gt;  out.write(file)&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 23 Apr 2007 17:13:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3860</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
  </channel>
</rss>
