text:
Q: mono csharp linux(ubuntu) global hook keyboard me need realized global hook in mono csharp, i read xkeyhook xkeyhookkeybord...  no work all samples(
hover me to think how best to implement ....
thank*
    public X11Hotkey(Gdk.Key key, Gdk.ModifierType modifiers)
    {
        this.key = key;
        this.modifiers = modifiers;

        Gdk.Window rootWin = Gdk.Global.DefaultRootWindow;
        IntPtr xDisplay = GetXDisplay(rootWin);
        this.keycode = XKeysymToKeycode(xDisplay, (int)this.key);
        //here ask the filter
        rootWin.AddFilter(new Gdk.FilterFunc(FilterFunction));
    }

    //function is not executed
    private Gdk.FilterReturn FilterFunction(IntPtr xEvent, Gdk.Event evnt)
    {
        XKeyEvent xKeyEvent = (XKeyEvent)Marshal.PtrToStructure(
            xEvent,
            typeof(XKeyEvent));

        if (xKeyEvent.type == KeyPress)
        {
            if (xKeyEvent.keycode == this.keycode
                && xKeyEvent.state == (uint)this.modifiers)
            {
                this.OnPressed(EventArgs.Empty);
            }
        }

        return Gdk.FilterReturn.Continue;
    }

filter no return evenе... what to do??

A:  public delegate void SpecialKeyPressedHandler(object o, SpecialKey key);

    public enum SpecialKey
    {
        one = Gdk.Key.exclam,
        two = Gdk.Key.at,
        tree = Gdk.Key.numbersign,
        four = Gdk.Key.dollar,
        five = Gdk.Key.percent,
        six = Gdk.Key.asciicircum,
        seven = Gdk.Key.ampersand,
        eight = Gdk.Key.asterisk,
        nine = Gdk.Key.parenleft,
        nul = Gdk.Key.parenright,
        retu = Gdk.Key.Return

    };

    public class SpecialKeys
    {
        private Hashtable key_map = new Hashtable();
        private Hashtable key_registrations = new Hashtable();
        private IEnumerable keycode_list;
        private TimeSpan raise_delay = new TimeSpan(0);
        private DateTime last_raise = DateTime.MinValue;

        public SpecialKeys()
        {
            Console.WriteLine("init");
            keycode_list = BuildKeyCodeList();
            InitializeKeys();
        }

        public void Dispose()
        {
            UnitializeKeys();
        }

        public void RegisterHandler(SpecialKeyPressedHandler handler, params SpecialKey [] specialKeys)
        {
            foreach(SpecialKey specialKey in specialKeys) {
                if(key_map.Contains(specialKey)) {
                    int key = (int)key_map[specialKey];
                    key_registrations[key] = Delegate.Combine(key_registrations[key] as Delegate, handler);
                }
            }
        }

        public void UnregisterHandler(SpecialKeyPressedHandler handler, params SpecialKey [] specialKeys)
        {
            foreach(SpecialKey specialKey in specialKeys) {
                if(key_map.Contains(specialKey)) {
                    int key = (int)key_map[specialKey];
                    key_registrations[key] = Delegate.Remove(key_registrations[key] as Delegate, handler);
                }
            }
        }

        private IEnumerable BuildKeyCodeList()
        {
            ArrayList kc_list = new ArrayList();

            foreach(SpecialKey key in Enum.GetValues(typeof(SpecialKey))) {
                IntPtr xdisplay = gdk_x11_get_default_xdisplay();

                if(!xdisplay.Equals(IntPtr.Zero)) {
                    int keycode = XKeysymToKeycode(xdisplay, key);
                    if(keycode != 0) {
                        key_map[keycode] = key;
                        key_map[key] = keycode;
                        kc_list.Add(keycode);
                    }
                }
            }
            return kc_list;
        }

        private void InitializeKeys()
        {
            for(int i = 0; i < Gdk.Display.Default.NScreens; i++) {
                Gdk.Screen screen = Gdk.Display.Default.GetScreen(i);

                foreach(int keycode in keycode_list) {
                    GrabKey(screen.RootWindow, keycode);
                }
                screen.RootWindow.AddFilter(FilterKey);
            }

        }

        private void UnitializeKeys()
        {
            for(int i = 0; i < Gdk.Display.Default.NScreens; i++) {
                Gdk.Screen screen = Gdk.Display.Default.GetScreen(i);
                foreach(int keycode in keycode_list) {
                    UngrabKey(screen.RootWindow, keycode);
                }
                screen.RootWindow.RemoveFilter(FilterKey);
            }
        }

        private void GrabKey(Gdk.Window root, int keycode)
        {

            IntPtr xid = gdk_x11_drawable_get_xid(root.Handle);
            IntPtr xdisplay = gdk_x11_get_default_xdisplay();

            gdk_error_trap_push();

            XGrabKey(xdisplay, keycode, XModMask.None, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod2, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod5, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Lock, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Mod5, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Lock, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod5 | XModMask.Lock, xid, true, XGrabMode.Async, XGrabMode.Async);
            XGrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Mod5 | XModMask.Lock, xid, true,
                XGrabMode.Async, XGrabMode.Async);

            gdk_flush();

            if(gdk_error_trap_pop() != 0) {
                Console.Error.WriteLine(": Could not grab key {0} (maybe another application has grabbed this key)", keycode);
            }
        }

        private void UngrabKey(Gdk.Window root, int keycode)
        {
            IntPtr xid = gdk_x11_drawable_get_xid(root.Handle);
            IntPtr xdisplay = gdk_x11_get_default_xdisplay();

            gdk_error_trap_push();

            XUngrabKey(xdisplay, keycode, XModMask.None, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod2, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod5, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Lock, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Mod5, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Lock, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod5 | XModMask.Lock, xid);
            XUngrabKey(xdisplay, keycode, XModMask.Mod2 | XModMask.Mod5 | XModMask.Lock,xid);

            gdk_flush();

            if(gdk_error_trap_pop() != 0) {
                Console.Error.WriteLine(": Could not ungrab key {0} (maybe another application has grabbed this key)", keycode);
            }
        }

        private Gdk.FilterReturn FilterKey(IntPtr xeventPtr, Gdk.Event gdkEvent)
        {
            Console.WriteLine("filter "+ gdkEvent.Type);
            if(DateTime.Now - last_raise < raise_delay) {
                return Gdk.FilterReturn.Continue;
            }

            last_raise = DateTime.Now;

            XKeyEvent xevent = (XKeyEvent)Marshal.PtrToStructure(xeventPtr, typeof(XKeyEvent));

            if(xevent.type != XEventName.KeyPress) {
                return Gdk.FilterReturn.Continue;
            }

            int keycode = (int)xevent.keycode;
            object x = key_map[keycode];

            Console.WriteLine("filter "+ keycode);

            if(x == null) {
                return Gdk.FilterReturn.Continue;
            }

            SpecialKey key = (SpecialKey)key_map[keycode];

            if(key_registrations[keycode] != null) {
                x = key_registrations[keycode];
                if(x is SpecialKeyPressedHandler) {
                    ((SpecialKeyPressedHandler)x)(this, key);
                }
                return Gdk.FilterReturn.Remove;
            }

            return Gdk.FilterReturn.Continue;
        }

        public TimeSpan Delay {
            get {
                return raise_delay;
            }

            set {
                raise_delay = value;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct XKeyEvent
        {
            public XEventName type;
            public IntPtr serial;
            public bool send_event;
            public IntPtr display;
            public IntPtr window;
            public IntPtr root;
            public IntPtr subwindow;
            public IntPtr time;
            public int x;
            public int y;
            public int x_root;
            public int x_y;
            public uint state;
            public uint keycode;
            public bool same_screen;
        }

        [DllImport("libX11")]
        private static extern int XKeysymToKeycode(IntPtr display, SpecialKey keysym);

        [DllImport("libX11")]
        private static extern void XGrabKey(IntPtr display, int keycode, XModMask modifiers,
            IntPtr window, bool owner_events, XGrabMode pointer_mode, XGrabMode keyboard_mode);

        [DllImport("libX11")]
        private static extern void XUngrabKey(IntPtr display, int keycode, XModMask modifiers,
            IntPtr window);

        [DllImport("gdk-x11-2.0")]
        private static extern IntPtr gdk_x11_drawable_get_xid(IntPtr window);

        [DllImport("gdk-x11-2.0")]
        private static extern IntPtr gdk_x11_get_default_xdisplay();

        [DllImport("gdk-x11-2.0")]
        private static extern void gdk_error_trap_push();

        [DllImport("gdk-x11-2.0")]
        private static extern int gdk_error_trap_pop();

        [DllImport("gdk-x11-2.0")]
        private static extern void gdk_flush();

        [Flags]
        private enum XModMask {
            None    = 0,
            Shift   = 1 << 0,
            Lock    = 1 << 1,
            Control = 1 << 2,
            Mod1    = 1 << 3,
            Mod2    = 1 << 4,
            Mod3    = 1 << 5,
            Mod4    = 1 << 6,
            Mod5    = 1 << 7
        }

        private enum XGrabMode {
            Sync  = 0,
            Async = 1
        }

        private enum XEventName {
            KeyPress   = 2,
            KeyRelease = 3,
        }
    }

all work!

A: GDK filters are not designed as global hooks. They will only give you events that would already be delivered to your process, before the normal processing.
To arrange to have keyboard events for a specific key combination delivered to your process, use the XGrabKey function with the root window. Note that some things not normally considered "modifiers", such as CapsLock, are considered modifiers by X11, and you will need to grab with all possible configurations of the modifiers you wish to ignore. You may also find this question useful.
X is not designed with global keyboard or mouse hooks in mind. While it is possible to have ALL events delivered to your process, it cannot be done without interfering with other processes.


text:
Q: method toequal() with protractor failed I have a problem with protractor. This is my code :
var NewSimulationPage = function () {
    this.errormsg = element(by.xpath("//div[@class='errormsg']"));
}

describe('language ', function () {
    it("Creation d'un nouveau Previndi ", function func() {
    //nouvelle tarification
    oNewSimulationPage = new NewSimulationPage();
    oNewSimulationPage.nextTaskClick();
    expect(oNewSimulationPage.errormsg.getText()).toEqual("La saisie est incomplète");
    });
});

In the HTML code I have this:

La saisie est incomplète

The value of the oNewSimulationPage.errormsg.getText() is "La saisie est incomplète", but when I run the test with protractor, I have an error message: "Expected 'La saisie est incomplète' to equal 'La saisie est incompl?te'."
Why does protractor replace the character 'è' by the charachter '?' ?

A: *

*Save your test files with UTF8 encoding (check for your files editor's preferences)

*Ensure the webpage is UTF8.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How calculate distance between two points measured in longitude and latitude I have a dataframe where, columns with subscript 1 are starting points and with 2 are end points.
I want to find a difference in kilometers between them.
I tried following code however got an error
import mpu
import pandas as pd
import numpy as np

data = {'lat1': [116.51172,116.51135,116.51135,116.51627,116.47186],
        'lon1': [39.92123,39.93883,39.93883,39.91034,39.91248],
        'lat2': [np.nan,116.51172,116.51135,116.51135,116.51627],
        'lon2': [np.nan,39.92123,39.93883,39.93883,39.91034]}

# Create DataFrame
df_test = pd.DataFrame(data)

mpu.haversine_distance((df.lat1, df.lon1), (df.lat2, df.lon2))


text:
Q: PHP file_get_contents very slow when using full url I am working with a script (that I did not create originally) that generates a pdf file from an HTML page. The problem is that it is now taking a very long time, like 1-2 minutes, to process. Supposedly this was working fine originally, but has slowed down within the past couple of weeks.
The script calls file_get_contents on a php script, which then outputs the result into an HTML file on the server, and runs the pdf generator app on that file.
I seem to have narrowed down the problem to the file_get_contents call on a full url, rather than a local path.
When I use
$content = file_get_contents('test.txt');

it processes almost instantaneously. However, if I use the full url
$content = file_get_contents('http://example.com/test.txt');

it takes anywhere from 30-90 seconds to process.
It's not limited to our server, it is slow when accessing any external url, such as http://www.google.com. I believe the script calls the full url because there are query string variables that are necessary that don't work if you call the file locally.
I also tried fopen, readfile, and curl, and they were all similarly slow. Any ideas on where to look to fix this?

A: Sometimes, it's because the DNS is too slow on your server, try this:
replace
echo file_get_contents('http://www.google.com');

as
$context=stream_context_create(array('http' => array('header'=>"Host: www.google.com\r\n")));
echo file_get_contents('http://74.125.71.103', false, $context);

A: I would use curl() to fetch external content, as this is much quicker than the file_get_contents method. Not sure if this will solve the issue, but worth a shot.
Also note that your servers speed will effect the time it takes to retrieve the file.
Here is an example of usage:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/test.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

A: I had the same issue,
The only thing that worked for me is setting timeout in $options array.
$options = array(
    'http' => array(
        'header'  => implode($headers, "\r\n"),
        'method'  => 'POST',
        'content' => '',
        'timeout' => .5
    ),
);

A: $context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
$string = file_get_contents("http://localhost/testcall/request.php",false,$context);

Time: 50976 ms (avaerage time in total 5 attempts)
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, "http://localhost/testcall/request.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
echo $data = curl_exec($ch);
curl_close($ch);

Time: 46679 ms (avaerage time in total 5 attempts)
Note: request.php is used to fetch some data from mysql database.

A:
Note: This has been fixed in PHP 5.6.14. A Connection: close header will now automatically be sent even for HTTP/1.0 requests. See commit 4b1dff6.

I had a hard time figuring out the cause of the slowness of file_get_contents scripts.
By analyzing it with Wireshark, the issue (in my case and probably yours too) was that the remote web server DIDN'T CLOSE THE TCP CONNECTION UNTIL 15 SECONDS (i.e. "keep-alive").
Indeed, file_get_contents doesn't send a "connection" HTTP header, so the remote web server considers by default that's it's a keep-alive connection and doesn't close the TCP stream until 15 seconds (It might not be a standard value - depends on the server conf).
A normal browser would consider the page is fully loaded if the HTTP payload length reaches the length specified in the response Content-Length HTTP header. File_get_contents doesn't do this and that's a shame.
SOLUTION
SO, if you want to know the solution, here it is:
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
file_get_contents("http://www.something.com/somepage.html",false,$context);

The thing is just to tell the remote web server to close the connection when the download is complete, as file_get_contents isn't intelligent enough to do it by itself using the response Content-Length HTTP header.

A: Can you try fetching that url, on the server, from the command line? curl or wget come to mind. If those retrieve the URL at a normal speed, then it's not a network problem and most likely something in the apache/php setup.

A: I have a huge data passed by API, I'm using file_get_contents to read the data, but it took around 60 seconds. However, using KrisWebDev's solution it took around 25 seconds.
$context = stream_context_create(array('https' => array('header'=>'Connection: close\r\n')));
file_get_contents($url,false,$context);

A: What I would also consider with Curl is that you can "thread" the requests. This has helped me immensely as I do not have access to a version of PHP that allows threading at the moment .
For example, I was getting 7 images from a remote server using file_get_contents and it was taking 2-5 seconds per request. This process alone was adding 30seconds or something to the process, while the user waited for the PDF to be generated.
This literally reduced the time to about 1 image.  Another example, I verify 36 urls in the time it took before to do one. I think you get the point. :-)
    $timeout = 30;
    $retTxfr = 1;
    $user = '';
    $pass = '';

    $master = curl_multi_init();
    $node_count = count($curlList);
    $keys = array("url");

    for ($i = 0; $i < $node_count; $i++) {
        foreach ($keys as $key) {
            if (empty($curlList[$i][$key])) continue;
            $ch[$i][$key] = curl_init($curlList[$i][$key]);
            curl_setopt($ch[$i][$key], CURLOPT_TIMEOUT, $timeout); // -- timeout after X seconds
            curl_setopt($ch[$i][$key], CURLOPT_RETURNTRANSFER, $retTxfr);
            curl_setopt($ch[$i][$key], CURLOPT_HTTPAUTH, CURLAUTH_ANY);
            curl_setopt($ch[$i][$key], CURLOPT_USERPWD, "{$user}:{$pass}");
            curl_setopt($ch[$i][$key], CURLOPT_RETURNTRANSFER, true);
            curl_multi_add_handle($master, $ch[$i][$key]);
        }
    }

    // -- get all requests at once, finish when done or timeout met --
    do {  curl_multi_exec($master, $running);  }
    while ($running > 0);

Then check over the results:
            if ((int)curl_getinfo($ch[$i][$key], CURLINFO_HTTP_CODE) > 399 || empty($results[$i][$key])) {
                unset($results[$i][$key]);
            } else {
                $results[$i]["options"] = $curlList[$i]["options"];
            }
            curl_multi_remove_handle($master, $ch[$i][$key]);
            curl_close($ch[$i][$key]);

then close file:
    curl_multi_close($master);

A: I know that is old question but I found it today and answers didn't work for me. I didn't see anyone saying that max connections per IP may be set to 1. That way you are doing API request and API is doing another request because you use full url. That's why loading directly from disc works. For me that fixed a problem:
if (strpos($file->url, env('APP_URL')) === 0) {
    $url = substr($file->url, strlen(env('APP_URL')));
} else {
    $url = $file->url;
}
return file_get_contents($url);


text:
Q: Formatting a string in php Can anyone help with this formatting. I have a paragraph in a database with says (for example) 'black;blue;green' and I want to call it from the db and the format all the ; to be new lines \n.
so it becomes
black
blue
green

Any ideas?

A: $string = str_replace(';', "\n", $string);

A: $str = str_replace(";", "\n", $string);
Finds the ; and replaces it by newline.
Refer this for more


text:
Q: What are books/notes on coordinate-free statistics? There are some books here, but all focus on linear models.
Do we have books/notes with broader coverages?
In case of linear models, "coordinate-free" basically means "matrix-free" and uses the theory of vector space, and the viewpoint is geometric. (Outside of linearity, would we go into something like Information Geometry?)
Edit: It seems Information Geometry and Topological Data Analysis are related to this question. But books on IG and TDA tend to collect recent research results, and the problems solved are specialized. Rather, I'd like to see coordinate-free reconstructions of main stream statistical methods (maybe also advanced ones), and this would also help to learn IG and TDA, proper.


text:
Q: One to many relationship with the mandatory participation at the 1: site I am new to SQL and I would like to develop a database with two tables(project, task). One to many relationship. How can I create a constraint in SQL (javaDB, Apache Derby) to check that each project must have at least one or more task and each task must be assigned to at most one project. This is just an example but I am interested mainly in the mandatory participation at the 1: site.
In SQL Anywhere I can use Check Exist constraint something like this: CHECK(EXIST(SELECT * FROM task WHERE project.project_pk = task.task_pk). The problem is that CHECK EXIST constraint is not in Apache Derby.

A: you can't have both of these constraints in effect at the same time.
consider how these will be created - whichever one you create first will fail the constraint.
I think typically, the parent object, in your example the project, would not have a constraint about the children.  however the child, in your example the task, would contain a NOT NULL column that was a Foreign Key to the parent.


text:
Q: PHPExcel and Mpdf not generating file I'm generating a template using PHPExcel and then I want it to be converted to a PDF file using Mpdf. I'm using PHPExcel 1.7.8 and Mpdf 6.0
But the problem is that

*

*The PDF file is not generated

*The browser wants to display the generated file.

My Code
    $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
    $rendererLibrary = 'mpdf';
    $rendererLibraryPath = APPPATH.'plugins/' .
    $rendererLibrary;
    if (!PHPExcel_Settings::setPdfRenderer(
                 $rendererName,
                 $rendererLibraryPath
           )) {
           die(
                 'Please set the $rendererName and $rendererLibraryPath values' .
                 PHP_EOL .
                 ' as appropriate for your directory structure'
    ); }

    $filename = "DWG Register.pdf"; //save workbook to a file name

    header('Content-Type: application/pdf'); //mime type
    header('Content-Disposition: attachement;filename="'.$filename.'"'); //tell browser what's the file name
    header('Cache-Control: max-age=0'); //no cache

    $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF');
    $objWriter->setSheetIndex(0);
    $objWriter->save('php://output');
    exit;


text:
Q: How to access to the {window, location} in the gatsby-theme-material-ui-top-layout How can I access to the {window, location} in the gatsby-theme-material-ui-top-layout/components/top-layout
Do I have to use gatsby-plugin-layout?
Can I use both instead gatsby-plugin-layout and gatsby-theme-material-ui?

A: You don't need extra plugins to do that. You have a bunch of options to achieve this, but without any code provided it's difficult to guess which one fits your requirements or specifications. You can access the window object at any time, keeping in mind that your code may throw an error on build command, so:

*

*Place your code inside a componentDidMount lifecycle or a useEffect hook which ensures the code doesn't run unless it's in the browser, where the window will be defined.

*Use a condition before you execute your statement:
if (typeof window !== 'undefined') {
      //your code here
    }

*Another option is that your code uses a third-party module/library that needs the window to be defined before, so, when Gatsby builds (compiles and bundles) all your assets, your code may throw an error due to the needs of the library and the undefinition of the window object at that moment, in that case, you need to change your webpack loader to null. In your gatsby-node.js:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
  if (stage === "build-html") {
    actions.setWebpackConfig({
      module: {
        rules: [
          {
            test: /bad-module/,
            use: loaders.null(),
          },
        ],
      },
    })
  }
}


text:
Q: Sinch Android SDK crash when receiving new instant message I'm using Sinch Android SDK for instant messaging.
I'm Receiving the below error whenever someone send me a message, the error occurred before the "onIncomingMessage" listener is called.
I'm using Nexus 5, 5.1.1 with Sinch version 3.6.2, thanks.
Logcat:
08-10 17:48:00.853    4933-5484/com.my.package A/libc? Fatal signal 11 (SIGSEGV), code 1, fault addr 0x29a in tid 5484 (Thread-14334)
08-10 17:48:00.958      187-187/? I/DEBUG? *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-10 17:48:00.958      187-187/? I/DEBUG? Build fingerprint: 'google/hammerhead/hammerhead:5.1.1/LMY48B/1863243:user/release-keys'
08-10 17:48:00.960      187-187/? I/DEBUG? Revision: '11'
08-10 17:48:00.960      187-187/? I/DEBUG? ABI: 'arm'
08-10 17:48:00.963      187-187/? I/DEBUG? pid: 4933, tid: 5484, name: Thread-14334  >>> com.my.package <<<
08-10 17:48:00.964      187-187/? I/DEBUG? signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x29a
08-10 17:48:01.004      187-187/? I/DEBUG? r0 0000029a  r1 9af0bded  r2 00000054  r3 00000007
08-10 17:48:01.004      187-187/? I/DEBUG? r4 9a9704d0  r5 9a970460  r6 9a970480  r7 9a970620
08-10 17:48:01.004      187-187/? I/DEBUG? r8 9a9704ec  r9 9a9703d0  sl aefa84e0  fp aefa84e0
08-10 17:48:01.004      187-187/? I/DEBUG? ip 9af9ad70  sp 9a970388  lr 9ad215a5  pc b6df7372  cpsr 200b0030
08-10 17:48:01.004      187-187/? I/DEBUG? backtrace:
08-10 17:48:01.004      187-187/? I/DEBUG? #00 pc 00014372  /system/lib/libc.so (strcpy+5)
08-10 17:48:01.004      187-187/? I/DEBUG? #01 pc 001a85a1  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.004      187-187/? I/DEBUG? #02 pc 0025e2cc  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #03 pc 0026801c  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #04 pc 0026a640  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #05 pc 00245f54  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #06 pc 00243f50  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #07 pc 00245314  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #08 pc 00245480  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #09 pc 001ebb40  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #10 pc 001ed6c8  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #11 pc 001ec63c  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #12 pc 001ee064  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #13 pc 001ef8c0  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #14 pc 002d0e2c  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #15 pc 002d1354  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #16 pc 001abf07  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #17 pc 001af3dd  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #18 pc 001af7e3  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.005      187-187/? I/DEBUG? #19 pc 001afb91  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #20 pc 001b0621  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #21 pc 001b31f5  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #22 pc 001aee55  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #23 pc 001b8701  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #24 pc 001b7f53  /data/app/com.my.package-2/lib/arm/libsinch-android-rtc.so
08-10 17:48:01.006      187-187/? I/DEBUG? #25 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
08-10 17:48:01.006      187-187/? I/DEBUG? #26 pc 00014af3  /system/lib/libc.so (__start_thread+6)
08-10 17:48:02.271      187-187/? I/DEBUG? Tombstone written to: /data/tombstones/tombstone_01
08-10 17:48:02.271     752-5712/? W/ActivityManager? Process com.my.package has crashed too many times: killing!
08-10 17:48:02.271     752-5712/? W/ActivityManager? Force finishing activity 4 com.my.package/.ui.activities.messenger.MessengerActivity
08-10 17:48:02.271      752-822/? I/BootReceiver? Copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE)
08-10 17:48:02.278    4933-4933/com.my.package I/Choreographer? Skipped 78 frames!  The application may be doing too much work on its main thread.
08-10 17:48:02.308     752-5712/? W/ActivityManager? Force finishing activity 4 com.my.package/.ui.activities.myapp.myappActivity
08-10 17:48:02.323     752-5712/? W/ActivityManager? Wtf, activity ActivityRecord{3652e5b u0 com.my.package/.ui.activities.myapp.myappActivity t2536 f} in proc activity list not using proc ProcessRecord{1b40577f 4933:com.my.package/u0a179}?!?
08-10 17:48:02.323     752-5712/? W/ActivityManager? Wtf, activity ActivityRecord{d075827 u0 com.my.package/.ui.activities.messenger.MessengerActivity t2536 f} in proc activity list not using proc ProcessRecord{1b40577f 4933:com.my.package/u0a179}?!?
08-10 17:48:02.323      178-178/? E/lowmemorykiller? Error writing /proc/4933/oom_score_adj; errno=22
08-10 17:48:02.329     752-5712/? I/ActivityManager? Killing 4933:com.my.package/u0a179 (adj 9): crash
08-10 17:48:02.386      752-766/? I/art? Background sticky concurrent mark sweep GC freed 134459(6MB) AllocSpace objects, 17(432KB) LOS objects, 13% free, 42MB/48MB, paused 2.489ms total 111.011ms
08-10 17:48:02.438      202-202/? I/Zygote? Process 4933 exited due to signal (11)
08-10 17:48:02.481     752-1308/? W/ActivityManager? Spurious death for ProcessRecord{1b40577f 4933:com.my.package/u0a179}, curProc for 4933: null
08-10 17:48:02.739      752-768/? W/InputMethodManagerService? Got RemoteException sending setActive(false) notification to pid 4933 uid 10179
08-10 17:48:02.742    1140-1140/? I/Keyboard.Facilitator? onFinishInput()

Here is the SinchService I'm using, I copied it from sinch sdk samples (sinch-rtc-sample-messaging) :
    package com.sinch.android.rtc.sample.messaging;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

import com.sinch.android.rtc.*;
import com.sinch.android.rtc.messaging.MessageClientListener;
import com.sinch.android.rtc.messaging.WritableMessage;

public class SinchService extends Service {

    private static final String APP_KEY = "enter-application-key";
    private static final String APP_SECRET = "enter-application-secret";
    private static final String ENVIRONMENT = "sandbox.sinch.com";

    private static final String TAG = SinchService.class.getSimpleName();

    private final SinchServiceInterface mServiceInterface = new SinchServiceInterface();

    private SinchClient mSinchClient = null;
    private StartFailedListener mListener;

    public class SinchServiceInterface extends Binder {

        public boolean isStarted() {
            return SinchService.this.isStarted();
        }

        public void startClient(String userName) {
            start(userName);
        }

        public void stopClient() {
            stop();
        }

        public void setStartListener(StartFailedListener listener) {
            mListener = listener;
        }

        public void sendMessage(String recipientUserId, String textBody) {
            SinchService.this.sendMessage(recipientUserId, textBody);
        }

        public void addMessageClientListener(MessageClientListener listener) {
            SinchService.this.addMessageClientListener(listener);
        }

        public void removeMessageClientListener(MessageClientListener listener) {
            SinchService.this.removeMessageClientListener(listener);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        if (mSinchClient != null && mSinchClient.isStarted()) {
            mSinchClient.terminate();
        }
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mServiceInterface;
    }

    private boolean isStarted() {
        return (mSinchClient != null && mSinchClient.isStarted());
    }

    public void sendMessage(String recipientUserId, String textBody) {
        if (isStarted()) {
            WritableMessage message = new WritableMessage(recipientUserId, textBody);
            mSinchClient.getMessageClient().send(message);
        }
    }

    public void addMessageClientListener(MessageClientListener listener) {
        if (mSinchClient != null) {
            mSinchClient.getMessageClient().addMessageClientListener(listener);
        }
    }

    public void removeMessageClientListener(MessageClientListener listener) {
        if (mSinchClient != null) {
            mSinchClient.getMessageClient().removeMessageClientListener(listener);
        }
    }

    private void start(String userName) {
        if (mSinchClient == null) {
            mSinchClient = Sinch.getSinchClientBuilder().context(getApplicationContext()).userId(userName)
                    .applicationKey(APP_KEY)
                    .applicationSecret(APP_SECRET)
                    .environmentHost(ENVIRONMENT).build();

            mSinchClient.setSupportMessaging(true);
            ;
            mSinchClient.setSupportActiveConnectionInBackground(true);
            mSinchClient.startListeningOnActiveConnection();

            mSinchClient.addSinchClientListener(new MySinchClientListener());
            mSinchClient.start();
        }
    }

    private void stop() {
        if (mSinchClient != null) {
            mSinchClient.stopListeningOnActiveConnection();
            mSinchClient.terminate();
            mSinchClient = null;
        }
    }

    public interface StartFailedListener {

        void onStartFailed(SinchError error);

        void onStarted();
    }

    private class MySinchClientListener implements SinchClientListener {

        @Override
        public void onClientFailed(SinchClient client, SinchError error) {
            if (mListener != null) {
                mListener.onStartFailed(error);
            }
            mSinchClient.terminate();
            mSinchClient = null;
        }

        @Override
        public void onClientStarted(SinchClient client) {
            Log.d(TAG, "SinchClient started");
            if (mListener != null) {
                mListener.onStarted();
            }
        }

        @Override
        public void onClientStopped(SinchClient client) {
            Log.d(TAG, "SinchClient stopped");
        }

        @Override
        public void onLogMessage(int level, String area, String message) {
            switch (level) {
                case Log.DEBUG:
                    Log.d(area, message);
                    break;
                case Log.ERROR:
                    Log.e(area, message);
                    break;
                case Log.INFO:
                    Log.i(area, message);
                    break;
                case Log.VERBOSE:
                    Log.v(area, message);
                    break;
                case Log.WARN:
                    Log.w(area, message);
                    break;
            }
        }

        @Override
        public void onRegistrationCredentialsRequired(SinchClient client,
                ClientRegistration clientRegistration) {
        }
    }
}


text:
Q: getline function not working with multiple string input
Possible Duplicate:
Need help with getline()

I'm trying to use the getline function in conjunction with cin to get input from the keyboard but my code skips over the getline statement and instead proceeds to cin function below. Here is my code and a screenshot of what is happening.

void addmovie(ofstream& MovieContentsFile) {

string movieTitle;
int movieQuantity;

cout << " \n Add Movie Selected \n " << endl;

cout << "Please type in the movie title and press enter \n" << endl;

getline(cin,movieTitle, '\n');

cout << "Movie: " << movieTitle << "Please type in the amount of copies we have of this movie \n " << endl;

cin >> movieQuantity;

I'd appreciate an explanation of why this is happening and how I can avoid it in the future

A: cin >> something leaves the trailing newline in the buffer, which would be ignored by the next cin >> something_else (presumably this is how you read the menu option). However, getline gets everything up to and including the next newline in the buffer, not ignoring whitespace. I.e. it gets nothing in this case (well, just the newline character).
Generally it's best not to mix use of both, it can get kinda messy.
Edit: To clarify, getline will remove that last newline from the buffer, but won't store it in your string.

A: It's because the newline character is still in the buffer so when it gets to the getline it sees it and skips over it. To avoid this you could place something like cin.ignore(25, "\n") on the line before. This will ignore 25 characters until it gets to the newline and then it takes that as well.


text:
Q: How do I create a new classic asp project in Microsoft Azure I'm trying to create a new classic asp project in Azure, to run my company's web site. We will be upgrading it later to .NET but I'm only just starting with that so I am not sure how this goes.
I have an Azure account and can create web apps till the cows come home but I can't get them to run under classic asp. I've tried all the Google tips to no avail. Is there anyone out there who can help!

A: Yes, you should be able to run Classic ASP on Azure by running an elevated startup task.
More info is available in the following video on MSDN Channel 9:
https://channel9.msdn.com/Shows/Cloud+Cover/Cloud-Cover-Episode-31-Startup-Tasks-Elevated-Privileges-and-Classic-ASP
Hope that helps!


text:
Q: jQuery: Post callback-on-success can be 2nd or 3rd parameter? I do understand how to use jquery functions, and how jquery works. According to jquery API, $.post function looks like this:
jQuery.post( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] )

I believe this is ok:
$.post(url, myOptions, callbackFunctionOnSuccess);

but my question is, Why the below code is valid?
$.post(url, callbackFunctionOnSuccess);

shouldn't it be something like:
$.post(url, null, callbackFunctionOnSuccess);

or
$.post(url, {}, callbackFunctionOnSuccess);

I believe that: jquery checks if the 2nd parameter is a function, then it considers that there is no options (data) passed, and passes the 2nd parameter (the callback-function) to the 3rd parameter. but isn't this kind-of weird for proper implementation? Or is really a best-practice approach?

A: This is what makes jQuery so easy to use. This code may look like this:
$.post = function(url, options, successCallback) {
  if (options instanceof Function) {
    successCallback = options;
    options = null;
  }
  //rest of code
}

Sometimes I use this trick in my projects and it works nicely
Edit
Here is original jQuery (1.11.0) post method code:
function ( url, data, callback, type ) {
    // shift arguments if data argument was omitted
    if ( jQuery.isFunction( data ) ) {
        type = type || callback;
        callback = data;
        data = undefined;
    }

    return jQuery.ajax({
        url: url,
        type: method,
        dataType: type,
        data: data,
        success: callback
    });
}

A: By using the arguments object, you can accept function arguments even if they aren't pre-defined.
function goHere(a, b) {
    return a + b;
}

If you try to call this function as goHere(3, 5, 10);, no errors will occur.  The only thing that will be different is the extra argument in this case will be ignored since it doesn't get addressed.
function goHere(a, b) {
    var values;
    for (var i = 0; i < arguments.length; i++) {
        if(typeof arguments[i] === 'string') // Assume this is "url" since it's the only string
        if(typeof arguments[i] === 'object') // Assume this is "data" since it's the only object;
        if(typeof arguments[i] === 'function') //  Assume this is the callback
        values += arguments[i];
    }
    return values;  // For fun.  No real reason.
}

Experience it in 3D
This is how you can do what you're asking.  Here is a little more light reading on the subject:  Function arguments on Javascript.info


text:
Q: Python, using subprocess.Popen to make linux command line call? I'm getting "[Errno 2] No such file or directory" I'm trying to follow the info I can find about  subprocess.Popen as I want to make a linux command line call.. I am trying as below but am getting the error "[Errno 2] No such file or directory". I'm not trying to open a file so I don't understand this error, and it works fine (although with other issues relating to waiting for the process to finish when I don't want it to) when I use a regular os.popen.
I can't seem to figure out how to do this properly, any advice is appreciated.
EDIT: THE COMMAND I AM USING IS COMPLEX AND VARIABLIZED, it would be too out-of-context to include it here, I think its suffice to say that the code works when I use os.popen and not when I do the new way, so no, the "linux command line call" is obviously not the call I am using
subprocess.Popen([r"linux command line call"])
>>> [Errno 2] No such file or directory

A: import subprocess
proc=subprocess.Popen(['ls','-l'])  # <-- Change the command here
proc.communicate()

Popen expects a list of strings. The first string is typically the program to be run, followed by its arguments. Sometimes when the command is complicated, it's convenient to use shlex.split to compose the list for you:
import shlex
proc=subprocess.Popen(shlex.split('ls -l'))
proc.communicate()


text:
Q: Systemverilog: referencing to a register/variable with a string and changing its value I have a sample of code of what I would like to do below
logic [3:0] c0_var, c1_var, c2_var, c3_var;
string pref = "c1"

always_ff @(posedge clk) begin
    //Change the value of c1_var to 11
    pref + "_var" = 4'd11;
end

Is there a way to use strings to reference to a variable/logic/register so that I could change them? I'm not sure how well I am phrasing my question, but please do let me know if you need more clarification. Thank you!

A: Preprocessor can handle this case.
logic [3:0] c0_var, c1_var, c2_var, c3_var;
`define PREF c1
`define ADD_VAR(VAR) VAR``_var

always_ff @(posedge clk) begin
    //Change the value of c1_var to 11
    //pref + "_var" = 4'd11;
    `ADD_VAR(`PREF) = 4'd11;
end


text:
Q: qmllive plugin cannot be loaded for module Trying to integrate qmllive with my project. Qmllive live bench have problems with finding qml QtQuick.Controls module. Live bench error log:
plugin cannot be loaded for module "QtQuick.Controls": Cannot load library G:\tools\Qt\5.11.1\mingw53_32\qml\QtQuick\Controls.2\qtquickcontrols2plugin.dll: The specified module could not be found.

etc. How to make it work?

A: For future generations.
Log is misleading. The real cause of error, is lacking of several .dll files in qmllive exe directory, omitted by windeployqt.


text:
Q: Terminal Command Line to find corrupted files I do have just one corrupted photo into my Photos Library.
Is there is any UNIX command line that I can use in terminal in order to scan my Photos Library Folder and find out which file is corrupted?

A: My first thought was that ImageMagick is bound to have something for this, and indeed it does. You could run something like this
find . -name "*.JPG" -exec identify {} \; | grep Corrupt

where you can replace . with your directory of choice (it will descend recursively) to check each file or image with ImageMagick's identify command. Grepping for 'Corrupt' will print you identifys output for those files which are in fact corrupt. You could probably trim the output to make it more readable, which would involve some regexing for grep.
Obviously, you need to have ImageMagick installed for this. If you use MacPorts, it's as simple as sudo port install ImageMagick.


text:
Q: Android: Moving multiple objects I was wondering- how can I move multiple objects (imageviews) in a view (any view) in Android? I just want a simple, general approach.
I have successfully implemented a surfaceview with multiple moving objects but each time an object moves, the whole canvas has to be updated even for the non moving objects, which is slowing the ui. I have tried fixing this for days, but I'm at a loss.

A: Got the answer:
http://blahti.wordpress.com/2011/01/17/moving-views-part-2/


text: Q: How to save more power on top of Powertop and TLP? I have TLP and Powertop to run at boot (with autotune for powertop set at boot as well). However, I still get abysmal battery life -- 2 hours usually at max when I'm using Eclipse or the internet -- and I can't find any specific ways to save more power and get more life. I'm going to need my laptop for school soon and 4 hours would really be preferrable. I've already rfkill block'd my bluetooth; is there anything else I can do? I'm pretty sure my battery itself isn't the issue either as it's fine on Windows.


text:
Q: Relation between the center of two isomorphic graphs IF we have two isomorphic graphs $G_1$ and $G_2$ with:
$C(G_1) , C(G_2)$ : the Center of the graph $G_1$ and $G_2$ respectively, and they contain all vertices with minimum eccentricity $\varepsilon(v)$ by definition.
Can we say that for any two isomorphic graphs the following holds:
$$|C(G_1)| = |C(G_2)|$$
Thanks in advance.

A: Since relabelling the vertices does not affect the distances between them, the centres of two isomorphic graphs are the same (up to relabelling).


text:
Q: How to include childnodes when targeting dynamically generated elements in Javascript? I currently have buttons dynamically generated onto the page with plain JavaScript.
Example
<button class="c-config__option c-config__option--button c-config__option--pack" data-index="0">
    Item 1
    Subtext
</button>
<button class="c-config__option c-config__option--button c-config__option--pack" data-index="1">
    Item 2
    Subtext
</button>
...

I am targeting the parent class (.c-config__wrapper) and using event.target to target the buttons. If I click on the span inside of the button THAT becomes the target rather than the button.
Using plain Javascript, how do I ensure that the parent button remains the target and not the span? OR how do I include the span as a target along with the button?

A: Based on the MDN event documentation, the event object has a method called composedPath which stores:

An array of the objects on which listeners will be invoked. This
  does not include nodes in shadow trees if the shadow root was created
  with its ShadowRoot.mode closed.

While this seems to work in Chrome, it is not specified in the documentation how other browsers support this method.
Inspecting the event object further also revealed a event.path property which also contains the same path array, at least in Chrome, however, I could not find any documentation on event.path at all.

Having said that, I did see samples suggesting it might be saver to do
  var eventPath = event.path || (event.composedPath &&
  event.composedPath()); instead of just using var eventPath =
  event.composedPath();

Assuming your browser does support it, you can iterate through the path of the clicked element and check if it is a child of the button or the button itself.
The below code demonstrates this and stores the button element reference for further use.

document.getElementById('wrapper').addEventListener('click', function() {
  // actual element clicked
  console.log(event.target);

  var buttonClicked = false;
  var button;

  var eventPath = event.composedPath();
  for (let i = 0; i < eventPath.length; i++) {
    if (eventPath[i].tagName && eventPath[i].tagName.toLowerCase() === 'button') {
      buttonClicked = true;
      button = eventPath[i];
      break;
    }
  }

  if (buttonClicked) {
    console.log(button);
    console.log('button was clicked');
  }
})

  <button class="c-config__option c-config__option--button c-config__option--pack" data-index="0">
    Item 1
    Subtext
</button>
  <button class="c-config__option c-config__option--button c-config__option--pack" data-index="1">
    Item 2
    Subtext
</button>

As an alternative you can replicate jQuery.closest using the code from this SO post: DOM / pure JavaScript solution to jQuery.closest() implementation?


text:
Q: Go (Golang) efficient logic processing in a chat system In order to build a messaging app, I have followed this example : https://github.com/gorilla/websocket/tree/master/examples/chat
This consists of a Hub, running in a single goroutine in the program, which binds together the Clients (the intermediary between the socket and the Hub).
In this example, each Client (connected user/websocket) runs 2 goroutines : one for reading messages, one for writing.
So we end up with a single goroutine for the Hub, and many goroutines for all the connected users in the app (2 per each user)
But this is for an app which all it does is broadcast all the messages to all the connected users. Since my goal is to build a messaging app (similar in functionality to whatsapp, messenger and the likes, where a user has private conversations with a friend(s)), I need to adjust this design accordingly.
So, I've split this into two layers :

*

*Connection layer - Hub + Client. This layer is responsible for keeping the connections with the clients (plus everything that it entails - reading/writing messages, encoding/decoding, etc.)

*Business Logic layer - the "core" / the logic itself. Meaning - communicating with the DBs, be it an SQL or Cache like Redis, in order to insert messages, finding participants in each conversation, etc.

Challenges :
Since the Logic layer has more resource-consuming operations (reading and writing to DBs, finding out which users belong in the conversation so it would know to tell the hub which users in its Clients mapping to send the message to), I'm having hard time to decide where that should lie and how the two layers should interact/communicate with each other?
Because the Hub is central to the app and has 1 goroutines to handle all traffic, I'm assuming it cannot just call "processMessage" in the Service layer, and wait for its response. Otherwise we can potentially reach a state where we have many pending messages and users will start receiving messages with great delay. (Please do correct me if I'm wrong here)
Ideas so far + problems :
So what I thought of doing, is to have another Service goroutine for the app, just like the Hub, which the Hub will run once it's initialized, and then the Hub could send a message for it to process using a channel between them. Then, once the Service is done, it sends back to the Hub's channel something like "hey dear Hub, send this message I gave you, to users: 1, 2, 3".
But here I think I have another problem - since Hub and Service are in different packages, it means I need to have a cyclic dependency, because Hub knows about Service (it forwards a received message for it to process), and Service knows about the Hub (it tells the Hub what message to send to which users after it's done processing the received message from hub).
So it seems that each option has either a performance issue or an architectural/design issue. Or both.
Since I'm not an expert in Go, that would be really helpful to learn how to handle this kind of case both efficiently(performance-wise) and correctly (design-wise).
EDIT :
Following Jory Geerts's fantastic answer using one goroutine for the service layer, I have tried to pull together a solution that runs service/logic goroutine for each client instead of one goroutine for the app. But I'm not sure about this solution, and I'm also not sure how to terminate the service gorourtine when a client disconnects.
this is a half-baked code, just to show what I had in mind :
type Service struct {
    ('processing' chan of type messaging.Incoming will come as a parameter in run())

    delivery chan messaging.Outgoing // reference from Hub
    repo *sqlx.DB // pool of postgres connections.
    cache redis.Pool // pool of redis connections.
}

type Hub struct {
    clients map[*Client]bool
    delivery chan messaging.Outgoing
}

type Client struct {
    hub *Hub
    send chan []byte
    conn *websocket.Conn
    processing chan messaging.Incoming
}

and the code itself :
main.go :
func main() {
    ...
    ...

    hub := newHub()
    go hub.run()

    service := logic.NewService(delivery : hub.delivery, repo: postgresPool, cache: redisPool)

    http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
        serveWs(hub, service, w, r)
    })
}

