Q: Using an external tool for C# builds in Visual Studio When using Visual Stdio 2008, you can make a C++ project build with an internal tool rather than having the IDE invoke MSVC directly. This improves the consistency of builds across platforms if a cross-platform build system is used.
However, I cannot figure out how to do the same as a C# project. It would be possible to simply register it as a native project with C# sources, however, you lose some of the advantages gained through having a C# project. More importantly, it will mean that allowing a project to build both directly and with an external tool (which is sadly necessary) will require two separate projects, rather than merely creating an alternate build configuration to invoke the external tool.
Does anyone know if it's possible to prevent Visual Studio from invoking csc by itself and instead call an external tool?
EDIT: Apparently there has some misunderstanding. The goal here is not to compile anything outside of Visual Studio. Instead, it's to allow Visual Studio to serve as the IDE but not the build system. There is already a (Scons-based) build system capable of compiling the C# and C++ sources, and Visual Studio has been configured to invoke Scons for compilation of C++ projects. I'm trying to configure it so that when you hit the 'Build' button, it will invoke Scons for the C# projects as well as the C++ ones.

A: Edit:  Your question is still answered using MSBuild(if you are simply looking to compile outside the IDE).  The IDE(Visual Studios) is simply a "fancy" way of constructing the build files that are built by MSBuild.  Visual Studios isn't building the files, it simply is invoking MSBuild which ships with the .NET Framework 2.0 and up which compiles your code based on the project file that you create.  If Scons can read and process an MSBuild file then I'm sure you can invoke it to build your project.  But considering the fact that C# is a Microsoft language, I think you will be hard-pressed to find a value-add in not using MSBuild since I'd assume both the language and build tool are very tuned to work together. - End Edit
You can use MSBuild to compile your C# project.  If you open your .csproj file in a text editor you will see that it is a MSBuild file.  If you want to write some C# outside of the IDE you can construct a build file using the .csproj file as a starting point and invoke MSBuild to compile your apps.  The IDE is just a way of abstracting the editing of the MSBuild file away for you.
If you are really industrious you can create a set of custom tasks to do things in your custom build process like move files around and versioning.  MSBuild Community Tasks are a great example of using custom code to do task for you during MSBuild.

A: Given all the other answers, what MSBuild does when either VS or MSBuild perform a build can be found in the Targets files that ship with .Net. These can be be found in the FrameWork directory on your system. In my case:
C:\Windows\Microsoft.NET\Framework64\v3.5

Contains Microsoft.Common.targets among others. This file contains the following snippit:
<!--
============================================================
                                    Build

The main build entry point.
============================================================
-->
<PropertyGroup>
    <BuildDependsOn>
        BeforeBuild;
        CoreBuild;
        AfterBuild
    </BuildDependsOn>
</PropertyGroup>
<Target
    Name="Build"
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
    DependsOnTargets="$(BuildDependsOn)"
    Outputs="$(TargetPath)"/>

This means that redifining this Target you can make MSBuild an VS do anything you want. The top of the mentioned file contains an important messagge:
Microsoft.Common.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

This file defines the steps in the standard build process for .NET projects.  It
contains all the steps that are common among the different .NET languages, such as
Visual Basic, C#, and Visual J#.

My suggestion would be to read all you can about MSBuild and it's build file syntax and try redifining the Build target in your project(s). My impression is that after reading up on MSBuild you'll probably find an easier way to meet your requierements. You can find an example of redifining a Target like this in one of the answers of this so question .
Edit:
How to redefine a target?
Redefining is essentially defining the same target 'after' it has been defined. So for instance in your .*proj file(s) define a Build Task after the <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> line that imports all targets needed to in this case build a C# project. An example could be
<Target
    Name="Build"
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
    DependsOnTargets="BeforeBuild"
    Outputs="$(TargetPath)">
    <Exec Command="nmake" />
</Target>

A: I found a question in the same direction here, where it is suggested to edit the registry. I am pretty sure there is no other way to change the compiler used by Visual Studio because there is no trace of csc.exe in any solution, config, csproj file or whatsoever, nor in the Visual Studio 9.0 folder / subfolders within the Program Files dir.
Registry locations can be found in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\74ACAA9F1F0087E4882A06A5E18D7D32
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\9055DA7481CC1024CB23A6109FD8FC9B

but those keys may differ dependng on your installation. Conclusion: changing the compiler used by VS seems next to impossible.
Addition: The following MSDN article deals with the same question for an custom C++ compiler, and Ed Dore's answer seems to confirm my theory that there's no way to choose an custom compiler for use within VS.

A: Under 'Tools' > 'External Tools' you should be able to define an outside tool to do activities for you. The Command should be the path to the executible for your external tool.
Hope this helps some.

A: You don't have to maintain different project files to build using an external tool.  MSBuild is designed to build using the same project files that Visual Studio uses.
Here's an article that describes it.
Customize Your Builds in Visual Studio Using the Standalone MSBuild Tool
It's for VS2005, but should apply to VS2008 as well.

A: You can build your solution from the command line like this:
C:\WINDOWS\Microsoft.NET\Framework\v3.5>msbuild.exe "C:\path\Your Solution.sln"

A: Edit your project file and update the CscToolPath keys to point to the directory containing your tool and add CscToolExe keys that holds the name of the directory:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|.NET 3.5' ">
   .
   .
   .
   <CscToolPath>path\to\custom\tool\directory</CscToolPath>
   <CscToolExe>exe name</CscToolExe>
   .
   .
   .
</PropertyGroup>

I have not tested this, and the CscToolExe key may cause problems, in which case I would simply rename the external tool executable to "csc.exe".

A: Looking through the answers, it seems clear to me that integrating scons into Visual Studio in a way that is compatible with the debugger and so on is not going to happen...
An option you might to consider, and I understand you don't want to change build systems, but bear with me, is to use a meta-build system, ie 'cmake'. http://www.cmake.org/
Cmake doeesn't actually build the project.  What it does is to create build files for you, that you can use to build the project, and on Windows, the build files it creates for you are: Visual Studio project files.  You can simply load those directly into your IDE, and compile, and use normally!
CMake is I feel very easy to use, and provides a high level of transparence and maintainability.
The exact same CMakeLists.txt files on linux will causes linux makefiles to be generated.
On mingw, they can generate mingw makefiles.
There are numerous generators available within cmake.  The list is here:
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_Generators
http://springrts.com is a huge opensource rts game that used to use scons as its cross-platform build system and now uses cmake.
I understand that you don't really want to have to change build systems, so it is a medium to long term solution.
Cmake is in any case one more option, to add to those of using a custom build tool, or using msbuild, or running the scons build from the commandline by hand.


Q: RDLC image not show by set report parameter I am working with RDLC Report in 2010
I want to bind image from external source
ReportParameter rpara = new ReportParameter("rpt1", "D:\\Projects\\Image\\logo.jpg");
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpara });

I also set all the property of rdlc design like
add parameter rpt1 in report data window
add new image in body part then set image property to external and select report parameter
everything okay but still I am not able to get image on my report viewer

A: Try to use this way
string imagepath = "File:///" + "C:\\image.jpg";
this.reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter[] param = new ReportParameter[1];
param[0] = new ReportParameter("Path", imagepath);
this.reportViewer1.LocalReport.SetParameters(param);
this.reportViewer1.RefreshReport();


Q: How get the biggest number? I am trying to get the biggest number from a field in my database using this code:
var bb=(from c in Office_TBLs select c.CodeNumber).Max();

When i run the query I receive the result "999" which is wrong because the biggest number in the databse is 1601. Does the datatype being Nvarchar in the field of database matter?
How could I fix my code to get the correct max number.

A: Since you are using LINQ to SQL you should use Convert.ToInt32 for converting to string to number, so your query would be:
var bb =(from c in Office_TBLs select Convert.ToInt32(c.CodeNumber)).Max();

See: Standard Query Operator Translation

C# casts are supported only in projection. Casts that are used
  elsewhere are not translated and are ignored. Aside from SQL
  function names, SQL really only performs the equivalent of the common
  language runtime (CLR) Convert. That is, SQL can change the value of
  one type to another. There is no equivalent of CLR cast because there
  is no concept of reinterpreting the same bits as those of another
  type. That is why a C# cast works only locally. It is not remoted.

A: "999" > "1601" as string comparison - so to get result you want you need to convert string values to numbers.
The easiest approach would be to use .Select(s => int.Parse(s)).Max()) (or .Max(s => int.Parse(s))) instead of .Max() which ends up using regular string comparison.
Note that depending on where data is coming from there could be much better ways to get integer results (including changing field type in database). Using .Select on query most likely force query to return all rows from DB and only than compute Max in memory.

A: Try this
var bb=(from c in Office_TBLs select (e => e.CodeNumber).Max())

A: If you use NVarChar then you are asking to have the values sorted alphabetically.  "999" comes after "1601" just like "ZZZ" comes after "HUGS".
If the column is supposed to only contain numeric values then the best fix is to change the datatype to a more appropriate choice.


Q: Registry is setting 1 char My code is setting 1 char of the registry name and value.
bool setRegValue(std::wstring valueName, std::wstring  valueToSet)
{
    HKEY key=NULL;
    if (get_HKEY_LOCAL_MACHINE(&key) && (key!=NULL))
    {

        if (RegSetValueEx((HKEY)key, (LPCSTR)valueName.c_str(), 0, REG_SZ, (const BYTE*)valueToSet.c_str(), (valueToSet.size() +1)*sizeof(wchar_t)) != ERROR_SUCCESS)
        {
            RegCloseKey((HKEY)key);
            log.error("Failed to SET the registry value. Name : "+ std::string(valueName.begin(), valueName.end())+" Value : "+ std::string(valueToSet.begin(), valueToSet.end()));
            RegCloseKey(key);
            return false;
        }
        log.info("Successfully SET the registry value. Name : " + std::string(valueName.begin(), valueName.end()) + " Value : " + std::string(valueToSet.begin(), valueToSet.end()));
        RegCloseKey(key);
        return true;
    }
    return false;
}

And, this is the calling method.
bool setServiceAsClient()
{
    if (setRegValue(L"ServiceType", L"Client"))
        return true;
    return false;
}

Its setting the registry name as S
And, value as C

A: When a wide-char string is seen as a 1-char string, that's a symptom that you're providing a wide-char string where a multi-byte string is expected.
Indeed we see the error here: (LPCSTR)valueName.c_str() (where valueName is a std::wstring).
LPCSTR is const char *, whereas wstring::c_str() returns const wchar_t *.
So L"ServiceType" is seen as "S\0e\0r\0v\0i\0c\0e\0T\0y\0p\0e\0", which becomes simply "S"
There are 2 solutions possible:

*

*Use std::string instead of std::wstring (and remove the L from strings like L"ServiceType"). This solution is not recommended, since the Win32 API internally is Unicode.

*Change project settings from Multi-byte to Unicode Character Set and remove the casting to LPCSTR (if you do need to cast, use LPTSTR instead, which always matches project character set settings).

See Working with Strings - Win32 API for more details.


Q: how to detect merged cells in vba (Word 2010) I would like to detect and skip merged cells in vba on word 2010.
I'm making a macro which need to write in the first column but I've some merged cells and I don't want to write in.
All examples I found was for Excel.
I tried to detect the number of columns per rows but that didn't works. I got "Error 5991 table has vertically merged cells".
So how can I just skip the row when I get merged cells ?
Sub test()

