ქინდლისვის გავაკეთე ლექსიკონი. წიგნის კითხვის დროს მონიშნავთ სიტყვას და ავტომატურად გაიხსნება ფანჯარა, სადაც მონიშნული სიტყვის განმარტებას ნახავთ.
Google drive დან ფაილის გადმოსაწერი ლინკი;
ესეც ლინკი ამაზონზე.
იმედია მოგეწონებათ :)
#ifndef HEADER_H_INCLUDED #define HEADER_H_INCLUDED int buildRequest(char * input, char * answer, int inputLenth); typedef void(*NotificationListener)(char *, int); void callbackTriger(const NotificationListener l); void getDeviceRandomStatus(char *answer, int sizeOfChars); int randNum( int min, int max); #endif // HEADER_H_INCLUDED
#include<stdio.h> #include "header.h" #include <stdlib.h> #include <time.h> int buildRequest(char * input, char * answer, int inputLenth) { printf("C: log passed params from java to C: "); int i = 0; for (; *input; ++input) { i++; if (i > inputLenth) { break; } char c = *input; int i = (int) c; printf("%d ", i); } printf("\n"); answer[0] = 0xFE; answer[1] = 0x81; return i - 1; } void callbackTriger(const NotificationListener l) { int size = randNum(1, 20); char answer[size]; getDeviceRandomStatus(answer, size); (*l)(answer, sizeof(answer)); } void getDeviceRandomStatus(char *answer, int sizeOfChars) { int i; for (i = 0; i < sizeOfChars; i++) { int i = randNum(0, 255); answer[i] = i + '0'; } } int randNum(int min, int max) { srand(time(NULL)); double scaled = (double) rand() / RAND_MAX; int val = (max - min + 1) * scaled + min; return val; }
#include<stdio.h> #include <limits.h> #include <stdlib.h> int main(void) { char ch [] = {0x01, 0x07, 0x09 ,0xA, 0xB,0xC, 0xD,0xE ,0xF }; char answer[2]; int r=buildRequest(ch, answer, 5); printf("Returned params: "); int i; for (i = 0; i < sizeof(answer); ++i){ printf("%d ", answer[i]); } return 0; }
gcc -c -Wall -Werror -fpic header.c gcc -shared -o libHeader.so header.o gcc main.c -o main -lHeader -L/home/vq/Desktop -Wl,-rpath=/home/vq/Desktop ./main
import java.util.Arrays; import java.util.logging.Logger; import com.sun.jna.Callback; import com.sun.jna.Library; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; /** * * @author vakhtang Koroghlishvili * */ public class BuildRequestMaker { public static Logger log = Logger.getLogger(CallBack.class .getSimpleName()); public interface CLibrary extends Library { public int buildRequest(Pointer input, Pointer output, int inputLenth); } public interface CLibraryCallBack extends Library { public interface NotificationListener extends Callback { void invoke(Pointer val, int lenth); } public static class NotificationListenerImpl implements NotificationListener { @Override public void invoke(Pointer val, int lenth) { log.info("java mehtod, callback: " + Arrays.toString(val.getByteArray(0, lenth))); } } public void callbackTriger(NotificationListener callback); } public byte[] buildRequest(byte[] inputArr) { CLibrary clib = (CLibrary) Native.loadLibrary( "/home/vq/Desktop/libHeader.so", CLibrary.class); Pointer input = new Memory(inputArr.length * Native.getNativeSize(Byte.TYPE)); Pointer answer = new Memory(inputArr.length * Native.getNativeSize(Byte.TYPE)); for (int i = 0; i < inputArr.length; i++) { input.setByte(i * Native.getNativeSize(Byte.TYPE), inputArr[i]); } int resultSize = clib.buildRequest(input, answer, inputArr.length); log.info("returned value from c lib is: " + resultSize); byte[] resultByte = answer.getByteArray(0, resultSize); log.info("returned value array from c lib is: " + Arrays.toString(resultByte)); return resultByte; } public void callBackListener() { CLibraryCallBack clib = (CLibraryCallBack) Native .loadLibrary("/home/vq/Desktop/libHeader.so", CLibraryCallBack.class); // instantiate a callback wrapper instance CLibraryCallBack.NotificationListenerImpl callbackImpl = new CLibraryCallBack.NotificationListenerImpl(); // pass the callback wrapper to the C library clib.callbackTriger(callbackImpl); } }
import org.junit.Assert; import org.junit.Test; public class JNATests { @Test public void buildRequestTest() { BuildRequestMaker m = new BuildRequestMaker(); byte[] input = { (byte) 0x81, (byte) 0xFE }; byte[] expect = { (byte) 0xFE, (byte) 0x81 }; Assert.assertArrayEquals(expect, m.buildRequest(input)); } @Test public void callBacklTest() { BuildRequestMaker m = new BuildRequestMaker(); Exception ex = null; try { m.callBackListener(); } catch (Exception e) { ex = e; } Assert.assertEquals(null, ex); }შედეგები:
INFO: started call back listener INFO: java mehtod, callback: [-64, -28, 119, 124, 84, 127, 0, 0] ... INFO: started building request INFO: returned value from c lib is: 2 INFO: returned value array from c lib is: [-2, -127] C: log passed params from java to C: -127 -2
<bean id="dataSource" class= "org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value= "oracle.jdbc.driver.OracleDriver" /> <property name="url" value="${database.url}" /> <property name="username" value="${database.username}" /> <property name="password" value="${database.password}" /> </bean>
<bean id="dataSource" class= "org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <property name="initialSize" value="${database.initialSize}" /> <property name="maxActive" value="${database.maxActive}" /> <property name="maxIdle" value="${database.maxIdle}" /> <property name="minIdle" value="${database.minIdlel}" /> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="${database.url}" /> <property name="username" value="${database.username}" /> <property name="password" value="${database.password}" /> </bean>
show parameter processes;
NAME TYPE VALUE ------------------------------------------- aq_tm_processes integer 0 db_writer_processes integer 1 gcs_server_processes integer 0 global_txn_processes integer 1 job_queue_processes integer 5 log_archive_max_processes integer 4 processes integer 10
ALTER SYSTEM SET processes=2000 SCOPE=SPFILE; ALTER SYSTEM SET job_queue_processes=1000 scope=both;
rule "HelloPersons" when Person( firstName == "mariam" ) then // შესრულება end
rule "CheckPerson" when p: Person(age >= 18, country == "Georgia", nick: nickName) then System.out.println( "Hello Mariam" ); end
http://download.jboss.org/drools/release/
http://download.jboss.org/drools/release/latest/org.drools.updatesite/
<dependency> <groupId>org.drools</groupId> <artifactId>drools-compiler</artifactId> <version> [ვერსია]</version> </dependency> <dependency>
KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession("ksession-rules"); Person p= new Person(); ... kSession.insert(p); kSession.fireAllRules();
F(n)=F(n-1) + F(n+2)ამასთან
F(1) =1, და F(2)=1;
public static class Fibonacci { private int sequence; private long value; public Fibonacci(int sequence) { this.setSequence(sequence); this.setValue(-1); } //... }
rule "ფიბანაჩის ობიექტების შექმნა" when f : Fibonacci ( value == -1 ) not ( Fibonacci ( sequence == 1 ) ) then insert( new Fibonacci( f.sequence - 1 ) ); System.out.println( "recurse for " + f.sequence ); end
rule "F(1) , F(2) ის ინიციალიზება"
when
f : Fibonacci( sequence==1 || ==2, value == -1 )
then
modify ( f ){
value = 1
};
System.out.println( f.sequence + " და " + f.value );
end
rule "გამოთვლა"
when
f1 : Fibonacci( s1 : sequence, value != -1)
f2 : Fibonacci( s2: sequence == (s1+1), value != -1 )
f3 : Fibonacci( s3 : sequence == (f1.sequence+2 ), value == -1 )
then
modify ( f3 ) {
value = f1.value + f2.value
};
System.out.println( s3 + " == " + f3.value );
end
1 = 1 2 = 1 3 == 2 4 == 3 5 == 5 6 == 8 7 == 13 8 == 21 9 == 34 10 == 55 11 == 89 12 == 144 13 == 233 14 == 377 15 == 610 16 == 987 17 == 1597 18 == 2584 19 == 4181 20 == 6765 21 == 10946 22 == 17711 23 == 28657 24 == 46368 25 == 75025 26 == 121393 27 == 196418 28 == 317811 29 == 514229 30 == 832040 31 == 1346269 32 == 2178309 33 == 3524578 34 == 5702887 35 == 9227465 36 == 14930352 37 == 24157817 38 == 39088169 39 == 63245986 40 == 102334155 41 == 165580141 42 == 267914296 43 == 433494437 44 == 701408733 45 == 1134903170 46 == 1836311903 47 == 2971215073 48 == 4807526976 49 == 7778742049 50 == 12586269025 51 == 20365011074 52 == 32951280099 53 == 53316291173 54 == 86267571272 55 == 139583862445 56 == 225851433717 57 == 365435296162 58 == 591286729879 59 == 956722026041 60 == 1548008755920 61 == 2504730781961 62 == 4052739537881 63 == 6557470319842 64 == 10610209857723 65 == 17167680177565 66 == 27777890035288 67 == 44945570212853 68 == 72723460248141 69 == 117669030460994 70 == 190392490709135 71 == 308061521170129 72 == 498454011879264 73 == 806515533049393 74 == 1304969544928657 75 == 2111485077978050 76 == 3416454622906707 77 == 5527939700884757 78 == 8944394323791464 79 == 14472334024676221 80 == 23416728348467685 81 == 37889062373143906 82 == 61305790721611591 83 == 99194853094755497 84 == 160500643816367088 85 == 259695496911122585 86 == 420196140727489673 87 == 679891637638612258 88 == 1100087778366101931 89 == 1779979416004714189 90 == 2880067194370816120 91 == 4660046610375530309 92 == 7540113804746346429 ... ... ...