func serveWs(hub, service, w, r) {
    processing := make(chan messaging.Incoming)

    go service.run(processing)

    client := &Client{hub, processing, conn, send: make(chan []byte, 256)}
    go client.readPump()
}

client.go (package connection):
func readPump() {
    ...
    defer func() {
        c.conn.Close()
        close(c.processing)
    }()

    for {
       msg := c.socket.ReadMessage()
       c.processing <- msg
    }
}

service.go (package logic) :
func (s *Service) run(processing <-chan messaging.Incoming) {
    for {
        select {
        case incomingMessage := <-processing:
            result := processMessage(incomingMessage)
            s.delivery <- result
    }
}

hub.go (package connection) :
func (h *Hub) run() {
    for {
        select {
        case result := <-h.delivery:
            clients[result.userId].send <- result.msg
        }
    }
}

A: Lets start with your specific concern about a cyclic dependency. In Go, you can easily solve this by defining interfaces in the dependent packages had having those interfaces only expose types from outside their package.
That could look something like this:

package messaging

type Incoming struct {}

type Outgoing struct{}

type ProcessingResult struct {}

type DeliveryResult struct {}

package hub

type service interface {
  Process(m messaging.Incoming) messaging.ProcessingResult
}

func New() *hub {}

type hub struct {}

func (hub) Deliver(m messaging.Outgoing) messaging.DeliveryResult {}

package service

type hub interface {
  Deliver(m messaging.Outgoing) messaging.DeliveryResult
}

func New() *service {}

type service struct {}

func (service) Process(m messaging.Incoming) messaging.ProcessingResult {}

So now, both service and hub can use each other, without knowing each other. The only problem that is left is constructing them with a reference to one another. One option for that would be to not have a New() function that sets up a ready-to-use instance, but give service a method that receives hub (say, func (service) ProcessFor(h hub)) - or the other way around, or both.
Another option (which is a better match Go, in my opinion) would be for them to not know each other at all. Instead you create two channels in your main(). One that hub writes to and service reads from and one the other way around. In addition, each time your push a thing to a channel for which you need to know if it was handled successfully, you also pass along a single-use channel to receive the result on.
That could look something like this:

package main

func main () {
    processing := make(chan messaging.Incoming)
    delivery := make(chan messaging.Outgoing)

    go hub.New(processing, delivery)
    go service.New(processing, delivery)
}

package hub

func New(processing chan<- messaging.Incoming, delivering <-chan messaging.Outgoing) {

    // whenever the hub gets a message from somewhere
    msg := new(messaging.Incoming)
    processing <- *msg
    result := <- msg.Result

    // delivering messages
    for {
        msg := <-delivering
        // do your delivery
        msg.Result <- messaging.DeliveryResult{}
    }
}

package service

func New(processing <-chan messaging.Incoming, delivering chan<- messaging.Outgoing) {

    // whenever the service needs a message to be delivered
    msg := new(messaging.Outgoing)
    delivering <- *msg
    result := <- msg.Result

    // processing things the hub needs to have processed
    for {
        msg := <-processing
        // do your delivery
        msg.Result <- messaging.ProcessingResult{}
    }
}

This approach gives you a number of benefits. For one, things are more loosely coupled, which is always a good thing. In addition, it becomes easier to scale things. If the service is to slow, just start two. If the hub is to slow, just shard it (ok, that one is a little bit more complicated).
A downside of this is that reasoning about your code becomes a bit more complex and unit tests become a little bit more complicated.
For higher throughput, a next step can be to let both hub and service start an ad-hoc inline goroutine around the async communication - that way, other messages won't have to wait. This is, again, more complicated though.


text:
Q: Hide Simple Social Buttons plugin output in custom post type I'm working in a custom post type and now I need to hide the output generated by Simple Social Buttons plugin. I tried this code: remove_filter('the_content', 'plugin_action_links', 100); in single-magazine_post_type.php just below get_header() but didn't work. Any advice?
PS: Exists any plugin that can work on this without the need to touch code all the time?

A: There is a function in simple social plugin called insert_buttons in simple-social-buttons/simple-social-buttons.php. This function puts social buttons to your content. You can make an exception there like;
function insert_buttons($content) {
    global $post;
    if ( !empty( $post ) ) {
        if ( get_post_type( $post ) == "your_post_type") {
            return $content;
        }
    }
   ......
}

Edit: How to do that?
1) Open plugin editor in admin panel