Dim Ro As Integer, Col As Integer

        'init
        Count = 1
        Col = 1
        For Ro = 4 To ActiveDocument.Tables(4).Rows.Count
           'format
            If Count < 10 Then
                flag = "0"
            Else
                flag = ""
            End If

            'detect merge
            If ActiveDocument.Tables(4).Rows(Ro).Cells.Count = 9 Then

                ActiveDocument.Tables(4).Cell(Ro, Col).Range.Text = "R" & flag & CStr(Count)
                Count = Count + 1

            Else

                Ro = Ro + 1
            End If

        Next Ro
End Sub

A: i found a solution !
i used this to bypass the error:
On Error GoTo ErrorHandler
ErrorHandler:
                If Err.Number = 5991 Or Err.Number = 5941 Then
                    Err.Clear
                    Resume byebye
                End If
            For Ro = 4 To ActiveDocument.Tables(4).Rows.Count
            [My ugly code]
#in my case i can use a cell to determinate if it's a my row is merged or not
                If Len(ActiveDocument.Tables(4).Cell(line, 5).Range.Text) > 0 Then
            [My Ugly Code]

byebye:
            Next Ro

Hope my solution can help you...


Q: How to save model in keras python? Model description:
cnn1=Sequential()
cnn1.add(Conv2D(128,(2,300), activation = 'relu',input_shape = (maxLenofSent,300,1)))

cnn1.add(MaxPooling2D(1,3))

cnn1.add(Flatten())
cnn1.add(Dense(100, activation = 'relu'))

cnn2=Sequential()
cnn2.add(Conv2D(128,(2,300), activation = 'relu',input_shape = (maxLenofSent,300,1)))
cnn2.add(MaxPooling2D(1,3))
cnn2.add(Flatten())
cnn2.add(Dense(100, activation = 'relu'))

classifier2=Sequential()
classifier2.add(Merge([cnn1,cnn2], mode='concat'))
classifier2.add(Dense(70,activation='sigmoid'))
classifier2.add(Dropout(0.2))
classifier2.add(Dense(2,activation='tanh'))
sgd = SGD(lr = 0.01, momentum = 0.9, decay=1e-2, nesterov = False)
classifier2.compile(loss = 'categorical_crossentropy', optimizer = sgd, metrics = ['accuracy'])

How to save full model so that it can be used later for testing. Output of two cnn goes to ann and classify.

A: Here how to save the model:
model_json = model.to_json()
with open("<path.json>", "w") as json_file:
    json_file.write(model_json)
model.save_weights("<path.hdf5>", overwrite=True)

If you want to save the model and weights at every epoch, try searching for callbacks.

A: before saving the model, you need to train it using classifier2.fit()
https://keras.io/models/sequential/#fit
to save the model use classifier2.save('filename.hdf5')


Q: express static files on cPanel server with phussion passanger I am trying to deploy a node app with Cpanel using the setup node js app tool. The application has been deployed successfully but the static files of my application are broken I am getting a 404 error for my public folder. My hosting server uses Phusion Passanger to manage HTTP requests. Are there any settings I need to provide to add the path to my static files? In localhost it was enough to use: server.use(express.static(path.join(__dirname, 'public')));
But when testing it in production there seems to be some overlap of the passenger configuration with respect to my express server configuration.


Q: PHP - Absolute & Relative URL Types I wrote a login code in PHP:
<form NAME="form1" METHOD="POST" ACTION="operation/validateLogin.php">
        Username
<input name="username" type=text autocomplete="off">

        Password
<input name="password" type=text autocomplete="off">

        <button class="btn btn-primary submit" type="submit">Sign In</button>
</form>

When I submit the form the credentials are sent to a validation file. If an error occurs the file sends the error message back to the login page:
header("Location: http://localhost/demoapp/login.php/?em=28");

I handle the 'GET' parameter and print the error message:
if (isset($_GET['em'])){
        if($_GET['em'] == 28){$errorMessage = "Your username or password was incorrect.";}
}

Now the user needs to try to login again by resubmitting the form, but the action of the form is:
operation/validateLogin.php

and the URL is now:
http://localhost/demoapp/login.php/?em=28

Therefore, when the form is submitted the url becomes:
http://localhost/demoapp/login.php/operation/validateLogin.php

When it should be...
http://localhost/demoapp/operation/validateLogin.php

How do you prevent this from happening to the URL?

A: The ACTION attribute of an HTML form can be set with a relative URL:
/operation/validateLogin.php

or
/validateLogin.php

It's actually recommended to work with relative URLs for HTML elements:
Absolute vs relative URLs
However, when working with PHP an absolute URL is your best option:
http://localhost/demoAPP/operation/validateLogin.php

The use of absolute URLs will relieve your code of accidental URL concatenation.
I had trouble recently figuring out which type of URL to use for certain situations, but this is what I've realized...
PHP (local/server language) = Absolute Local/Server Address
require "C:/dev/www/DEMO/operation/login/validateLogin.php";
include "C:/dev/www/DEMO/operation/login/validateLogin.php";
header("Location: http://localhost/demoapp/login.php/?em=28"); (redirect to a web address)

This may seem really simple but remembering this will save you a lot of troubleshooting time.
If you are using .PHP files, alter the URL in any way, and are not using absolute URLs you will most certainly receive errors.

Additional: You'll notice that you can use a web address for HTML attributes and not run into any problems. However, with PHP requires and includes you can only use local addresses. There is a reason for this limitation and it's all because of one important PHP setting...
https://help.dreamhost.com/hc/en-us/articles/214205688-allow-url-include


Q: How to separate 2 values returned by a function into 2 different variables C++ The function that return the values is this
float calcVelocity(float xacceleration, float yacceleration,sf::Clock clock, float originalDistance){
    sf::Time time = clock.getElapsedTime(); //get current time and store in variable called time
    float xvelocity = xacceleration*time.asSeconds();
    float yvelocity = yacceleration*time.asSeconds();
    while (!(originalDistance + calcDisplacement(yacceleration, clock, originalDistance) <= 0)) {
        time = clock.getElapsedTime(); //get current time and store in variable called time
        xvelocity = xacceleration*time.asSeconds();//Calculates velocity from acceleration and time
        yvelocity = yacceleration*time.asSeconds();
        cout << xvelocity<<endl;//print velocity
        cout << yvelocity << endl;
        system("cls");//clear console
    }
    return xvelocity;
    return yvelocity;
}

I then want them to print as finalXvelocity = blah and finalYvelocity = blah after the while loop is finised. In the main code when I call the function and output the result, it prints both values together. E.g finalXvelocity = blahblah.
I was thinking I could separate the values returned into the main code and then print them using those but I don't know how to do that.
Thanks

A: Use a struct:
struct velocity
{
    float x_component; /*ToDo - do you really need a float*/
    float y_component;
};

This will be the most extensible option. You can extend to provide a constructor and other niceties such as computing the speed. Perhaps a class is more natural, where the data members are private by default.

A: If you have more than one return value, since C++11 you can return them as a std::tuple. No need to explicit declare a data struct.
e.g.
tuple<float,float> calcVelocity(/*parameters*/) {
  // your code
  return make_tuple(xvelocity,yvelocity);
}

Outside the function you can access the values by:
tuple mytuple = calcVelocity(/*parameters*/);
float xvelocity = get<0>(my_tuple);
float yvelocity = get<1>(my_tuple);

For pre-C++11 std::pair is also an option for just 2 values. But in this case the struct solution is more explicit.


Q: type 'int' is not a subtype of type 'String' i am trying to fetch the data from api, i am getting the value when i print it in console, but when i am tried to access it using shared perference on other screen, i am not getting the values, and it print this error
type 'int' is not a subtype of type 'String'

here is my api code
getstatus=(req,res)=>{
  jwt.verify(req.body.token, 'secret' , function(err, decoded) {
    if(err) {
     err["expiredAt"] = err["expiredAt"].toLocaleString();  //here the error points
     res.status(300).json(err)
    }
    else
      {
  let leaves=0,sick_leaves=0,annual_leaves=0,maternity_leaves=0;

  User.find({"username":req.body.username,"leave":"ON"},function(err,data){
      User.find({"username":req.body.username,"leave":"ON","type":"Sick"},function(err,value){

          User.find({"username":req.body.username,"leave":"ON","type":"annual"},function(err,value1){

              User.find({"username":req.body.username,"leave":"ON","type":"maternity"},function(err,value2){
                console.log(value2.length)
                if(data.length>0){
                    leaves = data.length
                  }
                if(value2.length>0){
                     maternity_leaves= value2.length
                  }
                  if(value.length>0){
                     sick_leaves= value.length}
                    if(value1.length>0){
                        annual_leaves= value1.length
                      }
         console.log(leaves,sick_leaves,annual_leaves,maternity_leaves)
         res.json({"leaves":leaves,"sick":sick_leaves,"annual":annual_leaves,"maternity":maternity_leaves}).status(200)

              })

          })

      })

  })
}})

}

and here i am fetching the api on frontend
 data={
          "token":token,
          "username":name,
          "leave":"ON",
          "type":"maternity"
        };
         dio
          .post(localHostUrlleaveCount, data: json.encode(data))
            .then((onResponse) async {
              print(onResponse.data);

              String sickCount=(onResponse.data['sick'].toString());
              print("sickCount");  //i get value here
              print(sickCount);
              String annualCount=(onResponse.data['annual'].toString());
              String maternityCount=(onResponse.data['maternity']);
              String totalleaveCount=(onResponse.data['leaves']);
              print("annualcount");
              print(annualCount); // but it prints this "type 'int' is not a subtype of type 'String'"
 error before this line

              myPrefs.setString('totalleave', totalleaveCount);
              myPrefs.setString('sickcount', sickCount);
              myPrefs.setString('annualcount', annualCount);
              myPrefs.setString('maternitycount', maternityCount);

            }).catchError((onerror){
              print(onerror.toString());
            // showAlertDialog(context);
          });

and on dashboard screen i getting the shared perference value like this
String sickcount="";
 _userDetails() async {
    SharedPreferences myPrefs = await SharedPreferences.getInstance();
    setState(() {
      sickcount=myPrefs.getString('sickcount');
      print(int.parse(sickcount));  //error on this way "Unhandled Exception: FormatException: Invalid number (at character 1)"
      print(sickcount);  //i tried in this way
      print(sickcount.toString());  //i tried in this way but same error on all the ways

    });
  }

i am getting values perfectly from other api's, i don't know what i am doing wrong with this api, please help me to fix it.
one more thing i am doing is when i am logged in in app i am calling the dashboard screen on click on login button, but i want this above api output in leave screen, so when i create this api on leave screen and call it in initState function it send me this error on backend
TypeError: Cannot read property 'toLocaleString' of undefined

and Http status error [500]  error on frontend
Api output is
 {leaves: 3, sick: 2, annual: 0, maternity: 1}


Q: Rails 3 vs Rails 2 "wild controller" routing I'm trying to get my Rails 3 project to automatically resolve namespaced controllers, similar to the Rails 2 behaviour. For example (Rails 2):
$ rails pathtest && cd pathtest
$ script/generate controller First
$ script/generate controller first/second
$ script/generate controller first/second/third
$ script/server

Requests to:

*/first routes to first controller

*/first/second routes to second controller

*/first/second/third routes to third controller
But, Rails 3 yields different routing using the 'wild controllers' path.
$ rails new pathtest && cd pathtest
$ rails generate controller First
$ rails generate controller first/second
$ rails generate controller first/second/third

## config/routes.rb
Pathtest::Application.routes.draw do
  match ':controller(/:action(/:id(.:format)))'
end

$ rails server

Requests to:

*/first routes to first controller

*/first/second routes to first#second

*/first/second/third routes to first#second :id => 'third'
I'm starting to think that kind of automatic resolution of namespaced controllers isn't the way anymore? Has anyone found a way to automatically resolve namespaced controllers like this?
Thanks!

