analyze table unrated_usage.ft_unrated_usage_o compute statistics;For one given partition:
analyze table unrated_usage.ft_unrated_usage_o partition(P0) compute statistics;
analyze table unrated_usage.ft_unrated_usage_o compute statistics;For one given partition:
analyze table unrated_usage.ft_unrated_usage_o partition(P0) compute statistics;
SELECT table_name, partition_name, high_value, num_rows FROM SYS.ALL_TAB_PARTITIONS where table_name = 'SMSC_CDR_MT' and num_rows != 0 ORDER BY partition_name;
DECLARE TYPE ARRAY_TYPE IS TABLE OF VARCHAR2(20); mno_array ARRAY_TYPE; mno_id VARCHAR2(20); BEGIN SELECT * BULK COLLECT INTO mno_array FROM (SELECT DT_PARTY.HOST_MNO_ID FROM RESOURCE_DB.HT_SIM_PARTY, RESOURCE_DB.DT_PARTY WHERE HT_SIM_PARTY.PARTY_ID = DT_PARTY.PARTY_ID AND HT_SIM_PARTY.SIM_ID = 'SIM_0000000000000184'); DBMS_OUTPUT.PUT_LINE('count='||mno_array.COUNT); FOR i in 1 .. mno_array.COUNT LOOP DBMS_OUTPUT.PUT_LINE(mno_array(i)); END LOOP; END;
DECLARE TYPE HASH_TYPE IS TABLE OF NUMBER INDEX BY VARCHAR2(20); mno_array HASH_TYPE; mno_id VARCHAR2(20); BEGIN FOR r IN (SELECT DT_PARTY.HOST_MNO_ID FROM RESOURCE_DB.HT_SIM_PARTY, RESOURCE_DB.DT_PARTY WHERE HT_SIM_PARTY.PARTY_ID = DT_PARTY.PARTY_ID AND HT_SIM_PARTY.SIM_ID = 'SIM_0000000000000184') LOOP MNO_ARRAY(R.HOST_MNO_ID) := 1; END LOOP; IF mno_array.EXISTS('BT') THEN DBMS_OUTPUT.PUT_LINE('BT=YES'); END IF; END;
SELECT table_name,
partition_name,
high_value,
num_rows
FROM all_tab_partitions
ORDER BY table_name, partition_name;
Installing the Window System drivers
Installing X.Org Server 1.11 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.
Installing graphics libraries and desktop services components ...fail!
(See the log file /var/log/vboxadd-install-x11.log for more information.)
Press Return to close this window...
install_x11_startup_app: no script given
Before installing the new guest additions version, you need to remove manually 2 symlinks:
rm /usr/lib64/VBoxGuestAdditions
rm /usr/share/VBoxGuestAdditions
BEGIN
SELECT ... INTO x_data
FROM ...
WHERE ...;
EXCEPTION
WHEN NO_DATA_FOUND THEN
x_data := NULL;
END;
select * from (select * from monitor.at_process_log order by log_id desc)
where ROWNUM <=10;
To accomplish the equivalent to MySql:
select * from sometable order by name limit 20,10
AskTom proposes:
select * from (select a.*, ROWNUM rnum from
(select * from monitor.at_process_log order by log_id desc) a where rownum <= 20)
where rnum >= 10;
- tar xvfz vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz
- cd vpnclient
- sudo ./vpn_install
- wget http://projects.tuxx-home.at/ciscovpn/patches/vpnclient-linux-2.6.24-final.diff
- patch < ./vpnclient-linux-2.6.24-final.diff
- wget http://lamnk.com/download/vpnclient-linux-4.8.02-64bit.patch
- patch < ./vpnclient-linux-4.8.02-64bit.patch
- sed -i 's/^CFLAGS/EXTRA_CFLAGS/' Makefile
- wget http://lamnk.com/download/vpnclient-linux-2.6.31-final.diff
- patch < ./vpnclient-linux-2.6.31-final.diff
- sudo sed -i 's/const\ struct\ net_device_ops\ \*netdev_ops;/struct\ net_device_ops\ \*netdev_ops;/' `find /usr/src -name netdevice.h`
- sudo ./vpn_install
- sudo /sbin/service vpnclient_init start
- cp *.pcf /etc/opt/cisco-vpnclient/Profiles directory
- vpnclient connect site-name (site-name is the same as site-name.pcf)
[jerome@monster] > patch < ./vpnclient-linux-2.6.24-final.diff
patching file GenDefs.h
Hunk #1 succeeded at 105 with fuzz 2.
Hunk #2 succeeded at 122 (offset 2 lines).
patching file interceptor.c
Hunk #3 FAILED at 111.
Hunk #4 succeeded at 142 (offset 5 lines).
Hunk #5 FAILED at 364.
Hunk #6 FAILED at 921.
Hunk #7 FAILED at 949.
4 out of 7 hunks FAILED -- saving rejects to file interceptor.c.rej
(**)
Replace
static void interceptor_init(struct net_device *);
with
static
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
int
#else
int __init
#endif
interceptor_init(struct net_device *);
(***)
[main] Description=sample user profile Host=<x.x.x.x> AuthType=1 GroupName=<GroupName> GroupPwd=<GroupPwd> EnableISPConnect=0 ISPConnectType=0 ISPConnect= ISPCommand= Username=<Username> UserPassword=<UserPassword> SaveUserPassword=1 EnableBackup=0 BackupServer= EnableNat=1 CertStore=0 CertName= CertPath= CertSubjectName= CertSerialHash=00000000000000000000000000000000 DHGroup=2 ForceKeepAlives=1
TYPE varchar2_array_type IS TABLE OF VARCHAR2(100) INDEX BY PLS_INTEGER;In package body:
ze_or_keys varchar2_array_type; BEGIN FOR i in 1 .. ze_or_keys.count LOOP IF i != 1 THEN my_string := my_string || ' OR '; END IF; my_string := my_string || ze_or_keys(i) || '=''' || ze_or_values(i) || ''''; END LOOP; END;
TYPE hash_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(100);In package body:
ze_assoc hash_type; BEGIN my_col_name := ze_assoc.first; LOOP EXIT WHEN my_col_name is null; my_string := my_string || ' OR ' || my_col_name || '=' || ze_assoc(my_col_name); my_col_name := ze_assoc.next(my_col_name); END LOOP; END;
VBoxService --timesync-set-threshold 10000
CTRL-x <RET> f iso-8859-1-unix <RET>
This matches the M-x set-buffer-file-coding-system
function.
cd ~/src
git diff fc20f9f c52bb9c -- perl/file_manager/bin/fm_extract_cdr.pl
[root@test ~]# fdisk -l /dev/sda
Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d30cf
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 26109 104857600 83 Linux
Add a new partition
[root@test ~]# fdisk /dev/sda
n {new partition}
p {primary partition}
4 {partition number}
t {change partition id}
8e {Linux LVM partition}
w
Reboot
[root@test ~]# reboot
Check the new partition table
[root@test ~]# fdisk -l /dev/sda
Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d30cf
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 26109 104857600 83 Linux
/dev/sda4 26109 39162 104853565 8e Linux LVM
Create a new physical volume from the new partition
[root@test ~]# pvcreate /dev/sda4
Extend the existing volume group
[root@test ~]# vgextend vg_test /dev/sda4
NB: The volume group name is given by lvdisplay:
[root@test ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg_test/lv_root
VG Name vg_test
LV UUID wkJfwT-hJkJ-fQCL-HTqP-0ZrZ-i8vL-TrLTif
LV Write Access read/write
LV Status available
# open 1
LV Size 149.99 GiB
Current LE 38398
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
...
Extend the logical volume
[root@test ~]# lvextend /dev/vg_test/lv_home /dev/sda4
Resize the filesystem in the logical volume
[root@test ~]# resize2fs /dev/vg_test/lv_home
Check that the new space has ben taken into account
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
148G 6.4G 134G 5% /
tmpfs 1002M 0 1002M 0% /dev/shm
/dev/sda1 485M 68M 392M 15% /boot
/dev/mapper/vg_test-lv_home
144G 5.0G 132G 4% /home
[root@test ~]#
Only for declarations and definitions of symbols.
M-. goes to the symbol definition
M-0 M-. goes to the next matching definition
M-* return to your starting point
For invocations (any symbol actually):
M-x tags-search initiate a search
M-, go to the next match
cd <my directory>
find . -name "*.[chCH]" -print | etags --output=/vob/signalware/Master/TAGS -a -
cd /vob/
find . -name "*.[chCH]" -print | etags --output=/vob/signalware/Master/TAGS -
Or
cd /vob/signalware/Master
find tcap gsm2 -name "*.[chCH]" -print | etags --output=/vob/signalware/Master/TAGS -
In `replace-regexp’, the NEWSTRING need not be constant. It can refer to all or part of what is matched by the REGEXP. `\&’ in NEWSTRING stands for the entire text being replaced. `\D’ in NEWSTRING, where D is a digit, stands for whatever matched the D’th parenthesized grouping in REGEXP. For example,
M-x replace-regexp c[ad]+r \&-safe
would replace (for example) `cadr’ with `cadr-safe’ and `cddr’ with `cddr-safe’.
M-x replace-regexp \(c[ad]+r\)-safe \1
would perform exactly the opposite replacements. To include a `\’ in the text to replace with, you must give `\\’.
M-x -replace-regexp
would replace smth like SLK21, into SLK2a,
;;; --- Add it to C mode Hook (c-add-style "DAP" '((c-basic-offset . 8) (substatement-open . 0) (c-offsets-alist . ( (namespace-open . 0) (namespace-close . 0) (innamespace . 0) ;;; -- brace that opens a substatement block (substatement-open . 0) ;;; -- brace that opens an in-class inline me thod (inline-open . 0) (case-label . +) (access-label . -2) (class-open . 0) ) ) )) (defun dap-hook () (c-set-style "DAP")) (add-hook 'c-mode-hook 'dap-hook)
M-x hide-ifdef-mode Load mode
M-x hide-ifdefs (C-c @ h) Explicitly hide ifdefs
M-x show-ifdefs (C-c @ s) Undo hide-ifdefs
M-x hide-ifdef-define (C-c @ d) To define a symbol.
M-x hide-ifdef-undef (C-c @ u) To undefine a symbol.
We can use the command
C-c C-s (bound to c-show-syntactic-information)
to simply report what the syntactic analysis is for the current line.
E.g.:
void swap( int& a, int& b ) { int tmp = a; a = b; b = tmp; }
Running this command on line 4 of this example, we’d see in the echo area:
((statement 35))
http://www.xemacs.org/Install/index.html
Recuperer p. ex. xemacs-21.4.22.tar.gz et xemacs-sumo.tar.gz
Creer un repertoire d’install temporaire dont on deplacera le contenu ensuite.
optimal> mkdir ~/install
Installer tout le bordel.
optimal> gzip -dc xemacs-21.4.22.tar.gz | tar xvf -
optimal> cd xemacs-21.4.22
optimal> usegcc346
optimal> ./configure --prefix=/u/gallinar/install
optimal> make
optimal> make install
Ensuite installer les xemacs-packages:
optimal> cd ~/install/lib/xemacs
optimal> gzip -dc ~/xemacs-sumo.tar.gz | tar xvf -
Deplacer ensuite tout le contenu de ~/install vers /u/engineering/...
> sudo yum -y install xsel
And use the following command to capture selection in Eterm:
> xsel | xsel -b
The problem is now to bind it to a key, let's say Ctrl-Ins ;), in OpenBox.<keybind key="C-Insert"> <action name="Execute"> <startupnotify> <enabled>true</enabled> <name>xsel</name> </startupnotify> <command>sh -c '/usr/bin/xsel | /usr/bin/xsel -b'</command> </action> </keybind>Do not forget the sh -c or it won't work.
> rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv
Output:
/etc/httpd/conf.d/php.conf
./etc/php.d
./etc/php.ini
./usr/bin/php
...
19188 blocks
Output of rpm2cpio piped to cpio command (see how to use cpio) with following options:> sudo /etc/init.d/apache2 restart
or
> sudo service apache2 restart
or
> sudo apachectl restart
AddVMOption -Duser.language=en
sudo yum -y install system-config-lvm
French article describing how to proceed.
NB: If meeting the following error:process 702: D-Bus library appears to be incorrectly set up; failed to read
machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory.
Then run the following command as root.
> dbus-uuidgen > /var/lib/dbus/machine-id
NETWORKING=yes HOSTNAME="plain.domainname.com" GATEWAY="192.168.0.1" GATEWAYDEV="eth0" FORWARD_IPV4="yes"So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME variable.
serverSo on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:
/etc/init.d/hostname.sh start
to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot.
useradd --home /home/jerome jerome -g users
passwd jerome
Delete user:
userdel --remove jerome
C-x rr i copy rectangle into register i
C-x rg i paste rectangle from register i
C-x rk cut rectangle region
C-x ry yank rectangle region
C-x rc clear rectangle region
cpan[1]> install DBIx::Class::Schema::Loader
...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/bin'
Do not have write permissions on '/usr/local/bin'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
ANDK/CPAN-1.9800.tar.gz
/usr/bin/make install -- NOT OK
----
You may have to su to root to install the package
(Or you may want to run something like
o conf make_install_make_command 'sudo make'
to raise your permissions.Failed during this command:
ANDK/CPAN-1.9800.tar.gz : install NO
Trying as suggested will do no good:
cpan[4]> o conf make_install_make_command 'sudo make'
make_install_make_command [sudo make]
Please use 'o conf commit' to make the config permanent!
cpan[5]> install DBIx::Class::Schema::Loader
Running install for module 'DBIx::Class::Schema::Loader'
Running make for R/RK/RKITOVER/DBIx-Class-Schema-Loader-0.07017.tar.gz
Has already been unwrapped into directory /home/jerome/.cpan/build/DBIx-Class-Schema-Loader-0.07017-_upIn_
Has already been made
Running make test
Has already been tested successfully
Running make install
Already tried without success
So the solution is:
cpan[6]> force install DBIx::Class::Schema::Loader
tar xvfz local-lib-1.008004.tar.gz
cd local-lib-1.008004
We now need to tell local::lib we want it to 'bootstrap' itself. This creates a 'perl5' folder within your home directory, and instructs the toolchain to install local::lib there.
perl Makefile.PL --bootstrap
Then, build, test and install local::lib:
make
make test
make install
Now set some environment variables that tell Perl where your installed modules are kept.
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
Test it:
perl -MCPAN -eshell
At the CPAN prompt, enter:
cpan[1]> install DBIx::Class::Schema::Loader
export PERL5LIB=/u/gallinar/perl5lib/tmp/lib/site_perl
perl Makefile.PL PREFIX=/u/gallinar/perl5lib/tmp CC=gcc LD=gcc CCCDLFLAGS=-fPIC OPTIMIZE=-O3 CCFLAGS=" "
make
make install
#!/usr/bin/perl sub test_it { my ($count) = @_; return sub { ++$count; }; } my $test1 = test_it(10); my $test2 = test_it(50); print $test1->(), "\n"; # 11 print $test2->(), "\n"; # 51 print $test1->(), "\n"; # 12 print $test2->(), "\n"; # 52
#!/usr/bin/php <?php function test_it_ro($count) { return function() use($count) { return ++$count; }; } function test_it_rw($count) { return function() use(&$count) { return ++$count; }; } $test1 = test_it_ro(10); $test2 = test_it_ro(50); print $test1()."\n"; // 11 print $test2()."\n"; // 51 print $test1()."\n"; // 11 print $test2()."\n"; // 51 $test1 = test_it_rw(10); $test2 = test_it_rw(50); print $test1()."\n"; // 11 print $test2()."\n"; // 51 print $test1()."\n"; // 12 print $test2()."\n"; // 52 ?>
git init
This will create a local .git repository for git. Run
git status
As we did not add any files to git, it will show you all files as untracked.
.svn*
From now on, git status won't show .svn folders anymore.
git add .
git status will show all files as ready to be commited. Proceed:
git commit -am "initial file import"
Run: git status - it will show everything is ok
git branch idea
git checkout idea
or
git checkout -b idea
Run git status, it will show you are in new branch.
git checkout master
and return to the new branch:
git checkout idea
If you want to merge the new branch into the master branch, you have to move all changes made in the idea branch.
git checkout master
git merge idea
To drop the idea branch, run:
git branch -d idea
public static <E> Set<E> union(Set<E> s1, Set<E> s2)should be re-written
public static <E> Set<E> union(Set<? extends E> s1, Set<? extends E> s2)
// pushAll method without wildcard type - deficient! public void pushAll(Iterable<E> src) { for (E e : src) { push(e); } }should be re-written:
// Wildcard type for parameter that serves as an E producer public void pushAll(Iterable<? extends E> src) { for (E e : src) { push(e); } }Similarly, a method that pops each element off the stack and adds the elements to the given collection:
// popAll method without wildcard type - deficient! public void popAll(Collection<E> dst) { while (!isEmpty()) { dst.add(pop()); } }should be re-written:
// Wildcard type for parameter that serves as an E consumer public void popAll(Collection<? super E> dst) { while (!isEmpty()) { dst.add(pop()); } }
public static void swap(List<?> list, int i, int j);over
public static <E> void swap(List<E> list, int i, int j);However, this implementation won't compile:
public static void swap(List<?> list, int i, int j) { list.set(i, list.set(j, list.get(i))); }because you can’t put any value except null into a List<?>. Instead, we will have to use:
public static void swap(List<?> list, int i, int j) { swapHelper(list, i, j); } // Private helper method for wildcard capture private static <E> void swapHelper(List<E> list, int i, int j) { list.set(i, list.set(j, list.get(i))); }
// Wrapper class - uses composition in place of inheritance public class InstrumentedSet<E> extends ForwardingSet<E> { private int addCount = 0; public InstrumentedSet(Set<E> s) { super(s); } @Override public boolean add(E e) { addCount++; return super.add(e); } @Override public boolean addAll(Collection<? extends E> c) { addCount += c.size(); return super.addAll(c); } public int getAddCount() { return addCount; } }
// Reusable forwarding class public class ForwardingSet<E> implements Set<E> { private final Set<E> s; public ForwardingSet(Set<E> s) { this.s = s; } public void clear() { s.clear(); } public boolean contains(Object o) { return s.contains(o); } public boolean isEmpty() { return s.isEmpty(); } public int size() { return s.size(); } public Iterator<E> iterator() { return s.iterator(); } public boolean add(E e) { return s.add(e); } public boolean remove(Object o) { return s.remove(o); } public boolean containsAll(Collection<?> c) { return s.containsAll(c); } public boolean addAll(Collection<? extends E> c) { return s.addAll(c); } public boolean removeAll(Collection<?> c) { return s.removeAll(c); } public boolean retainAll(Collection<?> c) { return s.retainAll(c); } public Object[] toArray() { return s.toArray(); } public <T> T[] toArray(T[] a) { return s.toArray(a); } @Override public boolean equals(Object o) { return s.equals(o); } @Override public int hashCode() { return s.hashCode(); } @Override public String toString() { return s.toString(); } }
// Example use Set<Date> s = new InstrumentedSet<Date>(new TreeSet<Date>(comparator));
// Potential security hole! public static final Thing[] VALUES = { ... };Solution:
private static final Thing[] PRIVATE_VALUES = { ... }; public static final List<Thing> VALUES = Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));Or:
private static final Thing[] PRIVATE_VALUES = { ... }; public static final Thing[] values() { return PRIVATE_VALUES.clone(); }
public abstract class AbstractShape { private DrawingProgram dp; public abstract void draw(); public AbstractShape(DrawingProgram dp) { this.dp = dp; } public void drawLine() { this.dp.drawLine(); } public void drawCircle() { this.dp.drawCircle(); } }
public class Rectangle extends AbstractShape { public Rectangle(DrawingProgram dp) { super(dp); } @Override public void draw() { drawLine(); drawLine(); drawLine(); drawLine(); } }
public class Circle extends AbstractShape { public Circle(DrawingProgram dp) { super(dp); } @Override public void draw() { drawCircle(); } }
public interface DrawingProgram { void drawLine(); // implicitly public void drawCircle(); }
public class DrawingProgram1 implements DrawingProgram { @Override public void drawLine() { ... } @Override public void drawCircle() { ... } }
public class DrawingProgram2 implements DrawingProgram { @Override public void drawLine() { ... } @Override public void drawCircle() { ... } }
public class client { public static void main(String[] args) { Drawing dp1 = new DrawingProgram1(); Rectangle rectangle = new Rectangle(dp1); Drawing dp2 = new DrawingProgram2(); Circle circle = new Circle(dp2); circle.draw(); rectangle.draw(); } }
public interface WindowFactory { Window createWindow(); // implicitly public }
public MsWindowFactory implements WindowFactory { @Override public Window createWindow() { return new MsWindow(); } }
public AppleWindowFactory implements WindowFactory { @Override public Window createWindow() { return new AppleWindow(); } }
public Client { public static void main(String[] args) { WindowFactory factory; String osName = System.getProperty("os.name"); if ((osName != null) && (osName.indexOf("Windows") != -1)) { factory = new MsWindowFactory(); } else { factory = new AppleWindowFactory(); } Window window = factory.createWindow(); } }
private Document doc; ... JButton button = new JButton("Load"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingWorker<Document, Void> worker = new SwingWorker<Document, Void>() { @Override public Document doInBackground() { return load(); } @Override public void done() { try { doc = get(); } catch (Exception e) { e.printStackTrace(); } } }; worker.execute(); } });
SwingUtilities.invokeLater(Runnable):
SwingUtilities.invokeAndWait(Runnable):
sudo mount /dev/cdrom /media/cdrom
cd /media/cdrom
sudo ./VBoxLinuxAdditions.run
sudo reboot
public interface Logger { void debug(String message); // implicitly public }
public class FileLogger implements Logger { @Override public void debug(String message) { ... } }
public abstract class AbstractLoggerFactory { public abstract Logger createLogger(); // factory method public Logger getLogger() { Logger logger = createLogger(); ... return logger; } }
public class FileLoggerFactory extends AbstractLoggerFactory { @Override public Logger createLogger() { return new FileLogger(); } }
public class Client { private AbstractLoggerFactory factory = new FileLoggerFactory(); public doSomething(AbstractLoggerFactory factory) { Logger logger = factory.getLogger(); logger.debug("debug message"); } }
// Enum singleton - the preferred approach: concise + serializable public enum Singleton { // implicitly final INSTANCE; // implicitly public static final public void doSomething() { ... } }
public interface Visitable { void accept(Visitor visitor); // implicitly public }
public class Book implements Visitable { @Override public void accept(Visitor visitor) { if (...) visitor.visit(this); } }
public interface Visitor { void visit(Book book); // implicitly public void visit(CD cd); }
public class PostageVisitor implements Visitor { @Override public void visit(Book book) { this.totalPostage += ...; } @Override public void visit(CD cd) { this.totalPostage += ...; } public void getTotalPostage() { return this.totalPostage; } }
public class Client { public double calculatePostage() { PostageVisitor visitor = new PostageVisitor(); for (Visitable item : this.items) { item.accept(visitor); } return visitor.getTotalPostage(); } }
code { ... display: block; }
.syntaxhighlighter { padding: 1px !important; }
tar czf - 3rdparty common ectasea extensions global.inc index.php login
| ssh me@mamlan.com "tar xzf - -C www/ectasea"
MyJFrame.this.processWindowEvent( new WindowEvent(MyJFrame.this,WindowEvent.WINDOW_CLOSED));
AWT.EventQueueClass=jnewmarch.replay.TracedEventQueue
to this, then all events that enter the event queue will be printed to standard output.
public class Person { private String name; private Date birth; public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (getClass() != other.getClass()) return false; Person person = (Person)other; return ( (name == person.name || (name != null && name.equals(person.name))) && (birth == person.birth || (birth != null && birth.equals(person.birth))) ); } }
static Frame JOptionPane.getFrameForComponent(Component)
// Always pack before using setLocationRelativeTo
myDialog.dialog.pack();
myDialog.dialog.setLocationRelativeTo(frame);
boolean rowIsAnchor = (getSelectionModel().getAnchorSelectionIndex() == row);
boolean colIsAnchor =
(getColumnModel().getSelectionModel().getAnchorSelectionIndex() == column);
javax.swing.DefaultCellEditor dce =
(javax.swing.DefaultCellEditor)table.getDefaultEditor(Object.class);
dce.setClickCountToStart(1);
import javax.swing.BorderFactory;
import java.awt.Color;
setBorder(BorderFactory.createLineBorder(Color.black);
if (comboBox.getEditor().getEditorComponent()
instanceof JTextField) {
JTextField tf =
(JTextField)comboBox.getEditor().getEditorComponent();
tf.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent fe) {
// get the text using getText() method
}});
}
public Dimension getMinimumSize() {
return new Dimension(
MINIMUM_WIDTH, MINIMUM_HEIGHT);
}
Note that the native implementation of Frame does not allow minimum size below certain size.
/**
* Reads the next token from the given stream tokenizer.
*
* @param aScanner Stream tokenizer to read from.
* @return Read string token or null.
*
* @ulcm.msg 403 getString()
* @ulcm.msg 410 EOF
* @ulcm.msg 411 EOL
*/
private String getString(StreamTokenizer aScanner) {
String rtnString = null;
try {
aScanner.nextToken();
switch (aScanner.ttype) {
case StreamTokenizer.TT_EOF:
rtnString = CommItlBundle.getString(410);
break;
case StreamTokenizer.TT_EOL:
rtnString = CommItlBundle.getString(411);
break;
case StreamTokenizer.TT_WORD:
rtnString = aScanner.sval;
break;
case StreamTokenizer.TT_NUMBER:
rtnString = String.valueOf((int) aScanner.nval);
break;
case '"':
rtnString = aScanner.sval;
break;
default:
rtnString = String.valueOf((char) aScanner.ttype);
}
} catch (IOException e) {
if (this.LOGGER.isLoggable(Level.FINER)) {
this.LOGGER.throwing(getClass().getName(),
CommItlBundle.getString(403),
e);
}
}
return rtnString;
}
cd /usr/lib
sudo tar xvfz /media/host/apache-ant-1.8.2-bin.tar.gz
sudo ln -s apache-ant-1.8.2 apache-ant
sudo update-alternatives --install /usr/bin/ant ant /usr/lib/apache-ant/bin/ant 1
sudo mkdir -p /usr/lib/jvm/
cd /usr/lib/jvm/
tar xvfz /media/host/jdk-7u2-linux-x64.tar.gz
ln -s jdk1.7.0_02 jdk
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java
sudo update-java
and select /usr/lib/jvm/jdk