2) Select Simple Social Buttons from the list

3) Select buttons/simple-social-buttons.php from list

4) Update insert_buttons function as I mentioned above


text:
Q: How to upload a file to a folder location on server2, Having php script on server1 I am having a php enabled server1. I have a php code for file upload. But i need the file to be saved on server2.
I have FTP access to server2.
While searching i found this code,
    <?php
$ftp_server = "199.53.23.1";
$ftp_user_name = "xxxx";
$ftp_user_pass = "**********";
$remote_dir = "http://server2/Images/";

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

//default values
$file_url = "";

if($login_result) {
//set passive mode enabled
ftp_pasv($conn_id, true);

$file = $_FILES["uploadedfile"]["tmp_name"];
$remote_file = $_FILES["uploadedfile"]["name"];

$ret = ftp_nb_put($conn_id, $remote_file, $file, FTP_BINARY, FTP_AUTORESUME);
while(FTP_MOREDATA == $ret) {
$ret = ftp_nb_continue($conn_id);
}

if($ret == FTP_FINISHED) {
echo "File '" . $remote_file . "' uploaded successfully.";
} else {
echo "Failed uploading file '" . $remote_file . "'.";
}
} else {
echo "Cannot connect to FTP server at " . $ftp_server;
}
?>

It said unable to connect to Server.
Anyone have an idea on this type of requirement?
Please help.
UPDATE