A: Try this:
Pathtest::Application.routes.draw do
  resources :first do
    resources :second do
      resources :third
    end
  end
end


Q: How to pass ui-sref url to ng-click function
  {{x.name}}

In the above code segment, I have a  with ui-sref="private.Registered_details ({uid:
   x.userID,vid:x.vehicleID,page_value:'page1'})"..How to pass this a s url to linkClick funtion in ng-click

A: Have ng-click like this. Pass all the details necessary to navigate to your chosen state.

  {{x.name}}

And in controller, first inject $state as dependency, and then, use $state.go to navigate to the state.
$scope.navigateToDetails = function(x) {
  // some amazing code to decide whether or not to navigate
  $state.go("private.Registered_details", {
    uid: x.userID,
    vid: x.vehicleID,
    page_value:'page1'
  });
}


Q: How to make UITableView look like the one in Contacts? I'm trying to make UITableViewController look like following.
(it has picture and several rows for someone's identify.)
I wonder how to make like following programmatically.
How to adjust UITableViewCell's origin.x and width?
How to add a picture at left top?
Please help me..  I will thank you.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell;

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier];

    cell.frame = CGRectMake(50, 0, 250, 44) <--- ?????? I think this is wrong way.

    return cell;
}

A: My best bet is that either there are two static UITableViews inside a UIScrollView or that it's some custom subclass UIView set as tableHeaderView and styled to look as on the picture.  If I were to implement it I'd go with the second choice.

A: Make a subclass of UITableView.  Give your subclass properties referring to the photo well and the three special row cells.
Override layoutSubviews to call [super layoutSubviews] and then set the frames of the photo well and the three special row cells.
The photo well should not be a cell.


Q: Pushing the content without it changing width when opening sidebar I have a sidebar which I open on smaller screens,
When opening the sidebar, I want the content on its right to be pushed, but when I do that in the current code, the width of the div where the content is changes, making what's inside of it resize based on its width. Because it is responsive. I have several divs within it.
This is the code in JSFiddle   MyCode
Here I've only put text as content, so you can see how the text also behaves when I close the sidebar.
How do I make it so that the page-wrapper content to push be pushed left and right, but without it changing width ?
My HTML Code :

    asdasdadas

    <button type="button" class="hamburger is-closed" data-toggle="offcanvas">

    </button>

       Lorem ipsum dolor sit amet, quo ex graeco option, elit malis eam et. Probo solet lucilius ea pri.
                        Civibus electram referrentur pri no, sea in brute adipisci eleifend. His at gubergren conclusionemque.

My css :
body {
position: relative;
overflow-x: hidden;
}
*-------------------------------*/

 #wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 220px;
overflow: hidden;
/* width:100%; */
width: 100%;
/* position: absolute; */
}
 #sidebar-wrapper {
z-index: 2000;
left: 220px;
width: 0;
height: 100%;
margin-left: -220px;
overflow-y: auto;
overflow-x: hidden;
background: black;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
 transition: all 0.5s ease;
 bottom: 0;
padding: 0;
display:block;
 }

#wrapper a.nav-link.active {
color: #1C2058;
font-weight: bold;
 }
 #sidebar-wrapper::-webkit-scrollbar {
 display: none;
  }
#wrapper.toggled #sidebar-wrapper {
width: 220px;
}
#page-content-wrapper {
width: 100%;
padding-top: 25px;
}
#wrapper.toggled #page-content-wrapper {
position:absolute;
margin-right: -220px;
 }
/* Custom Css on Sidebar */

ul.full-width-navigation {
width: 220px;
}
.side .active {
position: relative;
}

nav.set-top-zindex {
background: #fff;
min-height: 50px;
/* display: none; */
}

.overlay {
position: fixed;
display: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(250, 250, 250, .8);
z-index: 1;
}
/*sidebar */

@media screen and (min-width: 576px) {
#wrapper #sidebar-wrapper {
    width: 220px;
}
#wrapper.toggled #page-content-wrapper {
    padding-left: 0;
}
#wrapper #page-content-wrapper {
    padding-left: 220px;
}
button.hamburger.is-closed {
    display: none;
}
#sidebar-wrapper {
    z-index: 1;
}

}
@media screen and (max-width: 576px) {

#wrapper.toggled .overlay {
    height: 100%;
    width: 100%;
    position: fixed;
    background-color: rgba(0, 0, 0, .8);
    margin-top: 69px;
    z-index: 1500;
    display: block;
}

}

Any help is appreciated !
Thanks!
Edit :
Current Fiddle
When opening sidebar- it pushes the content for 220px.
When pressing close on the sidebar, you can see how the letters within the content shuffle, and that happens because by padding padding, the width of the page-wrapper-content get smaller, and the content inside of it changes because it is responsive..
What I need is :
Press sidebar - content seems to be pushed to the right for 220px.
Close sidebar - content transition back to its initial state with left:0 as the sidebar closes.
Need to transition back and forth between push and pull.

A: I have created this simple example on CodePen which you may use to help solve your question and learn. In the demo, click the 'menu' button to toggle the sidebar.
The method I think you need to use is to position your main content area 'absolutely', and 'left' by the width of your sidebar when it is expanded I demo this in my demo by toggling a CSS class containing these properties on the main content area. This allows your responsive grid cells to remain the same width whilst the menu is open.
I find it easier to see examples on CodePen but I have also embedded my example here:

$("button").on("click", function() {
  $(".sidebar").toggleClass('is-active');
})
body {
  margin: 0;
  overflow-x: hidden;
}
.sidebar {
  display: none;
  width: 220px;
  height: calc(100vh - 28px);
  background: #eee;
  border-right: #ccc;
  padding: 14px;
  position: relative;
  left: -220px;
}

.sidebar.is-active {
  display: block;
  left: 0;
  transition: all 2000ms ease;
}

.sidebar.is-active~.main-content {
  width: 100vw;
  height: calc(100vh - 28px);
  position: absolute;
  left: calc(220px + 28px);
}

.main-content {
  width: 100%;
  padding: 14px;
}

.row {
  display: flex;
  flex-wrap: no-wrap;
  flex-direction: row;
  justify-content: space;
}

.row .cell {
  width: 100%;
  background: #eee;
  padding: 14px;
}

.row .cell:nth-of-type(2) {
  border-right: 1px solid lightgray;
  border-left: 1px solid lightgray;
}

nav a {
  display: block;
  padding: 14px;
}

.menu-btn {
  position: absolute;
  right: 0;
  z-index: 9999;
}

.wrapper {
  width: 100%;
  height: 100vh;
  display: flex;
}

<button type="button" class="menu-btn">Menu</button>

      Link #1
      Link #2
      Link #3
      Link #4

Main content

         Cell #1

         Cell #2

         Cell #3


Q: Writing output to a single csv file in python I am new to programming. May requirement will be simple for core developer.
I have 5 .log file which are log file of database. here I want to read these all files, check the error and success message in these files and write the error and success message to single csv file along with name of the file which I read.
import glob

file_list = glob.glob('C:\\Users\\Rahul\\AppData\\Roaming\\JetBrains\\PyCharmCE2021.3\\*.log')
file_out = open('error.csv', "a") #creating a csv file

for file in file_list:
    file_in = open(file, "r").readlines()
    count = 0
    for line in file_in: # Loop every line
        if 'ERROR' in line: # Search for ERROR in line
            count += 1
            file_out.write(str(count) +"error.csv"+ "," + line + "\n")    #writing csv file
        elif 'SUCCESS' in line: # Search for SUCCESS in line
            print(line) # Print line
file_out.close()

I want output of file something like below to be written into single CSV file
Filename:test.log Error: Compilation error
Filename:test2.log Success: It is successful

Any help or suggestions ?

A: Here's a suggestion. There's a neat module in the standard library called fileinput that allows you to easily read several files in a row and also gives you access to the filenames, line numbers, etc. Try something like the following and see if it fits your needs:
import glob
import fileinput

file_list = glob.glob(...)

with fileinput.input(file_list) as fin,\
     open("error.csv", "a") as fout:
    out = "Filename: {}, Line: {}, {}: {}\n"
    write = False
    for line in fin:
        line = line.rstrip()
        line_folded = line.casefold()
        if "error" in line_folded:
            write, var = True, "Error"
        elif "success" in line_folded:
            write, var = True, "Success"
        if write:
            fout.write(out.format(fin.filename(), fin.filelineno(), var, line))
            write = False

It's a bit unclear why you want to write a CSV-file: Your output doesn't look like it's in a csv-format?


Q: java cloneing error I have a method that tries to clone an instance of a class (B) i have writen.This method is being called in class A so this method is not in the same class as the class i'm trying to clone (B). The class i'm trying to clone impliments colneable. when i try to compile my code i get an error message that reads "clone() has protected access in Java.lang.Object. Why might this be happing?

A: That may be happening because you are trying to call the clone() method outside its allowed access. For you to be able to call it, the class that is calling it should extend directly from Object, or belong to the Same Package, or be Object. More information here http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

A: If you want some code inside class A to clone an instance of class B, then either place A and B in the same package, or broaden the access to B.clone() by making it public (rather than leaving it protected-scope.)
Furthermore, I would refer you to the book Effective Java by Josh Bloch. I found a PDF of Chapter three here

A: You can only access protected members of a type in a different package if the compile-time type of the expression you're referencing it through is either your own class or a subclass.
Check this link.


Q: kill -s SIGINT ps SHELL I am using this command kill -s SIGINT ps on the command line and it works (the process is eliminated), but when I use that command on a SHELL script it doesn´t work and it shows this error message kill: SIGNIT: invalid signal specification. How can I solve this. Thanks

A: Error messages exist to give developers, and also users, a clue when something goes wrong.  I suspect that you're mistyping SIGINT as SIGNIT. The error message you're getting is consistent with a typo in your statement.
I feel like this shows poor research effort because if you had read the error message before asking help, you would have figured it out.

A: I would like to answer this because I solved the similar problem recently. When you call kill -s SIGINT, you may use sh to run the script. Unfortunately, sh which is different from bash(linux shell kill signal SIGKILL && KILL) will run in compatibility mode and not recognize SIGINT.
The best solution is to use /bin/bash explicitly. By the way, #!/bin/bash doesn't work when you sh the script, either.
Hope it helps.

A: It's possible that the shell executing the script is using a built-in "kill" command while your command-line shell is using an external binary, or vice-versa.  Use /bin/kill explicitly and see if that helps be more consistent.  kill -SIGINT is, I believe, the more common way of doing this (instead of "-s SIGINT").
Also, kill normally takes a process-id and not a process-name.  Built-in vs external "kill" commands may also support (or not support) this differently.


Q: Option Data from google finance in Json format not parse-able in Groovy I am trying to parse Option data from google finance using JsonSlurper in Groovy. I get an error and looking at the data, it seems it is not proper Json format. (It is missing quotes around values).
Is this normal. Do I have to massage this data before JsonSlurper will parse it. I can see the data after puts would be in proper format.
Here is the url that I get the data from :
This is the error that I get in groovy:
Encountered exception : Lexing failed on line: 1, column: 2, while reading 'e', no possible valid JSON value or punctuation could be recognized. -

