[dev] [OT] a "suckless" plasmid

2018-10-16 Thread Jens Staal
Dear all,

Just wanted to share a preprint describing the generation of a minimalistic
plasmid which got 56% size reduction from elimination of "useless bloat" DNA
code, while actually gaining additional functionality (more restriction enzyme
cloning sites).

https://www.preprints.org/manuscript/201807.0287/v2

The preprint paper is not really hypothesis-driven science as such and more a
description of the generation of a very useful tool, so I do not think I will
try to make it published "for real".





[dev] [slstatus] [patch] netspeed_*: allow reporting transfer speeds of more than one network interface (on linux)

2018-10-16 Thread John Soros
diff --git a/components/netspeeds.c b/components/netspeeds.c
index 02c030e..1814d86 100644
--- a/components/netspeeds.c
+++ b/components/netspeeds.c
@@ -1,35 +1,70 @@
 /* See LICENSE file for copyright and license details. */
 #include 
+#include 
+#include 
 #include 

 #include "../util.h"

+#define NINTERFACES 2
+
 #if defined(__linux__)
#include 

+   struct netspeed_xif {
+   char *iface;
+   uintmax_t xbytes;
+   };
+   int find_interface_idx(const char * interface, int * nextidx, struct
netspeed_xif * interfaces[]) {
+   int i;
+   int found = 0;
+   for (i=0; i<*nextidx; i++) {
+   if (!strcmp(interfaces[i]->iface, interface)) {
+   found = 1;
+   return i;
+   }
+   }
+   if (!found) {
+   interfaces[*nextidx] = 
malloc(sizeof(interfaces[*nextidx]));
+   interfaces[*nextidx]->iface = malloc(sizeof(interface));
+   sprintf(interfaces[*nextidx]->iface, "%s", interface);
+   interfaces[*nextidx]->xbytes = 0;
+   i = *nextidx;
+   *nextidx = *nextidx+1;
+   return i;
+   }
+   return -1;
+   }
+
const char *
netspeed_rx(const char *interface)
{
uintmax_t oldrxbytes;
-   static uintmax_t rxbytes;
+   static struct netspeed_xif  * rxbytes[NINTERFACES];
+   static int rx_nextidx = 0;
+   int idx = 0;
extern const unsigned int interval;
char path[PATH_MAX];

-   oldrxbytes = rxbytes;
+   idx = find_interface_idx(interface, &rx_nextidx, rxbytes);
+   if (idx < 0) {
+   return NULL;
+   }
+
+   oldrxbytes = rxbytes[idx]->xbytes;

if (esnprintf(path, sizeof(path),
  "/sys/class/net/%s/statistics/rx_bytes",
  interface) < 0) {
return NULL;
}
-   if (pscanf(path, "%ju", &rxbytes) != 1) {
+   if (pscanf(path, "%ju", &rxbytes[idx]->xbytes) != 1) {
return NULL;
}
if (oldrxbytes == 0) {
return NULL;
}
-
-   return fmt_human((rxbytes - oldrxbytes) * 1000 / interval,
+   return fmt_human((rxbytes[idx]->xbytes - oldrxbytes) * 1000 / 
interval,
 1024);
}

@@ -37,25 +72,32 @@
netspeed_tx(const char *interface)
{
uintmax_t oldtxbytes;
-   static uintmax_t txbytes;
+   static struct netspeed_xif  * txbytes[NINTERFACES];
+   static int tx_nextidx = 0;
+   int idx;
extern const unsigned int interval;
char path[PATH_MAX];

-   oldtxbytes = txbytes;
+   idx = find_interface_idx(interface, &tx_nextidx, txbytes);
+   if (idx < 0) {
+   return NULL;
+   }
+
+   oldtxbytes = txbytes[idx]->xbytes;

if (esnprintf(path, sizeof(path),
  "/sys/class/net/%s/statistics/tx_bytes",
  interface) < 0) {
return NULL;
}
-   if (pscanf(path, "%ju", &txbytes) != 1) {
+   if (pscanf(path, "%ju", &txbytes[idx]->xbytes) != 1) {
return NULL;
}
if (oldtxbytes == 0) {
return NULL;
}

-   return fmt_human((txbytes - oldtxbytes) * 1000 / interval,
+   return fmt_human((txbytes[idx]->xbytes - oldtxbytes) * 1000 / 
interval,
 1024);
}
 #elif defined(__OpenBSD__)



Re: [dev] [OT] a "suckless" plasmid

2018-10-16 Thread Laslo Hunhold
On Tue, 16 Oct 2018 09:21:49 +0200
Jens Staal  wrote:

Dear Jens,

> Just wanted to share a preprint describing the generation of a
> minimalistic plasmid which got 56% size reduction from elimination of
> "useless bloat" DNA code, while actually gaining additional
> functionality (more restriction enzyme cloning sites).
> 
> https://www.preprints.org/manuscript/201807.0287/v2
> 
> The preprint paper is not really hypothesis-driven science as such
> and more a description of the generation of a very useful tool, so I
> do not think I will try to make it published "for real".

this looks really interesting! Thanks for sharing this! I like to think
of DNA as a Turing-tape and "optimizing" it (removing old cruft mostly)
is a very adventurous and futuristic approach.

With best regards

Laslo

-- 
Laslo Hunhold 


pgp8ZdjDv2Ql8.pgp
Description: PGP signature