W celu zwolnienia pamięci zajętej na bufory i pamięć podręczną jądra należy wykonać polecenie:
1 |
echo 3 > /proc/sys/vm/drop_caches |
W celu zwolnienia pamięci zajętej na bufory i pamięć podręczną jądra należy wykonać polecenie:
1 |
echo 3 > /proc/sys/vm/drop_caches |
Ostatnio, gdy do jednej z moich wirtualnych maszyn dodałem nowe urządzenie blokowe SCSI, bardzo zależało mi na tym żeby system operacyjny zobaczył to urządzenie bez konieczności restartu całej maszyny wirtualnej. Rozwiązaniem okazało się tzw. skanowanie szyny SCSI. Skanowanie wymusza się…
Klucz prywatny i certyfikat osbisty w formacie pem są używane np. przez GSI (Grid Security Infrastructure). W przypadku konieczności importu takich poświadczeń do przeglądarki internetowej, przydatne może być wcześniejsze ich przekonwertowanie do formatu pkcs12. Konwersji można dokonać poleceniem:
1 |
openssl pkcs12 -export -out <usercert>.p12 -inkey <path-to-pem-priv-key> -in <path-to-pem-user-cert> |
gdzie:…
W infrastrukturze GSI (Grid Security Infrastructure) ścieżka i nazwa pliku z certyfikatem CA musi odpowiadać wzorcowi:
1 |
/etc/grid-security/certificates/<hash>.0 |
gdzie <hash> to hash wyliczony z nazwy DN danego CA. Do wyliczenia (czy też weryfikacji) wartości <hash> można użyć następującego polecenia:
1 |
openssl x509 -hash -noout -in <path_to_ca_file> |
gdzie…
Link do zadania: https://codility.com/programmers/task/max_counters Przykładowe rozwiązanie w języku Java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import java.util.Arrays; class Solution { public int[] solution(int N, int[] A) { int curr_max = 0; int last_max = 0; int max_counter_operations_number = 0; // output array with all operations applied int[] counters = new int[N]; Arrays.fill(counters, 0); // history of all max operations performed on // individual counters form counters array int[] max_performed = new int[N]; Arrays.fill(max_performed, 0); for(int i = 0; i < A.length; i++) { // operation: max counter if(A[i] == N+1) { // increase counter of encountered max counter operations max_counter_operations_number++; // new value for postponed max counter operations last_max=curr_max; // operation: increase(X) } else { // determine index of current counter int counters_index = A[i]-1; // check if postponed max counter operation should be applied first if(max_performed[counters_index] < max_counter_operations_number) { // postponed max counter operation max_performed[counters_index] = max_counter_operations_number; counters[counters_index] = last_max; } // just increase the counter in output array counters[counters_index]++; // check if new curr_max should be remembered if(counters[counters_index] > curr_max) curr_max = counters[counters_index]; } } // for() /* * apply all postponed max counter operations */ for(int i=0; i<max_performed.length; i++) { if(max_performed[i] < max_counter_operations_number) { counters[i] = last_max; } } // for() return counters; } // solution() } |
Podsumowanie rozwiązania: https://codility.com/demo/results/trainingV589CY-YXP/
Link do zadania: https://codility.com/programmers/task/frog_river_one Przykładowe rozwiązanie w języku Java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import java.util.Arrays; class Solution { public int solution(int x, int[] A) { int earliest_time = -1; boolean found_all_leaves = false; int[] detected_leavs = new int[x+1]; Arrays.fill(detected_leavs, 0); // number of leaves that alredy lay on the way int leaves_on_way = 0; for(int i=0; i<A.length; i++) { // increate the earliest time (the result value of the function) earliest_time++; // detection of new leaf on the way if(detected_leavs[A[i]] == 0 ) { leaves_on_way++; detected_leavs[A[i]] = 1; } // the number of leraves on the way is equal to the position we have to reach // so, all required leaves are on the way, break the loop, the result of // function is the current value of the earlies_time variable if(leaves_on_way == x) { found_all_leaves = true; break; } } // for() /* * return the earliest time when all leaves are on the way, * or -1 if no there is no such a case */ if(found_all_leaves) { // return the found result return earliest_time; } else { // ERROR, no solution found return -1; } // if() } // solution() } |
Podsumowanie rozwiązania: https://codility.com/demo/results/trainingT2ZVD4-Y7Z/
Link do zadania: https://codility.com/programmers/task/frog_jmp Przykładowe rozwiązanie w języku Java:
1 2 3 4 5 6 7 8 9 |
import java.lang.Math; class Solution { public int solution(int X, int Y, int D) { return (int) Math.ceil((double)(Y-X)/D); } } |
Podsumowanie rozwiązania: https://codility.com/demo/results/training8FGFKM-EBF/
Link do zadania: https://codility.com/programmers/task/perm_missing_elem Przykładowe rozwiązanie w języku Java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class Solution { public int solution(int[] A) { // calculate sum of all elements from 1 to N+1 long n_plus_one_sum = (long)(A.length + 1) * (A.length + 2) / 2; // calculate sum of all elements in A long sum = 0; for(int i = 0; i < A.length; i++) { sum += A[i]; } // return value of missing number return (int) (n_plus_one_sum - sum); } // solution() } |
Podsumowanie rozwiązania: https://codility.com/demo/results/trainingFFYN64-V2N/
Link do zadania: https://codility.com/programmers/task/tape_equilibrium Przykładowe rozwiązanie w języku Java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import java.lang.Math; class Solution { public int solution(int[] A) { // left and right side sums long sum_left = 0; long sum_right = 0; // absolute difference between the sums long ads = 0; // return value int rv = 0; // initial left sum sum_left = A[0]; // initial right sum for(int i=1; i<A.length; i++){ sum_right += A[i]; } // initial absolute difference between the sums ads = Math.abs(sum_left - sum_right); // first candidate to become retrun value rv = (int) ads; // loop over whole array, in each step update side sums, calculate and compare ads long tmp_ads = 0; int loop_length = A.length-1; for(int P=1; P<loop_length; P++) { sum_right -= A[P]; sum_left += A[P]; tmp_ads = Math.abs(sum_left - sum_right); if (tmp_ads < rv) rv = (int) tmp_ads; } // for return rv; } // solution() } |
Podsumowanie rozwiązania: https://codility.com/demo/results/trainingDA629V-GDR/
Do wyświetlenia atrybutów żądania podpisania certyfikatu można użyć następującej komendy:
1 |
openssl req -text -noout -in cert.csr |
gdzie cert.csr – plik z żądaniem podpisania certyfikatu.