Server2 doesn't support PHP

A: Here your line
$login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

Remove @
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

For SFTP
$conn_id = ssh2_connect($ftp_server, 22);
ssh2_auth_password($conn_id, $ftp_user_name, $ftp_user_pass);

$sftp = ssh2_sftp($conn_id);

Uses example: $stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r');
*send a file
ssh2_scp_send($conn_id, '/local/filename', '/remote/filename', 0644);

*fetch file
ssh2_scp_recv($conn_id, '/remote/filename', '/local/filename');

*Create a new folder
ssh2_sftp_mkdir($sftp, '/home/username/newdir');

*Rename the folder
ssh2_sftp_rename($sftp, '/home/username/newdir', '/home/username/newnamedir');

*Remove the new folder
ssh2_sftp_rmdir($sftp, '/home/username/newnamedir');

*Create a symbolic link
ssh2_sftp_symlink($sftp, '/home/username/myfile', '/var/www/myfile');

*Remove a file
ssh2_sftp_unlink($sftp, '/home/username/myfile');


text:
Q: Multiple bar widths in Chart.js bar chart Is it possible to have different bar widths for different datasets? I have a couple datasets in one stack, and another dataset in its own stack. The single dataset should be narrower than the other stack
Example. Here I duplicated the left stack, resulting in it being twice the width of the right stack. This breaks certain effects, including nonzero borders
var data = {
  labels: ["1", "2", "3", "4", "5"],
  datasets: [
    {
      label: "d1",
      backgroundColor: "rgba(182,127,0,1)",
      borderColor: "rgba(117,61,41,1)",
      borderWidth: 1,
      data: [42, 78, 64, 90, 97],
      stack: "s1"
    },
    {
      label: "d2",
      backgroundColor: "rgba(71,161,65,1)",
      borderColor: "rgba(36,93,56,1)",
      borderWidth: 1,
      data: [27, 63, 46, 64, 43],
      stack: "s1"
    },
    {
      label: "d3",
      backgroundColor: "rgba(255,141,106,1)",
      borderColor: "rgba(99,60,32,1)",
      borderWidth: 1,
      data: [18, 50, 23, 83, 35],
      stack: "s1"
    },
    {
      label: "d1",
      backgroundColor: "rgba(182,127,0,1)",
      borderColor: "rgba(117,61,41,1)",
      borderWidth: 1,
      data: [42, 78, 64, 90, 97],
      stack: "s1b"
    },
    {
      label: "d2",
      backgroundColor: "rgba(71,161,65,1)",
      borderColor: "rgba(36,93,56,1)",
      borderWidth: 1,
      data: [27, 63, 46, 64, 43],
      stack: "s1b"
    },
    {
      label: "d3",
      backgroundColor: "rgba(255,141,106,1)",
      borderColor: "rgba(99,60,32,1)",
      borderWidth: 1,
      data: [18, 50, 23, 83, 35],
      stack: "s1b"
    },
    {
      label: "d4",
      backgroundColor: "rgba(160,160,160,1)",
      borderColor: "rgba(60,60,60,1)",
      borderWidth: 1,
      data: [152, 141, 170, 194, 128],
      stack: "s2",
      barPercentage: 0.3
    }
  ]
};
var options = {
  scales: {
    xAxes: [{
      categoryPercentage: 0.6,
      barPercentage: 1
    }]
  },
  legend: {
    display: false
  }
};

