text:
Q: How to change the Tabmenu text to smaller cases? I know by default tabmenu text appears in capital letters but i want to change the tabmenu text in a smaller letters like this image

Style.xml
<resources>

<style name="AppTheme" parent="AppTheme.Base">

</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColor">@color/textColorPrimary</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="android:textColorSecondary">@color/textColorPrimary</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="TabTexTheme" parent="TabTexTheme.Base">

</style>

<style name="TabTexTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="android:textStyle">bold</item>
    <item name="android:actionBarTabTextStyle">@style/TabtextStyle</item>
    <item name="actionBarTabTextStyle">@style/TabtextStyle</item>

</style>

<style name="TabtextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu">
    <item name="android:textAllCaps">false</item>
    <item name="android:background">@color/colorTabBackground</item>
    <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>

MainActivity.java
    public class MainActivity extends AppCompatActivity {

    private TabLayout tabLayout;
    private ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_information_category1);
        Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar_information);
        setSupportActionBar(toolbar);

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);
    }

    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        adapter.addFragment(new TodayInformationFragment(), "Today");
        adapter.addFragment(new ThisWeekInformationFragment(), "This Week");
        adapter.addFragment(new ThisMonthInformationFragment(), "This Month");
        adapter.addFragment(new AllInformationFragment(), "All");
        viewPager.setAdapter(adapter);
    }
    class ViewPagerAdapter extends FragmentPagerAdapter {
        private final List<Fragment> mFragmentList = new ArrayList<>();
        private final List<String> mFragmentTitleList = new ArrayList<>();

        public ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        public void addFragment(Fragment fragment, String title) {
            mFragmentList.add(fragment);
            mFragmentTitleList.add(title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentTitleList.get(position);
        }
    }
}

activitymain.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <RelativeLayout
        android:id="@+id/layout_information"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.vimalsagarji.vimalsagarjiapp.InformationCategory1">

        <include
            android:id="@+id/toolbar_information"
            layout="@layout/toolbar_home"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <EditText
            android:id="@+id/etText"
            android:layout_below="@+id/toolbar_information"
            android:hint="    Information cat 1"
            android:textColorHint="@color/colorPrimary"
            android:background="@color/colorTabBackground"
            android:layout_width="match_parent"
            android:focusable="false"
            android:drawableRight="@drawable/search"
            android:layout_height="50dp"/>

        <View
            android:id="@+id/line"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="-7dp"
            android:layout_below="@+id/etText"
            android:background="@color/colorPrimary"/>
    </RelativeLayout>
    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/TabtextStyle"
        app:tabTextColor="@color/colorTabColor"
        app:tabSelectedTextColor="@color/colorTabColor"
        app:tabMode="fixed"
        app:tabGravity="fill"/>
    <View
        android:id="@+id/line1"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="-5dp"
        android:layout_below="@+id/tabs"
        android:background="@color/colorPrimary"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"  />

I used this code but there is no change in the tabmenu text. It still showing as capital letters

A: try this code it will help you.
<android.support.design.widget.TabLayout
                    android:id="@+id/tabLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabIndicatorColor="@android:color/white"
                    app:tabIndicatorHeight="2dp"
                    app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
                    app:tabSelectedTextColor="@android:color/white"
                    app:tabTextColor="@android:color/white" />

A:  TextView textview = (TextView)  mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
textview.setTextSize(25);

Set this after setting the adapter

But use the text size according to the screen size like
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

for(int i = 0; i <= 3; i++){
    textview = (TextView)  mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
    if(width == 720 || height == 1184){
        textview.setTextSize(10);
    }else if (width > 720 || height > 1184) {
        textview.setTextSize(12);
    }else if (width > 900 || height > 1500) {
        textview.setTextSize(15);
    }
    textview.setTextColor(Color.parseColor("#E73421")); // To set text color
}

