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

vata2999
tomcat config large file upload
ایجاد شده 2 هفته پیش
1
2
3
4
5
6
<Connector URIEncoding="UTF-8" acceptCount="100" 
    connectionTimeout="20000" disableUploadTimeout="true" 
    maxHttpHeaderSize="8192" maxParameterCount="50000" 
    maxPostSize="-1" maxSpareThreads="75" 
    maxThreads="150" minSpareThreads="25" 
    port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
vata2999
Spring Hibernate Query cache with Batch Insert
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="com.model" />
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="generateDdl" value="true" />
				<property name="showSql" value="${profile.db.show_sql}" />
				<property name="databasePlatform" value="${profile.db.dialect}" />
				<property name="database" value="${profile.db.database}" />
			</bean>
vata2999
Jboss standalone conf
ایجاد شده 2 هفته پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<system-properties>
        <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
        <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
        <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/>
        <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="text/javascript,text/css,text/html,text/xml,text/json"/>
        <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="20000"/>
    </system-properties>

<virtual-server name="default-host" default-web-module="omidbiz">
                <alias name="www.omidbiz.com"/>
                <alias name="omidbiz.com" />                
vata2999
chunk large csv into smaller files
ایجاد شده 4 هفته پیش
1
2
3
4
5
6
7
8
#!/bin/sh
tail -n +2 sell_report.csv | split -l 1000 - split_
for file in split_*
do
    head -n 1 sell_report.csv > tmp_file
    cat $file >> tmp_file
    mv -f tmp_file $file
done
vata2999
tcmpdump sniff
ایجاد شده 4 هفته پیش
1
sudo tcpdump -i enp5s0 tcp -XX -v | tee tcpdump.log
vata2999
JPA 2 Criteria
ایجاد شده 1 ماه پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try
        {
            CriteriaBuilder cb = entityManager.getCriteriaBuilder();
            CriteriaQuery<User> cq = cb.createQuery(User.class);
            Root<BusinessPartner> from = cq.from(BusinessPartner.class);
            cq.select(from.get("user"));
            List<Predicate> predicates = new ArrayList<Predicate>();
            predicates.add(cb.equal(from.get("user").get("id"), userId));
            cq.where(predicates.toArray(new Predicate[predicates.size()]));
            return entityManager.createQuery(cq).setMaxResults(1).getSingleResult();
        }
vata2999
generic method
ایجاد شده 1 ماه پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public static <T> T test(T o)
    {
        return (T) o;
    }
    
    public static void main(String[] args)
    {
        String test = test("salam");
        Long test2 = test(new Long(1));
        Integer test3 = test(new Integer(1));
    }
vata2999
Java concurrent Programming
ایجاد شده 1 ماه پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public static void main(String[] args) throws InterruptedException, ExecutionException
    {
        List<String> test= new ArrayList<>();
        CompletableFuture<Void> completedFuture = CompletableFuture.runAsync(()->{
            try
            {
                Thread.sleep(5000);
            }
            catch (Exception e)
            {
            }
vata2999
Resource Acquisition Is Initialization
ایجاد شده 1 ماه پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Permit implements Closeable {
  private Semaphore sem;
  Permit(Semaphore s) {
    this.sem = s;
  }
  @Override
  public void close() {
    this.sem.release();
  }
  public Permit acquire() {
    this.sem.acquire();
vata2999
Generate N-gram
ایجاد شده 1 ماه پیش
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
private static void generateNgrams(int N, String sent, List ngramList) {
  String[] tokens = sent.split("\\s+"); //split sentence into tokens
 
  //GENERATE THE N-GRAMS
  for(int k=0; k<(tokens.length-N+1); k++){
    String s="";
    int start=k;
    int end=k+N;
    for(int j=start; j<end; j++){
     s=s+""+tokens[j];
    }
لطفا منتظر بمانید