var barChart = new Chart($("#myChart"), {
  type: 'bar',
  data: data,
  options: options
});

A: This actually is possible to do in chart.js, but the solution is a bit "hackish".  The gist of it is that you can create a 2nd x axis scale and set the barThickness property to a value smaller than your other axis.  Then you assign your dataset to this access and finally, set the scale display to false.
You end up with some datasets on 1 axis and another dataset on a different hidden axis.  Everything else still works (no breaking effects like you mentioned in your question).
Here is what your options would look like.
var options = {
  scales: {
    xAxes: [{
      categoryPercentage: 0.6,
      barPercentage: 1,
    }, {
      id: 'x-axis-2',
      type: 'category',
      display: false,
      categoryPercentage: 0.6,
      barPercentage: 1,
      barThickness: 20,
      gridLines: {
        offsetGridLines: true
      }
    }],
  },
  legend: {
    display: false
  }
};

You have to make sure you add xAxisID: 'x-axis-2' to whichever dataset you want to bind to the new axis.
Here is a codepen example demonstrating all of this.
You can even do this for a horizontal bar chart by changing the scales around.  See this codepen example showing this.

A: The chart.js documentation shows a barThickness attribute available in the options for a chart, but no such option available at the data set level. I think you may be out of luck unless you want to create your own custom chart type.


