کدهای خود را به اشتراک بگذارید

vata2999
تولید svg گانت با استفاده از jfreechart و Apache batik
ایجاد شده 4 روز پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public static ChartInfo createSVG(JFreeChart jfchart, int width, int heigth) throws UnsupportedEncodingException
    {
        DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
        Document document = domImpl.createDocument(null, "svg", null);
        // Create an instance of the SVG Generator
        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
        ctx.setEmbeddedFontsOn(true);
        ctx.setGenericImageHandler(new SimpleImageHandler(new ImageHandlerBase64Encoder()));
        SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
        svgGenerator.setSVGCanvasSize(new Dimension((int) width, (int) heigth));
vata2999
SSLUtil
ایجاد شده 4 روز پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

/**
 * This class provide various static methods that relax X509 certificate and 
vata2999
spring jpa data pagination with primefaces
ایجاد شده 1 هفته پیش
1
page = service.findAll(new PageRequest(first / pageSize, pageSize, new Sort(Direction.DESC, "id")));
vata2999
oracle pagination
ایجاد شده 1 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT * FROM
(
    SELECT a.*, rownum r__
    FROM
    (
        SELECT * FROM ORDERS WHERE CustomerID LIKE 'A%'
        ORDER BY OrderDate DESC, ShippingDate DESC
    ) a
    WHERE rownum < ((pageNumber * pageSize) + 1 )
)
WHERE r__ >= (((pageNumber-1) * pageSize) + 1)
omidp
Lock کردن فایل هنگام خواندن
ایجاد شده 1 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public class FileLockTest {

    private static final Log LOG = LogFactory.getLog(FileLockTest.class);

    private static FileChannel fc;

    private static RandomAccessFile randomAccessFile;

    public FileLockTest(String fileName) throws FileNotFoundException {

        randomAccessFile = new RandomAccessFile(fileName, "rw");
vata2999
ارسال درخواست به url و خواندن محتوا
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;

import javax.net.ssl.HttpsURLConnection;
vata2999
jasper با فریم ورک اسپرینگ
ایجاد شده 2 هفته پیش
1
2
3
4
5
6
JasperReport compileReport = JasperCompileManager.compileReport(new FileInputStream(new File("/home/omidp/report/reportTemplate.jrxml")));
//JasperReport jasperReport = (JasperReport) JRLoader.loadObject(new File("/home/omidp/report/reportTemplate.jasper"));
Map<String, Object> params = new HashMap<String, Object>();
params.put("familyCnt", "100");
org.springframework.ui.jasperreports.JasperReportsUtils.renderAsPdf(compileReport, params, 
					new ArrayList(), new FileOutputStream(new File("/home/omidp/output.pdf")));
vata2999
پیدا کردن رکوردهای قبلی و بعدی در postgresql
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT  
i.spv_prj_progress_id,i.proj_id,
  COALESCE(LEAD(i.spv_prj_progress_id)  OVER (ORDER BY i.data_date DESC)
          ,FIRST_VALUE(i.spv_prj_progress_id)
           OVER (ORDER BY i.data_date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) AS nextitemid,
  COALESCE(LAG(i.spv_prj_progress_id)       
    OVER (ORDER BY i.data_date DESC)
          ,LAST_VALUE(i.spv_prj_progress_id)  
          OVER (ORDER BY i.data_date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) AS previtemid,  
  i.data_date AS data_date
FROM spv_prj_progress i  
vata2999
"Recursively throgh Java nio"
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public static void main(String[] args) throws IOException
    {
        Path start = Paths.get("/home/omidp/jedlab/");
        Files.walkFileTree(start, new SimpleFileVisitor<Path>()
        {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
            {
                System.out.println(dir);
                return FileVisitResult.CONTINUE;
            }
vata2999
Hibernate metadata
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
final Map metadataMap = session.getSessionFactory().getAllClassMetadata();
            for (Object key : metadataMap.keySet()) {
                final ClassMetadata classMetadata = (ClassMetadata) metadataMap.get(key);
                final String entityName = classMetadata.getEntityName();
                final Query query = session.createQuery("from " + entityName);
                System.out.println("executing: " + query.getQueryString());
                for (Object o : query.list()) {
                    System.out.println("  " + o);
                }
            }
لطفا منتظر بمانید