View filter if field contains a value?

I’m trying to filter my view based on data in a single field. My field targetuser contains a string of numbers: 47, 505, 100, 20.

I’m trying to setup the view so that if targetuser contains the logged in user ID (in this case, that’s 47), the content should be visible.

The view's setup

However, the setup I have now only works if a single number is inside that field, not four numbers.

How can I accomplish this?

Note, I’ve installed the Views Argument Substitution module. The settings for the second contextual filter I’m referencing are the following.

content:targetuser:provide default value: logged in user id


Dynamically configurable ZMQ filter with Flask API

I have a stream of ZMQ messages, I need to filter the right ones and save them in MongoDB. The trick is to have an option to set the filter conditions dynamically.

I have come up with this solution using multiprocessing and Flask. Basicaly I use Flask HTTP API to change the global filter_parameters dictionary given by Manager and shared with another Process that is running the zmq filter itself. So my question is – is it a good solution and what is the best practice in this regard?

from multiprocessing import Process, Manager from flask import Flask, jsonify, request from pymongo import MongoClient  app = Flask(__name__) manager = Manager() filter_parameters = manager.dict() filter_parameters['addresses'] = ['']  def scan(q, filter_parameters):     import zmq     context = zmq.Context()     socket = context.socket(zmq.SUB)     socket.connect("tcp://localhost:5556")     socket.setsockopt_unicode(zmq.SUBSCRIBE, 'tx')     client = MongoClient() # localhost     db = client.transactions_db     tx_collection = db.tx_collection     while True:         recv_str = socket.recv_string()         recv_str = recv_str.split()         filter(recv_str, filter_parameters, tx_collection)  def filter(recv_str, filter_parameters, tx_collection):     if recv_str[0] == 'tx':         if recv_str[7] == '0':             if recv_str[2] in filter_parameters['addresses']:                 tx_collection.insert_one({'tx':recv_str}).inserted_id  p = Process(target=scan, args=(filter_parameters)) p.daemon = True p.start()  @app.route('/zmq_buffer/set_filter_addresses', methods=["POST"]) def set_filter_addresses():     data_jsn = request.json     filter_parameters['addresses'] = data_jsn['addresses']     return jsonify({'addresses':filter_parameters['addresses']}), 200  @app.route('/zmq_buffer/get_filter_addresses', methods=["GET"]) def get_filter_addresses():     if filter_parameters['addresses']:         resp = jsonify(filter_parameters['addresses'])     else:         resp = 'None'     return resp, 200  if __name__ == '__main__':     p.terminate() 

Resampling using Spline filter and weird artifacts [on hold]

I am trying to write a simple function to resample images. However I get weird artifacts when using “Spline” filter but now when using “Hermite” filter.

This is my input grayscale image:

enter image description here

Simplified, pseudocodish code:

  Func = SplineFilter;    Bmp2 = new Bitmap();   Bmp2.SetSize(350, 320);    ratioX = (Bmp.Width-1)/(Bmp2.Width -1);   ratioY = (Bmp.Height-1)/(Bmp2.Height -1);    for (y=0; y<Bmp2.Height; y++)   {   for (x=0; x<Bmp2.Width; x++)   {     xx = ratioX * x;     yy = ratioY * y;      //central point     xxx = Round(xx); //the result is integer     yyy = Round(yy); //the result is integer      diffX = xxx - xx;     diffY = yyy - yy;      p1 = Bmp.GetPixel(xxx-1,yyy-1);     p2 = Bmp.GetPixel(xxx  ,yyy-1);     p3 = Bmp.GetPixel(xxx+1,yyy-1);      p4 = Bmp.GetPixel(xxx-1,yyy  );     p5 = Bmp.GetPixel(xxx  ,yyy  );     p6 = Bmp.GetPixel(xxx+1,yyy  );      p7 = Bmp.GetPixel(xxx-1,yyy+1);     p8 = Bmp.GetPixel(xxx  ,yyy+1);     p9 = Bmp.GetPixel(xxx+1,yyy+1);       R = Func(diffX-1) * Func(diffY-1) * p1.Red +         Func(diffX  ) * Func(diffY-1) * p2.Red +         Func(diffX+1) * Func(diffY-1) * p3.Red +          Func(diffX-1) * Func(diffY  ) * p4.Red +         Func(diffX  ) * Func(diffY  ) * p5.Red +         Func(diffX+1) * Func(diffY  ) * p6.Red +          Func(diffX-1) * Func(diffY+1) * p7.Red +         Func(diffX  ) * Func(diffY+1) * p8.Red +         Func(diffX+1) * Func(diffY+1) * p9.Red;      RR = Clip(R); //result is integer. >=255 becomes 255. <=0 becomes 0. Everything else is rounded      Bmp2.SetPixel(x,y, RGBA(RR,RR,RR, 255));            }   } 

The “Spline” filter is defined in a rather standard way:

function SplineFilter(Value) {   if (Value < 0.0)   {     Value = -Value;   }   if (Value < 1.0)   {     tt = Sqr(Value);     Result = 0.5*tt*Value - tt + 2.0 / 3.0;   }    else if (Value < 2.0)   {     Value = 2.0 - Value;     Result = 1.0/6.0 * Sqr(Value) * Value;   }    else   {     Result = 0.0;   } } 

And this is how the result looks:

enter image description here

However the same function with “Hermite” filter works just fine. This is the result:

enter image description here

And here’s the code of Hermite, rather usual definition:

function HermiteFilter(Value) {   if (Value < 0.0)   {     Value = -Value;   }   if (Value < 1.0)   {     Result = (2.0 * Value - 3.0) * Sqr(Value) + 1.0   }   else   {     Result = 0.0;   } } 

The problem isn’t only with “Spline”. Some filters give similar problems to “Spline” (like “Lanczos”). However some other filters (like “Box”) work just as fine as “Hermite”. It doesn’t seem like a rounding error to me. Almost everything is done on floats. Integers are marked in code and there isn’t a lot of them.

How to filter list by Current Year and future?

I have found this thread, but this is not really same as my case. For example, I have a column Year, let us say, I enter a project Year 2018, I could finish the project in 2018, but it is also possible that I won’t finish it till 2019 or even 2020. But it does not matter, even it has not been finished and it is 2019 right now, when I filter it, I do NOT want the project shown up, since it was entered as 2018.

Right now it is 2019, I could enter 2020 in the Year column for upcoming project, so for custom view, I want this project to be shown.

So basically, the filter result should have Year 2019 or greater than 2019 in the column input, SINCE it is year of 2019 today.


Dynamic G-Mail Extension For Label And Filter

Over the past few weeks I’ve been looking at how you can set up filters to categorise your G-Mail inbox.

So currently, something like: 

Gets shown as Website/Contact in my inbox.

This is great, but I was wondering if there was a way to have multiple filters without having to set up multiple labels?

I’ll give you a hyperthetical example:

If my website had some details stored in php for each page: <?php $ page = "About";, And I was to apply this to my email address:

<a href="mailto:business+website.<?php echo $ page; ?>">

Resulting In:

Website/About Website/Contact Website/Projects

Would it be possible to have a label to capture these time without having to set up multiple labels and filters?