text:
Q: Android 10 ACTION_GET_CONTENT image with GPS info? I'm using ACTION_GET_CONTENT to let user import photos into my app. It reads GPS data from selected photos. It worked fine up until Android 10.
I found that I'm supposed to use MediaStore.setRequireOriginal() on the uri but getContentResolver().openFileDescriptor() throws an error
SecurityException: Permission Denial: reading com.android.providers.media.MediaDocumentsProvider
...obtain access using ACTION_OPEN_DOCUMENT or related APIs

The original uri doesn't contain GPS exif data.
I added the ACCESS_MEDIA_LOCATION permission with no luck. Photos are imported but GPS exif is lost. android:requestLegacyExternalStorage in Manifest doesn't seem to change this.
How am supposed to use this ? ACTION_GET_CONTENT examples don't use gps data from exif and MediaStore examples don't use ACTION_GET_CONTENT.
My code:
    public void openGallery(View v) {
        Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
        photoPickerIntent.setType("image/*");
        photoPickerIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        startActivityForResult(photoPickerIntent, 4);
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            ...
            Uri selecteduri = data.getData();
            ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(selecteduri, "r");
            FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
            copyPhoto(fileDescriptor, localFile);
            ...
    }

another failed attempt:
                        Uri selecteduri = data.getData();
                        Cursor cursor = getContentResolver().query(selecteduri, null, null, null, null);
                        if (cursor != null && cursor.moveToFirst()) {
                            String[] parts = cursor.getString(0).split(":");
                            Uri photoUri = Uri.withAppendedPath(
                                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, parts[1]);
                            photoUri = MediaStore.setRequireOriginal(photoUri);
                            InputStream stream = getContentResolver().openInputStream(photoUri);
                            ExifInterface exifInterface = new ExifInterface(stream);
                            double[] returnedLatLong = exifInterface.getLatLong();
                            stream.close();
                        }

