Monday, July 22, 2013
OSX Dock magnification/menus/hot corners not working!
Moved the Wireless mouse/keyboard dongle to the other input on the KVM switch. Problem solved!
Wednesday, May 1, 2013
Zebra Printer Problems
I arrived at this script.
It works on a Gx420t with Factory defaults. It’s not exactly what I was aiming for,
but it’s pretty close.
^XA
^LT10 //Label
Top. Sets the top edge of the label (determined
experimentally)
^PW200 //Print Width. Sets the left edge of the label (determined
experimentally)
^LH10,15 //Label
Home. Offsets from left and top edges from
which fields positions are relative to.
^PR2 //Print Rate. 2 is the slowest setting
^MD30 //Media Darkness. Set to maximum darkness
^BY1 //Set the barcode bar-width to 1 dot … If
not set, the previous setting will be used.
The factory default is too big for this label.
^FO0,0^BCN,26,N,N,N,N^FD%s^FS
^FO0,30^A0,20,17^FD%s^FS
^FO0,50^A0,20,17^FD%s^FS
^XZ
Some key insights:
a)
the gx420t has lower resolution(203dpi) than the
gx430t (300dpi), so all positions and sizes needed to be determined again. Multiplying everything by 2/3 was insufficient…I
had to do it experimentally.
b)
Some settings persist between print jobs (examples:
^PW, ^BY). The printer maintains state
between jobs. Not all of the printers
state is visible through the web interface.
It’s important to develop and test your scripts against a printer with factory
default settings. To restore factory
defaults you must apply ‘restore default settings’ AND then power-cycle the
printer.
Thursday, April 25, 2013
I was looking for quick way to 'encrypt' an integer into another integer. I tried a few things:
I tried using Java Ciphers with 32-bit block size ( ex. "DES/OFB32/NoPadding")
I couldn't make Ciphers work. The encrypted integers that were returned were not sufficiently distributed in the integer domain....probably because I was doing something wrong... I didn't have time to figure it out. See java code snippet at the bottom of the message.
I found this code snipped implementing a Fiestel Network
http://wiki.postgresql.org/wiki/Pseudo_encrypt
I made the changes recommended by J. Jancar to implement this:
-- Function: pseudo_encrypt(integer)
-- DROP FUNCTION pseudo_encrypt(integer);
CREATE OR REPLACE FUNCTION pseudo_encrypt(value integer)
RETURNS integer AS
$BODY$
DECLARE
l1 int;
l2 int;
r1 int;
r2 int;
i int:=0;
BEGIN
l1:= (VALUE >> 16) & 65535;
r1:= VALUE & 65535;
WHILE i < 3 LOOP
l2 := r1;
r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
l1 := l2;
r1 := r2;
i := i + 1;
END LOOP;
RETURN ((r1 << 16) + l1);
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE STRICT
COST 100;
ALTER FUNCTION pseudo_encrypt(integer)
OWNER TO thyroid;
Tested x = f(f(x)) on 4 million positive integers, works.
Translated to Java:
public static int pseudoEncrypt(int data) {
int l1 = (data >> 16) & 65535;
int r1 = data & 65535;
for (int i = 0; i<3 br="" i=""> int l2 = r1;
//Don't change these constants until and unless we understand this better
int r2 = l1 ^ (int)((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767);
l1 = l2;
r1 = r2;
}
return (r1 << 16) + l1;
}3>
Tested x = f(f(x))Java integers. Works.
@Test
public void test3() throws Exception {
for (int i=0; i<1000 br="" i="">
final String keyString = "YKQ22ROLDQYU6===";
final String ivParametersString = "TOSHCB6GRJBLC===";
byte[] data = ByteBuffer.allocate(4).putInt(i).array();
SecretKey secretKey = new SecretKeySpec(base32.decode(keyString), "DES");
final IvParameterSpec iv = new IvParameterSpec(base32.decode(ivParametersString));
Cipher cipher = Cipher.getInstance("DES/OFB32/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
//IvParameterSpec iv = new IvParameterSpec(base32.decode(ivDataString));
byte[] encryptedData = cipher.doFinal(data);
int intEncrypted = ByteBuffer.wrap(encryptedData).getInt();
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
byte[] decryptedData = cipher.doFinal(encryptedData);
Assert.assertArrayEquals(data, decryptedData);
int intDecrypted = ByteBuffer.wrap(decryptedData).getInt();
System.out.printf("%s %s %s%n", i, intEncrypted, intDecrypted);
}
}1000>
13 762798568 13
14 762798571 14
15 762798570 15
16 762798581 16
17 762798580 17
18 762798583 18
19 762798582 19
20 762798577 20
21 762798576 21
22 762798579 22
23 762798578 23 <--i be="" br="" distributed="" encrypted="" expecting="" in="" integer="" space.="" the="" to="" values="" was="" widely="">--i>
I tried using Java Ciphers with 32-bit block size ( ex. "DES/OFB32/NoPadding")
I couldn't make Ciphers work. The encrypted integers that were returned were not sufficiently distributed in the integer domain....probably because I was doing something wrong... I didn't have time to figure it out. See java code snippet at the bottom of the message.
I found this code snipped implementing a Fiestel Network
http://wiki.postgresql.org/wiki/Pseudo_encrypt
I made the changes recommended by J. Jancar to implement this:
-- Function: pseudo_encrypt(integer)
-- DROP FUNCTION pseudo_encrypt(integer);
CREATE OR REPLACE FUNCTION pseudo_encrypt(value integer)
RETURNS integer AS
$BODY$
DECLARE
l1 int;
l2 int;
r1 int;
r2 int;
i int:=0;
BEGIN
l1:= (VALUE >> 16) & 65535;
r1:= VALUE & 65535;
WHILE i < 3 LOOP
l2 := r1;
r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
l1 := l2;
r1 := r2;
i := i + 1;
END LOOP;
RETURN ((r1 << 16) + l1);
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE STRICT
COST 100;
ALTER FUNCTION pseudo_encrypt(integer)
OWNER TO thyroid;
Tested x = f(f(x)) on 4 million positive integers, works.
Translated to Java:
public static int pseudoEncrypt(int data) {
int l1 = (data >> 16) & 65535;
int r1 = data & 65535;
for (int i = 0; i<3 br="" i=""> int l2 = r1;
//Don't change these constants until and unless we understand this better
int r2 = l1 ^ (int)((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767);
l1 = l2;
r1 = r2;
}
return (r1 << 16) + l1;
}3>
Tested x = f(f(x))Java integers. Works.
@Test
public void test3() throws Exception {
for (int i=0; i<1000 br="" i="">
final String keyString = "YKQ22ROLDQYU6===";
final String ivParametersString = "TOSHCB6GRJBLC===";
byte[] data = ByteBuffer.allocate(4).putInt(i).array();
SecretKey secretKey = new SecretKeySpec(base32.decode(keyString), "DES");
final IvParameterSpec iv = new IvParameterSpec(base32.decode(ivParametersString));
Cipher cipher = Cipher.getInstance("DES/OFB32/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
//IvParameterSpec iv = new IvParameterSpec(base32.decode(ivDataString));
byte[] encryptedData = cipher.doFinal(data);
int intEncrypted = ByteBuffer.wrap(encryptedData).getInt();
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
byte[] decryptedData = cipher.doFinal(encryptedData);
Assert.assertArrayEquals(data, decryptedData);
int intDecrypted = ByteBuffer.wrap(decryptedData).getInt();
System.out.printf("%s %s %s%n", i, intEncrypted, intDecrypted);
}
}1000>
13 762798568 13
14 762798571 14
15 762798570 15
16 762798581 16
17 762798580 17
18 762798583 18
19 762798582 19
20 762798577 20
21 762798576 21
22 762798579 22
23 762798578 23 <--i be="" br="" distributed="" encrypted="" expecting="" in="" integer="" space.="" the="" to="" values="" was="" widely="">--i>
Monday, April 8, 2013
Remote Debugging Tomcat running as a Windows Service
To enable Remote Debugging in Tomcat7 running as a service
1. Run %TOMCAT_HOME/bin/Tomcat7w.exe
( ex. C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin)
2. Java Tab
3. Add these to 'Java Options' before the -D options
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
4. Apply
5. Start Tomcat service
Thursday, March 14, 2013
Upgrading Postgres 9.1 to 9.2
Had PostgreSQL 9.1 installed
Installed PostgreSQL 9.2, disint application and data directory.
Changed postgres instance password in pgAdminIII, then couldn't log in.
Set connection Method to trust in pg_hba.conf
Connect with pgAdmin
Right Click Login Roles >> postgres
Uncheck Account expires
Tried to run pg_upgrade:
C:\Users\mmuller\PostgreSQL>"C:\Program Files\PostgreSQL\9.2\bin\pg_upgrade.exe" --old-datadir data --new-datadir 9.2/data --old-bindir "C:\Program Files\PostgreSQL\9.1\bin" --new-bindir "C:\Program Files\PostgreSQL\9.2\bin" -u postgres
Many problems. Solutions:
Grant Firewall permission to PostgreSQL server (windows control panel)
Set connection Method to trust in pg_hba.conf (both old and new data directories)
Be sure to set -u postgres
Installed PostgreSQL 9.2, disint application and data directory.
Changed postgres instance password in pgAdminIII, then couldn't log in.
Set connection Method to trust in pg_hba.conf
Connect with pgAdmin
Right Click Login Roles >> postgres
Uncheck Account expires
Tried to run pg_upgrade:
C:\Users\mmuller\PostgreSQL>"C:\Program Files\PostgreSQL\9.2\bin\pg_upgrade.exe" --old-datadir data --new-datadir 9.2/data --old-bindir "C:\Program Files\PostgreSQL\9.1\bin" --new-bindir "C:\Program Files\PostgreSQL\9.2\bin" -u postgres
Many problems. Solutions:
Grant Firewall permission to PostgreSQL server (windows control panel)
Set connection Method to trust in pg_hba.conf (both old and new data directories)
Be sure to set -u postgres
Sunday, March 3, 2013
HP D4620 Reinstallation
My HP D4620 crapped out on me this weekend. Returned it to Costco. Bought another.
First mistake, tried to set up with my old Ink Cartridges. No,no. Printer wouldn't set up with them, nor would it let me take out the old cartridges. I don't know what I did to finally get them out and install the new ones.
Did a few other things to get Scan To Computer working:
Update Firmware
http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=219&lc=en&cc=us&dlc=en&sw_lang=&product=5191646#N332
HP Officejet Full Feature Software and Drivers - Mac OS X 10.6, OS X 10.7, OS X 10.8
http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=mp-107215-1&cc=us&dlc=en&lc=en&os=219&product=5191646&sw_lang=
Now Scan To Computer Works.
First mistake, tried to set up with my old Ink Cartridges. No,no. Printer wouldn't set up with them, nor would it let me take out the old cartridges. I don't know what I did to finally get them out and install the new ones.
Did a few other things to get Scan To Computer working:
Update Firmware
http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=219&lc=en&cc=us&dlc=en&sw_lang=&product=5191646#N332
HP Officejet Full Feature Software and Drivers - Mac OS X 10.6, OS X 10.7, OS X 10.8
http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=mp-107215-1&cc=us&dlc=en&lc=en&os=219&product=5191646&sw_lang=
Now Scan To Computer Works.
Wednesday, February 27, 2013
Eclipselink Postgres GeneratedValue strategy=Identity not compatible with HistoryPolicy
I wanted to do this in my Eclipselink/Postgres application:
TABLE
-------------------
ID SERIAL NOT NULL
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column
private long id;
This produces exceptions upon persist(). I think it's this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347539
Solution is to do this
TABLE
-------------------
ID SERIAL NOT NULL
It's important to know that SERIAL implicitly creates a sequence named TABLE_ID_SEQ. So I can use strategy=SEQUENCE to use it:
@Id
@SequenceGenerator(name="table_id_seq", allocationSize=1)
@GeneratedValue(strategy=SEQUENCE, generator="table_id_seq")
@Column
private long id;
It's important to include allocationSize=1, otherwise Eclipselink will start using nextval() - 50 as the next ID... producing Primary Key conflicts upon persist.
TABLE
-------------------
ID SERIAL NOT NULL
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column
private long id;
This produces exceptions upon persist(). I think it's this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347539
Solution is to do this
TABLE
-------------------
ID SERIAL NOT NULL
It's important to know that SERIAL implicitly creates a sequence named TABLE_ID_SEQ. So I can use strategy=SEQUENCE to use it:
@Id
@SequenceGenerator(name="table_id_seq", allocationSize=1)
@GeneratedValue(strategy=SEQUENCE, generator="table_id_seq")
@Column
private long id;
It's important to include allocationSize=1, otherwise Eclipselink will start using nextval() - 50 as the next ID... producing Primary Key conflicts upon persist.
Subscribe to:
Posts (Atom)