This is the the data that is returned from the url:
{expiry:{y:2013,m:5,d:31},expirations:[{y:2013,m:5,d:31},{y:2013,m:6,d:7},{y:2013,m:6,d:14},{y:2013,m:6,d:22},{y:2013,m:6,d:28},{y:2013,m:7,d:20},{y:2013,m:8,d:17},{y:2013,m:9,d:21},{y:2013,m:12,d:21},{y:2014,m:1,d:18},{y:2015,m:1,d:17}],puts:[{cid:"861808824253659",name:"",s:"GOOG130531P00625000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"14",vol:"-",strike:"625.00",expiry:"May 31, 2013"},{cid:"90291598673294",name:"",s:"GOOG130531P00630000",e:"OPRA",p:"0.50",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"3",vol:"-",strike:"630.00",expiry:"May 31, 2013"},{cid:"883084064658290",name:"",s:"GOOG130531P00635000",e:"OPRA",p:"0.50",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"3",vol:"-",strike:"635.00",expiry:"May 31, 2013"},{cid:"550606621196196",name:"",s:"GOOG130531P00640000",e:"OPRA",p:"0.50",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"6",vol:"-",strike:"640.00",expiry:"May 31, 2013"},{cid:"907661465271381",name:"",s:"GOOG130531P00645000",e:"OPRA",p:"0.76",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"4",vol:"-",strike:"645.00",expiry:"May 31, 2013"},{cid:"312331955116595",name:"",s:"GOOG130531P00650000",e:"OPRA",p:"0.50",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"7",vol:"-",strike:"650.00",expiry:"May 31, 2013"},{cid:"1034371554903574",name:"",s:"GOOG130531P00655000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"138",vol:"-",strike:"655.00",expiry:"May 31, 2013"},{cid:"849038193044261",name:"",s:"GOOG130531P00660000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"221",vol:"-",strike:"660.00",expiry:"May 31, 2013"},{cid:"448843840017009",name:"",s:"GOOG130531P00665000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"17",vol:"-",strike:"665.00",expiry:"May 31, 2013"},{cid:"956560337544029",name:"",s:"GOOG130531P00670000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"89",vol:"-",strike:"670.00",expiry:"May 31, 2013"},{cid:"168619215452014",name:"",s:"GOOG130531P00675000",e:"OPRA",p:"0.20",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"4",vol:"-",strike:"675.00",expiry:"May 31, 2013"},{cid:"1117974573979659",name:"",s:"GOOG130531P00680000",e:"OPRA",p:"0.15",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"8",vol:"-",strike:"680.00",expiry:"May 31, 2013"},{cid:"753362057423145",name:"",s:"GOOG130531P00685000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"64",vol:"-",strike:"685.00",expiry:"May 31, 2013"},{cid:"764049961140541",name:"",s:"GOOG130531P00690000",e:"OPRA",p:"0.35",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"19",vol:"-",strike:"690.00",expiry:"May 31, 2013"},{cid:"856579959673404",name:"",s:"GOOG130531P00695000",e:"OPRA",p:"0.15",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"52",vol:"-",strike:"695.00",expiry:"May 31, 2013"},{cid:"824170367827899",name:"",s:"GOOG130531P00700000",e:"OPRA",p:"0.25",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.70",oi:"10",vol:"-",strike:"700.00",expiry:"May 31, 2013"},{cid:"414605646886183",name:"",s:"GOOG130531P00705000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"211",vol:"-",strike:"705.00",expiry:"May 31, 2013"},{cid:"1123808986964380",name:"",s:"GOOG130531P00710000",e:"OPRA",p:"0.35",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.65",oi:"28",vol:"-",strike:"710.00",expiry:"May 31, 2013"},{cid:"428007176517959",name:"",s:"GOOG130531P00715000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"96",vol:"-",strike:"715.00",expiry:"May 31, 2013"},{cid:"1004640940579345",name:"",s:"GOOG130531P00720000",e:"OPRA",p:"1.15",cs:"chb",c:"0.00",cp:"0.00",b:"0.05",a:"0.55",oi:"1",vol:"-",strike:"720.00",expiry:"May 31, 2013"},{cid:"547870112882747",name:"",s:"GOOG130531P00725000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"26",vol:"-",strike:"725.00",expiry:"May 31, 2013"},{cid:"713283828090500",name:"",s:"GOOG130531P00730000",e:"OPRA",p:"0.75",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.65",oi:"16",vol:"-",strike:"730.00",expiry:"May 31, 2013"},{cid:"330110346878283",name:"",s:"GOOG130531P00735000",e:"OPRA",p:"0.50",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"6",vol:"-",strike:"735.00",expiry:"May 31, 2013"},{cid:"741172786814707",name:"",s:"GOOG130531P00740000",e:"OPRA",p:"0.60",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"11",vol:"-",strike:"740.00",expiry:"May 31, 2013"},{cid:"305806735527325",name:"",s:"GOOG130531P00745000",e:"OPRA",p:"0.10",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"16",vol:"-",strike:"745.00",expiry:"May 31, 2013"},{cid:"836255382420185",name:"",s:"GOOG130531P00750000",e:"OPRA",p:"0.95",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"28",vol:"-",strike:"750.00",expiry:"May 31, 2013"},{cid:"10060751156355",name:"",s:"GOOG130531P00755000",e:"OPRA",p:"0.05",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.10",oi:"55",vol:"-",strike:"755.00",expiry:"May 31, 2013"},{cid:"184650813944442",name:"",s:"GOOG130531P00760000",e:"OPRA",p:"0.25",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"14",vol:"-",strike:"760.00",expiry:"May 31, 2013"},{cid:"439480549217736",name:"",s:"GOOG130531P00765000",e:"OPRA",p:"0.10",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.10",oi:"97",vol:"-",strike:"765.00",expiry:"May 31, 2013"},{cid:"308783986011504",name:"",s:"GOOG130531P00770000",e:"OPRA",p:"0.20",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.65",oi:"20",vol:"-",strike:"770.00",expiry:"May 31, 2013"},{cid:"51018175031907",name:"",s:"GOOG130531P00775000",e:"OPRA",p:"0.15",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.10",oi:"145",vol:"-",strike:"775.00",expiry:"May 31, 2013"},{cid:"917630774138659",name:"",s:"GOOG130531P00780000",e:"OPRA",p:"0.80",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"11",vol:"-",strike:"780.00",expiry:"May 31, 2013"},{cid:"1116428272838913",name:"",s:"GOOG130531P00785000",e:"OPRA",p:"0.05",cs:"chr",c:"-0.10",cp:"-66.67",b:"-",a:"0.10",oi:"71",vol:"3",strike:"785.00",expiry:"May 31, 2013"},{cid:"768225161293425",name:"",s:"GOOG130531P00790000",e:"OPRA",p:"0.25",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.60",oi:"16",vol:"-",strike:"790.00",expiry:"May 31, 2013"},{cid:"755499966485666",name:"",s:"GOOG130531P00795000",e:"OPRA",p:"0.21",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.05",oi:"107",vol:"-",strike:"795.00",expiry:"May 31, 2013"},{cid:"1013649638331262",name:"",s:"GOOG130531P00800000",e:"OPRA",p:"0.20",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"56",vol:"-",strike:"800.00",expiry:"May 31, 2013"},{cid:"357377673137695",name:"",s:"GOOG130531P00805000",e:"OPRA",p:"0.05",cs:"chr",c:"-0.23",cp:"-82.14",b:"0.05",a:"0.10",oi:"3615",vol:"123",strike:"805.00",expiry:"May 31, 2013"},{cid:"690708626756771",name:"",s:"GOOG130531P00810000",e:"OPRA",p:"0.75",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.25",oi:"28",vol:"-",strike:"810.00",expiry:"May 31, 2013"},{cid:"21150003535275",name:"",s:"GOOG130531P00815000",e:"OPRA",p:"0.05",cs:"chr",c:"-0.20",cp:"-80.00",b:"0.05",a:"0.15",oi:"177",vol:"6",strike:"815.00",expiry:"May 31, 2013"},{cid:"275905429065075",name:"",s:"GOOG130531P00820000",e:"OPRA",p:"0.08",cs:"chr",c:"-0.24",cp:"-75.00",b:"0.05",a:"0.15",oi:"1037",vol:"107",strike:"820.00",expiry:"May 31, 2013"},{cid:"1055025518544642",name:"",s:"GOOG130531P00825000",e:"OPRA",p:"0.70",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"3",vol:"-",strike:"825.00",expiry:"May 31, 2013"},{cid:"1035321415642280",name:"",s:"GOOG130531P00830000",e:"OPRA",p:"0.13",cs:"chr",c:"-0.40",cp:"-75.47",b:"0.10",a:"0.20",oi:"489",vol:"68",strike:"830.00",expiry:"May 31, 2013"},{cid:"70557296969979",name:"",s:"GOOG130531P00835000",e:"OPRA",p:"0.63",cs:"chb",c:"0.00",cp:"0.00",b:"0.10",a:"0.40",oi:"43",vol:"-",strike:"835.00",expiry:"May 31, 2013"},{cid:"29904266868370",name:"",s:"GOOG130531P00840000",e:"OPRA",p:"1.40",cs:"chb",c:"0.00",cp:"0.00",b:"0.05",a:"0.30",oi:"34",vol:"-",strike:"840.00",expiry:"May 31, 2013"},{cid:"60994034524162",name:"",s:"GOOG130531P00845000",e:"OPRA",p:"0.25",cs:"chr",c:"-0.95",cp:"-79.17",b:"0.25",a:"0.30",oi:"620",vol:"138",strike:"845.00",expiry:"May 31, 2013"},{cid:"1062537796162167",name:"",s:"GOOG130531P00850000",e:"OPRA",p:"1.80",cs:"chb",c:"0.00",cp:"0.00",b:"0.20",a:"0.65",oi:"116",vol:"-",strike:"850.00",expiry:"May 31, 2013"},{cid:"985844474705712",name:"",s:"GOOG130531P00855000",e:"OPRA",p:"0.51",cs:"chr",c:"-1.78",cp:"-77.73",b:"0.50",a:"0.55",oi:"578",vol:"377",strike:"855.00",expiry:"May 31, 2013"},{cid:"412696606024360",name:"",s:"GOOG130531P00860000",e:"OPRA",p:"3.50",cs:"chb",c:"0.00",cp:"0.00",b:"0.55",a:"0.90",oi:"150",vol:"-",strike:"860.00",expiry:"May 31, 2013"},{cid:"788760175384132",name:"",s:"GOOG130531P00865000",e:"OPRA",p:"5.50",cs:"chb",c:"0.00",cp:"0.00",b:"0.85",a:"1.30",oi:"169",vol:"-",strike:"865.00",expiry:"May 31, 2013"},{cid:"495262825571032",name:"",s:"GOOG130531P00870000",e:"OPRA",p:"1.60",cs:"chr",c:"-4.80",cp:"-75.00",b:"1.65",a:"1.75",oi:"1993",vol:"1044",strike:"870.00",expiry:"May 31, 2013"},{cid:"784479429576717",name:"",s:"GOOG130531P00875000",e:"OPRA",p:"3.00",cs:"chr",c:"-6.28",cp:"-67.67",b:"2.40",a:"2.65",oi:"172",vol:"127",strike:"875.00",expiry:"May 31, 2013"},{cid:"475018278612528",name:"",s:"GOOG130531P00880000",e:"OPRA",p:"3.30",cs:"chr",c:"-9.60",cp:"-74.42",b:"3.60",a:"4.00",oi:"304",vol:"92",strike:"880.00",expiry:"May 31, 2013"},{cid:"23479753271876",name:"",s:"GOOG130531P00885000",e:"OPRA",p:"5.60",cs:"chr",c:"-9.50",cp:"-62.91",b:"5.40",a:"5.70",oi:"911",vol:"1053",strike:"885.00",expiry:"May 31, 2013"},{cid:"752454851539195",name:"",s:"GOOG130531P00890000",e:"OPRA",p:"7.90",cs:"chr",c:"-10.49",cp:"-57.04",b:"7.60",a:"8.00",oi:"531",vol:"918",strike:"890.00",expiry:"May 31, 2013"},{cid:"70240546867537",name:"",s:"GOOG130531P00895000",e:"OPRA",p:"10.40",cs:"chr",c:"-12.33",cp:"-54.25",b:"10.10",a:"10.80",oi:"252",vol:"231",strike:"895.00",expiry:"May 31, 2013"},{cid:"897963621776473",name:"",s:"GOOG130531P00900000",e:"OPRA",p:"13.49",cs:"chr",c:"-14.14",cp:"-51.18",b:"12.00",a:"14.50",oi:"131",vol:"4",strike:"900.00",expiry:"May 31, 2013"},{cid:"85067464862382",name:"",s:"GOOG130531P00905000",e:"OPRA",p:"23.60",cs:"chb",c:"0.00",cp:"0.00",b:"15.80",a:"18.60",oi:"0",vol:"20",strike:"905.00",expiry:"May 31, 2013"},{cid:"805187710443767",name:"",s:"GOOG130531P00910000",e:"OPRA",p:"20.20",cs:"chr",c:"-18.50",cp:"-47.80",b:"21.50",a:"22.50",oi:"576",vol:"37",strike:"910.00",expiry:"May 31, 2013"},{cid:"885641012669822",name:"",s:"GOOG130531P00915000",e:"OPRA",p:"-",c:"-",b:"24.60",a:"27.30",oi:"0",vol:"-",strike:"915.00",expiry:"May 31, 2013"},{cid:"899858163597569",name:"",s:"GOOG130531P00920000",e:"OPRA",p:"31.00",cs:"chr",c:"-17.00",cp:"-35.42",b:"30.10",a:"32.00",oi:"127",vol:"9",strike:"920.00",expiry:"May 31, 2013"},{cid:"384946575665642",name:"",s:"GOOG130531P00925000",e:"OPRA",p:"-",c:"-",b:"34.10",a:"36.90",oi:"0",vol:"-",strike:"925.00",expiry:"May 31, 2013"},{cid:"195709831580001",name:"",s:"GOOG130531P00930000",e:"OPRA",p:"-",c:"-",b:"39.10",a:"41.80",oi:"0",vol:"-",strike:"930.00",expiry:"May 31, 2013"},{cid:"105979139287680",name:"",s:"GOOG130531P00935000",e:"OPRA",p:"-",c:"-",b:"44.10",a:"46.70",oi:"0",vol:"-",strike:"935.00",expiry:"May 31, 2013"},{cid:"178992314903890",name:"",s:"GOOG130531P00940000",e:"OPRA",p:"-",c:"-",b:"49.00",a:"51.70",oi:"0",vol:"-",strike:"940.00",expiry:"May 31, 2013"},{cid:"1081213298325092",name:"",s:"GOOG130531P00945000",e:"OPRA",p:"-",c:"-",b:"54.00",a:"57.00",oi:"0",vol:"-",strike:"945.00",expiry:"May 31, 2013"},{cid:"849137800680828",name:"",s:"GOOG130531P00950000",e:"OPRA",p:"-",c:"-",b:"59.40",a:"61.60",oi:"0",vol:"-",strike:"950.00",expiry:"May 31, 2013"},{cid:"252708185356048",name:"",s:"GOOG130531P00955000",e:"OPRA",p:"-",c:"-",b:"63.90",a:"67.60",oi:"0",vol:"-",strike:"955.00",expiry:"May 31, 2013"},{cid:"849787286766910",name:"",s:"GOOG130531P00960000",e:"OPRA",p:"-",c:"-",b:"68.90",a:"71.60",oi:"0",vol:"-",strike:"960.00",expiry:"May 31, 2013"},{cid:"39686410476830",name:"",s:"GOOG130531P00965000",e:"OPRA",p:"-",c:"-",b:"74.00",a:"77.20",oi:"0",vol:"-",strike:"965.00",expiry:"May 31, 2013"}],calls:[{cid:"897932155474025",name:"",s:"GOOG130531C00625000",e:"OPRA",p:"-",c:"-",b:"262.70",a:"265.60",oi:"0",vol:"-",strike:"625.00",expiry:"May 31, 2013"},{cid:"184287418485356",name:"",s:"GOOG130531C00630000",e:"OPRA",p:"248.20",cs:"chb",c:"0.00",cp:"0.00",b:"257.70",a:"260.60",oi:"5",vol:"-",strike:"630.00",expiry:"May 31, 2013"},{cid:"905931936433954",name:"",s:"GOOG130531C00635000",e:"OPRA",p:"-",c:"-",b:"252.70",a:"255.60",oi:"0",vol:"-",strike:"635.00",expiry:"May 31, 2013"},{cid:"135801183483562",name:"",s:"GOOG130531C00640000",e:"OPRA",p:"-",c:"-",b:"247.70",a:"250.60",oi:"0",vol:"-",strike:"640.00",expiry:"May 31, 2013"},{cid:"543749135131573",name:"",s:"GOOG130531C00645000",e:"OPRA",p:"-",c:"-",b:"242.70",a:"245.60",oi:"0",vol:"-",strike:"645.00",expiry:"May 31, 2013"},{cid:"430718357015828",name:"",s:"GOOG130531C00650000",e:"OPRA",p:"208.30",cs:"chb",c:"0.00",cp:"0.00",b:"237.70",a:"240.60",oi:"2",vol:"-",strike:"650.00",expiry:"May 31, 2013"},{cid:"188702697546621",name:"",s:"GOOG130531C00655000",e:"OPRA",p:"-",c:"-",b:"232.70",a:"235.60",oi:"0",vol:"-",strike:"655.00",expiry:"May 31, 2013"},{cid:"828515608830763",name:"",s:"GOOG130531C00660000",e:"OPRA",p:"-",c:"-",b:"227.70",a:"230.60",oi:"0",vol:"-",strike:"660.00",expiry:"May 31, 2013"},{cid:"999908579656355",name:"",s:"GOOG130531C00665000",e:"OPRA",p:"215.00",cs:"chb",c:"0.00",cp:"0.00",b:"222.70",a:"225.60",oi:"6",vol:"-",strike:"665.00",expiry:"May 31, 2013"},{cid:"543778324287872",name:"",s:"GOOG130531C00670000",e:"OPRA",p:"-",c:"-",b:"218.30",a:"220.60",oi:"0",vol:"-",strike:"670.00",expiry:"May 31, 2013"},{cid:"911061111100062",name:"",s:"GOOG130531C00675000",e:"OPRA",p:"-",c:"-",b:"213.30",a:"215.60",oi:"0",vol:"-",strike:"675.00",expiry:"May 31, 2013"},{cid:"530480483916026",name:"",s:"GOOG130531C00680000",e:"OPRA",p:"-",c:"-",b:"208.20",a:"210.60",oi:"0",vol:"-",strike:"680.00",expiry:"May 31, 2013"},{cid:"972896973547783",name:"",s:"GOOG130531C00685000",e:"OPRA",p:"-",c:"-",b:"202.70",a:"205.70",oi:"0",vol:"-",strike:"685.00",expiry:"May 31, 2013"},{cid:"703518576890345",name:"",s:"GOOG130531C00690000",e:"OPRA",p:"-",c:"-",b:"198.30",a:"200.60",oi:"0",vol:"-",strike:"690.00",expiry:"May 31, 2013"},{cid:"173645130459646",name:"",s:"GOOG130531C00695000",e:"OPRA",p:"-",c:"-",b:"193.30",a:"195.60",oi:"0",vol:"-",strike:"695.00",expiry:"May 31, 2013"},{cid:"252936815518459",name:"",s:"GOOG130531C00700000",e:"OPRA",p:"-",c:"-",b:"187.30",a:"191.50",oi:"0",vol:"-",strike:"700.00",expiry:"May 31, 2013"},{cid:"40857533404165",name:"",s:"GOOG130531C00705000",e:"OPRA",p:"-",c:"-",b:"183.30",a:"185.60",oi:"0",vol:"-",strike:"705.00",expiry:"May 31, 2013"},{cid:"957476173492076",name:"",s:"GOOG130531C00710000",e:"OPRA",p:"-",c:"-",b:"177.30",a:"181.50",oi:"0",vol:"-",strike:"710.00",expiry:"May 31, 2013"},{cid:"108863832559161",name:"",s:"GOOG130531C00715000",e:"OPRA",p:"-",c:"-",b:"173.20",a:"175.60",oi:"0",vol:"-",strike:"715.00",expiry:"May 31, 2013"},{cid:"98617325850106",name:"",s:"GOOG130531C00720000",e:"OPRA",p:"-",c:"-",b:"168.20",a:"170.60",oi:"0",vol:"-",strike:"720.00",expiry:"May 31, 2013"},{cid:"753686669907511",name:"",s:"GOOG130531C00725000",e:"OPRA",p:"-",c:"-",b:"163.30",a:"165.60",oi:"0",vol:"-",strike:"725.00",expiry:"May 31, 2013"},{cid:"489933059142682",name:"",s:"GOOG130531C00730000",e:"OPRA",p:"-",c:"-",b:"157.30",a:"161.50",oi:"0",vol:"-",strike:"730.00",expiry:"May 31, 2013"},{cid:"905425017312349",name:"",s:"GOOG130531C00735000",e:"OPRA",p:"174.80",cs:"chb",c:"0.00",cp:"0.00",b:"152.70",a:"155.70",oi:"1",vol:"-",strike:"735.00",expiry:"May 31, 2013"},{cid:"136536386201059",name:"",s:"GOOG130531C00740000",e:"OPRA",p:"-",c:"-",b:"147.30",a:"151.50",oi:"0",vol:"-",strike:"740.00",expiry:"May 31, 2013"},{cid:"147619908144017",name:"",s:"GOOG130531C00745000",e:"OPRA",p:"-",c:"-",b:"142.70",a:"145.70",oi:"0",vol:"-",strike:"745.00",expiry:"May 31, 2013"},{cid:"966255278051458",name:"",s:"GOOG130531C00750000",e:"OPRA",p:"-",c:"-",b:"137.30",a:"141.50",oi:"0",vol:"-",strike:"750.00",expiry:"May 31, 2013"},{cid:"91531149317385",name:"",s:"GOOG130531C00755000",e:"OPRA",p:"-",c:"-",b:"132.70",a:"135.70",oi:"0",vol:"-",strike:"755.00",expiry:"May 31, 2013"},{cid:"1073058963314671",name:"",s:"GOOG130531C00760000",e:"OPRA",p:"-",c:"-",b:"127.70",a:"130.70",oi:"0",vol:"-",strike:"760.00",expiry:"May 31, 2013"},{cid:"211715618356204",name:"",s:"GOOG130531C00765000",e:"OPRA",p:"-",c:"-",b:"122.90",a:"125.70",oi:"0",vol:"-",strike:"765.00",expiry:"May 31, 2013"},{cid:"864401376962645",name:"",s:"GOOG130531C00770000",e:"OPRA",p:"-",c:"-",b:"117.30",a:"121.60",oi:"0",vol:"-",strike:"770.00",expiry:"May 31, 2013"},{cid:"625513742158849",name:"",s:"GOOG130531C00775000",e:"OPRA",p:"-",c:"-",b:"113.30",a:"115.70",oi:"0",vol:"-",strike:"775.00",expiry:"May 31, 2013"},{cid:"150940569707753",name:"",s:"GOOG130531C00780000",e:"OPRA",p:"97.87",cs:"chb",c:"0.00",cp:"0.00",b:"108.30",a:"110.80",oi:"1",vol:"-",strike:"780.00",expiry:"May 31, 2013"},{cid:"1096966496977199",name:"",s:"GOOG130531C00785000",e:"OPRA",p:"-",c:"-",b:"102.70",a:"105.90",oi:"0",vol:"-",strike:"785.00",expiry:"May 31, 2013"},{cid:"596267655966317",name:"",s:"GOOG130531C00790000",e:"OPRA",p:"68.00",cs:"chb",c:"0.00",cp:"0.00",b:"97.30",a:"101.60",oi:"11",vol:"-",strike:"790.00",expiry:"May 31, 2013"},{cid:"797644140819446",name:"",s:"GOOG130531C00795000",e:"OPRA",p:"-",c:"-",b:"92.70",a:"95.90",oi:"0",vol:"-",strike:"795.00",expiry:"May 31, 2013"},{cid:"67114730428643",name:"",s:"GOOG130531C00800000",e:"OPRA",p:"90.20",cs:"chb",c:"0.00",cp:"0.00",b:"87.40",a:"91.10",oi:"48",vol:"-",strike:"800.00",expiry:"May 31, 2013"},{cid:"524083644435811",name:"",s:"GOOG130531C00805000",e:"OPRA",p:"76.20",cs:"chb",c:"0.00",cp:"0.00",b:"82.90",a:"85.80",oi:"10",vol:"-",strike:"805.00",expiry:"May 31, 2013"},{cid:"1027523638915015",name:"",s:"GOOG130531C00810000",e:"OPRA",p:"25.30",cs:"chb",c:"0.00",cp:"0.00",b:"78.50",a:"81.30",oi:"28",vol:"-",strike:"810.00",expiry:"May 31, 2013"},{cid:"731421388062365",name:"",s:"GOOG130531C00815000",e:"OPRA",p:"94.02",cs:"chb",c:"0.00",cp:"0.00",b:"73.10",a:"75.70",oi:"3",vol:"-",strike:"815.00",expiry:"May 31, 2013"},{cid:"201733430660498",name:"",s:"GOOG130531C00820000",e:"OPRA",p:"53.87",cs:"chb",c:"0.00",cp:"0.00",b:"68.60",a:"71.20",oi:"13",vol:"-",strike:"820.00",expiry:"May 31, 2013"},{cid:"424269582116081",name:"",s:"GOOG130531C00825000",e:"OPRA",p:"-",c:"-",b:"63.60",a:"66.30",oi:"0",vol:"-",strike:"825.00",expiry:"May 31, 2013"},{cid:"1108741066703867",name:"",s:"GOOG130531C00830000",e:"OPRA",p:"55.50",cs:"chb",c:"0.00",cp:"0.00",b:"58.40",a:"60.70",oi:"71",vol:"-",strike:"830.00",expiry:"May 31, 2013"},{cid:"665032675403725",name:"",s:"GOOG130531C00835000",e:"OPRA",p:"65.70",cs:"chb",c:"0.00",cp:"0.00",b:"53.50",a:"55.70",oi:"14",vol:"-",strike:"835.00",expiry:"May 31, 2013"},{cid:"870334633948548",name:"",s:"GOOG130531C00840000",e:"OPRA",p:"50.00",cs:"chb",c:"0.00",cp:"0.00",b:"48.70",a:"51.30",oi:"35",vol:"-",strike:"840.00",expiry:"May 31, 2013"},{cid:"607302185263535",name:"",s:"GOOG130531C00845000",e:"OPRA",p:"-",c:"-",b:"43.80",a:"46.40",oi:"0",vol:"-",strike:"845.00",expiry:"May 31, 2013"},{cid:"260537929897126",name:"",s:"GOOG130531C00850000",e:"OPRA",p:"24.20",cs:"chb",c:"0.00",cp:"0.00",b:"38.80",a:"41.50",oi:"60",vol:"-",strike:"850.00",expiry:"May 31, 2013"},{cid:"869025962460528",name:"",s:"GOOG130531C00855000",e:"OPRA",p:"-",c:"-",b:"33.90",a:"36.70",oi:"0",vol:"-",strike:"855.00",expiry:"May 31, 2013"},{cid:"271885603677647",name:"",s:"GOOG130531C00860000",e:"OPRA",p:"31.20",cs:"chb",c:"0.00",cp:"0.00",b:"29.20",a:"31.40",oi:"49",vol:"-",strike:"860.00",expiry:"May 31, 2013"},{cid:"328801446656020",name:"",s:"GOOG130531C00865000",e:"OPRA",p:"26.95",cs:"chg",c:"+14.95",cp:"124.58",b:"24.80",a:"25.80",oi:"178",vol:"34",strike:"865.00",expiry:"May 31, 2013"},{cid:"829450250741566",name:"",s:"GOOG130531C00870000",e:"OPRA",p:"19.10",cs:"chg",c:"+9.90",cp:"107.61",b:"20.20",a:"22.10",oi:"138",vol:"13",strike:"870.00",expiry:"May 31, 2013"},{cid:"989626103025718",name:"",s:"GOOG130531C00875000",e:"OPRA",p:"12.50",cs:"chg",c:"+5.71",cp:"84.09",b:"16.10",a:"17.90",oi:"61",vol:"10",strike:"875.00",expiry:"May 31, 2013"},{cid:"1105249690063656",name:"",s:"GOOG130531C00880000",e:"OPRA",p:"13.00",cs:"chg",c:"+8.20",cp:"170.83",b:"12.40",a:"14.90",oi:"252",vol:"35",strike:"880.00",expiry:"May 31, 2013"},{cid:"339698646824918",name:"",s:"GOOG130531C00885000",e:"OPRA",p:"9.70",cs:"chg",c:"+6.40",cp:"193.94",b:"9.60",a:"9.90",oi:"1126",vol:"1868",strike:"885.00",expiry:"May 31, 2013"},{cid:"280517630346946",name:"",s:"GOOG130531C00890000",e:"OPRA",p:"6.94",cs:"chg",c:"+5.09",cp:"275.14",b:"6.70",a:"7.20",oi:"262",vol:"432",strike:"890.00",expiry:"May 31, 2013"},{cid:"963465706946796",name:"",s:"GOOG130531C00895000",e:"OPRA",p:"4.75",cs:"chg",c:"+3.41",cp:"254.48",b:"4.60",a:"4.90",oi:"467",vol:"1408",strike:"895.00",expiry:"May 31, 2013"},{cid:"183457594845045",name:"",s:"GOOG130531C00900000",e:"OPRA",p:"3.13",cs:"chg",c:"+2.18",cp:"229.47",b:"3.10",a:"3.20",oi:"1627",vol:"2036",strike:"900.00",expiry:"May 31, 2013"},{cid:"646238429691215",name:"",s:"GOOG130531C00905000",e:"OPRA",p:"2.00",cs:"chg",c:"+1.36",cp:"212.50",b:"1.95",a:"2.05",oi:"793",vol:"951",strike:"905.00",expiry:"May 31, 2013"},{cid:"212732374141821",name:"",s:"GOOG130531C00910000",e:"OPRA",p:"0.65",cs:"chb",c:"0.00",cp:"0.00",b:"1.15",a:"1.45",oi:"78",vol:"-",strike:"910.00",expiry:"May 31, 2013"},{cid:"710257727382042",name:"",s:"GOOG130531C00915000",e:"OPRA",p:"0.95",cs:"chg",c:"+0.63",cp:"196.88",b:"0.65",a:"0.90",oi:"40",vol:"7",strike:"915.00",expiry:"May 31, 2013"},{cid:"563703158549966",name:"",s:"GOOG130531C00920000",e:"OPRA",p:"0.22",cs:"chb",c:"0.00",cp:"0.00",b:"0.20",a:"0.80",oi:"70",vol:"-",strike:"920.00",expiry:"May 31, 2013"},{cid:"834257765385117",name:"",s:"GOOG130531C00925000",e:"OPRA",p:"0.37",cs:"chg",c:"+0.22",cp:"146.67",b:"0.35",a:"0.40",oi:"280",vol:"262",strike:"925.00",expiry:"May 31, 2013"},{cid:"420529541878506",name:"",s:"GOOG130531C00930000",e:"OPRA",p:"0.95",cs:"chb",c:"0.00",cp:"0.00",b:"0.10",a:"0.40",oi:"8",vol:"-",strike:"930.00",expiry:"May 31, 2013"},{cid:"888055439268652",name:"",s:"GOOG130531C00935000",e:"OPRA",p:"0.75",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"14",vol:"-",strike:"935.00",expiry:"May 31, 2013"},{cid:"801449057323065",name:"",s:"GOOG130531C00940000",e:"OPRA",p:"0.45",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"88",vol:"-",strike:"940.00",expiry:"May 31, 2013"},{cid:"607038769941357",name:"",s:"GOOG130531C00945000",e:"OPRA",p:"0.55",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"14",vol:"-",strike:"945.00",expiry:"May 31, 2013"},{cid:"667068548867948",name:"",s:"GOOG130531C00950000",e:"OPRA",p:"0.45",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"60",vol:"-",strike:"950.00",expiry:"May 31, 2013"},{cid:"4937120138052",name:"",s:"GOOG130531C00955000",e:"OPRA",p:"0.55",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"2",vol:"-",strike:"955.00",expiry:"May 31, 2013"},{cid:"217861932232686",name:"",s:"GOOG130531C00960000",e:"OPRA",p:"0.40",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"3",vol:"-",strike:"960.00",expiry:"May 31, 2013"},{cid:"312327429834115",name:"",s:"GOOG130531C00965000",e:"OPRA",p:"0.40",cs:"chb",c:"0.00",cp:"0.00",b:"-",a:"0.40",oi:"2",vol:"-",strike:"965.00",expiry:"May 31, 2013"}],underlying_id:"694653",underlying_price:889.58002}


Q: Extracting data embedded in an 8-bit array into different size array I am working on a project which receives a series of parameters condensed into an 8 bit array. These parameters can come in varying sizes, but are always sent in an 8 bit array. The goal is to extract these parameters into an array the size of the largest sized parameter (which is already known beforehand).

For example, there could be two 4 bit parameters stored in the first index of the parameter array, then one 8 bit parameter, then one 16 bit parameter. The goal would then be to place each parameter separately in a 16 bit array of length 4, where extra space are just 0's. I am struggling finding a way to do this efficiently, especially since the i2c array could potentially have multiple parameters embedded within one byte of the array. Any suggestions would be greatly appreciated!

To better illustrate this, take our 8-bit data array = [0011 1011, 0110 1111] and take our parameter lengths to be = [2, 2, 4, 8]. Then, I would want the result array to appear as [0000 0000, 0000 0011, 0000 1011, 0110 1111]. The bold numbers indicate the bits taken from the data array.

A: I solved this kind of problem before by simply considering the received array of bytes as a bit flow.
So it's quite easy to read 3 bits, then 7 bits, then 10 bits, then 2 bits, etc. until the end of the buffer.
You simply need to keep an index to the current bit:
struct bitflow {
  unsigned char* data ; // Received data
  size_t datasize ; // Data size, in bytes.
  size_t pc ;  // Current bit pointer, initialize it to zero.
}

To get the next bit (0/1=bit, -1=error):
int getnextbit (struct bitflow* b) {
  // Check if we didn't already reached the end of buffer.
  // "pc" must be stricly below (classic C indexes) than the number of bytes (datasize) multiplied by 8 (number of bits per byte).
  // A shift of 3 ranks to the left is the same as multiplying by 8, but is faster and will be faster even without any enabled optimization from compiler.
  if (pc>=(datasize<<3))
    return -1 ;
  // Where is the bit:
  // - Targeted byte is the integer part of "pc/8". Again, a shift to accelerate that.
  // - Targeted bit is the remainder of "pc/8". A binary mask with 7 do the same, again faster than a modulo even without optimizations.
  // We then shift a bit (1) to the position of the remainder, and with a bitwise "AND", we extract the bit.
  // If the result is zero, the bit wasn't set, we return zero.
  // If non-zero (equal to (1<<((b->pc) & 7)), in fact), we return "1".
  int result = (((b->data[(b->pc)>>3]) & (1<<((b->pc) & 7))) ? 1 : 0) ;
  // We extracted a bit, so we increment the pointer to next bit.
  b->pc++ ;
  return result ;
}

To get the next N bits (max. 31 bits, >=0 = OK, <0=error):
// l2m==0: read from LSB to MSB, otherwise, read from MSB to LSB.
int getnextbits (struct bitflow* b, int nbbits, int l2m) {
  if ((nbbits<0) || (nbbits>31))
    return -2 ;
  if ((pc+nbbits)>=(datasize<<3))
    return -1 ;
  int result = 0 ;
  size_t j=b->pc ;
// Alternatives for endianness (depends on both CPU used and I2C data format, read both datasheets and/or simply test):
  if (l2m) {
    // 1st read bit is LSB (least significant bit), last read bit is MSB (most significant bit).
    for (int i=0 ; i<nbbits ; i++, j++)
      result |= (((b->data[j>>3]) & (1<<(j & 7))) ? (1<<i) : 0) ;
  } else {
    // 1st read bit is MSB, last read bit is LSB.
    for (int i=(nbbits-1) ; i>=0 ; i--, j++)
      result |= (((b->data[j>>3]) & (1<<(j & 7))) ? (1<<i) : 0) ;
  }
  b->pc += nbbits ;
  return result ;
}

This last function can be heavily optimized by getting directly all possible remaining bits of the current byte, if nbbits (or the number of bits still to extract) is greater or equal to the number of bits left in the current byte. But it shouldn't be needed if you don't have a huge load of data, which is quite unlikely if you get these data from I²C.
Endianness can complexify things a bit, but it's not impossible to solve - I usually do the endianness swap directly at reception when needed.
Finally, you can read data this way:
// Considering structure is filled by reception routine.
struct bitflow b = getdatafromi2c() ;
// Number of bits for each consecutive element.
int format[10] = { 4, 4, 2, 2, 4, 16, 10, 2, 1, 1 } ;
unsigned short int result[10] ;
for (int i=0 ; i<10 ; i++ ) {
  int v = getnextbits(&b, format[i]) ;
  if (v<0) {
    // Error handling
    ....
  }
  result[i] = (unsigned short int)v ;
}
// Use result array normally from now.

A:     uint8_t input_array[4];
    uint16_t output_array[4];

    // I have to make an assumption that the two fours are filled little-endian. If it's wrong, it's wrong.
    // You will generally have this problem whenever parameters span bytes. You have to know.
    output_array[0] = input_array[0] & 0xF;
    output_array[1] = input_array[0] >> 4;
    output_array[2] = input_array[1];
    // Similar story here. I assume that input_array's bytes are little endian.
    // You normally find bit-endian and byte-endian are the same but a contrary system could exist.
    output_array[3] = input_array[2] | (input_array[3] << 8);

In the old days people used to do this with structs. Somebody's going to come by and tell me this is undefined, etc; it doesn't really matter. A compiler that emits terrible code for the above emits good code for the below. It's the modern optimizing compilers that an figure the most efficient way for the above that will mess up the below. This has all kinds of alignment and endian assumptions built into it; however where it works, it works well. Where it doesn't work it's undefined.
     union u {
         uint8_t input_array[4];
         struct input {
             unsigned char param0 : 4;
             unsigned char param1 : 4;
             unsigned char param2 : 8;
             unsigned char param3 : 6;
         }
     } input_form;

    union input_form input;
    uint16_t output_array[4];
    output_array[0] = input.input.param0;
    output_array[1] = input.input.param1;
    output_array[2] = input.input.param2;
    output_array[3] = input.input.param3;


Q: Create xib based interface with Xcode 5 I am trying to create a new app with Singe View template but there is no xib or storyboard option to make my interface as xib file !!! why does Apple remove xib from iOS 7 ?!! How can I create application with xib interface files ?

A: Apple removed it because they just want to "force" everybody to use Storyboards, although from what I know, a big amount of people just don't find them useful.
I'm afraid you'll have to do it yourself, just create an empty app and set yourself the view.
Check an example:
http://www.appcoda.com/hello-world-app-using-xcode-5-xib/

A: Apple remove it from xcode 5 . you have only one option to choose storyboard.
if you want to xibs then remove storyboard after creating singleView application and add xib manually.
another option is to create application in xcode 4.6 or earliar version then run it on xcode 5.

A: *

*Create a new project

*Select Single View Application

*Set ProjectName and other settings

*Save Project at location

*Select Project in Navigator Panel in Left

*Remove Main.storyboard file from project

*Add New .xib file in Project

*Set Main Interface to your .xib file in "General Tab" on right panel.

*Paste following code in didFinishLaunchingWithOptions method

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[UIViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
[self.window makeKeyAndVisible];


Q: Download and save static images in phone In my application when i query a http URL i get list of object, some times these object needs to be rendered on listview and sometimes in my custom view.
Each of the object which i receive from server has image tag, most of the time images are always constant i.e same image URL only.
I just want to download the images once, & also my app should have to download once in a while when the images got changed in server. What is the best way?
I know like, we need to perform operation in thread, but not getting the exact idea of how to do?. how to check for change of image & efficient way of storing them. Any hint

A: For storage, I recommend Internal Storage
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
And for downloading
http://developer.android.com/reference/android/os/AsyncTask.html
You can create a AsyncTask where you pass a ImageView, where you want to show the img, with the url as a tag. And check in the internal storage if you have that img already saved if not just download it.


Q: Why is this ignoring the where clause? Why is the where clause being ignored in this code? It seems to be ignoring the where clause on the update which means every records has been written over. How can i fix this? Any help would be greatly appreciated.
namespace ResitAssignment2
{
    public partial class HomeCareVisitEddit : Form
    {
        public HomeCareVisitEddit()
        {
            InitializeComponent();
        }

        private void SubmitHCVA_Click(object sender, EventArgs e)
        {
            SqlConnection a = Database.GetConnection();
            a.Open();

            string sqltext;
            sqltext = @"update HomeCareVisit set
             PatientNo=@PatientNo,
             FurtherVisitRequired=@FurtherVisitRequired,
             AdvisoryNotes=@AdvisoryNotes,
             Prescription=@Prescription,
             TreatmentProvided=@TreatmentProvided,
             ActualVisitDateTime=@ActualVisitDateTime,
             Priority=@Priority,
             ScheduledDateTime=@ScheduledDateTime,
             TreatmentInstructions=@TreatmentInstructions,
             MedicalStaffID=@MedicalStaffID
              WHERE
             VisitRefNo=VisitRefNo";

            SqlCommand command = new SqlCommand(sqltext, a);

            try
            {
                using (a)
                {
                    command.Parameters.AddWithValue("@PatientNo", PatientNo.Text);
                    command.Parameters.AddWithValue("@FurtherVisitRequired", FurtherVisitRequired.Text);
                    command.Parameters.AddWithValue("@AdvisoryNotes", AdvisoryNotes.Text);
                    command.Parameters.AddWithValue("@Prescription", Prescription.Text);
                    command.Parameters.AddWithValue("@TreatmentProvided", TreatmentProvided.Text);
                    command.Parameters.AddWithValue("@ActualVisitDateTime",SqlDbType.DateTime );
                    {
                        DateTime.Parse(ActualVisitDateTime.Text);
                    };
                    command.Parameters.AddWithValue("@Priority", Priority.Text);
                    command.Parameters.AddWithValue("@ScheduledDateTime",SqlDbType.DateTime );
                    {
                        DateTime.Parse(ScheduledDateTime.Text);
                    };

                    command.Parameters.AddWithValue("@TreatmentInstructions", TreatmentInstructions.Text);
                    command.Parameters.AddWithValue("@MedicalStaffID", MedicalStaffID.Text);
                    command.Parameters.AddWithValue("@VisitRefNo", VisitRefNo.Text);
                    command.ExecuteNonQuery();

                    MessageBox.Show("Record altered");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            a.Close();
        }

        private void HomeCareVisitEddit_Load(object sender, EventArgs e)
        {
            SqlConnection a = Database.GetConnection();
            a.Open();

            string sqlText = "select * from HomeCareVisit where VisitRefNo =" + VisitRefNo;
            SqlCommand command = new SqlCommand(sqlText, a);
            SqlDataReader HomeCareVisitData = command.ExecuteReader();

            while (HomeCareVisitData.Read())
            {
                //DateTime actual = DateTime.Parse("ActualVisitDateTime");
                //DateTime scheduled = DateTime.Parse("ActualVisitDateTieme");
                PatientNo.Text = HomeCareVisitData["PatientNo"].ToString();
                FurtherVisitRequired.Text = HomeCareVisitData["FurtherVisitRequired"].ToString();
                AdvisoryNotes.Text = HomeCareVisitData["AdvisoryNotes"].ToString();
                Prescription.Text = HomeCareVisitData["Prescription"].ToString();
                TreatmentProvided.Text = HomeCareVisitData["TreatmentProvided"].ToString();
                ActualVisitDateTime.Text = HomeCareVisitData["ActualVisitDateTime"].ToString();
                Priority.Text = HomeCareVisitData["Priority"].ToString();
                ScheduledDateTime.Text = HomeCareVisitData["ScheduledDateTime"].ToString();
                TreatmentInstructions.Text = HomeCareVisitData["TreatmentInstructions"].ToString();
                MedicalStaffID.Text = HomeCareVisitData["MedicalStaffID"].ToString();
             }
             a.Close();
         }
     }
}

A: WHERE VisitRefNo=VisitRefNo"; should be WHERE VisitRefNo=@VisitRefNo";.

A: WHERE VisitRefNo=VisitRefNo

Should be
WHERE VisitRefNo=@VisitRefNo


Q: Using pointers in Class Templates with Subclasses I have a problem with using pointers with Class templates. I can't properly access vv from the B subclass if 'vv' stores pointers to vectors; if I simply store vectors it works. But what I'm trying to do requires me to store pointers. I honestly have no idea what I'm doing wrong so here is the code:
template<typename T>
class A{
    public:
        std::vector<std::vector<T>*> vv;
        void add(std::vector<T> new_vec)
        {
            vv.push_back(&new_vec);
        }

        virtual void print(){}
        virtual ~A(){}
};

template<typename T>
class B : public A<T>{
    public:
        void print() override{
            std::cout << this->vv[0]->at(0) << std::endl;
        }
};

int main(){
    int i = 10;
    std::vector<int> v;
    v.push_back(i);

    A <int>*a = new B<int>();
    a->add(v);
    a->print();
    return 0;
}

a->print() prints 0 instead of 10. Also I can't change what is inside main().
I would be very thankful for some help!

A: Here:
    void add(std::vector<T> new_vec)
    {
        vv.push_back(&new_vec);
    }

You store a pointer to the local argument new_vec in vv. That local copy will only live till the method returns. Hence the pointers in the vector are useless. Dereferencing them later invokes undefined behavior. If you really want to store pointers you should pass a pointer (or reference) to add. Though, you should rather use smart pointers.


Q: is filter is replaceable of query in mongo queries using c#? I'm new to mongo in c#
I found tow ways to find documents based on search critiria:
the first using filter:
var collection = _database.GetCollection<BsonDocument>("restaurants");
var filter = Builders<BsonDocument>.Filter.Eq("address.zipcode", "10075");
var result = await collection.Find(filter).ToListAsync();

The second using query:
MongoCollection<BsonDocument> books;
var query = Query.EQ("author", "Kurt Vonnegut");
foreach (BsonDocument book in books.Find(query)) {
    // do something with book
}

What's the best way to find documents based to what MongoDB recommendation?

A: As far I know query builders (like your second example  using Query.EQ) belong to old versions of C# drivers (1.X) (see Query class). Also I suggest you to see Builder section in this link that confirm query builders is the old way to consult data.
After the release of the 2.0 version of the .NET driver, a lot of changes were made, including the way of consult the data (you can read more about that in this link). If you are using the last C# driver version you should use your first approach.

A: The first way you mentioned is quite fine. You might want to incorporate using a mongo cursor as well to allow you to iterate through results
    var collection = _database.GetCollection<BsonDocument>("restaurants");
    var filter = Builders<BsonDocument>.Filter.Eq("address.zipcode", "10075");
    using(var _cursor = await collection.Find(filter).ToCursorAsync())
    {
        while(await _cursor.MoveNextAsync())
        {
            foreach(var _document in _cursor.Current) //gets current document
            {
                //you can do things like get the _id of the document
                var _id = _document["_id"];
            }
        }
    }


Q: Java .wav get binary data I'm using the Microsoft Project Oxford Speaker Recognition API REST, in order to create an enrollment I need to send a Binary Data of a .wav file. I already have the class that records and saves the .wav file, now I have to POST it, I just dunno how do I kinda "decode" the .wav file I have to that Binary Data that I want...
Appreciate any help.
Here's the link to what I'm trying to do: Speaker Recognition Create Enrollment.

A: In the documentation of the API, it is mentioned that the "body" of the request is the raw binary data for the *.wav file that you have recorded. This means you just need to send the file as is without any decoding.


Q: How wrap every 3rd elements in to a div, xslt each I am quite newbie on XSLT.
here is my XML
<contact>
 <person>
   <name>Hannah</name>
   <phone>123-123-123</phone>
   <address>No.1 A St. city</address>
 <person>

 <person>
   <name>David</name>
   <phone>223-223-223</phone>
   <address>No.2 B BRC. city</address>
 <person>

 <person>
   <name>Tim</name>
   <phone>323-223-333</phone>
   <address>No.3 c BRC. city</address>
 <person>

  <person>
   <name>May</name>
   <phone>443-443-443</phone>
   <address>No.4 bb Rd. city</address>
  <person>

  <person>
   <name>Rose</name>
   <phone>7743-443-443</phone>
   <address>No.7 rolling Rd. city</address>
  <person>

  ..........more
 <contact>

The OUTPUT I am trying to have

Hannah

123-123-123

No.1 A St. city

David

223-223-223

No.2 B BRC. city

Tim

323-223-333

No.3 c BRC. city

May

443-443-443

No.4 bb Rd. city

Rose

7743-443-443

No.7 rolling Rd. city

 ..... Loop if has more

Here is what I did, but there are many errors.
how to select more for-each select?
<xsl:template name="group">
    <xsl:param name="name"/>
    <xsl:param name="phone"/>
    <xsl:param name="address"/>

<xsl:value-of select="$name"/>

<xsl:value-of select="$phone"/>

<xsl:value-of select="$address"/>

</xsl:template>

  <xsl:template match="/*">

    <xsl:variable name="name" select="//name"/>
    <xsl:variable name="phone" select="//phone"/>
    <xsl:variable name="address" select="//address"/>

      <xsl:for-each select="$name">
        <xsl:if test="(position() mod 4) = 1">
          <xsl:variable name="position" select="position()"/>

            <xsl:call-template name="group">
              <xsl:with-param name="name" select="."/>
               <xsl:with-param name="phone" select="."/>
                <xsl:with-param name="address" select="."/>
            </xsl:call-template>

        </xsl:if>
      </xsl:for-each>

  </xsl:template>
</xsl:stylesheet>

If someone could please correct my errors please? Many thanks

A: I wouldn't use for-each at all. The following stylesheet solves your problem in a more idiomatic way:
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:variable name="group" select="3" />
    <xsl:template match="/">
        <xsl:apply-templates select="contact/person[position() mod $group = 1]" />
    </xsl:template>
    <xsl:template match="person">

            <xsl:apply-templates
                select=".|following-sibling::person[position() < $group]"
                  mode="inner" />

    </xsl:template>
    <xsl:template match="person" mode="inner">

            <xsl:apply-templates />

    </xsl:template>
    <xsl:template match="name">

<xsl:apply-templates />

    </xsl:template>
    <xsl:template match="phone">

<xsl:apply-templates />

    </xsl:template>
    <xsl:template match="address">

<xsl:apply-templates />

    </xsl:template>
</xsl:stylesheet>

We select every third person (starting with the first one) and apply a special template (using modes) to that element and its next two siblings.

A:
If someone could please correct my errors please?

I don't know if I can correct your errors, because I don't really understand where you're going with your stylesheet. You seem to have the right idea that a processing template is required here, but I lost you after that.
Try the following approach:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:template match="/">
<root>
    <xsl:call-template name="divide">
        <xsl:with-param name="items" select="contact/person"/>
    </xsl:call-template>
</root>
</xsl:template>

<xsl:template name="divide">
    <xsl:param name="items" />
    <xsl:param name="groupSize" select="3"/>
    <xsl:param name="i" select="1"/>
    <xsl:choose>
        <xsl:when test="$i > count($items)"/>
        <xsl:otherwise>

                <xsl:for-each select="$items[$i <= position() and position() < $i+$groupSize]">

<xsl:value-of select="name"/>

<xsl:value-of select="phone"/>

<xsl:value-of select="address"/>

                </xsl:for-each>

            <xsl:call-template name="divide">
                <xsl:with-param name="items" select="$items"/>
                <xsl:with-param name="i" select="$i+$groupSize"/>
            </xsl:call-template>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

</xsl:stylesheet>

Note that I have added a <root> element to the output which is missing from your required output. While I am at it, your input is also invalid: the <person> tags are not closed.


Q: angular 2 - kendo datepicker max and min doesnt work Kendo datepicker doesn't work. Can anyone tell me where I made mistake? Min date suppose to be today's date. Here is sample code:
app.html
<div [class]="datePickerClass">
    <kendo-datepicker class="kendo-datepicker"
                        id="startDate"
                        [ngModel]="_startValue"
                        [min]="min"
                        [max]="max"
                        (ngModelChange)="startValueChanged($event)"
                        [format]="formatDisplay"></kendo-datepicker>
</div>
<div [class]="datePickerClass">
    <kendo-datepicker class="kendo-datepicker"
                        id="endDate"
                        [ngModel]="_endValue"
                        [min]="min"
                        [max]="max"
                        (ngModelChange)="endValueChanged($event)"
                        [format]="'d MMM yyyy'"></kendo-datepicker>
</div>
<ng-content>
</ng-content>

app.ts

public min = new Date();
public max: Date = new Date(2017, 1, 1);

File structure

A: I had the same problem recently try the following :
private today = new Date();
public min: Date = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate());

this worked for me, also change the "max" to some date after 11/7/2017  :)


Q: What's wrong with my rackup file? When i attempt to start my unicorn server I've got the next stack trace:
Can't understand what's wrong with rackup file? Why it is not readable?
sites@bck:~/fatfreecrm$ /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/bin/unicorn_rails -E -D production -c /home/sites/fatfreecrm/config/unicorn.rb
/home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn/configurator.rb:600:in `parse_rackup_file': rackup file (production) not readable (ArgumentError)
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn/configurator.rb:74:in `reload'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn/configurator.rb:65:in `initialize'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn/http_server.rb:102:in `new'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn/http_server.rb:102:in `initialize'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn.rb:30:in `new'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/lib/unicorn.rb:30:in `run'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/gems/unicorn-3.7.0/bin/unicorn_rails:208:in `<top (required)>'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/bin/unicorn_rails:19:in `load'
    from /home/sites/.rvm/gems/ruby-1.9.2-p180@fatfreecrm/bin/unicorn_rails:19:in `<main>'

A: The problem is the order of your arguments. Try to switch -E and -D.


Q: Subtracting value across multiple lists in Sharepoint 2010 I am attempting to perform a simple subtraction function across two lists in Sharepoint 2010.
I have one list called Inventory that has part number, part name, and quantity.
I have a second list called Tasks that has title, description, status, used part, and quantity.
I have a workflow rule that states the following:

The issue is that it's just throwing an error when I run a test task with a status of completed, used part selected, and quantity field holding an integer value.
I am creating the workflow and attached it to the Tasks lists, so all current item equal items in the tasks.
The end of update item in Inventory I am setting the variable New Inventory to be the new value of quantity in the Inventory lists.

Any help with this would be great.  Thanks.

A: Disregard, found out during the CurrentItem: Quantity lookup i had set the part name to string instead of lookup value.


Q: OOP Javascript, get attribute of class not the event e In a event handler from my custom class, I want to use an attribute of my class in a private event method. Its more clearly with this simple example :

class myClass {
  constructor() {
    this._customAtt = "hello";
  }

  foo() {
    this._addListeners();
  }

  _addListeners() {
    $("input.two").click(this._anEvent);
  }

  _anEvent(e) {
    console.log(this._customAtt); // print 'undefined'
    console.log(self._customAtt); // print 'undefined'
  }
}

var myIClass = new myClass();

$('input.one').on("click", function() {
  myIClass.foo();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type='button' value='one' class='one'>
<input type='button' value='two' class='two'>

When I click on the button one, I add an handler to the button two. If I click on the button two the method _anEvent is called and from this method, I want use the private attribute class _customAtt. But, in the _anEvent method, this is the event e, not my class.
So, how can I can the attribute _customAtt from the method _anEvent ?

A: The reason for this is because the context of this varies depending on how the function is called, not what the function was originally attached to.
One relatively easy way to do this is to bind _anEvent to the instance of the class.
constructor() {
    this._customAtt = "hello";
    this._anEvent = this._anEvent.bind(this);
}

This will ensure that this is always the instance of myClass within the _anEvent function.


Q: Namespace issue class not found In my root folder I have a file folder that has my common files I use between different projects.
/files
I have a file redis.php that has Redis class that I want to use in one of my project in /var/www/html/project/example.php
The Class Redis is in /file/library/storage/redis/redis.php
my redis.php has
<?php

    namespace file\library\storage\redis;

    class Redis{

        public function init(){
            $redis = new Redis();
            $redis->connect('127.0.0.1', 6379);
        }

    }

?>

and in my example.php I call that namespace like
$redis = new \file\library\storage\redis\Redis();
$redis->init();

but it gives me an error
[Mon May 27 12:25:48 2013] [error] [client 127.0.0.1] PHP Fatal error:  Class 'file\\library\\storage\\redis\\Redis' not found

Any help will be appreciated

A: What you are looking for is an autoloader that can map your namespaces to actual paths and include the class files before you're creating an instance of them. Take a look at the commonly used PSR-0 autoloader.
<?php

function autoload($className)
{
    $className = ltrim($className, '\\');
    $fileName  = '';
    $namespace = '';
    if ($lastNsPos = strrpos($className, '\\')) {
        $namespace = substr($className, 0, $lastNsPos);
        $className = substr($className, $lastNsPos + 1);
        $fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
    }
    $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

    require $fileName;
}
spl_autoload_register('autoload');

If you include this code in /var/www/html/project/example.php, what happens then when you try to make an instance
$redis = new \file\library\storage\redis\Redis();

Is that it will try to include this file first
/var/www/html/project/file/library/storage/redis/Redis.php

A: You should include the file that contains the class. You can do it manually using: require_once 'redis.php' OR create a rontina autoload as stated in the first answer