getLatLong still returns null

Update:
Using ACTION_OPEN_DOCUMENT returns the same Uri. MediaStore.setRequireOriginal() just adds ?requireOriginal=1 to it and openFileDescriptor throws Permission Denial, unless I open it as MediaStore.Images.Media.EXTERNAL_CONTENT_URI + id with setRequireOriginal() which still strips GPS info.


text:
Q: How can I Use Access to combine tables of information I have two tables in access with a common ID number in both. One table has mail to info and the other table has account information. The account information can have multiple listings per ID. The mail to info has one listing per ID. I need to combine the two tables to create a new table with 1 row per ID but containing multiple columns with the added account information. How do I do that?

A: Use the query wizard to create a new "temporary" table - a 'view' (a query). This you can use then as source for your letter.


text:
Q: JMS vs Node.js comparison I just start to study JMS (Java Message Service). My first question is: when the point is "concurrency", is there some similarity between JMS' and Node.js' "purpose"?
Can I use Node.js for a "messaging system"?
I could search for lost samples, but i prefer to learn from someone's experience. Could you - that already used both technologies - help me?

A: I have never used JMS before, but from reading the wikipedia page, it seems like the main purpose is to have two or more java instances talk to each other. For example, you have 10 machines, each running a consuming application that takes a large files, and tries to find patterns in then, and one machine producing large files for the 10 other machines.
The main purpose of Node.JS is a much more local use, for example, when you read a file, instead of waiting for the answer, and not be able to do anything else, you can simply define a callback function to when the whole file is read.
The interesting ability of NodeJS is that it uses some kernel features that "warns" NodeJS that a certain file description has more information to be read.
For example, if you want to read 10 files at the same time in Java, you could create 10 different threads and read each file individually, and that can become very slow. In NodeJS would open the 10 files, and the kernel would just tell it that more information is available. Read more at Scalable networking.


text:
Q: How to set the optimal value to a trigger signal? I have an indicator which oscillates between -50 and +50 values.
Then I have to set a optimal signal value to go long or short.
I've thought in something like this:
if (indicator > ((50 / indicator.mean()) * 1.25)) and (isIncreasing(indicator) == True):
    # go long!
elif (indicator < ((-50 / indicator.mean()) * 0.75)) and (isDecreasing(indicator) == True):
    # go short!
else:
    # chillax

Therefore, to sum it up:

*

*The mean is usually round -5 and +5, ish.

*If the indicator is 25% above of the max/mean, and is increasing: go long.

*If the indicator is 25% below of the min/mean, and is decreasing: go short.

*If none of previous conditions were triggered, then take a coffee. :)

The point is to stop before the indicator change its direction.
But, as you see, the previous formula is merely intuitive. And what if the mean is zero? Then I would have problems in the division...
So there is any formula to calculate the optimal value to place my signal, in order to prevent go long and immediately after a decrease of my indicator? May be using some kind of pattern regression which calculates the following movement?


text:
Q: MP3 Files get distorted during read process I'm currently working on an application that plays back sound. I implemented playback for standard WAV File with the Java Sound API, no problems there, everything working fine. Now I want to add support for MP3 as well, but I'm having a strange problem: the playback gets distorted. I'm trying to figure out what I'm doing wrong, I would appreciate any leads in the right direction.
I'm using the Mp3SPI (http://www.javazoom.net/mp3spi/documents.html) for playing back the Mp3 Files.
I have already tried to take a look at the output and recorded a wav-file with the output I get from the mp3, then I compared the waveforms of the original and the recorded file. As it turns out, in the recorded file there are a lot of samples that are 0, or very close to it. Longer tones get broken up and the waveform returns to 0 all the time, then jumping back to the place the waveform is in the original.
I open the file like this:

private AudioInputStream mp3;
private AudioInputStream rawMp3;

private void openMP3(File file) {

// open the Audio INput Stream
    try {
    rawMp3 = AudioSystem.getAudioInputStream(file);
    AudioFormat baseFormat = rawMp3.getFormat();
    AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
              baseFormat.getSampleRate(),
              16,
              baseFormat.getChannels(),
              baseFormat.getChannels() * 2,
              baseFormat.getSampleRate(),
              false);
        mp3 = AudioSystem.getAudioInputStream(decodedFormat, rawMp3);
    } catch (UnsupportedAudioFileException | IOException ex) {
        Logger.getLogger(SoundFile.class.getName()).log(Level.SEVERE, null, ex);
    }
}

The part where I read the Mp3 File:
byte[] data = new byte[length];
// read the data into the buffer
int nBytesRead = 0;
while (nBytesRead != - 1 && nBytesRead < length) {
    nBytesRead = mp3.read(data, 0, data.length - nBytesRead);
}

Also I convert the byte-array to doubles, perhaps I do something wrong here  (I'm fairly new to using bitwise operators, so maybe there is the problem
double[][] frameBuffer = new double[2][1024]; // 2 channel stereo buffer
int nFramesRead = 0;
int byteIndex = 0;
// convert the data into double and write it to frameBuffer
for (int i = 0; i < length; ++i) {
    for (int c = 0; c < 2; ++c) {
        byte a = data[byteIndex++];
        byte b = data[byteIndex++];
        int val = a | b << 8; // a is the least significant byte. | functions as a + here. b << 8 moves 8 zeroes to the end of b.
        frameBuffer[c][i] = (double) val / (double) Short.MAX_VALUE;
        nFramesRead++;
    }
}

The double-array is then later used to play back the sound. When playing a wav file, I do the exact same thing to the buffer, so I'm pretty sure it has to be something during the read process, not me sending faulty bytes to the ouput.
I would expect this to work out of the box with Mp3SPI, but somehow something breaks the audio along the way.
I am also open to trying other libraries to play back the MP3, if you have any recommendations. Just a Decoder for the raw MP3 Data would actually be enough.

A: As it turns out, the AudioFormat from the mp3 (input) and the AudioFormat of the output didnt match, obviously resulting in distortion. So with those matched up, playback is fine!


text:
Q: Expansion of $\sin x$ I wanted to know, how can I derive:
$$\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!}+\cdots$$

