// Return first match in this List, or null. return contents.stream().filter(c -> c.name.equals(fieldName)).findFirst().orElse(null);
<3 lambda <3
According to The Directive 2009/24/EC of the European Parliament and of the Council, and Sec.103(f) of the DMCA (17 U.S.C. § 1201 (f)), the reverse engineering act committed to creating these blog posts is considered legal, as this is an original attempt to improve interoperability, and cannot be waived by license agreements.
The views expressed on this blog are my own and do not necessarily reflect the views of my past and present employers.
// Return first match in this List, or null. return contents.stream().filter(c -> c.name.equals(fieldName)).findFirst().orElse(null);
import java.time.Duration;
import java.time.Instant;
// ...
Instant start = Instant.now();
// Timed operations come here
Instant stop = Instant.now();
System.out.println("Task ran for: " + Duration.between(start, stop));
sysinfo (kernel source), which returns some metrics about the current process.long values, how to make them to be our beloved fractional numbers?SI_LOAD_SHIFT. So we just divide them:#include <sys/sysinfo.h>
// ...
struct sysinfo memInfo;
sysinfo(&memInfo);
printf("sysinfo: load1 = %2.2f\n", (float)memInfo.loads[0] / (float)(1 << SI_LOAD_SHIFT) );
LD_PRELOAD is set or not. For fun.#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *env_val = getenv("LD_PRELOAD");
if (env_val[0] != 0) // May be set but value is empty.
printf("LD_PRELOAD active: \"%s\"\n", env_val);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
void walk_dir(const char *path)
{
struct dirent **namelist;
int i, n;
n = scandir(path, &namelist, NULL/*filter*/, alphasort);
if (n < 0)
{
perror("scandir");
} else {
for (i = 0; i < n; i++) {
printf("Entry: %s\n", namelist[i]->d_name);
free(namelist[i]);
}
free(namelist);
}
}
int main(void)
{
walk_dir("/tmp");
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
void walk_dir(const char *path)
{
struct dirent *entry;
DIR *dir = opendir(path);
while ((entry = readdir(dir)) != NULL) {
printf("Entry: %s\n", entry->d_name);
}
}
int main(void)
{
walk_dir("/tmp");
return EXIT_SUCCESS;
}
void fancy(long l, long nearest)
{
char suffix[2] = "";
long mod, val = l;
float f;
if(val < 1500) /* Too small to pretty print. */
{
printf("%li B", val);
} else {
mod = val % nearest;
/* Where are we in the range? */
if(mod >= (nearest - mod))
{ // hi - we are at or above the 50% of the [0-nearest[ range.
// add the difference to reach upper nearest.
val += (nearest - mod);
} else { // lo
// substract the difference to reach lower nearest.
val -= mod;
}
if(val < 1100000L)
{
f = (float)val / 1000;
suffix[0] = 'K';
} else if(val < 1100000000L)
{
f = (float)val / 1000000;
suffix[0] = 'M';
} else {
f = (float)val / 1000000000;
suffix[0] = 'G';
}
printf("%.2f %sB", f, suffix); // Here you can play with the format.
}
}
long size = 3141592535L; fancy(size, 1000);
2012. évi I. törvény
a munka törvénykönyvéről
7. § (1) Tilos a joggal való visszaélés. E törvény alkalmazásában joggal való visszaélés különösen, ha az mások jogos érdekeinek csorbítására, érdekérvényesítési lehetőségeinek korlátozására, zaklatására, véleménynyilvánításának elfojtására irányul vagy ehhez vezet.
Érdekesség, hogy az említett "mások jogos érdekei"-ben a "mások" vonatkozik a munkaerőpiac többi tagjára (pl. jelen és leendő munkavállalók, tehát en bloc a Piac), illetve a fizetés eltitkolása nem jogszerű érdeke a munkáltatónak, hisz az piackorlátozó hatású.
Azaz például (leendő) munkáltató nem korlátozhatja munkaszerződés-ajánlat nyilvánosságra hozását, ajánlott bér összegének továbbközlését; munkáltatóról (vagy bármi másról) vélemény formálását, mely nem tetszik a munkáltatónak, pl. felvételi folyamat kritizálása, vagy sima leírása (lásd: Glassdoor, fórumok), hiszen az nem a munkája során kerül tudomására.
A probléma az, hogy a jogalkalmazói gyakorlatban viszont a PTK üzleti titok definícióját alkalmazzák, ami szerint a munkabér kifejezetten üzleti titok.
Ám mivel a munkabérrel, kompenzációval kapcsolatban az alkalmazó és az alkalmazott is titokgazda, az alkalmazottak a saját bérezésükkel kapcsolatban nem jogosulatlan személyek, így az üzleti titoksértés nem állhat fent (nincs illetéktelenség).
A Munka Törvénykönyve szerint a munkaszerződés munkaviszonyra vonatkozó szabálytól csak a munkavállaló javára térhet el, így elvileg egy ilyen irányú tiltás alapvetően jogellenes.
Mi hát a megoldás eme szürke zónában Magyarországon? Kinek van jobb ügyvédje, ha a munkáltató pert indít...
(gdb) bt #0 0x00007f8ac115bebe in __lll_lock_wait_private () from /lib64/libc.so.6 #1 0x00007f8ac10f22be in _L_lock_9876 () from /lib64/libc.so.6 #2 0x00007f8ac10f05c1 in free () from /lib64/libc.so.6 #3 0x0000000000402649 in handle_sig (signo=<optimized out>, info=<optimized out>, context=<optimized out>) at lol.c:158 #4 <signal handler called> #5 0x00007f8ac10edf03 in _int_malloc () from /lib64/libc.so.6 #6 0x00007f8ac10f06b7 in malloc () from /lib64/libc.so.6 #7 0x00000000004015ba in do_the_boogie (fd=3, gp=<optimized out>) at lol.c:715 #8 0x00000000004023cc in main (argc=5, argv=<optimized out>) at lol.c:810
malloc (frame #5), and the signal handler calls free in frame #3. Of course, the heap lock is held in frame #5 and both are in the same memory arena (see: break space), hence we are screwed.