in for(int i = 0; i <= 3; i++){ 3 indicates number of tabs (0,1,2,3)you have

A: create your customer style as below
<style name="TextAppearance.Widget.CustomTabWidget">
        <item name="textSize">16sp</item>
        <item name="textStyle">normal</item>
        <item name="textAllCaps">false</item>
        <item name="textColor">@color/tab_indicator_text</item>
    </style>

Apply this styple to your tabLayout as below
app:tabTextAppearance="@android:style/TextAppearance.Widget.CustomTabWidget"


text:
Q: Python module not recognizing files in the same folder I've made (at least tried) a package using setuptools and attempted to use it from another python-file. However, the modules within the packages don't seem to recognize each other.
Tree
pkg
|-- pkg
|     |-- __init__.py
|     \-- module.py
\-- setup.py

__init__.py:
import module
#code

pyfile.py
import pkg
#code

When I attempt to run pyfile.py, I get
Traceback (most recent call last):
  File "/.../py/pyfile.py", line 1, in <module>
    import pkg
  File "/.../pkg/pkg/__init__.py", line 1, in <module>
    import module
  ModuleNotFoundError: No module named 'module'

It works fine if I write import pkg.module, but I don't see why self.referential code would be practical.

A: Change the import in your  __init__ to
from . import module

You can read more about intra-package references in the python documentation.
(BTW, as far as I can tell, setuptools is not involved here.)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Using S3 object in S4 generic method causes error This is an example from Hadley's advanced R book:
setGeneric("type", function(x) standardGeneric("type"))
setMethod("type", signature("matrix"), function(x) "matrix")
setMethod("type", signature("character"), function(x) "character")

type(letters)
type(matrix(letters, ncol = 2))

foo <- structure(list(x = 1), class = "foo")
type(foo)

setOldClass("foo")
setMethod("type", signature("foo"), function(x) "foo")

type(foo)

setMethod("+", signature(e1 = "foo", e2 = "numeric"), function(e1, e2) {
  structure(list(x = e1$x + e2), class = "foo")
})
foo + 3

Everything works as expected except for the last line, which brings up an error in R 3.1.3:
Error in foo + 3 : non-numeric argument to binary operator

Any idea what's going on?

A: This problem is caused by confusion between S3 and S4 class systems. foo is an S3 class (it's created with setOldClass rather than setClass), so when + is called with it as first argument it tries S3 method dispatch (looking for a function called +.foo). This is why the suggestion in comments about defining such a function solves the problem.
if foo were a "pure S4" class (i.e. it has slots and is created via setClass) then your code would work.


text:
Q: Is there a function like min_active_rowversion for sequences? I have concurrent transactions getting values from a sequence. Is there a way to get the lowest active, non-committed value (and something like next value or NULL when nothing is active), like the function min_active_rowversion does for rowversions?
It could also be for IDENTITY.
I'm trying to make something like rowversion for a memory-optimized table.

A: You could read the transaction log looking for your table and changes to it.
Good place to start: How to read the SQL Server Database Transaction Log


text:
Q: how to add menu to section title? I have a section with TITLE_BAR, and i try to add a menu to the section header (like in the PDE editors).
All I could find is the context menu.

A: I'm not sure if the tutorial in the previous answer will work for sections - as far as I know the menu contributions (from a plugin.xml) only apply to a view tool bar or menu - not the section header.
You could try investigating Section.setTextClient(...);, you can certainly add a tool bar using that, so could use a drop-down button in order to show a menu, if that would achieve what you want?
This article has some interesting form / section related information too, though not directly related to your problem
Eclipse Forms: New in 3.3

A: Sounds like you are creating a view and you want to add a menu to the view.  Here is an article describing the way to do that:
http://www.ibm.com/developerworks/library/os-eclipse-3.3menu/index.html
Use the Menu Location URI scheme menu: and specify the view Id.


text:
Q: The function str() is not working and I do not know what to do I have the code:
def rides(x):
   return list(str(x))

When I input the word hi without any quotes
It returns the error that hi is not defined
However when input integers or hi with quotes it works, but I need it to work for hi without quotes.

A: When your input is hi without quotes, it means you pass a variable named hi to your function.
If you don't define such variable before passing it to your function, your code will fail during it's evaluation with NameError error.


text:
Q: Routing issue CodeIgniter i have link
http://www.raffaello-test.com/static/frontend/deutsch/mode-bilder/mode-herren-krawatten/gianni-versace-herren-krawatten.jpg
but i need to hide "/static/frontend" remove this part from URL and get get image from this URL
http://www.raffaello-test.com/deutsch/mode-bilder/mode-herren-krawatten/gianni-versace-herren-krawatten.jpg
i think it will be from .htaccess

A: One of the option is to create a symlink in the document root.
Second option is to use htaccess rewrite rule. Something like the following should work fine:
RewriteRule ^((deutsch|english)/.+/.+/.+\.(jpe?g|png|gif))$ /static/frontend/$1 [L]

If you have more languages just add them in first parenthesis, like (deutsch|english|russian).
Also note that It's not recommended to use rewriting in high load production for static content, better use symlinks


text:
Q: Can't install any version of nodejs >10 (10,12,13) in my lubuntu I typed following command on my lubuntu terminal from the nodejs download page to install 13.x version :
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs
but,when i checked the version of node it was showing me 8.x version.Even i tried to install all
the versions above 10.x ,but still the version was 8.x.Then i tried nvm to change version still the same version. The i tried using npm still the same problem.
Actuall the problem is that Angularcli will only work on node versions above 10.
Th

A: My guess is that you are running a 32-bit version of Lubuntu, probably because your CPU is only 32-bit capable.  More recent node.js official builds only support 64-bit architectures.  You can find builds for many unsupported architectures, including 32-bit i386 and i686 systems by visiting the web site for unofficial builds.
  See:  https://github.com/nodejs/unofficial-builds/
From that site, identify a build for your system.  A quick and dirty approach to installing it might then be to UNINSTALL your existing node.js system and (for node version 12, for example) run:
curl -sL 'https://unofficial-builds.nodejs.org/download/release/v12.6.0/node-v12.6.0-linux-x86.tar.xz' | xzcat | tar -vx --strip-components=1 -C /usr/local/.

This command above expands node directly into /usr/local, so you need to run it as root (super-user).


text:
Q: Writing a dict to an external .json file not reflecting outside of IDE I am trying to write a Python dict to a pre-existing external .json file which is empty.
    usersession = {
    'session_key' : key,
    'session_secret' : secret
}

j = json.dumps(usersession)

with open('usersession.json','w') as f:
    f.write(j)
    f.close()

When I view the usersession.json file with Finder it is not showing that the .json file has been modified. The .json file when viewed in the IDE also does not change.
However, some sort of modification did happen because when I read and print from 'usersession.json' in a subsequent runtime (commenting out the code block that initally wrote into the .json), the stored data appears.
file = open("usersession.json")
data = file.read()
print(data)

How can I fix this?


text:
Q: changing a single line in a file I have a file with about 2000 lines.
What is the easiest way to change a particular line to something else.
say for example I want to change the 400th line from:   int cut_off = flow_max_-6;
to int cut_off = flow_max_-8;
I need to do this in the linux console

A: You could achieve this by using sed:
sed -i '400s/6/8/' yourfile.c

A: I would use Vim.
But you may prefer:
sed -e '400,400s/6/8/' two_thousand_line_file.txt > new_two_thousand_line_file.txt

More generically:
sed -e '400,400s/[[:digit:]]{1,}/8/' two_thousand_line_file.txt > new_two_thousand_line_file.txt

Or:
sed -e '400,400s/\(int cut_off = flow_max_\).*\(;\)/\1some_other_number\2/' two_thousand_line_file.txt > new_two_thousand_line_file.txt


text:
Q: UILabel text to fill in the frame width I want to build typography poster using UILabel

*

*left and margin: 25

*320(device width) - 50(sum of the margins) = 270(label width frame)

The font size of each label should change in order to fit in 270 frame width
I try with sizeToFit(),adjustsFontSizeToFitWidth=true
var margin = 0;
let label = UILabel(frame: CGRectMake(25 , 72, 270, 70));
label.backgroundColor = UIColor.clearColor();
label.textAlignment = NSTextAlignment.Left;
label.textColor = UIColor.blackColor();
label.numberOfLines = 1;
label.font = UIFont.systemFontOfSize(50.0);
label.text = "Some Text";
label.adjustsFontSizeToFitWidth = true;
self.view.addSubview(label);
margin += 60;

let label2 = UILabel(frame: CGRectMake(25 , CGFloat(72+margin), 270, 70));
label2.backgroundColor = UIColor.clearColor();
label2.textAlignment = NSTextAlignment.Left;
label2.textColor = UIColor.whiteColor();
label2.numberOfLines = 1;
label2.font = UIFont.boldSystemFontOfSize(45.0);
label2.text = "Some Text Longer";
self.view.addSubview(label2);

Screenshot when lable1 and label2 adjustsFontSizeToFitWidth=true

The text should start from the end of first grey border and end in the beginning at the start of the second grey border

A: adjustsFontSizeToFitWidth does not increase the size of the font in the label to fit the width.
According to Apple's documentation,

adjustsFontSizeToFitWidth is a Boolean value indicating whether the
  font size should be reduced in order to fit the title string into the
  label's bounding rectangle.
Normally, the label text is drawn with the font you specify in the
  font property. If this property is set to YES, however, and the text
  in the text property exceeds the label's bounding rectangle, the
  receiver starts reducing the font size until the string fits or the
  minimum font size is reached. In iOS 6 and earlier, this property is
  effective only when the numberOfLines property is set to 1.

You can try increasing the size of the font to fit the width of the frame.
Source : https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/instm/UIView/sizeToFit
You can also use the following method to iteratively find the maximum size that fits the label.
How to adjust font size of label to fit the rectangle?

A: This should just work without changing many defaults. The posted code doesn't set adjustsFontSizeToFitWidth, look like this:
label.adjustsFontSizeToFitWidth = true


text:
Q: How to identify if some rows start with #txt? I have a text file installer_input.txt where after many rows I have some rows that start with product. or #product..
I wanna verify when I have first row who starts with #product. and if all rows after that who contains product. and starts with # it's like #product. then check all items from checkedListBox2.
On this way I tried this code :
linesInsTemp.Where(x => x.Contains("product.") )
            .ToList()
            .ForEach(item =>
                {
                    for (int i = 0; i < this.checkedListBox2.Items.Count; i++)
                    {
                        this.checkedListBox2.SetItemChecked(i, true);
                    }
                    var index = this.checkedListBox2.Items.IndexOf(item);
                    if (index >= 0)
                        this.checkedListBox2.SetItemChecked(index, true);
                });

But here when I have just product. without # then check the box.
In installer_input.ini I have something like this :
Many rows of text

#product.name1
#product.name2
...
#product.nameN

Rows with text

If all rows product.name have # in front then check all boxes. How I can do this ?

A: I think String.StartsWith method should help you. You can rewrite your method as
linesInsTemp.Where(x =>x.StartsWith("#product.") )
                .ToList()
                .ForEach(item =>
               {
                    for (int i = 0; i < this.checkedListBox2.Items.Count; i++)
                    {
                        this.checkedListBox2.SetItemChecked(i, true);
                    }
                    var index = this.checkedListBox2.Items.IndexOf(item);
                    if (index >= 0)
                        this.checkedListBox2.SetItemChecked(index, true);
                });

UPDATE:
this regex will return true for all rows which started with #product/product/prodact/#prodact

linesInsTemp.Where(x => Regex.IsMatch(x, "^(#)?prod(u|a)ct[\\w\\W]*") )
                .ToList()
                .ForEach(function);


text:
Q: Keep line attributes in QGIS Network Analysis - Shortest Path I'm running a simply Shortest Path task from the Network Analysis toolbox in QGIS, but it seems that the output doesn't transfer the line attributes, only the start layer attributes. I need the road types and lengths so I can summarise how much of each are traversed.
I've already tried transferring the attributes by converting the lines to points and intersecting them and I've also simply tried intersecting the road network with the output lines, but the result is disconnected segments as it coincides in some parts and in other it just slightly doesn't overlap exactly (which should really be the case as I applied no snapping tolerances to the Shortest Route).
Anyway, this should be simple, but I don't see an option to retain the network attributes.

A: Well, there are some minor inaccuracies with the resulted route. There are multiple ways to achieve this which heavily depends on the size of your data.
Here is a rather lengthy, but fast in terms of performance:

*

*First, buffer the roads by 2 meters. This value depends on the level of inaccuracy of route results.

*Then select by location: select lines from your network that intersect with your buffer

*After that explode the selected lines and get their centroids. Exploding them splits them into straight lines which positions the centroids on the lines.

*Next step is buffering the points by the same amount of inaccuracy (2 meters)
now you have polygons with the street information.

*Explode the routes from the network analysis.

*Finally spatial join the buffers with routes.
This should add attributes to the routes. you can dissolve the results based on the ID or name of the roads to have fewer shapes.
I recommend you to create a model in model builder for such lengthy processes.


text:
Q: Heroku: error running django migrations I'm writing a django app that is currently deployed on heroku. The latest migrations I have made throw an error which I don't understand, see below.
This error does not appear locally, maybe that is because I use sqlite locally and postgres on heroku, but that is only a guess.
I generated the migration locally and pushed it.
I use django 1.10 and a virtual environment with python 2.7.
Here is my terminal ouput when I try to run the migration:
heroku run python manage.py migrate
Running python manage.py migrate on ⬢ limitless-lake-59470... up, run.3202 (Free)
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, jobs, sessions
Running migrations:
  Applying jobs.0015_auto_20161230_2039...Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 204, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 495, in alter_field
    old_db_params, new_db_params, strict)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py", line 117, in _alter_field
    new_db_params, strict,
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 649, in _alter_field
    params,
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 112, in execute
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: invalid input syntax for integer: ""

A: The error disappeared after clearing the db and applying all migrations from scratch


text:
Q: A question on the proof of Thm 1.4 in Algebraic Geometry A First Course Thm 1.4 States that If $\Gamma\subset P^n$ is any collection of $d\leq 2n$ points in general position, then $\Gamma$ can be described by quadratic polynomials $\{f_i\}$.
The proof intends to show that for any $q$ such that if for all i, $f_i(\Gamma)=f(q)=0$, then $q\in\Gamma$ and it turns out that $q$ lies in a set of cardinality $|n|$. And then it wants to show that $q$ is an element of that set. So one took advantage of redundant information of 2n points in general position and $q$ lies in a set of cardinality $|n|$ to finish the proof.
What is the geometrical picture that forces $q$ to be an element of that special set?


text:
Q: what does "!!~this.roles.indexOf('*')" mean in MEAN.io framework In the startup code for the MEAN framework there's a line of code shown below
if (!!~this.roles.indexOf('*')) {

It's located in the public/modules/core/services/menus.client.service.js file in the shouldRender function.
var shouldRender = function(user) {
        if (user) {
            if (!!~this.roles.indexOf('*')) {  //Here is the code
                return true;
            } else {
                for (var userRoleIndex in user.roles) {
                    for (var roleIndex in this.roles) {
                        if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
                            return true;
                        }
                    }
                }
            }
        } else {
            return this.isPublic;
        }

        return false;
};

A: It evaluates whether the '*' is found or not, by converting it to boolean. It is plain Javascript.
~[1, 2, 3, 4].indexOf(4)
//returns -4 (bit inversion of 3)

indexOf returns 0, 1, 2, 3... when the element exists. Bit inversion converts those values to -1, -2, -3, -4, ... respectively.
When the element does not exist, -1 is returned. By bit inversion, 0 remains.
So, when the element exists, you get a nonzero. When the element does not exist, you get 0.
By prepending !!, you are converting the value to boolean (0 is a falsey value, !0 is true, !!0 is false; x (if not zero) is a nonfalsey value, !x is false, !!x is true).
So it could be understood as: if '*' is in this.roles ...


text:
Q: How to Parrallelize Read operation in MongoDB in Spark? I am using mongodb/mongo-hadoop
(https://github.com/mongodb/mongo-hadoop/wiki/Spark-Usage#python-example) but was confused on how I can do parallel read operations.
By parallel read operations means, do concurrent read operation on my MongoDB index. I have indexed my DB based on Timestamp, and want to query data bw T1-T2, T3-T4, etc. parallelly.


text:
Q: Is it worth converting 64bit integers to 32bit (of 16bit) ints in a spark dataframe? I have a dataframe that contains ~4bn records. Many of the columns are 64bit ints, but could be truncated into 32bit or 16bit ints without data loss. When I try converting the data types using the following function:
def switchType(df, colName):
    df = df.withColumn( colName + "SmallInt", df[colName].cast(ShortType()))
        df = df.drop(colName)
        return df.withColumnRenamed(colName + 'SmallInt', colName)

positionsDf = switchType(positionsDf, "FundId")
# repeat for 4 more cols...
print(positionsDf.cache().count())

This shows as taking 54.7 MB in ram. When I don't do this, it shows as 56.7MB in ram.
So, is it worth trying to truncate ints at all?
I am using Spark 2.01 in stand alone mode.

A: If you plan to write it in format that saves numbers in binary (parquet, avro) it may save some space. For calculations there will be probably no difference in speed.

A: Ok, for the benefit of anyone else that stumbles across this. If I understand it, it depends on your JVM implementation (so, machine/OS specific), but in my case it makes little difference. I'm running java 1.8.0_102 on RHEL 7 64bit.
I tried it with a larger dataframe (3tn+ records). The dataframe contains 7 coulmns of type short/long, and 2 as doubles:

*

*As longs - 59.6Gb

*As shorts - 57.1Gb

The tasks I used to create this cached dataframe also showed no real difference in execution time.
What is nice to note is that the storage size does seem to scale linearly with the number of records. So that is good.


text:
Q: Objective-C: strange behavior of Foundation collection object when using stack block under MRC This is my test code:
typedef NSObject TEST_OBJECT_TYPE;

-(void)testFunc
{
    __block TEST_OBJECT_TYPE *object = [[TEST_OBJECT_TYPE alloc] init];
    void(^block)() = ^{
        NSLog(@"%@", object.description);
    };
    NSLog(@"%@", [block class]);
    [object release];
    block();
}

This code is running under Manually Reference Counting and with NSZombieEnabled turned on.
The reason I turn on NSZombie is to make the object's memory scrambled the moment it is release.
Because the block is a stack block(the NSLog proved this), when the block is executed, the object is already released, so it should hit on a zombie.
This is true for my own object types and NSObject and UIView.
But when using foundation collection objects like NSSet, NSArray, NSDictionary, this code won't hit on a zombie, it can run without any problem, why?

A: My guess would be the collection objects have internally autoreleased themselves during their initialization.
You can test this by creating your own autorelease pool and then releasing it.
typedef NSObject TEST_OBJECT_TYPE;

-(void)testFunc
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    __block TEST_OBJECT_TYPE *object = [[TEST_OBJECT_TYPE alloc] init];
    void(^block)() = ^{
        NSLog(@"%@", object.description);
    };
    NSLog(@"%@", [block class]);
    [object release];
    [pool release];
    block();
}


text:
Q: Covering a $n$-holed torus for $n\geq 2$ with a hyperbolic tesselation? How can I cover a $n$-holed torus $(n\ge2)$ with $\frac{2-2n}{\frac pq-\frac p{2}+1}$ faces of regular hyperbolic tesselation {p,q}? I don't need the graphics, just the construction. For example, in the image at http://www.math.ucr.edu/home/baez/klein.html, the construction is an array$[56][3]$, which have each element from $1$ to $24$ ($24$ vertices) to describe which faces are created by which vertices. I just need to find a coloring pattern for a hyperbolic tessellation.
Edit: Assume the fraction is an integer. It is calculated directly from Euclid function V-E+F=2-2n.
Edit2: A way of going to its another copies in hyperbolic plane is also enough. There is also an example in http://www.math.ucr.edu/home/baez/klein.html. It is pretty on Klein's quartic, but probably not on other tessellations.


text:
Q: How to find location of application.yml loaded by spring? For configuring a spring boot application I can control which configuration/properties file (let's say application.yml) is loaded by placing the file in one of the locations where spring scans for such files (./config/, cwd, classpath:config/, classpath root). I can also point to a specific location using CLI (spring.config.location) or environment variables.
How can I find out where the properties file(s) was finally loaded from during runtime? I wish to check if the user specified/used his own config file or if the provided config file was used.
I am using spring 5.2.2 and springboot 2.2.2.

A: I don't think it's possible to find that after the application is started.
However, you can check the debug log output for 'org.springframework.boot' during startup.
To quickly enable debug logging to console you can run the spring boot application with --debug on the command line or debug=true in application.yml. The config files found by Spring Boot should be in the first few lines.
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.6.RELEASE)

2020-04-08 15:05:22.736  INFO 19079 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication on Dwalin with PID 19079 (/home/geertp/repos/github.com/greyfairer/spring-boot-test/demo/target/classes started by geertp in /home/geertp/repos/github.com/greyfairer/spring-boot-test/demo)
2020-04-08 15:05:22.736  INFO 19079 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2020-04-08 15:05:22.737 DEBUG 19079 --- [           main] o.s.boot.SpringApplication               : Loading source class com.example.demo.DemoApplication
2020-04-08 15:05:22.765 DEBUG 19079 --- [           main] o.s.b.c.c.ConfigFileApplicationListener  : Loaded config file 'file:/home/geertp/repos/github.com/greyfairer/spring-boot-test/demo/target/classes/application.yml' (classpath:/application.yml)

A: I don't know of a programmatic way of doing it, but there's a fantastic link in Spring's documentation which shows all 17(!) default property locations, including the order they are being read in.
You might want to check it out here: https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config

A: As with Spring Boot 2.4 the ConfigFileApplicationListener was deprecated the new one should be used: ConfigDataEnvironment:
logging.level:
    # For Spring Boot 1.x.x.
    "org.springframework.core.env": trace
    # For Spring Boot 1.x.x-2.3.x.
    "org.springframework.boot.context.config.ConfigFileApplicationListener": trace
    # For Spring Boot 2.4.x-3.x.x.
    "org.springframework.boot.context.config.ConfigDataEnvironment": trace
    "org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor": trace


text:
Q: Preg split or preg match to extract from string with known and constant pattern I have a database filled with product names, all of wich follow a strict and identical naming pattern like this European 222/555/111 obtained
I want to run a 'for each row in table' little php script and extract the 3 substrings in part 222/555/111 and add the three in separate columns but I'm failing to do the extraction.Should I use preg_split or preg_match?
My strings all start with the word 'European' then a space and after that the three options I need separated with /, these could also be only 2 characters like
European 96/43/55c strings strings
Should have
$option1 = 222
$option2 = 555
$option3 = 111

A: I'd use preg_match:
$string = 'European 222/555/111 obtained';

if (preg_match('~European ([^/]+)/([^/]+)/([^/\s]+)~', $string, $matches)) {
    print_r($matches);
}

Output:
Array
(
    [0] => European 222/555/111
    [1] => 222
    [2] => 555
    [3] => 111
)

Explanation:
~               : regex delimiter
  European\s+   : literally "European" followed by one or more space
  ([^/]+)       : match everything that is not a slash and store in group 1
  /             : a slash
  ([^/]+)       : match everything that is not a slash and store in group 2
  /             : a slash
  ([^/\s]+)     : match everything that is not a slash or a space and store in group 3
~               : regex delimiter


text:
Q: jquery add a fade to an .addClass How do I fade .addClass in and out.
Here is the link -
http://www.bikramyogajoondalup.com.au/about-bikram-yoga/postures-benefits.html
and here is the code -
$(document).ready(function() {
  $('#menu li#Q_01,#menu li#Q_03,#menu li#Q_05,#menu li#Q_07,#menu li#Q_09,#menu li#Q_11,#menu li#Q_13').hover(function() {
    $(this).addClass('pretty-hover');
  }, function() {
    $(this).removeClass('pretty-hover');
  });
});

$(document).ready(function() {
  $('#menu li#Q_02,#menu li#Q_04,#menu li#Q_06,#menu li#Q_08,#menu li#Q_10,#menu li#Q_12').hover(function() {
    $(this).addClass('pretty-hover_01');
  }, function() {
    $(this).removeClass('pretty-hover_01');
  });
});

Thanks

A: If jQuery UI is an option, you can use .toggleClass(class, duration) for this.
Also, you can probably simplify your selector, it looks like :even and :odd will do the job based on your current selector, like this:
$(function() {
  $('#menu li:even').hover(function() {
    $(this).toggleClass('pretty-hover', 500);
  });
  $('#menu li:odd').hover(function() {
    $(this).toggleClass('pretty-hover_01', 500);
  });
});

I realize the above seems backwards, but :even does select the first element, because it's 0 based, so even selects 0th, 2nd, 4th, etc.  I hope you'll agree, makes it a bit easier to maintain :)
Edit based on comments - Since .toggleclass() sticks on quick hovers, here's an alternative that works as expected, just a bit longer:
$('#menu li.post:even').hover(function() {
  $(this).stop().animate({ backgroundColor: '#009FDD', color: '#FFF' }, 500);
}, function() {
  $(this).stop().animate({ backgroundColor: '#FFFFFF', color: '#666' }, 500);
});
$('#menu li.post:odd').hover(function() {
  $(this).stop().animate({ backgroundColor: '#623A10', color: '#FFF' }, 500);
}, function() {
  $(this).stop().animate({ backgroundColor: '#FFFFFF', color: '#666' }, 500);
});