A:
Let $f(x)$ and its derivative $f'(x),f''(x),...,f^{(n)}(x)$ exist and are continous on $[a,b]$ and suppose that $f^{(n+1)}(x)$ exists in $(a,b)$. Then we can have $$f(x)=f(a)+f'(a)(x-a)+\frac{f''(a)}{2!}(x-a)^2+\dots+\frac{f^{(n)}(a)(x-a)^n}{n!}+R_n$$

This fact, sometimes, is called Taylor's Theorem of the mean

A: Use Mclaren series : $f(x) = f(0)+f^{'}(0)\frac{x}{1!}+f^{''}(0)\frac{x^2}{2!}+f^{'''}(0)\frac{x^3}{3!}+\cdots$
for $f(x)=\sin x$

A: One could use Euler's Theorem to get $$\cos x + i\sin x=e^{ix}=\sum_{k=0}^\infty \frac{(ix)^k}{k!}=\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}-\cdots\right)+i\left(x-\frac{x^3}{3!}+\frac{x^5}{5!}-\cdots  \right)$$ Now equating real and imaginary parts you will get the series expansion for both $\cos x$ and $\sin x$.


text:
Q: Create SharePoint groups with powershell Has anyone successfully used PS to create groups and assign a owner (another SP group not a domain user).  The scripts I've found online, I can't get them to work.  Just wondering if anybody has any working scripts to share.  Preferable create from csv or txt so I can create a template.

A: This is something we built in-house:
function Add-SPGroup {
<#
.SYNOPSIS
    Use Add-SPGroup to create a SharePoint Group.
.DESCRIPTION
    This function uses the Add() method of a SharePoint RoleAssignments property in an SPWeb to create a SharePoint Group.
.EXAMPLE
    Add-SPGroup -webUrl "http://sharepoint.local" `
                -groupName "Test Group" `
                -description "My Group" `
                -ownerName "DOMAIN\userlogin" `
                -defaultMemberName "DOMAIN\userlogin" `
                -membership "DOMAIN\userlogin, DOMAIN\userlogin2"`

#>
[CmdletBinding()]
Param(
    [Parameter(Mandatory=$true)][string]$webUrl,
    [Parameter(Mandatory=$true)][string]$groupName,
    [Parameter(Mandatory=$true)][string]$description,
    [Parameter(Mandatory=$true)][string]$ownerName,
    [Parameter(Mandatory=$true)][string]$defaultMemberName,
    [Parameter(Mandatory=$true)][string]$membership
)
try {
    $codeLocation = "Opening web and checking group does not already exist."
    $web = Get-SPWeb $webUrl;
    $spGroup = $web.SiteGroups[$groupName];

    if ($spGroup -ne $null) {
        Write-Warning "Group $groupName already exists!";
        return $spGroup;
    }
    $codeLocation = "Setting owner/member details.";
    $owner = $web.EnsureUser($ownerName);
    $member = $web.EnsureUser($defaultMemberName);

    $codeLocation = "Creating group.";
    $web.SiteGroups.Add($groupName, $owner, $member, $description);
    $spGroup = $web.SiteGroups[$groupName];

    $codeLocation = "Adding users to Group"
    $usersToAdd = $membership.split(",");
    foreach($user in $usersToAdd) {
        $ensuredUser = $web.EnsureUser($user.trim());
        $spGroup.AddUser($ensuredUser);
    }

    $web.RoleAssignments.Add($spGroup);
    $web.Dispose();
    return $spGroup;
}
catch {
    Write-Warning $codeLocation;
    Write-Error $Error[0];
} }

Hope this helps

A: I have a custom function adapted from this StackOverflow question. For whatever reason, the group owner is not settable if you are using the New-SPOSiteGroup commandlet.
Function Set-GroupOwner{
    <#
        .SYNOPSIS
        Sets the specified GroupOwner, a Sharepoint group, as the owner of the specified Group
        .DESCRIPTION
        When creating groups with New-SPOSiteGroup, there is no way to set the group owner. While -Owner is a parameter of Set-SPOSiteGroup,
        it does not appear to be settable. This function solves that problem.
        .PARAMETER SiteUrl
        The Url of the subsite the group needs permission to.
        .PARAMETER GroupToUpdate
        The name of the group that needs updated.
        .PARAMETER GroupOwner
        The SharePoint group that should be listed as the group owner.
        .EXAMPLE
        This example sets the Eric Playground Owners group as the group owner of A Test Subsite Members
        Set-GroupOwner -SiteUrl "https://tenant.sharepoint.com/teams/eric" -GroupToUpdate "A Test Subsite Members" -GroupOwner "Eric Playground Owners"
        .NOTES
        Adapted from https://stackoverflow.com/a/25654742/318776
        .LINK
        https://stackoverflow.com/a/25654742/318776
    #>
    Param(
        [Parameter(Mandatory=$true,HelpMessage="The URL of the site collection",Position=0)][ValidateNotNull()]
        [string]$SiteUrl,

        [Parameter(Mandatory=$true,HelpMessage="The group that needs updated",Position=1)][ValidateNotNull()]
        [string]$GroupToUpdate,

        [Parameter(Mandatory=$true,HelpMessage="The desired group owner",Position=2)][ValidateNotNull()]
        [string]$GroupOwner

    )
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName, $credential.Password)

    $owner = $context.Web.SiteGroups.GetByName($GroupOwner)
    $group = $context.Web.SiteGroups.GetByName($GroupToUpdate)

    $group.Owner = $owner
    $group.Update()
    $context.ExecuteQuery()

    $context.Dispose()
}


text:
Q: Minecraft command to induce hunger? I need to be hungry for a video I'm making. Are there any commands to make me hungry?

A: do this :)

/effect @p minecraft:hunger 2 201

A: There are no commands to make you hungry, only commands to cause effects
Using the command /effect <your username> 17 <time in seconds> you can cause the hunger effect, which rapidly drains your food bar.
Also, you can sprint and jump to lose hunger points faster also (not as fast though)


text: Q: How to run ARCore face tracking on per camera frame (instead of onDraw)? ARCore has very impressive face-tracking capabilities. But all the examples I have seen define a drawable and then call the face tracker to update on per-draw. Is there any to get updated face meshes with every new camera frame?


text:
Q: Do I need to uninstall vwd 2010 express before installing vs 2010 professional? I have installed vwd 2010 sp1 in my computer. Now I am about to install the professional version. I now wonder if I need to uninstall vwd 2010 express before installing vs 2010 professional?
In fact, when I check my control panel, I see too many programs related to visual studio. The same is true for sql server express 2008R2 that I'd like to replace by Sql Server developer version.
Should I just try to install newer versions, wishing that everything will go well. or, do I need to uninstall older versions first?
Thanks for helping.

A: I asked myself the same question today, so to be on the safe side, I installed Visual Studio Professional without removing any express versions. I'm running Win 7 home premium, so the express versions are in the Program Files (x86) folder, and the professional files went in the   Program Files folder.  Up to know everything's working well, and I'll probably be asking for help in uninstalling the express version later!


text:
Q: Ubuntu 12.04 - command line: no headless boot I'm setting up Ubuntu 12.04 minimal on a mini-pc using a GENE 5313 motherboard with a Geode lx800 CPU. I'll use it as a headless PC with just transmission, ssh, ddclient and few more stuff. The problem is that I cannot boot it without a monitor physically plugged.

*

*I did not install X11, and I will not. I want it only command-line (and it's working very good) so ...

*I will not use VNC, nor any kind of remote desktop

*I will access it only by ssh from my local network and maybe some web services

*I already tried to set the GRUB_CMDLINE_LINUX="nomodeset" variable on /etc/default/grub. It didn't work

*My BIOS is already set to "Halt on NO ERROR"

*I would prefer to not simulate a VGA monitor by wiring a resistor on the VGA connector, as suggested elsewhere.

All I can do is to make sure I have a monitor plugged when I power it on, let it boot and then I can also unplug the monitor, it works fine. But I will install my mini-pc far from my monitor. If I power it on without a monitor plugged, I only get to "Verifying DMI pool data", no OS boot.
I followed a lot of guides to solve this but always failed. Any help? Thank you

A: that sounds like an issue before the bios hands over to the MBR/boot medium, before GRUB and linux loads.  Id be contacting the manufacturer, Googleing that MB model and same issue, and look for a silly custom boot option in BIOS you may have missed.
Ive had that 'Verifying DMI...' message but it was hard disk related.  You've clearly identified its a monitor issue in your case.

A: You should try installing a Server version for a headless install. But, judging from the symptoms you described, it sounds like the issue has to do something with the motherboard or the graphics card in your computer, rather than something with GRUB or Ubuntu itself. I suggest contacting the manufacturer.