Skip to content

Instantly share code, notes, and snippets.

@kaizawa
kaizawa / TextFieldSample.scala
Created February 11, 2011 16:06
Sample code which listens to Enter key event on TextField
/**
* Sample code which listens to Enter key event on TextField
*/
package myscala
import scala.swing.BorderPanel
import scala.swing.Label
import scala.swing.MainFrame
import scala.swing.SimpleSwingApplication
import scala.swing.TextField
@kaizawa
kaizawa / SwingTest.scala
Created May 20, 2011 15:54
Sample program to see how implicit conversion works.
import javax.swing.SwingUtilities
import scala.swing.Button
import scala.swing.MainFrame
import scala.swing.SimpleSwingApplication
import scala.actors._
import scala.actors.Actor._
object Main extends SimpleSwingApplication {
implicit def functionToRunable[T](x: => T) : Runnable = new Runnable() { def run = x }
# pkg install developer_opensolaris_X
Creating Plan
pkg install: The following pattern(s) did not match any allowable packages. Try
using a different matching pattern, or refreshing publisher information:
developer_opensolaris_X
# pkg install developer/opensolaris/X
Creating Plan /
@kaizawa
kaizawa / build.xml
Created December 16, 2012 07:08
Ant script template
<?xml version="1.0" encoding="utf-8"?>
<project name="MyProject" default="jar" basedir=".">
<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
@kaizawa
kaizawa / gist:6475516
Created September 7, 2013 13:23
Method to get number at certain digit from value.
private getNumberAtDigit(int value, int digit)
{
return (number / (int) Math.pow(10, at - 1)) % 10;
}
@kaizawa
kaizawa / gist:6475542
Created September 7, 2013 13:26
Method to get digit of given number
private int getDigit (int num)
{
Double d = Math.floor(Math.log10(num));
int i = d.intValue() + 1;
return i;
}
@kaizawa
kaizawa / smtp.c
Last active May 26, 2016 08:41
Simple socket program lisning on port 25
#include <strings.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <syslog.h>
#include <libgen.h>
#include <arpa/inet.h>
#include <sys/time.h>