A: If you want to fade the colours of an element, you'll need to use jQuery UI which has more advanced support for fading and animating (the core jQuery can only fade/animate integer properties: colours don't work).
It even supports animating all the properties in an entire CSS class, so using jQuery UI, you should be able to achieve the effect you want.

A: the jQuery .animate function is the best bet, although this won't let you animate between CSS classes - you have to specify the individual styles.
You would be better using the jQquery UI, as this would provide for this sort of functionality, as stated in the jQuery animate page:

The jQuery UI project extends the
  .animate() method by allowing some
  non-numeric styles such as colors to
  be animated. The project also includes
  mechanisms for specifying animations
  through CSS classes rather than
  individual attributes


text:
Q: IPN not passing variable Im trying to pass a custom variable trought paypal button and get the value back with the ipn, im using this hidden field:
<input type="hidden" name="custom" value="<?php echo"".$username.""; ?>">

This is my full button :
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin-left:32px;" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo"".$settings['admin']['paypal'].""; ?>">
<input type="hidden" name="lc" value="PT">
<input type="hidden" name="item_name" value="account">
<input type="hidden" name="custom" value="<?php echo"".$username.""; ?>">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="amount" value="<?php echo"".$item_catch['price']."";?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

And this is my ipn listener :
<?php

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

// PAYMENT VALIDATED & VERIFIED!

$username = $_POST['custom'];

$add = $connect->prepare("INSERT INTO purchases(fromm) VALUES(?)");
$add->bind_param("s", $username);
$add->execute();
$add->close();

}

else if (strcmp ($res, "INVALID") == 0) {

// PAYMENT INVALID & INVESTIGATE MANUALY!

}
}
fclose ($fp);
}

the problem is that im not getting the custom variable back and it keeps inserting into database null on fromm

A: You have too many quotes:
<input type="hidden" name="custom" value="<?php echo $username; ?>">


text:
Q: How to get the results one property on two tables residential_projects(table name)
id    City   Project_name

1      1     Residential Property 1

residential_units_details (table name)
id   residential_project_id  cityId  unitType  price
1            1                  1     1 BHK    50000
2            1                  1     2 BHK    100000
3            1                  1     3 BHK    150000

Result i need like this
Property id =1
1 BHK = 50000 (price)
2 BHK = 100000 (price)
3 BHK = 150000 (price)

I writen the query like this but i am not getting the correct answer ,how can do pleaase i spend more time on this please tell me solution
My query
  $unitType = trim($_GET['unitType']);
  $first_second_tables = "SELECT * FROM residential_projects res_project JOIN residential_units_details res_unit ON res_project.id = res_unit.residential_project_id WHERE City='1'";
  if($unitType!='')
        {

            $first_second_tables .=" AND (unitType='$unitType')";
        }

 $sql=mysql_query($first_second_tables);
 while($res = mysql_fetch_assoc($sql)){
     echo "Proprty ID=".$res['id'].'
';
     echo "Unittype=" . $res['unitType'].'
';
     echo "Price=" . $res['price'].'
';
 }

i am getting answer
Proprty ID=1
Unittype=1
Price=50000
Proprty ID=2
Unittype=2
Price=100000
Proprty ID=3
Unittype=3
Price=150000

i think here printing all datas in second tables i don't know how to get my requirement answer anyone help me
Updated code var_dump($res);
array(3) {

["unitType"]=>
  string(1) "1"
  ["price"]=>
  string(5) "50000"
  ["Project_name"]=>
  string(22) "Residential Property 1"
}
array(3) {
  ["unitType"]=>
  string(1) "2"
  ["price"]=>
  string(6) "100000"
  ["Project_name"]=>
  string(22) "Residential Property 1"
}
array(3) {
  ["unitType"]=>
  string(1) "3"
  ["price"]=>
  string(6) "150000"
  ["Project_name"]=>
  string(22) "Residential Property 1"
}
array(3) {
  ["unitType"]=>
  string(1) "4"
  ["price"]=>
  string(4) "4343"
  ["Project_name"]=>
  string(21) "Residential Project 2"
}
array(3) {
  ["unitType"]=>
  string(1) "4"
  ["price"]=>
  string(4) "5353"
  ["Project_name"]=>
  string(21) "Residential Project 2"
}

A: SQL query for output is
 SELECT residential_units_details.unitType , residential_units_details.price , residential_projects.project_name
 FROM residential_units_details
 LEFT JOIN residential_projects
 ON residential_units_details.residential_project_id = residential_projects.id
 WHERE City = '1'

because you want only unitType ,price,project_name so no need to use *  for this you have to use left Join .
As you comment you want  poject_name on heading without repeating so you can try
$str = '' ; /* storing balnk string for matching */

while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
      if(strcmp($row['project_name'],$str) === 0){  /* if the project_name already store it will return 0 */

        echo $row['unittype']," = ",$row['price'],"
" ;

      } else {
        echo $row['project_name'],"
";
        echo $row['unittype']," = ",$row['price'],"
" ;
        $str = $row['project_name']; /* here we are storing the project_name */
      }
    }


text:
Q: Cannot chown, chmod on mounted ntfs partition I need to mount a ntfs partition and be able to use it with unix file system permissions. The problem is that, when I mount the partition using the following fstab entry, I cannot run chown and chmod successfully. It executes without error, but the file access rights are not changed.
PARTUUID=c3e3b171-d451-44e6-9f17-ffbe9e220dc7   /mnt/mounted_drive  ntfs-3g  defaults,umask=0022,uid=1000,gid=1000,errors=remount-ro,permissions 0 2

When I mount the partition without setting umask, uid, and gid I can use previously mentioned commands successfully.
PARTUUID=c3e3b171-d451-44e6-9f17-ffbe9e220dc7   /mnt/mounted_drive  ntfs-3g  defaults,errors=remount-ro,permissions 0 2

What shall I do to mount the partition properly?

A: With NTFS-3G, setting the owning user and group seems only to be possible when a UserMapping file containing a mapping for the targeted user/group is present.  This is not really clear from the documentation, but I'm testing it just now and that is what is happening.
If compatibility with an existing Windows installation is not needed, create an empty file .NTFS-3G/UserMapping on the mounted partition and fill it via:
getRUI4() { od -An -N4 -tu4 /dev/random | tr -d ' '; }
USERMAPPING=/media/NTFS_PARTITION/.NTFS-3G/UserMapping
echo ":users:S-1-5-21-$(getRUI4)-$(getRUI4)-$(getRUI4)-513" | sudo tee -a $USERMAPPING >/dev/null
echo "$(id -un):$(id -gn):S-1-5-21-$(getRUI4)-$(getRUI4)-$(getRUI4)-1001" | sudo tee -a $USERMAPPING >/dev/null

If you want to use existing Windows SIDs, you can instead use the program ntfsusermap on an unmounted (!) partition, which will interactively ask you to specify user- and group-names (do not need to be numeric, regardless of the message) for given paths where it first finds an as of yet unmapped ID.  This is quick to do.
User and group root is mapped by default, as is other.  The above lines will create a mapping for users group, and the current user.  Repeat as necessary.
Also, in my case, I mount the drive with the options
no_def_opts,allow_other,acl,nodev,nosuid,big_writes,hide_dot_files

However, in your case you should not need any of them, although I find that these options improve upon the default, as otherwise for instance chown/chmod fail silently in case of errors.


text:
Q: Visual Studio Variable Not Created When Manually Setting Next Statement I just started using a new Windows 7 x64 machine today and experienced something new during debugging. I have code that can be thought of as the following:
if(/*Some criteria that evaluates to false*/)
{
    int weekNum = (int)DateTime.Now.Subtract(_myObject.StartDate).TotalDays/7;

    //Do something with weekNum
}

I wanted to debug through the code within the if block. In my current circumstances, it's much easier just to set the next statement to the first line inside the block than to make my data meet the criteria so I set the next execution line to int weekNum... This gives a null reference exception because it, apparently, is not instantiating weekNum. I've verified that nothing on the right side expression is null and can successfully get a result by copying and pasting the right side into the watch or immediate window. If I literally replace it with if(true), it works fine. Choosing the next execution statement in scenarios like this has been a pretty routine way of debugging for me. Why is it behaving this way?
Edit: I have verified that the current build configuration is not optimized.
Edit: I cannot reproduce this in another test project. I modified my original code to remove my object from the equation and here is the new full code that gets the exception in the original project:
    private void SelectDefaultLearningUnit()
    {
        TODLogic.LearningUnit currentLu = null;

        //If sce is active get the learning unit for the current week.
        if (!_sce.IsCancelled && !_sce.IsCancelled
            && _sce.StartDate <= DateTime.Now
            && _sce.EndDate > DateTime.Now)
        {
            //Get number of weeks since semester started
            int currentWeek = (int)4;    //THIS LINE STILL BLOWS UP

            //Find the first learning unit for the current week
            currentLu = _LearningUnits.Where(lu => lu.StartWeek <= currentWeek && lu.EndWeek >= currentWeek).FirstOrDefault();  //May be null
        }

        if (currentLu == null)
            currentLu = _LearningUnits.FirstOrDefault();

        cbLearningUnit.SelectedItem = currentLu;
    }

Again, it only gets the exception if I manually set the execution inside of the if block when it would've otherwise been skipped. The only difference I see is if I put a watch on the variable in the test project it says the value of currentWeek is 0 until it hits the line and then it gets assigned. In the project where it blows up, it shows a red excalamation mark to the left of current week and the value says '' is null. I would expect it to either say the value is 0 or 'currentWeek' is undefined! This is why I originally thought it thought currentWeek was "not instantiated" i.e. didn't exist.


text:
Q: SQL order by query results in any arbitrary (but reproducible) manner For testing purposes I need to get some data from a set of database tables in any arbitrary (but reproducible) order. The idea being that I can later compare two runs using a textual diff tool. Is there an idiom for that?
E.g. I can obviously do a:
SELECT * FROM table_with_N_columns ORDER BY column_1, ... , column_N

I am just asking if there is an idiomatic way to achieve the same effect (for my purposes) without bothering to list every column in the ORDER BY clause. Any ordering will do so long as it is reproducible with subsequent runs of the query.

A: Use PK columns
Sorting by all columns of a table is potentially (very) expensive or sometimes simply impossible. Example: table with a json column or xml, or point or one of many other data types which cannot be used in ORDER BY, lacking the necessary operators. You get an exception.
If it doesn't fail, it should work for your purpose, but it still would not guarantee a true stable sort order. Without unique or primary key, completely duplicate rows are allowed, which are still sorted arbitrarily. Two concurrent sessions could both change the "first" in a set of dupes without conflict, resulting in two different rows being changed separately.
Use the primary key column(s) of each table. Unique constraint would work, too, but you really should have a pk on every table to begin with. Besides being correct and guaranteed to work, it's also typically much faster.
Function
Query the system catalogs pg_constraint and pg_attribute to get columns for a PRIMARY KEY or UNIQUE constraint.
I wrapped the query in a handy SQL function:
CREATE OR REPLACE FUNCTION f_order_cols(_tbl regclass)
  RETURNS text AS
$func$
SELECT string_agg(_tbl::text || '.' || quote_ident(attname), ',')
FROM (
   SELECT conrelid AS attrelid, conkey
   FROM   pg_catalog.pg_constraint
   WHERE  conrelid = $1
   AND    contype = ANY ('{p,u}'::"char"[]) -- primary or unique constraint
   ORDER  BY contype                        -- pk has priority ('p' < 'u')
           , array_length(conkey, 1)        -- else, fewest columns as quick tie breaker
   LIMIT  1                                 -- ... but any 1 of them is good
   )   c
JOIN   unnest(c.conkey) attnum ON TRUE      -- unnest array, possibly mult. cols
JOIN   pg_catalog.pg_attribute a USING (attrelid, attnum)

UNION  ALL                                  -- Default if first query returns no row
SELECT _tbl::text || '::text COLLATE "C"'   -- See chapter "Default" below
LIMIT  1
$func$ LANGUAGE sql;

*

*This is very fast.

*The function takes the table name as parameter, type regclass to be precise. Resolves the name according to the current search_path and raises an exception if invalid. At the same time provides a properly quoted identifier in the result automatically.

*Any PRIMARY KEY or UNIQUE constraint is good. PK has priority, else the unique constraint with the fewest columns is picked.

*The constraint can consist of multiple columns, attribute numbers of which are stored in the array pg_constraint.conkey. Using an implicit JOIN LATERAL to unnest() that.

*Result columns are table-qualified to get syntax ready for queries on multiple tables. This optional feature may have to be modified if you are using table aliases in queries.

*Also quote column names correctly to avoid SQL injection. quote_ident() does that for you. More about that:

*

*SQL injection in Postgres functions vs prepared queries
Default
If no constraint is found, the function returns NULL. Wrap the result into COALESCE and use the text representation of the whole row as default: tbl::text.
This is not going to sort rows like original values would, but you get a consistent sort order that works for every table. Since you are going to compare text representations anyway.
Better still, add COLLATE "C" to ignore collation rules. Faster, and just as good for your purpose.
ORDER BY tbl::text COLLATE "C"

Still a potentially very inefficient measure of last resort. Use PKs if at all possible. I put the default into the function above. Everything put together, for a query:
SELECT * FROM u JOIN p USING (a) JOIN n ON n.b = p.b ORDER BY ?
This returns the complete string for ?:
SELECT concat_ws(', ', f_order_cols('u')
                     , f_order_cols('p')
                     , f_order_cols('n')) AS order_by;

SQL Fiddle demonstrating all.

A:
without bothering to list every column in the ORDER BY clause

For just that goal, ORDER BY tablename.* does work.
If there are several tables involved, we can always write:
SELECT * FROM (select ... complex query...) as T order by T.*;

If the resultset has many wide rows making the sort inefficient, sorting a hashed representation instead might be a better idea:
SELECT * FROM (select ... complex query...) as T order by md5(T.*::text);


text:
Q: timing out when trying to connect to my own server using Hamachi Recently I've been unable to connect to my Minecraft server which I play on with a friend. It seems my friend has been able to access it just fine, but every time I try to connect I get the error:

connection lost: timed out

The strange thing is, this happened seemingly out of nowhere while I was playing two days ago. I lost my connection to the server while I was playing, and then when I tried to reconnect, I got this error. I've looked all over the internet for a solution, but I've tried everything that was suggested: my firewall is completely turned off, and I have set both inbound and outbound rules for hamachi. Resetting the server doesn't seem to help, nor does restarting my machine. Does anyone have a solution to this problem?
I've seen a somewhat similar problem raised in this question, but all of its answers either don't work for me, or are not applicable because I'm using Hamachi instead of port forwarding. My firewall settings have not changed since I was previously able to connect--same for my router/modem settings. IPconfig is not applicable because I'm using the IP address given to me by Hamachi, not the IP address of my machine. I didn't specify a port when I was initially able to connect. Additionally, the IP address of the Hamachi network I'm using hasn't changed since I was able to connect. And I can confirm that I do indeed have a working internet connection. Therefore I conclude that my problem is an entirely separate one from the one raise in this question.

A: How are you connecting? Internally or externally (are you getting your ip from the ipconfig command in the command prompt or from a website). If you're not, try connecting internally. Also, I'd really learn how to port forward (there are thousands of tutorials for Minecraft port forwarding everywhere) as Hamachi lets viruses in everywhere and can really mess up an internet connection. Also, keep your firewall on!


text:
Q: CentOS 7 LDAP Authentication: "Permission denied" I'm running a CentOS 7 VirtualBox instance. I am trying to set up LDAP authentication through our company Active Directory server.
Note: The AD server DOES NOT have Unix extensions installed.
Setup:

*

*I have nss-pam-ldapd installed

*The nslcd and nscd services are set to run at startup

*/etc/nsswitch.conf has been edited to add ldap:
passwd:     files ldap
group:      files ldap
shadow:     files ldap
hosts:      files ldap dns myhostname
ethers:     files ldap
networks:   files ldap
protocols:  files ldap
rpc:        files ldap
services:   files ldap sss
aliases:    files ldap nisplus

*/etc/pam.d/password-auth and /etc/pam.d/system-auth edited to add:
auth     sufficient    pam_ldap.so use_first_pas
account  [default=bad success=ok user_unknown=ignore] pam_ldap.so
password sufficient    pam_ldap.so use_authok
session  optional      pam_ldap
session  required      pam_mkhomedir.so skel=/etc/skel umask=0077

*/etc/nslcd.conf edited:
uid nslcd
gid nslcd

uri ldap://myserver.com/

base dc=myserver,dc=com

binddn CN=My Name,OU=Users,OU=DV,DC=myserver,DC=com

bindpw PASSWORDHERE

# Alternative mappings for Active Directory
pagesize 1000
referrals off
idle_timelimit 800
filter passwd (&(objectClass=user)(!(objectClass=computer)))
map    passwd uid           userPrincipalName
map    passwd uidNumber     objectSid:CorrectSID
map    passwd gidNumber     objectSid:CorrectSID
map    passwd homeDirectory "/home/$cn"
map    passwd gecos         displayName
map    passwd loginShell    "/bin/bash"
filter group (objectClass=group)
map    group gidNumber      objectSid:CorrectSID
ssl no

On rebooting the VM, and remoting in with the default user, I can list all the AD users (user@myserver.com), and the groups, using
    $ getent passwd
    and
    $ getent group

However, if I attempt to either login to the GUI or remote in with my AD user:
    $ ssh my.name@myserver.com@linuxboxip
    my.name@myserver.com@linuxboxip's password:
    Permission denied, please try again.

I've been over the related questions on this site, through the debug, and reconfigured fresh from scratch. No luck.
Any thoughts?

A: OK, I found the problem.
See link
When editing the PAM files: /etc/pam.d/password-auth and /etc/pam.d/system-auth
The edits must be done to the appropriate sections, not just added to the bottom of the file. In particular, the password    required      pam_deny.so lines MUST be the LAST entry in the section.
I can now log in with LDAP user/password via SSH and the GUI.


text:
Q: Filling table in angular js using ng-repeat I am able to fill the contents row-by-row. However, I was wondering how would we fill a table with two columns. I want it to be filled columnwise without repeating contents. Basically, it should return a table with two rows and two columns.

<!DOCTYPE html>

        {{x}}
        {{x}}

A: In AngularJS the data are manipulated mostly in JSON and collected as Array data structure.
Get your data from API or service call and convert the data into appropiate array of objects, then the data can be easily assigned to the table column and the record values are assigned to each row of the table using the "ng-repeat" in AngularJS.
In the below code you can see the "ng-repeat" and "x in records" is used as the loop for iterating through records of data values and assign to table.
<!DOCTYPE html>

        {{x.name}}

        {{x.location}}

A: Change your code like below
<!DOCTYPE html>

        {{x}}
        {{records[$index+1]}}

A: Your $scope is not taking, change your $scope like js array of object. And Give ng-repeat in correct place. Change your code like below.

              Object one
              Object two

       {{x1.name}}
       {{records1[$index].name}}

Your code result:-

              Country
              Languages

       {{x.name}}
        {{x.location}}

$scope.records = [
    {name:"Alfreds Futterkiste", location:"avenue1"},
    {name:"Berglunds snabbköp", location:"avenue2"},
    {name:"Centro comercial Moctezuma", location:"avenue3"},
    {name:"Ernst Handel", location:"avenue4"},
  ];

        {{x}}
        {{x}}


text:
Q: Aitken interpolation of a polynomial? How I can approximate a polynomial using Aitken's scheme using two nodes for the interpolation?
[HASKELL]
x1 = 2;
x2 = 3;
x3 = 4;
x4 = 5;

f1 = 2;
f2 = 3;
f3 = 12;
f4 = 147;

coefficientAitken[Xi_, Xinext_, Yi_, Yinext_] :=
  Collect[1/(Xinext - Xi)*Det[{{Yi, Xi - x}, {Yinext, Xinext - x}}],
   x];

(*c1 = coefficientAitken[2,3,2,3];
c2 = coefficientAitken[3,4,3,12];
c2 = coefficientAitken[4,5,12,147];*)

LnTwoNodes = coefficientAitken[x1, x2, f1, f2];
[/HASKELL]

A: This is Aitken's recursive algorithm:
ClearAll["Global`*"];
f[x_] := Exp[x]
(x[#] = #) & /@ Range@10;

p[i_, 1][_] := f[x[i]];
p[i_, k_][xs_] := 1/(x[i] - x[k-1]) Det[{{p[k-1,k-1][xs], x[k-1] - xs},
                                         {p[i, k-1] [xs], x[i]   - xs}}]

p[2, 2][x]
(* 2 E - E^2 - E x + E^2 x *)

r = p[9,9][x]
Plot[r, {x, 1, 9}, Epilog -> Point@Table[{x, Exp[x]}, {x, 1, 10}], PlotRange -> All]

I used this definition :

from here. Warning: there is code in that article, but you'd better ignore it.
Edit:
After reading your self-answer I saw that you want to interpolate points, not functions.
The following is a general solution for that. Posting with your own data as well:
ClearAll["Global`*"];
{xi, fi} = {{2, 3, 4, 5}, {2, 3, 12, 147}}
p[i_, 1][_] := fi[[i]];
p[i_, k_][xs_] := 1/(xi[[i]] - xi[[k - 1]])
                  Det[{{p[k - 1, k - 1][xs], xi[[k - 1]] - xs}, {p[i, k - 1][xs], xi[[i]] - xs}}]

p[4, 4][x]

(* -448 + (1477 x)/3 - 173 x^2 + (59 x^3)/3 *)

As you can see, it's terser than your code because the recursive step is already included in the function definition, while you are doing it manually.

A: I'm sorry for my English. I did it myself.
x1 = 2;
x2 = 3;
x3 = 4;
x4 = 5;

f1 = 2;
f2 = 3;
f3 = 12;
f4 = 147;

Determinant[a11_, a12_, a21_, a22_] := (a11*a22) - (a12*a21);

LnTwoNodes = coefficientAitken[x1, x2, f1, f2];
polynomAitken[Xi_, Xinext_, Yi_, Yinext_] :=
  Collect[(1/(Xinext - Xi))*
    Determinant[Yi, Xi - x, Yinext, Xinext - x], x];

LOne1 = polynomAitken[x1, x2, f1, f2]
LOne2 = polynomAitken[x2, x3, f2, f3]
LOne3 = polynomAitken[x3, x4, f3, f4]

LTwo1 = polynomAitken[x1, x3, LOne1, LOne2]
LTwo2 = polynomAitken[x2, x4, LOne2, LOne3]

Final = polynomAitken[x1, x4, LTwo1, LTwo2]


text:
Q: Entity Framework 6.1.3 NuGet Install Fails for target framework .NETStandard 1.4 Within Visual Studio 2017, I add a class library project to solution with framework '.NET Framework 4.5.2'. Inspection of newly created project properties shows the 'Target Framework' as '.NETStandard 1.4'. The 'Target Framework' dropdown, only lists frameworks starting '.NETStandard...'.
On attempting to install Entity Framework 6.1.3 via NuGet for the new class library, I receive the following error:
Package EntityFramework 6.1.3 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package EntityFramework 6.1.3 supports:
  - net40 (.NETFramework,Version=v4.0)
  - net45 (.NETFramework,Version=v4.5)
One or more packages are incompatible with .NETStandard,Version=v1.4.
Package restore failed. Rolling back package changes for 'Mercury.Test3'.

Given I can't reset target framework to '.NET Framework 4.5.2' how do I overcome NuGet's reluctance to install EF 6.1.3 against '.NETStandard 1.4'.
Thanks in advance.

A: The simplest answer is that since your class library is declaring that it works on all platforms that support .NETStandard 1.4, it cannot take a dependency on a component that has narrower requirements (e.g. EF 6.1.3, which only works with .NET Framework 4.x).
This is in a way similar to what happens when you need to add a reference that specifically targets x86 or x64 on a project that targets Any CPU: you are forced to change the project to use the same PlatformTarget.


text:
Q: Check out Attribute on WooCommerce I am using WooCommerce on one of the site. I need to add one more field at the time of checkout to ask buyer wheteher to issue Invoice on his name or the name of his business?
Any advise how to do that? Or something like this is already there in Woo Commerce? Or what could be the simplest way to do that?

A: As it happens, I just blogged about this yesterday, for how to add a subscribe to mailing list checkbox. The key points are:

*

*look at the WooCommerce tutorial

*woocommerce_checkout_fields is a filter hook that allows you to add or modify what fields appear on the checkout form

*woocommerce_checkout_update_order_meta is an action hook that allows you to save your new fields

*woocommerce_email_order_meta_keys is a filter hook that allows you to add your new fields to the confirmation emails

*the name you pick to save the post meta will be its label in the email

Here's the code I used:
class WooSubscribeCheckbox {

    // add hooks into WooCommerce
    public static function run() {
        add_filter('woocommerce_checkout_fields',
            array(__CLASS__, 'filterWooCheckoutFields'));

        add_action('woocommerce_checkout_update_order_meta',
            array(__CLASS__, 'actionWooCheckoutUpdateOrderMeta'));

        add_filter('woocommerce_email_order_meta_keys',
            array(__CLASS__, 'filterWooEmailOrderMetaKeys'));
    }

    /**
    * add custom fields to WooCommerce checkout
    * @param array fields
    * @return array
    */
    public static function filterWooCheckoutFields($fields) {
        global $woocommerce;

        // add field at end of billing fields section
        $fields['billing']['our_mailing_subscribe'] = array(
            'type' => 'checkbox',
            'label' => 'Subscribe to mailing list?',
            'placeholder' => 'Subscribe to mailing list',
            'required' => false,
            'class' => array(),
            'label_class' => array(),
        );

        return $fields;
    }

    /**
    * save custom order fields
    * @param int $order_id
    */
    public static function actionWooCheckoutUpdateOrderMeta($order_id) {
        if (isset($_POST['our_mailing_subscribe'])) {
            update_post_meta($order_id, 'Subscribe to mailing list',
                stripslashes($_POST['our_mailing_subscribe']));
        }
    }

    /**
    * add our custom fields to WooCommerce order emails
    * @param array $keys
    * @return array
    */
    public static function filterWooEmailOrderMetaKeys($keys) {
        $keys[] = 'Subscribe to mailing list';

        return $keys;
    }

}

WooSubscribeCheckbox::run();

A: The plugin is packed with hooks and provides an extensive documentation.
From that link: Tutorial – Customising checkout fields using hooks and filters.

How are checkout fields loaded into WooCommerce?
The fields for the checkout (billing and shipping) come from the countries class (class-wc-countries.php) and the get_address_fields function- this is so locale settings are applied to the fields letting WooCommerce enable/disable fields based on the users location.
Before returning the fields, WC will run the fields through a filter. This allows them to be edited by third party plugins and themes (and your own custom code).

my emphasis

A: If you don't want to code it yourself. There is a nice plugin available here:
http://terrytsang.com/shop/shop/woocommerce-custom-checkout-options/


text:
Q: How can I configure a NIC on a network with and without a bridge device for a VLAN at same time An am working with a CentOS 7 system which has a single physical Ethernet port which connects it to a network. This network primarily is on one subnet ("management network"), but also uses a tagged VLAN (VLAN 137) which has a separate subnet for VMs.
When configured "normally" - it appears and works on the management subnet.
However, I want to create a bridge device which connects to the same physical adapter, but for the bridge to use the 137 VLAN.
I can't figure out how to do this. I can either have the NIC on the normal (no tag) LAN, and I can create a bridge device, which is either on the (main) LAN or the VLAN. But I cannot figure out how to get the host on the "main" network and the bridge on the VLAN at the same time.
It appears as though a NIC can only be assigned to a single "bridge" at a time, and that one bridge can be assigned to a single VLAN, or no VLAN.
I'm obviously missing something. Any ideas?
(P.S. Preferably doing this without Network Manager - which I assume is a must).

A: Without using a bridge, I made the following test on virtual server, the server has eth0 configure.
ip link add link eth0 name eth0.100 type vlan id 100
ip addr add 10.0.0.10/24 dev eth0.100
ip link set eth0.100 up

If I try to ping google.it
[root@localhost ~]# tcpdump -i any not port 22 -nne
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
17:49:34.880834 Out 52:54:00:c5:83:ad ethertype IPv4 (0x0800), length 71: 10.0.2.15.57014 > 10.0.2.3.53: 53728+ A? google.it. (27)
17:49:34.928806  In 52:54:00:12:35:02 ethertype IPv4 (0x0800), length 87: 10.0.2.3.53 > 10.0.2.15.57014: 53728 1/0/0 A 216.58.205.99 (43)
17:49:34.929356 Out 52:54:00:c5:83:ad ethertype IPv4 (0x0800), length 100: 10.0.2.15 > 216.58.205.99: ICMP echo request, id 28643, seq 1, length 64
17:49:34.946459  In 52:54:00:12:35:02 ethertype IPv4 (0x0800), length 100: 216.58.205.99 > 10.0.2.15: ICMP echo reply, id 28643, seq 1, length 64
17:49:34.947340 Out 52:54:00:c5:83:ad ethertype IPv4 (0x0800), length 88: 10.0.2.15.35452 > 10.0.2.3.53: 7858+ PTR? 99.205.58.216.in-addr.arpa. (44)
17:49:34.997721  In 52:54:00:12:35:02 ethertype IPv4 (0x0800), length 156: 10.0.2.3.53 > 10.0.2.15.35452: 7858 2/0/0 PTR mil04s26-in-f99.1e100.net., PTR mil04s26-in-f3.1e100.net. (112)

If try to ping a host in the vlan subnet, you can see the vlan tag:
[root@localhost ~]# tcpdump -i any not port 22 -nne
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
17:51:12.237624 Out 52:54:00:c5:83:ad ethertype ARP (0x0806), length 44: Request who-has 10.0.0.11 tell 10.0.0.10, length 28
17:51:12.237628 Out 52:54:00:c5:83:ad ethertype 802.1Q (0x8100), length 48: vlan 100, p 0, ethertype ARP, Request who-has 10.0.0.11 tell 10.0.0.10, length 28
17:51:13.238115 Out 52:54:00:c5:83:ad ethertype ARP (0x0806), length 44: Request who-has 10.0.0.11 tell 10.0.0.10, length 28
17:51:13.238123 Out 52:54:00:c5:83:ad ethertype 802.1Q (0x8100), length 48: vlan 100, p 0, ethertype ARP, Request who-has 10.0.0.11 tell 10.0.0.10, length 28
17:51:14.239809 Out 52:54:00:c5:83:ad ethertype ARP (0x0806), length 44: Request who-has 10.0.0.11 tell 10.0.0.10, length 28

For me, you can have the management ip on the physical interface and the others ips on the vlan interfaces

A: Following config takes one NIC - creates a VLAN interface for it - then adds a bridge device to both the original NIC and the VLAN interface
ifcfg-br0
BOOTPROTO="static"
DEFROUTE="yes"
NAME="br0"
DEVICE="br0"
ONBOOT="yes"
DNS1="10.244.53.108"
DNS2="10.245.177.15"
DOMAIN="dssdhop.lab.emc.com"
NM_CONTROLLED="no"
TYPE="Bridge"
IPADDR=10.244.141.171
PREFIX=24
GATEWAY=10.244.141.1
DNS1="10.244.53.108"

ifcfg-br0.137
BOOTPROTO="static"
DEFROUTE="yes"
NAME="br0.137"
DEVICE="br0.137"
ONBOOT="no"
DNS1="10.244.53.108"
DNS2="10.245.177.15"
DOMAIN="dssdhop.lab.emc.com"
NM_CONTROLLED="no"
TYPE="Bridge"
# Enable the following 3 IF you want to assign a local address to the host on this network
#IPADDR=10.244.137.54
#PREFIX=24
#GATEWAY=10.244.137.1  – Generally don't want to specify a gatway - or it'll try using this as a default route!

ifcfg-eno1
TYPE=Ethernet
BOOTPROTO=none
NAME=eno1
UUID=8378a1f0-0330-45c8-bba6-7b77190cfb08
DEVICE=eno1
ONBOOT=yes
NM_CONTROLLED="no"
BRIDGE="br0"

ifcfg-eno1.137
DEVICE=eno1.137
VLAN=yes
ONBOOT=no
BRIDGE=br0.137
NM_CONTROLLED=NO


text:
Q: How to display images from an xml file in UI Image View
Possible Duplicate:
How to display images from an xml file in UI Image View

i have an xml file , there are number of images in subcategory i want
  to display all the images in a "Image View" and the "Image View" will
  be in scroll view as u scroll the images should keep loading . i am
  having difficulty in coding . The following code gives me the url
  links but i am having difficulties in displaying the images on 'Image
  View" which can be scrollable using "ScrollView". I am also showing
  the xml file ,where it shows one of the product

/////// XML File ////
<product>
        <product_name>HRC Classic Pin Collector Bag Blk – Hard Rock</product_name>
        <url>http://rockshop.hardrock.com/PinsCollectibles/Pins/Product/HRC Classic Pin Collector Bag Blk/?src=sli</url>
        <image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=177</image>
        <large_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=350</large_image>
        <front_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=80</front_image>
        <product_number>HRC Classic Pin Collector Bag Blk</product_number>
        <availability>1</availability>
        <long_des>HRC Classic Pin Collector Bag Blk</long_des>
        <launch_date>4/15/2011 10:49:54 AM</launch_date>
        <price>40</price>
        <category>Pins & Collectibles</category>
        <sub_category>Pins</sub_category>
    </product>

here is the code
-(IBAction)downloadImages:(id)sender
{
    NSData *data = [NSData dataWithContentsOfFile:@"pathOfURL"];
    NSError *error = nil;
    GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
    NSError *err=nil;
    NSArray *nodes = [document nodesForXPath:@"/product_list/product[category = \"Pins & Collectibles\"]/image" error:&err];
    NSMutableArray *array =[[NSMutableArray alloc]initWithCapacity:[nodes count]];

    for(int i=0;i<[nodes count]; i++)
    {
        [array addObject:(NSString *)[[(NSString *)[[(NSString *)[[[NSString stringWithFormat:@"%@",[nodes objectAtIndex:i]] componentsSeparatedByString:@"{"] objectAtIndex:1] componentsSeparatedByString:@"<image>"] objectAtIndex:1] componentsSeparatedByString:@"</image>"] objectAtIndex:0] ];
    }

    NSLog(@"%@",array);

}

NSLog(@"%@",array); it is showing all the images url in the output
  console i just need to display them on UIImage in nib file , i am not
  able to do that so when u click a button all the images should display
  in a scroll view.

A: Using the SDWebManager library might help you.
https://github.com/rs/SDWebImage
This will help with async download of the urls, then you can use the imageView setImageWithURL: method.


text:
Q: Default Apache index page parameters I was very surprised that I couldn't find this answer on Google.
I have seen someone access the default Apache index page (no index.html present, so it just shows the directory listing) with query string parameters. The URL they used was similar to:
http://example.com/?C=M;O=D

It looks like O=D means "order = descending," since it reversed the order of the list, but I want to know what other parameters can be passed in, and what they mean. Is this documented somewhere? I couldn't find it.

A: From http://www.gforums.net
"C=M;O=D" is the query string passed in to the URLs that are browseable. It's used to sort the files list.
O is the sort order, which can either be A or D for ascending and descending respectively.
C is for column name which is to be sorted. It can take the following values:
N - Name (file name) column
M - Last Modified column
S - Size column
D - might be for Description
You might want to have a look at this : https://httpd.apache.org/docs/2.2/mod/mod_autoindex.html


text:
Q: Alternative to TfsTeamProjectCollectionFactory.GetTeamProjectCollection taking ICredentialsProvider According to the MSDN the method GetTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentialsProvider fallbackCredentialsProvider of the TfsTeamProjectCollectionFactory class is now deprecated:

*

*"Note: This API is now obsolete."

*[ObsoleteAttribute("This method has been deprecated and will be removed in a future release. See GetTeamProjectCollection(RegisteredProjectCollection) instead.", false)]
The advice is to use the overload that only takes the RegisteredProjectCollection, but what should we use from now on if we want a fallback mechanism for credentials?
Thanks

A: You need to use the new TfsTeamProjectCollection constructor along with this TfsClientCredentials constructor which allows interactive prompts for authentication.
// Use default windows credentials, and if they fail, AllowInteractive=true
var tfsCreds = new TfsClientCredentials(new WindowsCredential(), true);

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
    new Uri("http://yourserver:8080/tfs/DefaultCollection"),
    tfsCreds);


text:
Q: Importing Lahman Baseball Database into Mysql I'm a new user to MySQL and MySQL workbench 6.3, and I am attempting to run the SQL script to open the Lahman baseball database 2015 SQL version. Link below:
http://www.seanlahman.com/baseball-archive/statistics/
I have unzipped the file and I have been able to run the script file 'stats', but I keep getting an error message when I try to run the larger file 'mssqlmaster'.  I go to the open a SQL script in a new query tab and get the warning that it is a large file.  I have then tried the run SQL script option with the default schema Name set to bbdata and the default character set left blank.
I then get this error code:

Preparing...
  Importing mssqlmaster.sql...
  ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: '��U'.
  Finished executing script
  Operation failed with exitcode 1

I have tried changing the default character set but nothing seems to work.
Any help would be greatly appreciated.

A: The mssqlmaster.sql file in the core/ directory is obviously for MS SQL server and not for MySQL. The stats.sql file is a MySQL dump and can directly be imported into MySQL. If you think that stats.sql does not contain as many records as the MS SQL variant then try the CSV download and import that instead (see LOAD DATA command in MySQL).

A: In case anyone stumbles on this, I've built a script for building a MySQL version of the latest Lahman data. It is available at https://github.com/WebucatorTraining/lahman-baseball-mysql.
Download lahman-mysql-dump.sql and import it into MySQL using MySQL Workbench:

*

*Server > Data Import

*Select Import from Self-Contained File

*Pick any Default Target Schema. It will be ignored, as the file creates a new one.

*Click Start Import button.


text:
Q: How to disable SFTP for some users, but keep SSH enabled? My project needs me to disable SFTP for some users, but those users still need to connect over SSH.  Does anyone know how to implement this?
I've seen suggestions to change the file at /etc/ssh/sshd_config, but I'm not sure what to change.

A: This doesn't make any sense, it is security through useless obscurity. Any user that can SSH will be able to transfer any file that they are able to read via the SSH session. You will also be able to write, if you have permissions to do so.
As can example, you can download /etc/passwd via ssh using the following method (no scp/sftp session required):
ssh foo@bar.com "cat /etc/passwd" > passwdcopy
If you can see it on your screen via SSH, then you can easily copy it as a file.
The only way this would make sense is if you have a custom restricted shell that enforces a security policy.
However, the inverse of this does make sense (disabling ssh shell but leeaving scp/sftp enabled) because you are not able to execute arbitrary commands via sftp/scp that you can via an ssh shell.
PS: I'm assuming the SSH shell you are granting is a standard shell that allows arbitrary execution. If this is not the case then see this: How to disable sftp subsystem for a specific user or group? and take a look at the Subsystem config option of sshd_config.

A: It is possible to enable SFTP globally, and disabling SFTP for only some users.
This does not work if you want your user to get a regular shell prompt. Nor
does it make sense, as you could circumvent most stuff if you have shell access.
It will only work if you only want to give access to a specific program.
I personally need this because I want to give access to some git repositories
over SSH, and I like to disable systems that are not needed. In that case SFTP is not needed.
Matching
To match a set of users, you could configure SSH with the Match keyword. From
the sshd_config(5) manual:
Match
        ...

        The arguments to Match are one or more criteria-pattern pairs or the
        single token All which matches all criteria.  The available criteria
        are User, Group, Host, LocalAddress, LocalPort, and Address.  The
        match patterns may consist of single entries or comma-separated
        lists and may use the wildcard and negation operators described in
        the PATTERNS section of ssh_config(5).

        ...

A couple of examples:

*

*Match User eva matches the "eva" user

*Match User stephen,maria matches the "stephen" and "maria" users

*Match Group wheel,adams,simpsons matches the "wheel", "adams", "simpsons"
groups

If you want more information, there are loads in the sshd_config(5) manual.
Forced command
Normally you get the user's login shell when you connect via SSH, but SSH can be
configured to force a certain command.  The command is forced for any SSH
connection, including SFTP, and thus you might have the option to force the
command you want.
The command to force can be configured with the ForceCommand keyword. From the
sshd_config(5) manual:
ForceCommand
        Forces the execution of the command specified by ForceCommand,
        ignoring any command supplied by the client and ~/.ssh/rc if
        present.  The command is invoked by using the user's login shell
        with the -c option.  This applies to shell, command, or subsystem
        execution.  It is most useful inside a Match block.  The command
        originally supplied by the client is available in the
        SSH_ORIGINAL_COMMAND environment variable.  Specifying a command of
        "internal-sftp" will force the use of an in-process sftp server that
        requires no support files when used with ChrootDirectory.  The
        default is "none".

So you can force the constrained command you want using ForceCommand <your command>.
For example:
Match User kim
        ForceCommand echo 'successful login man, congrats'

Example
In my case where I want to give git access, I only need the user to have access
to git-shell. This is the section that disables SFTP for my git users, along
with some security options:
Match Group git

        # have to do this instead of setting the login shell to `git-shell`,
        # to disable SFTP
        ForceCommand /usr/bin/git-shell -c "$SSH_ORIGINAL_COMMAND"

        # disable stuff we don't need
        AllowAgentForwarding no
        AllowTcpForwarding no
        AllowStreamLocalForwarding no
        PermitOpen none
        PermitTunnel no
        PermitTTY no
        X11Forwarding no

A: Match Group nosft
Subsystem   sftp  /bin/false

I prefer to use a group for this.
It is useful in combination with users who have restricted shells. I sometimes give ssh access to a client so that they can access a sql-dump of their database by setting their shell to a script that dumps their data. Cutting them off from scp also seems to be a smart idea. They don't have access to running cat to transfer a file over ssh.

A: Match User bob
MaxSessions 0

Tested and working on CentOS 6.6. Note that Subsystem is not allowed with Match at least on newer CentOS versions. The manpage for sshd_config lists the limited keywords that are allowed with the Match condition.

A: You can look at scponly to do the reverse, allow only scp/sftp but no shell access.
I agree with @Nathan above, this doesn't make a whole lot of sense.  If you are dead set, try editting your /etc/ssh/sshd_config file and removing/commenting  out the following line:
Subsystem       sftp    /usr/libexec/openssh/sftp-server

A: give no home directory for user
usermod username -d /bin/false

Change Subsystem sftp /usr/libexec/openssh/sftp-server in file /etc/ssh/sshd_config
to Subsystem sftp /dev/null/usr/libexec/openssh/sftp-server
Then restart the ssh
service ssh restart

it works for me, debian.

A: In the ~/authorized_key configure the user key as follow:
command="/bin/bash" ssh-rsa AAAAB3Nz.........


text:
Q: Is there a standard pseudocode for parallel algorithms? The common styles of pseudocode are largely intelligible, and it is more or less clear how to write pseudocode for sequential programs.
But if parallelism is not hidden behind a full library and is regarded as a regular part of programming, then it should be treated as the same way in regards to pseudo-code.
Is there a consistent and widely used style of pseudocode for parallel algorithms? Are there good, practical examples of this?

A: It depends on what level you need to reason about the code. For low-level code you may need to describe shared resources, readers, writers, and how they cooperate to prevent starvation (see the readers-writers problems). On a higher level it may be sufficient to describe system states, tasks, and how workers are synchronized.

A: Fundamentally, pseudocode is about low level algorithms, and tends to be only useful when you are describing sequential operations. Parallelism tends to occur at the next level up and there are planting of diagramming tools that are better suited to that.


text:
Q: separating real and imaginary part of complex number Question:
Separate into real and imaginary parts $(iy)^{iy}$
$(y : real, y \neq0)$.
My attempt
$iy^{iy} = e^{iylog(iy)} = e^{iy}*e^{log(iy)}=e^{iy}*e^{ln|iy| + i*arg(iy)}
= e^{iy} * e^{ln(y)+i*(\pi/2 + 2k\pi)}$
real part = $e^{ln(y)}$
imaginary part = $e^{i(y+ (\pi/2) + 2k\pi}$
Can anyone confirm whether it is right or wrong? If wrong, could you please point out which part is incorrect approach?
Thanks

A: I noticed that you had the step of the attempt that: $^{}$=$^{()}$=$^{}∗^{()}$ when this step should be, based on my knowledge of real number exponential rules:
Using exp(x)=$e^x$:
$^{()}$=$exp(iy)^{log(iy)}$= $(exp({log(iy)))^{iy}}$.
Exponents multiplied are an exponent to the power of another exponent whereas multiplications of the same bases would get you added exponents: $^{}∗^{()}$= $^{+()}$.
Anyways, as exp(iπ)=-1,$\sqrt {exp(iπ)}=\sqrt {-1}=i=$exp($\frac{πi}{2})$, this means that one value of ln(i) is $\frac{πi}{2}$. I will also use log(x)=ln(x) for convenience:
exp(iy*log(iy))=exp(iy(ln(i)+ln(y))=$exp(iy(\frac{πi}{2}+ln(y))$= $exp(\frac{-πy}{2}+iy*ln(y))$= $exp(iy*ln(y)-\frac{πy}{2})$
Splitting the exponent into two different bases reveals that:
$exp(iy*ln(y)-\frac{πy}{2})$=$ exp(-\frac{πy}{2})*exp(i(y*ln(y)))$=$C*e^{iθ'}$ where C=$e^{-\frac{πy}{2}}$ and θ-θ'=2πn,n $\in \Bbb Z$. Here θ'= y*ln(y)
Using Euler's Identity and/or De Moivre's Theorem shows the final answer is:
$f=f(y)=(iy)^{iy}=C(cosθ'+i*sinθ')=e^{-\frac {πy}{2}} cos(y*ln(y)+2πn)+i e^{-\frac {πy}{2}} sin(y*ln(y)+2πn)$
= Re(f)+i*Im(f), n∈ℤ.
This can also be written as: $e^{-\frac {πy}{2}} [cos(y*ln(y)+2πn)+i sin(y*ln(y)+2πn)]$, n∈ℤ.
Let's try y=1:
f(1)=$i^i$= $e^{-\frac {π}{2}} [cos(1*ln(1)+2πn)+i sin(1*ln(1)+2πn)]$ and n=0:
f(1)= $e^{-\frac {π}{2}}[1+0i]$=$e^{-\frac {π}{2}}$
Let's try y= $-\frac {i}{2}$:
f(-$\frac {i}{2}$)= $e^{-\frac {π\frac {-i}{2}}{2}} [cos((-\frac {i}{2})*ln(-\frac {i}{2})+2πn)+i sin((-\frac {i}{2})*ln(-\frac {i}{2})+2πn)]$
Using a similar technique to find $ln(-\frac {i}{2})$ and letting n=0, we get:
f(-$\frac {i}{2}$)= $(i\frac {-i}{2})^{(i \frac {-i}{2})}$=$(\frac 12)^{\frac 12}$=$\frac{1}{\sqrt2}$=$(\frac{1+i}{\sqrt2})[cos(\frac 14(2i*ln(2))+isin(\frac 14(2i*ln(2))]$
This answer simplifies down to:
$cosh(\frac{ln(2)}{2})-sinh(\frac{ln(2)}{2})$ which uses the hyperbolic trigonometric functions.
This finally simplifies down to $e^{-\frac{ln(2)}{2}}=\frac{1}{\sqrt 2}$ if the hyperbolic functions are written in terms of their exponential definition.
Here is a link about them:
https://en.m.wikipedia.org/wiki/Hyperbolic_functions
Correct me if I am wrong!

A: Your approach needs to be somewhat revised.
Given $y\in\mathbb{R}\setminus\{0\}$ and taking $k\in\mathbb{Z}$ we obtain

\begin{align*}
\color{blue}{(iy)^{iy}}&=e^{iy\ln(iy)}\tag{1}\\
&=e^{iy\left(\ln|iy|+i\left(\arg(iy)+2k\pi\right)\right)}\tag{2}\\
&=e^{iy\left(\ln|y|+i\left(\frac{\pi}{2}\mathrm{sgn}(y)+2k\pi\right)\right)}\tag{3}\\
&=e^{iy\ln|y|}e^{-y\left(\frac{\pi}{2}\mathrm{sgn}(y)+2k\pi\right)}\tag{4}\\
&\,\,\color{blue}{=e^{-y\left(\frac{\pi}{2}\mathrm{sgn}(y)+2k\pi\right)}\left(\cos(y\ln|y|)+i\sin(y\ln|y|)\right)}\tag{5}
\end{align*}
from which
\begin{align*}
\Re{\left((iy)^{iy}\right)}&=e^{-y\left(\frac{\pi}{2}\mathrm{sgn}(y)+2k\pi\right)}\cos(y\ln|y|)\\
\Im{\left((iy)^{iy}\right)}&=e^{-y\left(\frac{\pi}{2}\mathrm{sgn}(y)+2k\pi\right)}\sin(y\ln|y|)
\end{align*}
follows.

Comment:

*

*In (1) we use the identity $e^{\ln(z)}=z, z\in\mathbb{C}\setminus\{0\}$.

*In (2) we use the identity $\ln(z)=\ln|z|+i\left(\arg(z)+2k\pi\right), z\in\mathbb{C}\setminus\{0\}, k\in\mathbb{Z}$.

*In (3) and (4) we make some simplifications.

*In (5) we use the identity $e^{iz}=\cos(z)+i\sin(z), z\in\mathbb{C}$.

A: Since $y$ can be either positive or negative, it can be instructive to treat each case separately.
Case $y > 0$:  Here, $|\mathrm{i}y| = |y| = y$ and $\arg( \mathrm{i} y) = \pi/2$.  We can write
\begin{align*}
(\mathrm{i} y)^{\mathrm{i} y} &= (y \mathrm{e}^{\mathrm{i}\pi/2})^{\mathrm{i}y}  \\
    &= (\mathrm{e}^{\ln y} \mathrm{e}^{\mathrm{i}\pi/2})^{\mathrm{i}y}  \\
    &= (\mathrm{e}^{\ln(y) + \mathrm{i}\pi/2})^{\mathrm{i}y}  \\
    &= \mathrm{e}^{\mathrm{i} y \ln(y) - y \pi/2}  \\
    &= \mathrm{e}^{- y \pi/2} \left( \cos(y \ln y) + \mathrm{i} \sin(y \ln y) \right)  \\
    &= \mathrm{e}^{- |y| \pi/2} \left( \cos(y \ln |y|) + \mathrm{i} \sin(y \ln |y|) \right) \text{.}
\end{align*}
(In the last line, we have used foresight to write the result in the same form as the result of the case when $y < 0$.)
Case $y < 0$:  Here, $|\mathrm{i}y| = |y| = -y$ and $\arg(\mathrm{i}y) = -\pi/2$.  We can write
\begin{align*}
(\mathrm{i}y)^{\mathrm{i}y} &= (|y| \mathrm{e}^{-\mathrm{i}\pi/2})^{\mathrm{i}y}  \\
&= (\mathrm{e}^{\ln(|y|) - \mathrm{i}\pi/2})^{\mathrm{i}y}  \\
&= \mathrm{e}^{\mathrm{i} y \ln(|y|) + y\pi/2}  \\
&= \mathrm{e}^{y \pi/2}\left( \cos(y \ln |y|) + \mathrm{i} \sin(y \ln |y|) \right)  \\
&= \mathrm{e}^{-|y| \pi/2}\left( \cos(y \ln |y|) + \mathrm{i} \sin(y \ln |y|) \right) \text{.}
\end{align*}
So, in both cases, the real part is $\mathrm{e}^{-|y| \pi/2} \cos(y \ln |y|)$ and the imaginary part is $\mathrm{e}^{-|y| \pi/2} \sin(y \ln |y|)$.

"If wrong, could you please point out which part is incorrect approach?"...
First,
$$  \mathrm{e}^{\mathrm{i} y \ln (\mathrm{i} y)} \neq \mathrm{e}^{\mathrm{i} y} \mathrm{e}^{\ln (\mathrm{i} y)}  $$
The two correct rules are (depending on which side of the inequation we want to preserve),
$$  \mathrm{e}^{\mathrm{i} y \ln (\mathrm{i} y)} = \left( \mathrm{e}^{\mathrm{i} y} \right)^{\ln (\mathrm{i} y)}  $$
and
$$  \mathrm{e}^{\mathrm{i} y} \mathrm{e}^{\ln (\mathrm{i} y)} = \mathrm{e}^{\mathrm{i} y + \ln (\mathrm{i} y)}  \text{.}  $$
Also, you attempt to extract the real and imaginary parts of an exponential without actually writing it in the form
$$  \mathrm{e}^{u + \mathrm{i}v}  \text{,}  $$
where both $u$ and $v$ are unambiguously real expressions.  Once you have this form, you can read off the real component,
$$  \mathrm{e}^u \cos(v)  \text{,}  $$
and the imaginary component,
$$  \mathrm{e}^u \sin(v)  \text{.}  $$


text:
Q: Include specific slides from another presentation for Xaringan I use xaringan R package for making presentations.
I have following directory structure
└── presentations
    ├── 01_intro
    |    ├── intro.Rmd
    |    └── intro.html
    └── 02_test
    |    ├── test.Rmd
    |    └── test.html
    └── 03_new
         ├── new.Rmd
         └── new.html

For the new presentation (03_new), I would like to include slide number 3 from the intro slide (01_intro).
This could be done by:

*

*<iframe src="../01_intro/intro.html#3"></iframe> or,

*knitr::include_url("../01_intro/intro.html#3")
Question
Is there a way to do that using {r child='../01_intro/intro.Rmd{slide#}'}?
OR
Is there a way to do that using {r child='../01_intro/intro.Rmd{slide-name}'}?
Reasons I need a solution for this:

*

*Easy to reuse, and I have a track of slides.

*This would prevent me to work again on the same material.

This would be very beneficial when I have to make a new presentation from a number of existing presentations. I just input a specific section into a new one, then copy-paste or screenshot.

A: have a look at this question, I hope it helps, link
I think you are right about how you can go about it, just make the presentation slide it's own .RMD file, hopefully that doesn't get too confusing
 ---
 title: My Report
 output:
   pdf_document:
     toc: yes
 ---

 ```{r child = 'chapter1.Rmd'}
 ```

 ```{r child = 'chapter2.Rmd'}
 ```


text:
Q: Displaying uploaded image I'm trying to upload/resize an image using Ajax and then display it in the browser instead of saving it to a file. I'm expecting to have an image, instead I got a bunch of gibberish.
Is it doable? Or I can't and need to resort to something else like saving to a file and then take its path? Or perhaps using canvas?
Thanks for your time.
HTML
<form enctype="multipart/form-data" action="file.php" method="Post" id="form">
  <input type="file" name="user_image">
  <input type="submit" value="Submit" name="submit">
</form>

Javascript
//using jquery-form.js
$('#form').on('submit', function(e) {
  e.preventDefault();
  $(this).ajaxSubmit({
    target: '#blah',
    success:  function(){}
  });
});

PHP
$img_width = imagesx($this->image);
$img_height = imagesy($this->image);
$image = imagecreatefromjpeg($_FILE['user_image']['tmp_name']);
$resized_image = imagecreatetruecolor(300, 300);
imagecopyresampled($resized_image, $image, 0, 0, 0, 0, 300, 300, $img_width, $img_height);
header('Content-Type:image/jpeg');
imagejpeg($resized_image);

A: In your PHP do this
ob_start();
// header("Content-type: image/jpeg"); // fairly sure you won't need this
imagejpeg($resized_image);
echo base64_encode(ob_get_clean());
die;

assuming you have in HTML

then in JS
success:  function(data){
    $('#theimage').attr('src', 'data:image/jpeg;base64,' + data);
}

A: You're trying to get the raw jpeg data using ajax.You should not perform an ajax upload but instead send the form directly to see the resized image. If this is not what you want, then you'll need to encode the raw jpeg data to a base64-encoded data url and insert that as the src property of an  element.


text:
Q: Make Android WebView.loadUrl(...) Behave Synchronously Has anybody tried to make Android WebView.loadUrl(...) behave synchronously?
My scenario is this: I want to execute some javascript but I don't want to initialize the WebView that executes the javascript until the time at which the javascript is to be executed.  For the javascript to execute successfully the call stack needs to have been prepared.
I need to call loadUrl to load the html page that loads the javascript methods.  The problem is that loadUrl is called and then returns immediately, tearing down the call stack in the process.  Then WebViewClient::onPageFinished(...) gets called later signaling that the WebView is ready and I can execute my script.  But now it is too late because my call stack is gone.
I would like loadUrl to wait for onPageFinished but the problem is that onPageFinished gets called in the same thread as loadUrl was called on (even though the loadUrl happens in another thread).  So waiting after calling loadURL blocks the thread and onPageFinished never gets called.
Is there some pattern in android/java that permits a thread to wait but have the thread's message loop continue to execute so that a notification to that thread can be received?