qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
22,847,865
Please consider the following statement: ``` var matches = person.Contacts.Where(c => c.ContactType == searchContact.ContactType).ToList(); ``` This will filter all the records with matching ContactType of searchContact object and returns only the filtered Contacts of person. But without ToList() method call at the end of the Where clause, it will return all the Contacts of person. Now, consider the following code segment. ``` Dictionary<int, string> colors = new Dictionary<int, string>(){ {1, "red"}, {2, "blue"}, {3, "green"}, {4, "yellow"}, {5, "red"}, {6, "blue"}, {7, "red"} }; var colorSet = colors.Where(c => c.Value == "red"); ``` This query will filter only the elements with value "red", even without calling ToList() method. My question is why this two statements (one that compares values and one that compares properties) behave in a different way without ToList() method call? Why this problem does not occur with FirstOrDefault instead of Where clause? I really appreciate, if anyone can explain the scenario or post some references that I can follow. Thanks!!
2014/04/03
[ "https://Stackoverflow.com/questions/22847865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1710097/" ]
You are mistaken. Without calling `ToList()` or another method to force immediate execution, both statements will return an `IQueryable<T>`. Until you iterate over your query variable by using a `foreach` the query variable remains just that. This article on MSDN should explain things well: [Query Execution](http://msdn.microsoft.com/en-us/library/bb738633%28v=vs.110%29.aspx). What you are experiencing is called **Deferred Query Execution**. > > In a query that returns a sequence of values, the query variable > itself never holds the query results and only stores the query > commands. Execution of the query is deferred until the query variable > is iterated over in a foreach or For Each loop. This is known as > deferred execution. > > > When you use `ToList()` what occurs is known as **Immediate Query Execution**. > > In contrast to the deferred execution of queries that produce a > sequence of values, queries that return a singleton value are executed > immediately. Some examples of singleton queries are Average, Count, > First, and Max. These execute immediately because the query must > produce a sequence to calculate the singleton result. You can also > force immediate execution. This is useful when you want to cache the > results of a query. To force immediate execution of a query that does > not produce a singleton value, you can call the ToList method, the > ToDictionary method, or the ToArray method on a query or query > variable. > > > These are core behaviors of LINQ.
> > But without ToList() method call at the end of the Where clause, it will return all the Contacts of person. > > > No, without `ToList` it will return a query which, when iterated, will yield all of the contacts matching the value you specified to filter on. Calling `ToList` only materializes that query into the results of that query. Waiting a while and iterating it later, possibly using some other method of iteration such as `foreach`, will only change the results if the underlying data source (in this case, a database, by the look of thigns) changes its data. As to your dictionary filter, the same thing applies. Without calling `ToList` the variable represents *a query to get the data when asked*, not *the results of that query*, which is what you would get by calling `ToList`. The use of a property versus a field is irrelevant here. Having said *that*, both queries are using properties, not fields. Even if one did use a field though, it wouldn't change a thing.
425,227
Update: I’ve decided I’m giving up on what I have to work with, and I’m gonna buy a new battery. I have a 13 inch MacBook Pro that I have been working on refurbishing, and I’ve run into an issue where if I unplug it from the charger it shuts down and it won’t show battery percentage. I think this might have something to do with when I was dusting out the insides of the computer and a misaligned flex cable, but I am really not sure. Here’s an image of white happens when I first turn on the computer: [![enter image description here](https://i.stack.imgur.com/owgeY.jpg)](https://i.stack.imgur.com/owgeY.jpg) i’m really at a loss as to what to do at this point, because I’ve just been scouring forums for the better part of a month.
2021/08/06
[ "https://apple.stackexchange.com/questions/425227", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/428517/" ]
Either the battery is not connected or it has failed. Did you receive any messages about “service battery”? You will likely be taking the cover off again to check.
I have just replaced a battery in a 2016 MacBook Pro 13 with a third party replacement. It was the last part of a fairly major exercise to replace the keyboard. When I turned the laptop on it worked while plugged in but failed as soon as I removed the power cable. Turns out I had failed to transfer a cable from the old battery I had removed to the new replacement. Once I had put the cable in it started working although I am seeing some concerning entries in dmesg which I suspect is related to the third party battery not having the same hardware as the genuine part (update: actually was due to a faulty third party battery): ``` Failed to read nominal voltage rating key . voltage:0 rc:0x84 ``` The cable is the one in the picture below from [ifixit battery replacement guide](https://www.ifixit.com/Guide/MacBook+Pro+13-Inch+Function+Keys+Late+2016+Battery+Replacement/88305). I would check that it is connected correctly at both ends - something you will need to do regardless even if you are only replacing the battery. [![enter image description here](https://i.stack.imgur.com/t86wV.jpg)](https://i.stack.imgur.com/t86wV.jpg)
63,018,572
My Python version is 2.7 and I am using this code: ``` df1.select(*[x for x in df1.columns if x!='fields'], F.col("fields.*")).show() ``` But I got this error: ``` File "<ipython-input-16-3d81a8b987ed>", line 1 df1.select(*[x for x in df1.columns if x!='fields'], F.col("fields.*")).show() SyntaxError: only named arguments may follow *expression ``` How can I modify my code to make it work in Python 2? Thanks.
2020/07/21
[ "https://Stackoverflow.com/questions/63018572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10241161/" ]
You will create a repository and then you will follow the instructions given [here](https://docs.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line) I would suggest you also to watch a video in youtube there are plenty of them
I have two solutions for you that are easy to do for most users **Option 1:** your home page click `New` button and type in the repository name, click on `Upload existing file` and select your files you want to upload **Option 2:** You could also use the github desktop app [found here](https://desktop.github.com/) and upload folder directly YouTube is also a great place if you want to learn about git and github
32,310,508
I'm having an entity framework's EDMX generated class having two properties ``` public partial class Contact : EntityBase { public string FirstName { get; set; } public string LastName { get; set; } } ``` I require additional property that should return FullName by joining FirstName and LastName. So I created a partial class for this. ``` public partial class Contact { public string FullName { get { return string.Format("{0}{1}", FirstName, !string.IsNullOrEmpty(LastName) ? " " + LastName : String.Empty); } } } ``` Now, I created a LINQ expression to search records matching "Steeve John" against FullName. ``` Expression<Func<Contact, bool>> cntExpression = p => p.FullName.ToLower().Trim().Contains("Steeve John"); ``` I passed this expression to the business logic to retrieve an IQueryable instance. ``` IQueryable<Contact> qryContact = _cntMgr.GetFiltered(cntExpression); ``` The code fails at this line of code: ``` var contactLeads = qryContact.Select( s => s.Leads.Where(a => a.IsActive).GroupBy(a => a.ContactId).Select(a => a.FirstOrDefault())).ToList(); ``` and the error that I get is this: ``` The specified type member 'FullName' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported. ``` Please help me in fixing this issue. Thanks in advance.
2015/08/31
[ "https://Stackoverflow.com/questions/32310508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5284398/" ]
I know it's a few years later with no solution, but I had the exact same problem you described on one site that was working in other sites. So I did some research on what was different and to help others should they run into the same issue. **Background** * example.com is the domain * I have a WP page called "foobar" with content * I have a WP post category called "foobar" * I have a WP post entitled "fun things to do with foobars", and the category is set to "foobar" **Expectations** * When I go to `example.com/foobar`, I want to see the page about foobars, not a WP category page that shows all blog posts with that category. * When I go to the blog post about fun things, the URL is `example.com/foobar/fun-things-to-do-with-foobars/` **Setup** Here's my setup (it does not require any additional plugins or code edits) A couple of installed plugins are WP Rocket and Yoast on which I'll focus in this thread. 1. WP Dashboard->Settings->Permalinks 2. Select "Custom Structure" and enter `/%category%/%postname%/` in the field 3. On the same page, change "Category base" to a single dot. "." (no quotes, just a single dot/period/full stop I have Yoast installed, which I had set up to override the permalink settings, but I believe this messed up my task at hand. 4. WP Dashboard->SEO->Advanced->Permalinks(tab) 5. "Change URLs->Strip the category base..." = `Keep` 6. Then you need to clear the cache. I use WP Rocket for caching, so I flushed the cache and everything now works the way it should. **Edit**: make sure you save your changes after steps 3 and 5
I know this topic is old but question is still important. I will use blog example. This method is code free, WP native solution. One caveat is that you cannot translate "blog" slug, so this method is only for one language if you don't need to have different words/slugs for other languages. 1. Create page with slug "blog". Or whatever you like. **It must match word you put in next step as base: blog = blog it this example**. 2. Set permalink structure in settings to: `/blog/%category/%postname%/` (/ trailing slash on the end is your preference) 3. Use SEO plugin like Yoast or Seopress Pro (or any other method) to remove /category from URL. 4. Go to Settings -> Reading -> "Your homepage displays" section -> "A static page (select below)" 5. Set your static page for Homepage 6. Here is the magic: **set Posts page to your "Blog" page.** 7. Flush permalinks by visiting and saving settings on Permalink page (without any change). Then you will get proper URL: `/blog/yourcategory/single-post-title/` Breadcrumbs will work, all categories will be hierarchical, and `/blog` **will work as page instead of category**. Most importantly, when you go to your category page you will get `/blog/yourcategory` URL and it will work as archive page. When you visit single post, then also you get URL `/blog/yourcategory/single-post-title/` Breadcrumbs from Yoast should work. I use Seopress Pro and breadcrumbs works like a charm (you have to go to breadcrumbs setting page and select categories for posts and posts for categories and tags if you need them). If you do it without including `/blog` in your permalink setting it will still work, you will get page instead of category with proper url for categories, but single post will be `/yourcategory/single-post-title`.
43,625,889
Imported Excel sheet To SQL server.i have selects one table . in this table have lot of Rows values. in this Rows single Employee comes in this Table many time. i want single Employee in this COlumn should have all values available from Repeated columns. i will show Sample Data for reference. ``` Name E1 E2 E3 E4 E5 Jeni 1 0 0 0 0 Jeni 0 0 2 0 0 Jeni 0 5 0 0 3 Priya 0 3 0 0 0 Priya 0 0 0 0 3 Priya 0 0 7 0 0 Priya 10 0 0 0 0 ``` My table Looks like after Select the Table my Result should be Like ``` Name E1 E2 E3 E4 E5 Total jeni 1 5 2 0 3 11 Priya 10 3 7 0 3 23 ``` i want be like this. i hope Explained little bit clear.please how can achieve this. please also Refer BEST TUTORIAL For learn SQL very short period .thank you advance . I hope some Wil help. I am new SQL Server.
2017/04/26
[ "https://Stackoverflow.com/questions/43625889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4648432/" ]
``` CREATE TABLE #Table1 ([Name] varchar(5), [E1] int, [E2] int, [E3] int, [E4] int, [E5] int) ; INSERT INTO #Table1 ([Name], [E1], [E2], [E3], [E4], [E5]) VALUES ('Jeni', 1, 0, 0, 0, 0), ('Jeni', 0, 0, 2, 0, 0), ('Jeni', 0, 5, 0, 0, 3), ('Priya', 0, 3, 0, 0, 0), ('Priya', 0, 0, 0, 0, 3), ('Priya', 0, 0, 7, 0, 0), ('Priya', 10, 0, 0, 0, 0) ; SELECT *,A.E1+A.E2+A.E3+A.E4+A.E5 AS 'TOTAL' FROM ( SELECT NAME, SUM(E1) E1 ,SUM(E2) E2 ,SUM(E3) E3 ,SUM(E4) E4 ,SUM(E5) E5 FROM #TABLE1 GROUP BY NAME)A ``` output ``` NAME E1 E2 E3 E4 E5 TOTAL Jeni 1 5 2 0 3 11 Priya 10 3 7 0 3 23 ```
The thing you are looking for is a Group by . To get the result you are looking for , i just made the table you described and did a group by and did a sum on the integer values. ``` select name, sum(E1),sum(E2),sum(E3),sum(E4),sum(E5) from Test Group by name ```
43,625,889
Imported Excel sheet To SQL server.i have selects one table . in this table have lot of Rows values. in this Rows single Employee comes in this Table many time. i want single Employee in this COlumn should have all values available from Repeated columns. i will show Sample Data for reference. ``` Name E1 E2 E3 E4 E5 Jeni 1 0 0 0 0 Jeni 0 0 2 0 0 Jeni 0 5 0 0 3 Priya 0 3 0 0 0 Priya 0 0 0 0 3 Priya 0 0 7 0 0 Priya 10 0 0 0 0 ``` My table Looks like after Select the Table my Result should be Like ``` Name E1 E2 E3 E4 E5 Total jeni 1 5 2 0 3 11 Priya 10 3 7 0 3 23 ``` i want be like this. i hope Explained little bit clear.please how can achieve this. please also Refer BEST TUTORIAL For learn SQL very short period .thank you advance . I hope some Wil help. I am new SQL Server.
2017/04/26
[ "https://Stackoverflow.com/questions/43625889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4648432/" ]
``` CREATE TABLE #Table1 ([Name] varchar(5), [E1] int, [E2] int, [E3] int, [E4] int, [E5] int) ; INSERT INTO #Table1 ([Name], [E1], [E2], [E3], [E4], [E5]) VALUES ('Jeni', 1, 0, 0, 0, 0), ('Jeni', 0, 0, 2, 0, 0), ('Jeni', 0, 5, 0, 0, 3), ('Priya', 0, 3, 0, 0, 0), ('Priya', 0, 0, 0, 0, 3), ('Priya', 0, 0, 7, 0, 0), ('Priya', 10, 0, 0, 0, 0) ; SELECT *,A.E1+A.E2+A.E3+A.E4+A.E5 AS 'TOTAL' FROM ( SELECT NAME, SUM(E1) E1 ,SUM(E2) E2 ,SUM(E3) E3 ,SUM(E4) E4 ,SUM(E5) E5 FROM #TABLE1 GROUP BY NAME)A ``` output ``` NAME E1 E2 E3 E4 E5 TOTAL Jeni 1 5 2 0 3 11 Priya 10 3 7 0 3 23 ```
``` ;With cte(Name,E1,E2,E3,E4,E5) AS ( SELECT 'Jeni' ,1 ,0 , 0, 0, 0 Union all SELECT 'Jeni' ,0 ,0 , 2, 0, 0 Union all SELECT 'Jeni' ,0 ,5 , 0, 0, 3 Union all SELECT 'Priya',0 ,3 , 0, 0, 0 Union all SELECT 'Priya',0 ,0 , 0, 0, 3 Union all SELECT 'Priya',0 ,0 , 7, 0, 0 Union all SELECT 'Priya',10,0 , 0, 0, 0 ) SELECT Name,E1,E2,E3,E4,E5,Total FROM ( SELECT *,Row_number()Over(Partition by Name order by Name)AS Seq From ( SELECT Name,SUM(E1)E1, SUM(E2)E2, SUM(E3)E3, SUM(E4)E4, SUM(E5)E5, SUM(E1+E2+ E3+ E4+E5) AS Total FROM cte Group by Name )Dt )AS Final WHERE Final.Seq=1 ```
43,625,889
Imported Excel sheet To SQL server.i have selects one table . in this table have lot of Rows values. in this Rows single Employee comes in this Table many time. i want single Employee in this COlumn should have all values available from Repeated columns. i will show Sample Data for reference. ``` Name E1 E2 E3 E4 E5 Jeni 1 0 0 0 0 Jeni 0 0 2 0 0 Jeni 0 5 0 0 3 Priya 0 3 0 0 0 Priya 0 0 0 0 3 Priya 0 0 7 0 0 Priya 10 0 0 0 0 ``` My table Looks like after Select the Table my Result should be Like ``` Name E1 E2 E3 E4 E5 Total jeni 1 5 2 0 3 11 Priya 10 3 7 0 3 23 ``` i want be like this. i hope Explained little bit clear.please how can achieve this. please also Refer BEST TUTORIAL For learn SQL very short period .thank you advance . I hope some Wil help. I am new SQL Server.
2017/04/26
[ "https://Stackoverflow.com/questions/43625889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4648432/" ]
The thing you are looking for is a Group by . To get the result you are looking for , i just made the table you described and did a group by and did a sum on the integer values. ``` select name, sum(E1),sum(E2),sum(E3),sum(E4),sum(E5) from Test Group by name ```
``` ;With cte(Name,E1,E2,E3,E4,E5) AS ( SELECT 'Jeni' ,1 ,0 , 0, 0, 0 Union all SELECT 'Jeni' ,0 ,0 , 2, 0, 0 Union all SELECT 'Jeni' ,0 ,5 , 0, 0, 3 Union all SELECT 'Priya',0 ,3 , 0, 0, 0 Union all SELECT 'Priya',0 ,0 , 0, 0, 3 Union all SELECT 'Priya',0 ,0 , 7, 0, 0 Union all SELECT 'Priya',10,0 , 0, 0, 0 ) SELECT Name,E1,E2,E3,E4,E5,Total FROM ( SELECT *,Row_number()Over(Partition by Name order by Name)AS Seq From ( SELECT Name,SUM(E1)E1, SUM(E2)E2, SUM(E3)E3, SUM(E4)E4, SUM(E5)E5, SUM(E1+E2+ E3+ E4+E5) AS Total FROM cte Group by Name )Dt )AS Final WHERE Final.Seq=1 ```
8,801,924
i'm testing an app of getting current location with sumsung galaxy spica, it show me another location different from my one and it isn't the same showed in the AVD!! gps is activated but i don't know where is the problem exactly. Here is my code ``` import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.KeyEvent; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.MyLocationOverlay; public class MaptestActivity extends MapActivity implements LocationListener { private MapView mapView = null; private LocationManager lm = null; private double lat = 0; private double lng = 0; private MapController mc = null; private MyLocationOverlay myLocation = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) this.findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); lm = (LocationManager) this.getSystemService(LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); myLocation = new MyLocationOverlay(getApplicationContext(), mapView); myLocation.runOnFirstFix(new Runnable() { public void run() { mc.animateTo(myLocation.getMyLocation()); mc.setZoom(17); mc = mapView.getController(); lat = myLocation.getMyLocation().getLatitudeE6(); lng = myLocation.getMyLocation().getLongitudeE6(); Toast.makeText( getBaseContext(), "My Location : Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_LONG).show(); } }); mapView.getOverlays().add(myLocation); } @Override protected void onResume() { super.onResume(); myLocation.enableMyLocation(); myLocation.enableCompass(); } @Override protected boolean isRouteDisplayed() { return false; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_S) { mapView.setSatellite(!mapView.isSatellite()); return true; } return super.onKeyDown(keyCode, event); } public void onLocationChanged(Location location) { lat = location.getLatitude(); lng = location.getLongitude(); Toast.makeText( getBaseContext(), "Location change to : Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_SHORT).show(); GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setCenter(p); } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } } ``` here is my manifest ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manita.maptest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="3" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="com.google.android.maps" /> <activity android:name=".MaptestActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.ACCESS_COARSE" /> <uses-permission android:name="android.permission.LOCATION" /> </manifest> ``` and here the error in the logcat ``` 01-10 10:37:47.765: E/Sensors(5222): ####### akmd2 started!!! 01-10 10:37:47.770: E/SensorManager(5222): registerListener 0:AK8973 Compass 01-10 10:37:47.950: E/SensorManager(5222): =======>>>>>>> Sensor Thread RUNNING <<<============================ 01-10 10:37:47.995: I/MapActivity(5222): Handling network change notification:CONNECTED 01-10 10:37:47.995: E/MapActivity(5222): Couldn't get connection factory client ``` Thanks
2012/01/10
[ "https://Stackoverflow.com/questions/8801924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1093645/" ]
My problem was because of the tables used diffrent engines. Table Chart used MyISAM and Chartdata used InnoDB.
remove the `NULL` in your `INSERT` query since the column `idChartdata` is set to `Auto_Increment` and try again. ``` INSERT INTO `charts`.`Chartdata`(`param1` ,`param2` ,`Chart_id`) VALUES ('2012-01-10 05:00:00', '58', '3') ```
8,801,924
i'm testing an app of getting current location with sumsung galaxy spica, it show me another location different from my one and it isn't the same showed in the AVD!! gps is activated but i don't know where is the problem exactly. Here is my code ``` import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.KeyEvent; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.MyLocationOverlay; public class MaptestActivity extends MapActivity implements LocationListener { private MapView mapView = null; private LocationManager lm = null; private double lat = 0; private double lng = 0; private MapController mc = null; private MyLocationOverlay myLocation = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) this.findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); lm = (LocationManager) this.getSystemService(LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); myLocation = new MyLocationOverlay(getApplicationContext(), mapView); myLocation.runOnFirstFix(new Runnable() { public void run() { mc.animateTo(myLocation.getMyLocation()); mc.setZoom(17); mc = mapView.getController(); lat = myLocation.getMyLocation().getLatitudeE6(); lng = myLocation.getMyLocation().getLongitudeE6(); Toast.makeText( getBaseContext(), "My Location : Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_LONG).show(); } }); mapView.getOverlays().add(myLocation); } @Override protected void onResume() { super.onResume(); myLocation.enableMyLocation(); myLocation.enableCompass(); } @Override protected boolean isRouteDisplayed() { return false; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_S) { mapView.setSatellite(!mapView.isSatellite()); return true; } return super.onKeyDown(keyCode, event); } public void onLocationChanged(Location location) { lat = location.getLatitude(); lng = location.getLongitude(); Toast.makeText( getBaseContext(), "Location change to : Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_SHORT).show(); GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setCenter(p); } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } } ``` here is my manifest ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manita.maptest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="3" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <uses-library android:name="com.google.android.maps" /> <activity android:name=".MaptestActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.ACCESS_COARSE" /> <uses-permission android:name="android.permission.LOCATION" /> </manifest> ``` and here the error in the logcat ``` 01-10 10:37:47.765: E/Sensors(5222): ####### akmd2 started!!! 01-10 10:37:47.770: E/SensorManager(5222): registerListener 0:AK8973 Compass 01-10 10:37:47.950: E/SensorManager(5222): =======>>>>>>> Sensor Thread RUNNING <<<============================ 01-10 10:37:47.995: I/MapActivity(5222): Handling network change notification:CONNECTED 01-10 10:37:47.995: E/MapActivity(5222): Couldn't get connection factory client ``` Thanks
2012/01/10
[ "https://Stackoverflow.com/questions/8801924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1093645/" ]
My problem was because of the tables used diffrent engines. Table Chart used MyISAM and Chartdata used InnoDB.
You are trying to add a row to chartdata, with Chart\_id = 3. Is there a chart with idChart = 3? Trie to add a chart with id = 3 first, then perform your query. [edit] Nvm, you solved it already. :D
253,363
``` expr = Uncompress[FromCharacterCode[ Flatten[ImageData[Import["https://i.stack.imgur.com/Pva9y.png"], "Byte"]]]]; ListLinePlot[expr, PlotRange -> All,ImageSize -> 1000] ``` [![enter image description here](https://i.stack.imgur.com/ddFBm.png)](https://i.stack.imgur.com/ddFBm.png) As we see, it just 4 Callout labels? But how to show all Callout labels?
2021/08/15
[ "https://mathematica.stackexchange.com/questions/253363", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/21532/" ]
Now knowing `R = 8.31451` redefine your function ``` cv[T_?NumericQ, DT_?NumericQ] := Block[{x},9 R (T/DT)^3*NIntegrate[(x^4Exp[x])/(Exp[x] - 1)^2, {x, 0, DT/T}]]; ``` The fit should minimize `J[DT` ``` J[DT_?NumericQ] := Total@Map[(Cv[#[[1]], DT] - #[[2]])^2 &, Capacity] Table[ {DT, J [DT]} , {DT, 150, 250, 1}] //ListPlot ``` [![enter image description here](https://i.stack.imgur.com/NxPPd.png)](https://i.stack.imgur.com/NxPPd.png) ``` NMinimize[{J[DT], 150 < DT < 250}, DT] (*{4.47804, {DT -> 210.986}}*) ``` I don't know why `NonlinearModelFit` is quite slow. After ~500seconds it evaluates the same result ``` mod= NonlinearModelFit[Capacity, {cv[T,DT], 250 > DT > 150 }, {DT} , T, Method ->"NMinimize"] mod["BestFitParameters"] (*{DT -> 210.986}*) ```
``` Cv[T_?NumericQ, DT_?NumericQ] := Module[{R = 8.31451, a}, a = DT/T; 9 R NIntegrate[(x^4 Exp[x])/(Exp[x] - 1)^2, {x, 0, a}]/a^3] dfit = d /. FindFit[Capacity, Cv[t, d], {d}, t] (* 210.986 *) g[1] = ListPlot[Capacity]; g[2] = Plot[Cv[t, dfit], {t, 0, 300}]; Show[{g[1], g[2]}] ``` [![enter image description here](https://i.stack.imgur.com/K4rX5.png)](https://i.stack.imgur.com/K4rX5.png) The answer of @UlrichNeumann is perfect. My post does not add much to it. I simply started to type when it appeared, I thought it would be a pity to through away an almost ready post.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
You can put all these configuration in single config file config.py. ``` class Base(): DEBUG = False TESTING = False class DevelopmentConfig(Base): DEBUG = True DEVELOPMENT = True DATABASE_URI = "mysql+mysqldb://root:root@localhost/demo" class TestingConfig(Base): DEBUG = False TESTING = True DATABASE_URI = "mysql+mysqldb://root:root@test_server_host_name/demo_test" class ProductionConfig(Base): DEBUG = False TESTING = False DATABASE_URI = "mysql+mysqldb://root:root@prod_host_name/demo_prod" ``` on the shell set environment variable like > > APP\_SETTINGS = config.DevelopmentConfig > > > In your main application app.py, load this environment variable (flask app as example) ``` from flask import Flask import os app = Flask(__name__) app.config.from_object(os.environ['APP_SETTINGS']) ``` I hope this can help
One approach would be to write a "template" for each kind of configuration file, where the template contains mostly plain text, but with a few placeholders. Here is an example template configuration file, using the notation `${foo}` to denote a placeholder. ``` serverName = "${serverName}" listenPort = "${serverPort}" logDir = "/data/logs/${serverName}"; idleTimeout = "5 minutes"; workingDir = "/tmp"; ``` If you do that for all the configuration files used by your application, then you will probably find that performing a global-search-and-replace on the template configuration files with values for a relatively small number of placeholders will yield the ready-to-run configuration files for a particular deployment. If you are looking for an easy way to perform global search-and-replace on placeholders in template files and are comfortable with Java, then you might want to consider [Apache Velocity](https://velocity.apache.org/). But I imagine it would be trivial to develop similar-ish functionality in Python.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
You can put all these configuration in single config file config.py. ``` class Base(): DEBUG = False TESTING = False class DevelopmentConfig(Base): DEBUG = True DEVELOPMENT = True DATABASE_URI = "mysql+mysqldb://root:root@localhost/demo" class TestingConfig(Base): DEBUG = False TESTING = True DATABASE_URI = "mysql+mysqldb://root:root@test_server_host_name/demo_test" class ProductionConfig(Base): DEBUG = False TESTING = False DATABASE_URI = "mysql+mysqldb://root:root@prod_host_name/demo_prod" ``` on the shell set environment variable like > > APP\_SETTINGS = config.DevelopmentConfig > > > In your main application app.py, load this environment variable (flask app as example) ``` from flask import Flask import os app = Flask(__name__) app.config.from_object(os.environ['APP_SETTINGS']) ``` I hope this can help
It's usually a bad idea to commit your configuration settings to source control, particularly when those settings include passwords or other secrets. I prefer using environment variables to pass those values to the program. The most flexible way I've found is to use the `argparse` module, and use the environment variables as the defaults. That way, you can override the environment variables on the command line. Be careful about putting passwords on the command line, though, because other users can probably see your command line arguments in the process list. Here's [an example](https://github.com/cfe-lab/MiCall/blob/v7.9wip2/micall_watcher.py#L15) that uses `argparse` and environment variables: ``` def parse_args(argv=None): parser = ArgumentParser(description='Watch the raw data folder for new runs.', formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument( '--kive_server', default=os.environ.get('MICALL_KIVE_SERVER', 'http://localhost:8000'), help='server to send runs to') parser.add_argument( '--kive_user', default=os.environ.get('MICALL_KIVE_USER', 'kive'), help='user name for Kive server') parser.add_argument( '--kive_password', default=SUPPRESS, help='password for Kive server (default not shown)') args = parser.parse_args(argv) if not hasattr(args, 'kive_password'): args.kive_password = os.environ.get('MICALL_KIVE_PASSWORD', 'kive') return args ``` Setting those environment variables can be a bit confusing, particularly for system services. If you're using systemd, look at the [service unit](https://www.freedesktop.org/software/systemd/man/systemd.service.html), and be careful to use `EnvironmentFile` instead of `Environment` for any secrets. `Environment` values can be viewed by any user with `systemctl show`. I usually make the default values useful for a developer running on their workstation, so they can start development without changing any configuration. Another option is to put the configuration settings in a `settings.py` file, and just be careful not to commit that file to source control. I have often committed a `settings_template.py` file that users can copy.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
You can put all these configuration in single config file config.py. ``` class Base(): DEBUG = False TESTING = False class DevelopmentConfig(Base): DEBUG = True DEVELOPMENT = True DATABASE_URI = "mysql+mysqldb://root:root@localhost/demo" class TestingConfig(Base): DEBUG = False TESTING = True DATABASE_URI = "mysql+mysqldb://root:root@test_server_host_name/demo_test" class ProductionConfig(Base): DEBUG = False TESTING = False DATABASE_URI = "mysql+mysqldb://root:root@prod_host_name/demo_prod" ``` on the shell set environment variable like > > APP\_SETTINGS = config.DevelopmentConfig > > > In your main application app.py, load this environment variable (flask app as example) ``` from flask import Flask import os app = Flask(__name__) app.config.from_object(os.environ['APP_SETTINGS']) ``` I hope this can help
We ended up using a method similar to this [one](https://stackoverflow.com/a/50611386/3822311). We had a base settings file, and environment specific files that simply imported everything from the base file base.py: ```py SAMPLE_CONFIG_VARIABLE = SAMPLE_CONFIG_VALUE ``` prod.py: ```py from base.py import * ``` So all we had to do when accessing values from the configuration is read an environment variable and creating the file corresponding to it.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
You can put all these configuration in single config file config.py. ``` class Base(): DEBUG = False TESTING = False class DevelopmentConfig(Base): DEBUG = True DEVELOPMENT = True DATABASE_URI = "mysql+mysqldb://root:root@localhost/demo" class TestingConfig(Base): DEBUG = False TESTING = True DATABASE_URI = "mysql+mysqldb://root:root@test_server_host_name/demo_test" class ProductionConfig(Base): DEBUG = False TESTING = False DATABASE_URI = "mysql+mysqldb://root:root@prod_host_name/demo_prod" ``` on the shell set environment variable like > > APP\_SETTINGS = config.DevelopmentConfig > > > In your main application app.py, load this environment variable (flask app as example) ``` from flask import Flask import os app = Flask(__name__) app.config.from_object(os.environ['APP_SETTINGS']) ``` I hope this can help
If we are using flask, then we could do environment specific config management like this : ``` -- project folder structure config/ default.py production.py development.py instance/ config.py myapp/ __init__.py ``` During app initialization., ``` # app/__init__.py app = Flask(__name__, instance_relative_config=True) # Load the default configuration app.config.from_object('config.default') # Load the configuration from the instance folder app.config.from_pyfile('config.py') # Load the file specific to environment based on ENV environment variable # Variables defined here will override those in the default configuration app.config.from_object('config.'+os.getenv("ENV")) ``` While running the application: ``` # start.sh # ENV should match the file name ENV=production python run.py ``` The above method is my preferred way. This method is based on [best practices described here](https://exploreflask.com/en/latest/configuration.html#configuring-based-on-environment-variables) with few modifications like file name based on environment variable. But there are other options * [Python-dotenv](https://github.com/theskumar/python-dotenv) * [python-config2](https://github.com/grimen/python-config2)
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
It's usually a bad idea to commit your configuration settings to source control, particularly when those settings include passwords or other secrets. I prefer using environment variables to pass those values to the program. The most flexible way I've found is to use the `argparse` module, and use the environment variables as the defaults. That way, you can override the environment variables on the command line. Be careful about putting passwords on the command line, though, because other users can probably see your command line arguments in the process list. Here's [an example](https://github.com/cfe-lab/MiCall/blob/v7.9wip2/micall_watcher.py#L15) that uses `argparse` and environment variables: ``` def parse_args(argv=None): parser = ArgumentParser(description='Watch the raw data folder for new runs.', formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument( '--kive_server', default=os.environ.get('MICALL_KIVE_SERVER', 'http://localhost:8000'), help='server to send runs to') parser.add_argument( '--kive_user', default=os.environ.get('MICALL_KIVE_USER', 'kive'), help='user name for Kive server') parser.add_argument( '--kive_password', default=SUPPRESS, help='password for Kive server (default not shown)') args = parser.parse_args(argv) if not hasattr(args, 'kive_password'): args.kive_password = os.environ.get('MICALL_KIVE_PASSWORD', 'kive') return args ``` Setting those environment variables can be a bit confusing, particularly for system services. If you're using systemd, look at the [service unit](https://www.freedesktop.org/software/systemd/man/systemd.service.html), and be careful to use `EnvironmentFile` instead of `Environment` for any secrets. `Environment` values can be viewed by any user with `systemctl show`. I usually make the default values useful for a developer running on their workstation, so they can start development without changing any configuration. Another option is to put the configuration settings in a `settings.py` file, and just be careful not to commit that file to source control. I have often committed a `settings_template.py` file that users can copy.
One approach would be to write a "template" for each kind of configuration file, where the template contains mostly plain text, but with a few placeholders. Here is an example template configuration file, using the notation `${foo}` to denote a placeholder. ``` serverName = "${serverName}" listenPort = "${serverPort}" logDir = "/data/logs/${serverName}"; idleTimeout = "5 minutes"; workingDir = "/tmp"; ``` If you do that for all the configuration files used by your application, then you will probably find that performing a global-search-and-replace on the template configuration files with values for a relatively small number of placeholders will yield the ready-to-run configuration files for a particular deployment. If you are looking for an easy way to perform global search-and-replace on placeholders in template files and are comfortable with Java, then you might want to consider [Apache Velocity](https://velocity.apache.org/). But I imagine it would be trivial to develop similar-ish functionality in Python.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
We ended up using a method similar to this [one](https://stackoverflow.com/a/50611386/3822311). We had a base settings file, and environment specific files that simply imported everything from the base file base.py: ```py SAMPLE_CONFIG_VARIABLE = SAMPLE_CONFIG_VALUE ``` prod.py: ```py from base.py import * ``` So all we had to do when accessing values from the configuration is read an environment variable and creating the file corresponding to it.
One approach would be to write a "template" for each kind of configuration file, where the template contains mostly plain text, but with a few placeholders. Here is an example template configuration file, using the notation `${foo}` to denote a placeholder. ``` serverName = "${serverName}" listenPort = "${serverPort}" logDir = "/data/logs/${serverName}"; idleTimeout = "5 minutes"; workingDir = "/tmp"; ``` If you do that for all the configuration files used by your application, then you will probably find that performing a global-search-and-replace on the template configuration files with values for a relatively small number of placeholders will yield the ready-to-run configuration files for a particular deployment. If you are looking for an easy way to perform global search-and-replace on placeholders in template files and are comfortable with Java, then you might want to consider [Apache Velocity](https://velocity.apache.org/). But I imagine it would be trivial to develop similar-ish functionality in Python.
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
It's usually a bad idea to commit your configuration settings to source control, particularly when those settings include passwords or other secrets. I prefer using environment variables to pass those values to the program. The most flexible way I've found is to use the `argparse` module, and use the environment variables as the defaults. That way, you can override the environment variables on the command line. Be careful about putting passwords on the command line, though, because other users can probably see your command line arguments in the process list. Here's [an example](https://github.com/cfe-lab/MiCall/blob/v7.9wip2/micall_watcher.py#L15) that uses `argparse` and environment variables: ``` def parse_args(argv=None): parser = ArgumentParser(description='Watch the raw data folder for new runs.', formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument( '--kive_server', default=os.environ.get('MICALL_KIVE_SERVER', 'http://localhost:8000'), help='server to send runs to') parser.add_argument( '--kive_user', default=os.environ.get('MICALL_KIVE_USER', 'kive'), help='user name for Kive server') parser.add_argument( '--kive_password', default=SUPPRESS, help='password for Kive server (default not shown)') args = parser.parse_args(argv) if not hasattr(args, 'kive_password'): args.kive_password = os.environ.get('MICALL_KIVE_PASSWORD', 'kive') return args ``` Setting those environment variables can be a bit confusing, particularly for system services. If you're using systemd, look at the [service unit](https://www.freedesktop.org/software/systemd/man/systemd.service.html), and be careful to use `EnvironmentFile` instead of `Environment` for any secrets. `Environment` values can be viewed by any user with `systemctl show`. I usually make the default values useful for a developer running on their workstation, so they can start development without changing any configuration. Another option is to put the configuration settings in a `settings.py` file, and just be careful not to commit that file to source control. I have often committed a `settings_template.py` file that users can copy.
If we are using flask, then we could do environment specific config management like this : ``` -- project folder structure config/ default.py production.py development.py instance/ config.py myapp/ __init__.py ``` During app initialization., ``` # app/__init__.py app = Flask(__name__, instance_relative_config=True) # Load the default configuration app.config.from_object('config.default') # Load the configuration from the instance folder app.config.from_pyfile('config.py') # Load the file specific to environment based on ENV environment variable # Variables defined here will override those in the default configuration app.config.from_object('config.'+os.getenv("ENV")) ``` While running the application: ``` # start.sh # ENV should match the file name ENV=production python run.py ``` The above method is my preferred way. This method is based on [best practices described here](https://exploreflask.com/en/latest/configuration.html#configuring-based-on-environment-variables) with few modifications like file name based on environment variable. But there are other options * [Python-dotenv](https://github.com/theskumar/python-dotenv) * [python-config2](https://github.com/grimen/python-config2)
50,610,832
I've had a discussion with some people at work and we couldn't come to a conclusion. We've faced a dilemma - how do you manage different configuration values for different environments? We've come up with some options, but none of them seemed to satisfy us: - Separate config files (i.e. `config.test`, `config.prod` etc.), and having a file pointing to the selected one (at `~/env` for instance), or an environment variable pointing to it. - Using a single DB to store all configurations (you query it with your environment and get the corresponding configuration values) - Creating configuration files on deploy (Using CI/CD system like Atlassian Bamboo) Which is the more widely used option? Is there a better way? Should config file be kept in the git repository along with the rest of the code? Our systems are written in python (both 2.7 and 3)
2018/05/30
[ "https://Stackoverflow.com/questions/50610832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3822311/" ]
We ended up using a method similar to this [one](https://stackoverflow.com/a/50611386/3822311). We had a base settings file, and environment specific files that simply imported everything from the base file base.py: ```py SAMPLE_CONFIG_VARIABLE = SAMPLE_CONFIG_VALUE ``` prod.py: ```py from base.py import * ``` So all we had to do when accessing values from the configuration is read an environment variable and creating the file corresponding to it.
If we are using flask, then we could do environment specific config management like this : ``` -- project folder structure config/ default.py production.py development.py instance/ config.py myapp/ __init__.py ``` During app initialization., ``` # app/__init__.py app = Flask(__name__, instance_relative_config=True) # Load the default configuration app.config.from_object('config.default') # Load the configuration from the instance folder app.config.from_pyfile('config.py') # Load the file specific to environment based on ENV environment variable # Variables defined here will override those in the default configuration app.config.from_object('config.'+os.getenv("ENV")) ``` While running the application: ``` # start.sh # ENV should match the file name ENV=production python run.py ``` The above method is my preferred way. This method is based on [best practices described here](https://exploreflask.com/en/latest/configuration.html#configuring-based-on-environment-variables) with few modifications like file name based on environment variable. But there are other options * [Python-dotenv](https://github.com/theskumar/python-dotenv) * [python-config2](https://github.com/grimen/python-config2)
80,808
Kryptonite is green.... Can the Green Lantern defend himself against Kryptonians? Or can the ring not make something that acts sufficiently like kryptonite?
2015/02/03
[ "https://scifi.stackexchange.com/questions/80808", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/3823/" ]
**Yes.** This has actually happened on a number of occasions; ![enter image description here](https://i.stack.imgur.com/SysCK.jpg) ![enter image description here](https://i.stack.imgur.com/dMNjr.jpg) ![enter image description here](https://i.stack.imgur.com/9Kzw8.jpg)
The Green Lantern rings are capable of creating Kryptonite and Kryptonite Radiation because the rings are capable of Energy Projection and can therefore mimic certain types of materials and energy signatures. [From Wikia](https://dc.fandom.com/wiki/Green_Lantern_Ring): > > Energy Projection: The ring can be used to fire blasts of Oan energy > or create weapons such as projectiles of them. The ring can project > beams of force powered by the will of the user. The ring can be used > to produce kryptonite and kryptonite radiation. > > > DC Comics Presents Vol 1 26 > > >
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
Use a `WHERE` clause. ``` SELECT B.R_ARN, A.R_DEVICETYPE FROM COFFEE2.R_PROFILE_TOKEN A INNER JOIN COFFEE2.R_TOKEN_ARN B ON A.R_TOKEN=B.R_TOKEN WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a single profileid, then use ``` WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a range of profileIds , then use ``` WHERE R_PROFILE_ID IN ('VALUE1','VALUE2','VALUE3'); ```
You need to put a `where` condition in your MYSql query. ``` select b.r_arn, a.r_deviceType from coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b on a.r_token=b.r_token where r_profileid = "Specific value"; ```
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
You need to put a `where` condition in your MYSql query. ``` select b.r_arn, a.r_deviceType from coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b on a.r_token=b.r_token where r_profileid = "Specific value"; ```
``` select b.r_arn, a.r_deviceType, a.r_profileid from r_profile_token a INNER JOIN r_token_arn b on a.r_token=b.r_token; ```
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
You can try this Query against your requirements. ``` SELECT b.r_arn, a.r_deviceType , a.r_profileid FROM r_profile_token a INNER JOIN r_token_arn b ON a.r_token=b.r_token where r_profileid='profile name'; ```
You need to put a `where` condition in your MYSql query. ``` select b.r_arn, a.r_deviceType from coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b on a.r_token=b.r_token where r_profileid = "Specific value"; ```
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
Use a `WHERE` clause. ``` SELECT B.R_ARN, A.R_DEVICETYPE FROM COFFEE2.R_PROFILE_TOKEN A INNER JOIN COFFEE2.R_TOKEN_ARN B ON A.R_TOKEN=B.R_TOKEN WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a single profileid, then use ``` WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a range of profileIds , then use ``` WHERE R_PROFILE_ID IN ('VALUE1','VALUE2','VALUE3'); ```
``` select b.r_arn, a.r_deviceType, a.r_profileid from r_profile_token a INNER JOIN r_token_arn b on a.r_token=b.r_token; ```
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
Use a `WHERE` clause. ``` SELECT B.R_ARN, A.R_DEVICETYPE FROM COFFEE2.R_PROFILE_TOKEN A INNER JOIN COFFEE2.R_TOKEN_ARN B ON A.R_TOKEN=B.R_TOKEN WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a single profileid, then use ``` WHERE R_PROFILEID = 'SOME_VALUE'; ``` If you want for a range of profileIds , then use ``` WHERE R_PROFILE_ID IN ('VALUE1','VALUE2','VALUE3'); ```
You can try this Query against your requirements. ``` SELECT b.r_arn, a.r_deviceType , a.r_profileid FROM r_profile_token a INNER JOIN r_token_arn b ON a.r_token=b.r_token where r_profileid='profile name'; ```
24,198,485
I have TABLE 1: `r_profile_token` Columns: ``` r_sequence int(45) AI PK r_profileid varchar(45) r_token varchar(300) r_deviceType int(1) r_date date r_time time ``` and TABLE 2: `r_token_arn` Columns: ``` r_token varchar(300) PK r_arn varchar(300) ``` I need a result of the form - ``` r_profileid r_arn r_deviceType ``` where I can specify the `r_profileid`. So far my SQL statement is: ``` SELECT b.r_arn, a.r_deviceType FROM coffee2.r_profile_token a INNER JOIN coffee2.r_token_arn b ON a.r_token=b.r_token; ``` Which returns `r_arn` and `r_deviceType` but for ***all*** r\_profileid? How do I modify the statement so that it returns me `r_arn` and `r_deviceType` only corresponding to a specific `r_profileid`?
2014/06/13
[ "https://Stackoverflow.com/questions/24198485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760915/" ]
You can try this Query against your requirements. ``` SELECT b.r_arn, a.r_deviceType , a.r_profileid FROM r_profile_token a INNER JOIN r_token_arn b ON a.r_token=b.r_token where r_profileid='profile name'; ```
``` select b.r_arn, a.r_deviceType, a.r_profileid from r_profile_token a INNER JOIN r_token_arn b on a.r_token=b.r_token; ```
34,623,259
Very similar to [How to prevent jquery to override "this"](https://stackoverflow.com/questions/11053932/how-to-prevent-jquery-to-override-this) but in ES6. This is my class: ``` class FeedbackForm { constructor(formEl) { this.$form = $(formEl) this.$form.submit(this.sendStuff) this.alerts = $('#something'); } /** * Sends the feedback * @param {Event} e */ sendStuff(e) { e.preventDefault() if (this.alerts.length) { window.alert('Notice... stuff') } $.ajax({ type: this.$form.prop('method'), url: this.$form.prop('action'), data: this.$form.serialize() }).done(() => window.location.reload(true)) } } ``` The `sendStuff` method is the event handler of the form, and jQuery calls it using [`Function.prototype.apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) I believe. Therefore, `this` inside `sendStuff` is overwritten with the event target that jQuery applies and I can't access `this.alerts` or any other property methods. I'm not sure if I can apply the `var that = this` trick here or how do I work around this issue?
2016/01/05
[ "https://Stackoverflow.com/questions/34623259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404623/" ]
You can associate the `FeedbackForm` instance with the form element using a symbol. Then, inside the event listener, `this` or `e.currentTarget` will be the form element. Using the symbol you retrieve the `FeedbackForm` instance. ```js const myFeedbackForm = Symbol(); class FeedbackForm { constructor(formEl) { formEl[myFeedbackForm] = this; this.$form = $(formEl); this.$form.submit(this.sendStuff); this.alerts = $('#something'); } sendStuff(e) { e.preventDefault() if (this[myFeedbackForm].alerts.length) { window.alert('Notice... stuff') } } } new FeedbackForm(document.forms[0]).$form.submit(); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form></form> <div id="something"></div> ``` The limitation is that you can't associate the same form element with different `FeedbackForm` instances.
Try initializing a second sort of storage variable from outside of the scope of both functions inside the main one: ``` var that; class FeedbackForm { constructor(formEl) { this.$form = $(formEl) this.alerts = $('#something'); that = this; this.$form.submit(this.sendStuff) } /** * Sends the feedback * @param {Event} e */ sendStuff(e) { e.preventDefault() if (that.alerts.length) { window.alert('Notice... stuff') } $.ajax({ type: that.$form.prop('method'), url: that.$form.prop('action'), data: that.$form.serialize() }).done(() => window.location.reload(true)) } } ```
34,623,259
Very similar to [How to prevent jquery to override "this"](https://stackoverflow.com/questions/11053932/how-to-prevent-jquery-to-override-this) but in ES6. This is my class: ``` class FeedbackForm { constructor(formEl) { this.$form = $(formEl) this.$form.submit(this.sendStuff) this.alerts = $('#something'); } /** * Sends the feedback * @param {Event} e */ sendStuff(e) { e.preventDefault() if (this.alerts.length) { window.alert('Notice... stuff') } $.ajax({ type: this.$form.prop('method'), url: this.$form.prop('action'), data: this.$form.serialize() }).done(() => window.location.reload(true)) } } ``` The `sendStuff` method is the event handler of the form, and jQuery calls it using [`Function.prototype.apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) I believe. Therefore, `this` inside `sendStuff` is overwritten with the event target that jQuery applies and I can't access `this.alerts` or any other property methods. I'm not sure if I can apply the `var that = this` trick here or how do I work around this issue?
2016/01/05
[ "https://Stackoverflow.com/questions/34623259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404623/" ]
You can use an [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions): > > An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions **and lexically binds the this value** > > > This should do it: ``` this.$form.submit(e => this.sendStuff(e)); ```
Try initializing a second sort of storage variable from outside of the scope of both functions inside the main one: ``` var that; class FeedbackForm { constructor(formEl) { this.$form = $(formEl) this.alerts = $('#something'); that = this; this.$form.submit(this.sendStuff) } /** * Sends the feedback * @param {Event} e */ sendStuff(e) { e.preventDefault() if (that.alerts.length) { window.alert('Notice... stuff') } $.ajax({ type: that.$form.prop('method'), url: that.$form.prop('action'), data: that.$form.serialize() }).done(() => window.location.reload(true)) } } ```
34,623,259
Very similar to [How to prevent jquery to override "this"](https://stackoverflow.com/questions/11053932/how-to-prevent-jquery-to-override-this) but in ES6. This is my class: ``` class FeedbackForm { constructor(formEl) { this.$form = $(formEl) this.$form.submit(this.sendStuff) this.alerts = $('#something'); } /** * Sends the feedback * @param {Event} e */ sendStuff(e) { e.preventDefault() if (this.alerts.length) { window.alert('Notice... stuff') } $.ajax({ type: this.$form.prop('method'), url: this.$form.prop('action'), data: this.$form.serialize() }).done(() => window.location.reload(true)) } } ``` The `sendStuff` method is the event handler of the form, and jQuery calls it using [`Function.prototype.apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) I believe. Therefore, `this` inside `sendStuff` is overwritten with the event target that jQuery applies and I can't access `this.alerts` or any other property methods. I'm not sure if I can apply the `var that = this` trick here or how do I work around this issue?
2016/01/05
[ "https://Stackoverflow.com/questions/34623259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404623/" ]
You can use an [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions): > > An arrow function expression (also known as fat arrow function) has a shorter syntax compared to function expressions **and lexically binds the this value** > > > This should do it: ``` this.$form.submit(e => this.sendStuff(e)); ```
You can associate the `FeedbackForm` instance with the form element using a symbol. Then, inside the event listener, `this` or `e.currentTarget` will be the form element. Using the symbol you retrieve the `FeedbackForm` instance. ```js const myFeedbackForm = Symbol(); class FeedbackForm { constructor(formEl) { formEl[myFeedbackForm] = this; this.$form = $(formEl); this.$form.submit(this.sendStuff); this.alerts = $('#something'); } sendStuff(e) { e.preventDefault() if (this[myFeedbackForm].alerts.length) { window.alert('Notice... stuff') } } } new FeedbackForm(document.forms[0]).$form.submit(); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form></form> <div id="something"></div> ``` The limitation is that you can't associate the same form element with different `FeedbackForm` instances.
42,644,261
I am trying to use rest api basic authentication and testing it through postman. On the authorization field, I used Type as Basic Auth and used the username and password in the field as in image below: [![enter image description here](https://i.stack.imgur.com/elB1G.png)](https://i.stack.imgur.com/elB1G.png) Then it automatically generates the following on Header : [![enter image description here](https://i.stack.imgur.com/vZ8I2.png)](https://i.stack.imgur.com/vZ8I2.png) So what I basically want is to print the value of Authorization i.e `Basic YWRtaW46YWRtaW4=` on my controller. Printing the username and password works fine with `print_r($this->input->server('PHP_AUTH_USER'))` and `print_r($this->input->server('PHP_AUTH_PW'))`. However I didn't find a way to print the value from header field. Is there any best practice to achieve this. Any help appreciated. Thank You !
2017/03/07
[ "https://Stackoverflow.com/questions/42644261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5182454/" ]
just copy paste this code and you get your output in this format ==> > > Basic YWRtaW46YWRtaW4= > > > ``` $token = $this->input->get_request_header('Authorization'); print_r($token); die; ```
What I understand is you want to print the value from the header. There is a way to print it to the console or to the Test tab. ``` var (name) = postman.getResponseHeader("value-you-want-to-print"); // to console console.log((name)); // to Test tests[(name)] = (name); ```
32,459,606
I have a few integer lists of different length of which I want to preserve the order. I will be using them as alternative to each other, never 2 at the same time. The number of lists might grow in the future, although I expect it never to reach a value like 50 or so. I might want to insert one value within this list. These lists are relatively seldom modified, and using a manual editor like MS SQL Server Management Studio for this purpose is fine. For what I can see in this moment, these lists will be rarely used to directly make queries, there will be some C# in between. For storing one ordered list, a linked (or double-linked) list seems appropriate. But if I have to store several ordered lists, it seems to me that I will have to add one table for each one of them. The same is valid if I use an indexed list. On the other hand, I could also store all these lists in one table transforming them in strings (one string per list) with values comma separated, that I would then parse in my C# program. In sql, what is the best way to store several ordered vectors/lists in sql?
2015/09/08
[ "https://Stackoverflow.com/questions/32459606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2436175/" ]
Relational databases like SQL Server typically don't have "arrays" or "lists" - if you need to store more than one value - they have **tables** for that. And no - it's in no way *cumbersome* for a database like SQL Server to have even **thousands** of tables - if you really must..... After all - handling tables is the **core competency** of a relational database ... it should be good at it! (and SQL Server is - and so are many other mature RDBMS systems, too). And I would ***strongly recommend*** not to use comma-separated strings - those first of all violate even the first normal form of database design, and as soon as you *do need* to join those values against something else - you're in trouble. Don't do this - there's absolutely no need for this, and you'll just make your developer life miserable sometime in the future - if you have the opportunity to avoid it - **don't do it!**
A kind of this? ``` ListId ItemOrder ItemValue 1 1 10 1 4 7 1 2 5 2 1 55 1 7 23 2 4 15 Select ItemValue FROM [Table] WHERE ListId = 1 Order By ItemOrder ``` Here Each list has an ID (you can use a clustered index here) and the order is given by the field ItemOrder
306,520
I was trying to get some insight into how to solve *non-linear regression* model problems. Unfortunately, I've never attended a lecture on statistical math. Here is the [link](http://hspm.sph.sc.edu/courses/J716/pdf/716-5%20Non-linear%20regression.pdf): In page number 4, they said, calculate the least square regression. I don't understand what they mean by that. I tried searching for it. Could you give me an insight for that.
2013/02/17
[ "https://math.stackexchange.com/questions/306520", "https://math.stackexchange.com", "https://math.stackexchange.com/users/62706/" ]
Hints: 1) Show the set $\,M:=\{r\in R\;\;;\;r\,\,\,\text{is not invertible}\}$ is an ideal in $\,R\,$ 2) Deduce $\,M\,$ is a maximal ideal (and, in fact, the *only* maximal ideal) of $\,R\,$ Your ring $\,R\,$ is what's called a [local ring](http://en.wikipedia.org/wiki/Local_ring) , a rather important class of rings in commutative algebra and some other mathematical realms. This is, apparently, what BenjaLim was aiming at in his comment, as local things appear as localizations wrt prime ideals in some rings...
**Hint** $\ $ Every prime $\rm\:p \ne 3\:$ becomes a unit in $\rm\,R\,$ since $\rm\:1/p\in R.\:$ But the prime $\rm\,p = 3\,$ is not a unit in $\rm\,R\,$ since $\rm\,1/3\not\in R.\:$ Hence $\rm\ (n) = (2^a 3^b 5^c\cdots) = (3^b)\:$ in $\rm\,R,\,$ and $\rm\,3\nmid 1\:\Rightarrow\:3^b\nmid 1.$
306,520
I was trying to get some insight into how to solve *non-linear regression* model problems. Unfortunately, I've never attended a lecture on statistical math. Here is the [link](http://hspm.sph.sc.edu/courses/J716/pdf/716-5%20Non-linear%20regression.pdf): In page number 4, they said, calculate the least square regression. I don't understand what they mean by that. I tried searching for it. Could you give me an insight for that.
2013/02/17
[ "https://math.stackexchange.com/questions/306520", "https://math.stackexchange.com", "https://math.stackexchange.com/users/62706/" ]
Hints: 1) Show the set $\,M:=\{r\in R\;\;;\;r\,\,\,\text{is not invertible}\}$ is an ideal in $\,R\,$ 2) Deduce $\,M\,$ is a maximal ideal (and, in fact, the *only* maximal ideal) of $\,R\,$ Your ring $\,R\,$ is what's called a [local ring](http://en.wikipedia.org/wiki/Local_ring) , a rather important class of rings in commutative algebra and some other mathematical realms. This is, apparently, what BenjaLim was aiming at in his comment, as local things appear as localizations wrt prime ideals in some rings...
Step 1: Let $I$ be an ideal in $R$. Show that $\mathfrak{i} = I \cap \mathbb{Z}$ is an ideal of $\mathbb{Z}$ and that $I = \{ \frac{i}{s} \ | \ i \in \mathfrak{i}, s \in \mathbb{Z}^+, \ 3 \nmid s \}$. Deduce that if $\mathfrak{i} = n \mathbb{Z}$, then $I = n R$. Thus all ideals of $R$ are principal and generated by elements of $\mathbb{Z}$. Step 2: Figure out for which $m,n \in \mathbb{Z}^+$ we have $m R = nR$. The answer given by Math Gems is relevant here. Remark: $\S 7.2$ of [these notes](http://alpha.math.uga.edu/%7Epete/integral.pdf) contains a more general discussion along these lines. It amounts to finding the ideals in a localization, as Benjalim mentioned.
306,520
I was trying to get some insight into how to solve *non-linear regression* model problems. Unfortunately, I've never attended a lecture on statistical math. Here is the [link](http://hspm.sph.sc.edu/courses/J716/pdf/716-5%20Non-linear%20regression.pdf): In page number 4, they said, calculate the least square regression. I don't understand what they mean by that. I tried searching for it. Could you give me an insight for that.
2013/02/17
[ "https://math.stackexchange.com/questions/306520", "https://math.stackexchange.com", "https://math.stackexchange.com/users/62706/" ]
Step 1: Let $I$ be an ideal in $R$. Show that $\mathfrak{i} = I \cap \mathbb{Z}$ is an ideal of $\mathbb{Z}$ and that $I = \{ \frac{i}{s} \ | \ i \in \mathfrak{i}, s \in \mathbb{Z}^+, \ 3 \nmid s \}$. Deduce that if $\mathfrak{i} = n \mathbb{Z}$, then $I = n R$. Thus all ideals of $R$ are principal and generated by elements of $\mathbb{Z}$. Step 2: Figure out for which $m,n \in \mathbb{Z}^+$ we have $m R = nR$. The answer given by Math Gems is relevant here. Remark: $\S 7.2$ of [these notes](http://alpha.math.uga.edu/%7Epete/integral.pdf) contains a more general discussion along these lines. It amounts to finding the ideals in a localization, as Benjalim mentioned.
**Hint** $\ $ Every prime $\rm\:p \ne 3\:$ becomes a unit in $\rm\,R\,$ since $\rm\:1/p\in R.\:$ But the prime $\rm\,p = 3\,$ is not a unit in $\rm\,R\,$ since $\rm\,1/3\not\in R.\:$ Hence $\rm\ (n) = (2^a 3^b 5^c\cdots) = (3^b)\:$ in $\rm\,R,\,$ and $\rm\,3\nmid 1\:\Rightarrow\:3^b\nmid 1.$
1,970,786
To find max/min of $(\sin p+\cos p)^{10}$. I have to find value of $p$ such that the expression is max/min. I tried to manipulate expression so as to get rid of at least $\sin$ or $\cos$. Then I can put what is left over equals to $1$ to get the maximum. But I'm unable to do that.
2016/10/16
[ "https://math.stackexchange.com/questions/1970786", "https://math.stackexchange.com", "https://math.stackexchange.com/users/261331/" ]
Hint: $$ \sin p+\cos p=\sqrt{2}\sin\left(p+\frac{\pi}{4}\right) $$
$(\sin p + \cos p)^{10} = (\sin^2 p + 2\sin p\cos p + \cos^2 p)^5 = (1+\sin 2p)^5$ Function $x\mapsto (1+x)^5$ is monotone increasing, thus, extremes of $(1+\sin 2p)^5$ are the same as extremes of $\sin 2p$.
1,970,786
To find max/min of $(\sin p+\cos p)^{10}$. I have to find value of $p$ such that the expression is max/min. I tried to manipulate expression so as to get rid of at least $\sin$ or $\cos$. Then I can put what is left over equals to $1$ to get the maximum. But I'm unable to do that.
2016/10/16
[ "https://math.stackexchange.com/questions/1970786", "https://math.stackexchange.com", "https://math.stackexchange.com/users/261331/" ]
Hint: $$ \sin p+\cos p=\sqrt{2}\sin\left(p+\frac{\pi}{4}\right) $$
Another way would be this \begin{aligned} (\sin p + \cos p)^{10} &= (\sin p + \cos p)^{2\times5}\\ &=(\sin^2p+\cos^2p+2\sin p\cos p)^5\\ &=(1+\sin{2p})^5 \end{aligned} Since $-1\leq \sin{2p}\leq 1$ then $$0\leq(1+\sin{2p})^5=(\sin p + \cos p)^{10}\leq32$$ where $p=-\pi/4$ and $p=\pi/4$ correspond to the minimum and maximum, respectively, though not unique.
43,995,848
I want to add tooltip for title and subtitle for `highcharts`. Here is my JS Fiddle [JSFiddle](https://jsfiddle.net/v9n67zvx/9)
2017/05/16
[ "https://Stackoverflow.com/questions/43995848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3937114/" ]
Highcharts does not have hooks for title/subtitle events. You need to set events for mouseover/mouseout, build the tooltip and toggle its visibility. on chart's load ``` var title = document.querySelector('.highcharts-title') var tooltip = document.createElement('span') tooltip.setAttribute('class', 'tooltip') tooltip.innerHTML = title.innerHTML this.container.appendChild(tooltip) title.onmouseover = function(e) { tooltip.style.left = e.clientX + 'px' tooltip.style.top = e.clientY + 'px' tooltip.style.visibility = 'visible' } title.onmouseout = function() { tooltip.style.visibility = 'hidden' } ``` css ``` .tooltip { visibility: hidden; position: absolute; background-color: black; text-align: center; color: #fff; padding: 5px; border-radius: 6px; } ``` example: <http://jsfiddle.net/ym85u1ja/> The sample applies for the subtitle - you can grab the element with `.highcharts.subtitle` class.
``` title: { text: 'example', useHTML: true, widthAdjust: -400 }, subtitle: { text: 'Example1', useHTML: true , widthAdjust: -400 }, ```
38,491,171
I am using a modified version of a query similiar to another question here:[Convert SQL Server query to MySQL](https://stackoverflow.com/questions/5522433/convert-sql-server-query-to-mysql/5522462#5522462) ``` Select * from ( SELECT tbl.*, @counter := @counter +1 counter FROM (select @counter:=0) initvar, tbl Where client_id = 55 ORDER BY ordcolumn ) X where counter >= (80/100 * @counter); ORDER BY ordcolumn ``` tbl.\* contains the field 'client\_id' and I am attempting to get the top 20% of the records for each client\_id in a single statement. Right now if I feed it a single client\_id in the where statement it gives me the correct results, however if I feed it multiple client\_id's it simply takes the top 20% of the combined recordset instead of doing each client\_id individually. I'm aware of how to do this in most databases, but the logic in MySQL is eluding me. I get the feeling it involves some ranking and partitioning. Sample data is pretty straight forward. ``` Client_id rate 1 1 1 2 1 3 (etc to rate = 100) 2 1 2 2 2 3 (etc to rate = 100) ``` Actual values aren't that clean, but it works. As an added bonus...there is also a date field associated to these records and 1 to 100 exists for this client for multiple dates. I need to grab the top 20% of records for each client\_id, year(date),month(date)
2016/07/20
[ "https://Stackoverflow.com/questions/38491171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/455582/" ]
You need to do the enumeration for each client: ``` SELECT * FROM (SELECT tbl.*, @counter := @counter +1 counter (@rn := if(@c = client_id, @rn + 1, if(@c := client_id, 1, 1) ) ) FROM (select @c := -1, @rn := 0) initvar CROSS JOIN tbl ORDER BY client_id, ordcolumn ) t cross join (SELECT client_id, COUNT(*) as cnt FROM tbl GROUP BY client_id ) tt where rn >= (80/100 * tt.cnt); ORDER BY ordcolumn; ```
Using Gordon's answer as a starting point, I think this might be closer to what you need. ``` SELECT t.* , (@counter := @counter+1) AS overallRow , (@clientRow := if(@prevClient = t.client_id, @clientRow + 1, if(@prevClient := t.client_id, 1, 1) -- This just updates @prevClient without creating an extra field, though it makes it a little harder to read ) ) AS clientRow -- Alteratively (for everything done in clientRow) , @clientRow := if(@prevClient = t.client_id, @clientRow + 1, 1) AS clientRow , @prevClient := t.client_id AS extraField -- This may be more reliable as well; I not sure if the order -- of evaluation of IF(,,) is reliable enough to guarantee -- no side effects in the non-"alternatively" clientRow calculation. FROM tbl AS t INNER JOIN ( SELECT client_id, COUNT(*) AS c FROM tbl GROUP BY client_id ) AS cc ON tbl.client_id = cc.client_id INNER JOIN (select @prevClient := -1, @clientRow := 0) AS initvar ON 1 = 1 WHERE t.client_id = 55 HAVING clientRow * 5 < cc.c -- You can use a HAVING without a GROUP BY in MySQL -- (note that clientRow is derived, so you cannot use it in the `WHERE`) ORDER BY t.client_id, t.ordcolumn ; ```
194,167
I have a list of Accounts (think possibly dozens or low hundreds) and some end user who wants to just click one button to have all the reports of a certain format generated for them instead of needing to navigate to a different webpage for each item to then click some "generate X" button. So, for example I have a list of Payments (Payments\_\_c), I want to make it so that my end user can say "I want all the payments to be generated as a PDF", then click on some "Generate PDFs" button, which will then produce all the PDFs without requiring they move to a new page (all the processing happens in the background?) Does anyone have any resources? Googling around seemed to lead me to batch sending of emails. I ask if it's possible because currently I have some leftover code from the last person who worked on the individual generation and what the person did was pull data from the fields of the current page the user is on. **What I've tried** I had an idea to create the page object, then pass in the arguments I want (hopefully making the page constructor get called) but unfortunately it seems that the page is only created upon visiting it so that method won't work
2017/10/01
[ "https://salesforce.stackexchange.com/questions/194167", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/49458/" ]
Printing pretty PDFs in Visualforce is a kind of art. Takes a while to produce something pleasant to look that will also behave OK. For example your single print of Account record might take 3 pages. If you bulk print several accounts - you don't want last one to display "*page 10 of 12, 11 of 12, 12 of 12*". You want the counter to reset, still say "*1,2,3*", as if the PDF wasn't collated (if that's the right word). Styling it (picking right font that works for non-English characters, page orientation, breaking tables not in a middle of the row so upper half of the words is on previous page...) takes some experience ;) You might want to read up on "Standard Set Controllers" (SSC)... What you see below might be an overkill for you, you might be able to do what you need without Apex controller, with pure SSC. Still - have a look around. **Class:** ``` // This class has several constructors. Can be used in single-record prints, mass prints (from StandardSetController) // or without any base object at all - in which case it'll try to read Ids from the URL. global with sharing class Stack194167 { global transient String id {get; set;} // One record Id or a semicolon-separated list of Ids to query for global transient List<Account> accounts; // StandardSetController's getSelected() result, passed when list view button is clicked transient Set<String> ids; // Paremeterless constructor. Needed so we can use this class as component controller in email template. global Stack194167(){ PageReference pr = ApexPages.currentPage(); if(pr != null){ id = pr.getParameters().get('id'); } } global Stack194167(ApexPages.StandardController sc){ this(); } global Stack194167(ApexPages.StandardSetController ssc){ this(); if(ssc != null){ accounts = ssc.getSelected(); } } global List<Account> getAccounts(){ if(ids != null && !ids.isEmpty()){ return null; } ids = accounts == null ? new Set<String>() : new Map<String, Account>(accounts).keyset().clone(); if(String.isNotBlank(id)){ ids.addAll(id.split('[\\,\\:;\\s]')); } System.debug(ids); accounts = [SELECT Id, Name, Description FROM Account WHERE Id IN :ids ORDER BY Name]; return accounts; } } ``` **Page** ``` <apex:page standardController="Account" extensions="Stack194167" recordSetVar="records" sidebar="false" showHeader="false" applyHtmlTag="false" standardStylesheets="false" readonly="true" renderAs="pdf"> <html> <head> <style type="text/css"> table { margin: 10px 0px 10px 0px; width:100%; table-layout: fixed; } tr { page-break-inside: avoid; /* Don't split tables if possible. But if it's needed - at least inject page breaks on table row border rather than in middle of the row's content. */ } table, td, th { border: 1px solid black; border-collapse: collapse; } td, th{ text-align:center; padding:40px; /* This is extreme, just to illustrate what should happen if it doesn't fit on one page*/ white-space: pre-line; /* Preserve line breaks in data from textareas exactly as they were entered. */ } .pageBreak { page-break-before: always; -fs-page-sequence: start; } @page { size: A4; @bottom-left { font-size: 8pt; content: "<apex:outputText value="{0, date, dd.MM.yyyy HH:mm:ss}"><apex:param value="{!NOW()}" /></apex:outputText>"; } @bottom-right { font-size: 8pt; content: counter(page) " of " counter(pages); } } </style> </head> <body> <apex:repeat value="{!accounts}" var="a"> <div class="account"> <table> <caption>{!a.Name}</caption> <thead> <tr><th>Field</th><th>Value</th></tr> </thead> <tbody> <tr><td>{!$ObjectType.Account.fields.Id.label}</td><td>{!a.Id}</td></tr> <tr><td>{!$ObjectType.Account.fields.Name.label}</td><td>{!a.Name}</td></tr> <tr><td>{!$ObjectType.Account.fields.Description.label}</td><td>{!a.Description}</td></tr> </tbody> </table> <table> <tr><td>Some other stupid table, just to pad the data a bit...</td></tr> <tr><td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</td></tr> </table> </div> <!-- Looks bit funny but it's easy way to start each order on fresh page and yet not have last page blank. --> <apex:outputPanel layout="block" styleClass="pageBreak" rendered="{!a.Id != accounts[accounts.size-1].Id}" /> </apex:repeat> </body> </html> </apex:page> ``` **Usage** * From Account listview button (make sure to have it display checkboxes) * From single record: `/apex/Stack194167?id=0017000000vXh3m` * Custom URL to I don't know, collate all children of one parent account? `/apex/Stack194167?id=0017000000vXh3m,0017000001TSmA8,0017000000Lg8WY,0017000000Lg8Wf`
I gather this is a Visualforce-based PDF template. Do you want the result PDFs to get attached to some record? Do you want them to be e-mailed? Do you want existing ones to get re-created/duplicated upon that action? Do you want them all to end up in the same PDF file, or separate? In any case it is possible. Depending on your answers to the questions it may have to be bulkified in some way or other.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
It is a bit complicated ... --------------------------- Java ***tries*** to use the default character encoding to return bytes using String.getBytes(). * The default charset is provided by the system file.encoding property. * This is cached and there is no use in changing it via the System.setProperty(..) after the JVM starts. * If the file.encoding property does not map to a known charset, then the UTF-8 is specified. .... Here is the tricky part (which is probably never going to come into play) .... If the system cannot decode or encode strings using the default charset (UTF-8 or another one), then there will be a fallback to ISO-8859-1. If the fallback does not work ... the system will fail! .... Really ... (gasp!) ... Could it crash if my specified charset cannot be used, and UTF-8 or ISO-8859-1 are also unusable? Yes. The Java source comments state in the StringCoding.encode(...) method: > > // If we can not find ISO-8859-1 (a required encoding) then things are seriously wrong with the installation. > > > ... and then it calls System.exit(1) --- So, why is there an intentional fallback to ISO-8859-1 in the getBytes() method? -------------------------------------------------------------------------------- It is possible, although not probable, that the users JVM may not support decoding and encoding in UTF-8 or the charset specified on JVM startup. Then, is the default charset used properly in the String class during getBytes()? No. However, the better question is ... --- Does String.getBytes() deliver what it promises? ------------------------------------------------ The contract as defined in the Javadoc is correct. > > The behavior of this method when this string cannot be encoded in the > default charset is unspecified. The `CharsetEncoder` class should be > used when more control over the encoding process is required. > > > --- The good news (and better way of doing things) ---------------------------------------------- It is always advised to explicitly specify "ISO-8859-1" or "US-ASCII" or "UTF-8" or whatever character set you want when converting bytes into Strings of vice-versa -- unless -- you have previously obtained the default charset and made 100% sure it is the one you need. Use this method instead: ``` public byte[] getBytes(String charsetName) ``` To find the default for your system, just use: ``` Charset.defaultCharset() ``` Hope that helps.
That's for compatibility reason. Historically, all java methods on Windows and Unix not specifying a charset were using the common one at the time, that is `"ISO-8859-1"`. As mentioned by Isaac and the javadoc, the default platform encoding is used (see [Charset.java](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/nio/charset/Charset.java#597)) : ``` 594 public static Charset defaultCharset() { 595 if (defaultCharset == null) { 596 synchronized (Charset.class) { 597 String csn = AccessController.doPrivileged( 598 new GetPropertyAction("file.encoding")); 599 Charset cs = lookup(csn); 600 if (cs != null) 601 defaultCharset = cs; 602 else 603 defaultCharset = forName("UTF-8"); 604 } 605 } 606 return defaultCharset; 607 } ``` **Always specify the charset when doing string to bytes or bytes to string conversion.** Even when, as is the case for `String.getBytes()` you still find a non deprecated method not taking the charset (most of them were deprecated when Java 1.1 appeared). Just like with endianness, the platform format is irrelevant, what is relevant is the norm of the storage format.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
The parameterless `String.getBytes()` method *doesn't* use ISO-8859-1 by default. It will use the default platform encoding, if that can be determined. If, however, that's either missing or is an unrecognized encoding, it falls back to ISO-8859-1 as a "default default". You should *very* rarely see this in practice. Normally the platform default encoding will be detected correctly. However, I'd strongly suggest that you specify an explicit character encoding every time you perform an encode or decode operation. Even if you want the platform default, specify that explicitly.
That's for compatibility reason. Historically, all java methods on Windows and Unix not specifying a charset were using the common one at the time, that is `"ISO-8859-1"`. As mentioned by Isaac and the javadoc, the default platform encoding is used (see [Charset.java](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/nio/charset/Charset.java#597)) : ``` 594 public static Charset defaultCharset() { 595 if (defaultCharset == null) { 596 synchronized (Charset.class) { 597 String csn = AccessController.doPrivileged( 598 new GetPropertyAction("file.encoding")); 599 Charset cs = lookup(csn); 600 if (cs != null) 601 defaultCharset = cs; 602 else 603 defaultCharset = forName("UTF-8"); 604 } 605 } 606 return defaultCharset; 607 } ``` **Always specify the charset when doing string to bytes or bytes to string conversion.** Even when, as is the case for `String.getBytes()` you still find a non deprecated method not taking the charset (most of them were deprecated when Java 1.1 appeared). Just like with endianness, the platform format is irrelevant, what is relevant is the norm of the storage format.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
That's for compatibility reason. Historically, all java methods on Windows and Unix not specifying a charset were using the common one at the time, that is `"ISO-8859-1"`. As mentioned by Isaac and the javadoc, the default platform encoding is used (see [Charset.java](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/nio/charset/Charset.java#597)) : ``` 594 public static Charset defaultCharset() { 595 if (defaultCharset == null) { 596 synchronized (Charset.class) { 597 String csn = AccessController.doPrivileged( 598 new GetPropertyAction("file.encoding")); 599 Charset cs = lookup(csn); 600 if (cs != null) 601 defaultCharset = cs; 602 else 603 defaultCharset = forName("UTF-8"); 604 } 605 } 606 return defaultCharset; 607 } ``` **Always specify the charset when doing string to bytes or bytes to string conversion.** Even when, as is the case for `String.getBytes()` you still find a non deprecated method not taking the charset (most of them were deprecated when Java 1.1 appeared). Just like with endianness, the platform format is irrelevant, what is relevant is the norm of the storage format.
Elaborate on Skeet's answer (which is of course the correct one) In [java.lang.String](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/String.java#993)'s source `getBytes()` calls `StringCoding.encode(char[] ca, int off, int len)` which has on its first line : ``` String csn = Charset.defaultCharset().name(); ``` Then (not immediately but absolutely) it calls `static byte[] StringEncoder.encode(String charsetName, char[] ca, int off, int len)` where the line you quoted comes from - passing as the charsetName the csn - so in this line the `charsetName` **will** be the default charset if one exists.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
It is a bit complicated ... --------------------------- Java ***tries*** to use the default character encoding to return bytes using String.getBytes(). * The default charset is provided by the system file.encoding property. * This is cached and there is no use in changing it via the System.setProperty(..) after the JVM starts. * If the file.encoding property does not map to a known charset, then the UTF-8 is specified. .... Here is the tricky part (which is probably never going to come into play) .... If the system cannot decode or encode strings using the default charset (UTF-8 or another one), then there will be a fallback to ISO-8859-1. If the fallback does not work ... the system will fail! .... Really ... (gasp!) ... Could it crash if my specified charset cannot be used, and UTF-8 or ISO-8859-1 are also unusable? Yes. The Java source comments state in the StringCoding.encode(...) method: > > // If we can not find ISO-8859-1 (a required encoding) then things are seriously wrong with the installation. > > > ... and then it calls System.exit(1) --- So, why is there an intentional fallback to ISO-8859-1 in the getBytes() method? -------------------------------------------------------------------------------- It is possible, although not probable, that the users JVM may not support decoding and encoding in UTF-8 or the charset specified on JVM startup. Then, is the default charset used properly in the String class during getBytes()? No. However, the better question is ... --- Does String.getBytes() deliver what it promises? ------------------------------------------------ The contract as defined in the Javadoc is correct. > > The behavior of this method when this string cannot be encoded in the > default charset is unspecified. The `CharsetEncoder` class should be > used when more control over the encoding process is required. > > > --- The good news (and better way of doing things) ---------------------------------------------- It is always advised to explicitly specify "ISO-8859-1" or "US-ASCII" or "UTF-8" or whatever character set you want when converting bytes into Strings of vice-versa -- unless -- you have previously obtained the default charset and made 100% sure it is the one you need. Use this method instead: ``` public byte[] getBytes(String charsetName) ``` To find the default for your system, just use: ``` Charset.defaultCharset() ``` Hope that helps.
The parameterless `String.getBytes()` method *doesn't* use ISO-8859-1 by default. It will use the default platform encoding, if that can be determined. If, however, that's either missing or is an unrecognized encoding, it falls back to ISO-8859-1 as a "default default". You should *very* rarely see this in practice. Normally the platform default encoding will be detected correctly. However, I'd strongly suggest that you specify an explicit character encoding every time you perform an encode or decode operation. Even if you want the platform default, specify that explicitly.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
It is a bit complicated ... --------------------------- Java ***tries*** to use the default character encoding to return bytes using String.getBytes(). * The default charset is provided by the system file.encoding property. * This is cached and there is no use in changing it via the System.setProperty(..) after the JVM starts. * If the file.encoding property does not map to a known charset, then the UTF-8 is specified. .... Here is the tricky part (which is probably never going to come into play) .... If the system cannot decode or encode strings using the default charset (UTF-8 or another one), then there will be a fallback to ISO-8859-1. If the fallback does not work ... the system will fail! .... Really ... (gasp!) ... Could it crash if my specified charset cannot be used, and UTF-8 or ISO-8859-1 are also unusable? Yes. The Java source comments state in the StringCoding.encode(...) method: > > // If we can not find ISO-8859-1 (a required encoding) then things are seriously wrong with the installation. > > > ... and then it calls System.exit(1) --- So, why is there an intentional fallback to ISO-8859-1 in the getBytes() method? -------------------------------------------------------------------------------- It is possible, although not probable, that the users JVM may not support decoding and encoding in UTF-8 or the charset specified on JVM startup. Then, is the default charset used properly in the String class during getBytes()? No. However, the better question is ... --- Does String.getBytes() deliver what it promises? ------------------------------------------------ The contract as defined in the Javadoc is correct. > > The behavior of this method when this string cannot be encoded in the > default charset is unspecified. The `CharsetEncoder` class should be > used when more control over the encoding process is required. > > > --- The good news (and better way of doing things) ---------------------------------------------- It is always advised to explicitly specify "ISO-8859-1" or "US-ASCII" or "UTF-8" or whatever character set you want when converting bytes into Strings of vice-versa -- unless -- you have previously obtained the default charset and made 100% sure it is the one you need. Use this method instead: ``` public byte[] getBytes(String charsetName) ``` To find the default for your system, just use: ``` Charset.defaultCharset() ``` Hope that helps.
Elaborate on Skeet's answer (which is of course the correct one) In [java.lang.String](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/String.java#993)'s source `getBytes()` calls `StringCoding.encode(char[] ca, int off, int len)` which has on its first line : ``` String csn = Charset.defaultCharset().name(); ``` Then (not immediately but absolutely) it calls `static byte[] StringEncoder.encode(String charsetName, char[] ca, int off, int len)` where the line you quoted comes from - passing as the charsetName the csn - so in this line the `charsetName` **will** be the default charset if one exists.
12,659,417
from java.lang.StringCoding : ``` String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; ``` This is what is used from Java.lang.getBytes() , in linux jdk 7 I was always under the impression that UTF-8 is the default charset ? Thanks
2012/09/30
[ "https://Stackoverflow.com/questions/12659417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190032/" ]
The parameterless `String.getBytes()` method *doesn't* use ISO-8859-1 by default. It will use the default platform encoding, if that can be determined. If, however, that's either missing or is an unrecognized encoding, it falls back to ISO-8859-1 as a "default default". You should *very* rarely see this in practice. Normally the platform default encoding will be detected correctly. However, I'd strongly suggest that you specify an explicit character encoding every time you perform an encode or decode operation. Even if you want the platform default, specify that explicitly.
Elaborate on Skeet's answer (which is of course the correct one) In [java.lang.String](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/String.java#993)'s source `getBytes()` calls `StringCoding.encode(char[] ca, int off, int len)` which has on its first line : ``` String csn = Charset.defaultCharset().name(); ``` Then (not immediately but absolutely) it calls `static byte[] StringEncoder.encode(String charsetName, char[] ca, int off, int len)` where the line you quoted comes from - passing as the charsetName the csn - so in this line the `charsetName` **will** be the default charset if one exists.
53,623,263
In oracle is it possible to join a static list to a table? The list I have is something like this ``` ID 1 2 3 4 5 6 ``` I don't want to create a table for this list But then I want to join the list to an existing table that has the ID's in it... hoping to do a left join with the list Is this possible?
2018/12/05
[ "https://Stackoverflow.com/questions/53623263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2206329/" ]
You are lookig for a `WITH` clause that contains `UNION`s of `SELECT FROM DUAL`. Like : ``` WITH my_list AS ( select 'A' my_value from dual UNION ALL select 'B' my_value from dual UNION ALL select 'C' my_value from dual ) SELECT * FROM my_list LEFT JOIN my_table ON my_table.my_field = my_list.my_value ; ```
You can generate the ID list in a CTE and then join it to whatever you want. ``` with id_list as ( select rownum as id from dual connect by level <= 6 ) select * from id_list; ID 1 2 3 4 5 6 ``` <https://livesql.oracle.com/apex/livesql/s/hm2mczgx5udiig9vhryo86mfm>
3,479,490
C# Visual Studio 2010 I am loading a complex html page into a webbrowser control. But, I don't have the ability to modify the webpage. I want to click a link on the page automatically from the windows form. But, the ID appears to be randomly generated each time the page is loaded (so I believe referencing the ID will not work). This is the content of the a href link: ``` <a ``` `id="u_lp_id_58547" href="javascript:void(0)" class="SGLeftPanelText" onclick="setStoreParams('cases;212', 212); window.leftpanel.onClick('cases_ss_733');return false; ">` ``` My Assigned</a> ``` Is the anyway to click the link from C#? Thanks! --- **UPDATE:** I feel like this is close but it is just not working: ``` HtmlElementCollection links = helpdeskWebBrowser.Document.Window.Frames["main_pending_events_frame"].Document.GetElementsByTagName("a"); MessageBox.Show(links.Count.ToString()); ``` I have tried plugging in every single frame name and tried both "a" and "A" in the TagName field but just have not had any luck. I can just not find any links; the message box is always 0. What am I missing?
2010/08/13
[ "https://Stackoverflow.com/questions/3479490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419038/" ]
Something like this should work: ``` HtmlElement link = webBrowser.Document.GetElementByID("u_lp_id_58547") link.InvokeMember("Click") ``` EDIT: Since the IDs are generated randomly, another option may be to identify the links by their `InnerText`; along these lines. ``` HtmlElementCollection links = webBrowser.Document.GetElementsByTagName("A"); foreach (HtmlElement link in links) { if (link.InnerText.Equals("My Assigned")) link.InvokeMember("Click"); } ``` **UPDATE:** You can get the links within an IFrame using: ``` webBrowser.Document.Window.Frames["MyIFrame"].Document.GetElementsByTagName("A"); ```
Perhaps you will have to isolate the link ID value using more of the surrounding HTML context as a "target" and then extract the new random ID. In the past I have used the "[HtmlAgilityPack](http://htmlagilitypack.codeplex.com/)" to easily parse "screen-scraped" HTML to isolate areas of interest within a page - this library seems to be easy to use and reliable.
34,933
I want to use `<S-Tab>` to do the reverse of `<Tab>` in insert mode in Lua. (If this is complicated in Lua then VimScript is OK) How?
2021/11/09
[ "https://vi.stackexchange.com/questions/34933", "https://vi.stackexchange.com", "https://vi.stackexchange.com/users/10189/" ]
Is `<C-d>` what you want? `:h i_CTRL-D` ``` *i_CTRL-D* CTRL-D Delete one shiftwidth of indent at the start of the current line. The indent is always rounded to a 'shiftwidth' (this is vi compatible). ``` If so ``` inoremap <S-Tab> <C-d> ```
``` vim.api.nvim_set_keymap('i', '<S-Tab>', "v:lua.check_back_space() ? '<BS>' : '<NOP>'", EXPR_NOREF_NOERR_TRUNC) ``` where `EXPR_...` is ``` local EXPR_NOREF_NOERR_TRUNC = { expr = true, noremap = true, silent = true, nowait = true } ``` and `check_back_space` can be implemented easily.
55,452,576
I am trying to make a horizontal "navigation bar" of some sort, and can't figure out how to center the table I'm using. Is the table the right way to do it and if so, how would I go about centering it properly? This is my CSS ```css table.topbar { width: 100%; height: 100px; background-color: #efc700; margin: 0 auto; text-align: center; } a.topbar { font-family: Oswald; font-size: 40px; margin: 0 auto; } ``` And this is my HTML ```html <!DOCTYPE html> <html> <head> <title>Week One</title> <link href="./style_home.css" type="text/css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Baloo+Chettan|Montserrat|Oswald|ZCOOL+XiaoWei" rel="stylesheet"> </head> <body> <div class="topbar"> <table class="topbar"> <tr> <td><a class="topbar">Home</a></td> <td><a class="topbar">About</a></td> <td><a class="topbar">Contact</a></td> </tr> </table> </div> </body> </html> ``` [Image of the result (It's not centered properly)](https://i.stack.imgur.com/J6xJg.png)
2019/04/01
[ "https://Stackoverflow.com/questions/55452576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11290639/" ]
Use flexbox ```css nav { display: flex; justify-content: space-between; } ``` ```html <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> ```
You can use [Bootstrap](https://getbootstrap.com/) library. There are lots of table templates are given. You can use one of them. I also put code on fiddle you check link below. Hope it will help. ``` [2]: https://jsfiddle.net/anshulsharma989/ykw0mj93/1/ ``` **Edit: Core HTML and CSS implementation.** **HTML CODE:** ``` <html> <body> <div class="container"> <table class="table"> <thead> <tr> <th>#</th> <th>First</th> <th>Last</th> <th>Handle</th> </tr> </thead> <tbody> <tr> <th>1</th> <td>Mark</td> <td>Otto</td> <td>@mdo</td> </tr> <tr> <th>2</th> <td>Jacob</td> <td>Thornton</td> <td>@fat</td> </tr> <tr> <th>3</th> <td>Larry</td> <td>the Bird</td> <td>@twitter</td> </tr> </tbody> </table> </body> ``` **CSS CODE:** ``` .container { width: 100%; } .table { border: 1px solid; border-radius: 5px; width: 60%; margin: 0px auto; float: none; } ```
55,452,576
I am trying to make a horizontal "navigation bar" of some sort, and can't figure out how to center the table I'm using. Is the table the right way to do it and if so, how would I go about centering it properly? This is my CSS ```css table.topbar { width: 100%; height: 100px; background-color: #efc700; margin: 0 auto; text-align: center; } a.topbar { font-family: Oswald; font-size: 40px; margin: 0 auto; } ``` And this is my HTML ```html <!DOCTYPE html> <html> <head> <title>Week One</title> <link href="./style_home.css" type="text/css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Baloo+Chettan|Montserrat|Oswald|ZCOOL+XiaoWei" rel="stylesheet"> </head> <body> <div class="topbar"> <table class="topbar"> <tr> <td><a class="topbar">Home</a></td> <td><a class="topbar">About</a></td> <td><a class="topbar">Contact</a></td> </tr> </table> </div> </body> </html> ``` [Image of the result (It's not centered properly)](https://i.stack.imgur.com/J6xJg.png)
2019/04/01
[ "https://Stackoverflow.com/questions/55452576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11290639/" ]
Use flexbox ```css nav { display: flex; justify-content: space-between; } ``` ```html <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> ```
Mmm... you can use unordered list with css too . Here's an example: ```html <!DOCTYPE html> <html> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float:left; width: 33.3%; } li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover { background-color: #111; } </style> </head> <body> <ul> <li><a href="#home">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> </body> </html> ```
55,452,576
I am trying to make a horizontal "navigation bar" of some sort, and can't figure out how to center the table I'm using. Is the table the right way to do it and if so, how would I go about centering it properly? This is my CSS ```css table.topbar { width: 100%; height: 100px; background-color: #efc700; margin: 0 auto; text-align: center; } a.topbar { font-family: Oswald; font-size: 40px; margin: 0 auto; } ``` And this is my HTML ```html <!DOCTYPE html> <html> <head> <title>Week One</title> <link href="./style_home.css" type="text/css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Baloo+Chettan|Montserrat|Oswald|ZCOOL+XiaoWei" rel="stylesheet"> </head> <body> <div class="topbar"> <table class="topbar"> <tr> <td><a class="topbar">Home</a></td> <td><a class="topbar">About</a></td> <td><a class="topbar">Contact</a></td> </tr> </table> </div> </body> </html> ``` [Image of the result (It's not centered properly)](https://i.stack.imgur.com/J6xJg.png)
2019/04/01
[ "https://Stackoverflow.com/questions/55452576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11290639/" ]
Use flexbox ```css nav { display: flex; justify-content: space-between; } ``` ```html <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> ```
Make it simple by using `Flex` just add below **CSS** will resolve your issue. Thanks ``` tr { display: flex; align-items: center; height: 100%; justify-content: space-around; } ```
11,493,590
I use jQuery ajax to refresh a div every 2 seconds. How to stop this refresh after 60 seconds (example, if user is inactive) ? ``` setInterval(function() { $.ajax({ url: "feeds.php", cache: false }).done(function( html ) { $('#feeds').replaceWith('<div id="feeds">'+html+'</div>'); }); }, 2000); ``` Thank you !
2012/07/15
[ "https://Stackoverflow.com/questions/11493590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1527134/" ]
Assign the setInterval handle to a variable, which you will use to clear it after 60 seconds. ``` var interval = setInterval(function(){ ... }, 2000); // start a 60 second timer setTimeout(function(){ window.clearInterval(interval); }, 60000); ```
Not so hard. ``` var myInterval = setInterval(function(){},2000); setTimeout(function() { clearInterval( myInterval ); } ``` I'm not sure if this has leaks.
11,493,590
I use jQuery ajax to refresh a div every 2 seconds. How to stop this refresh after 60 seconds (example, if user is inactive) ? ``` setInterval(function() { $.ajax({ url: "feeds.php", cache: false }).done(function( html ) { $('#feeds').replaceWith('<div id="feeds">'+html+'</div>'); }); }, 2000); ``` Thank you !
2012/07/15
[ "https://Stackoverflow.com/questions/11493590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1527134/" ]
Assign the setInterval handle to a variable, which you will use to clear it after 60 seconds. ``` var interval = setInterval(function(){ ... }, 2000); // start a 60 second timer setTimeout(function(){ window.clearInterval(interval); }, 60000); ```
``` //store the ajax call into a variable var chr = $.ajax({ .....} //use setTimeout to invoke its abort() method after 1000 ms (1 second) setTimeout(function(){ chr.abort() }, 1000); ```
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
The `@` in front of a string literal makes it a [*verbatim string literal*](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx), so the backslash `\` does not need to be doubled. You can use `"\\"` instead of `@"\"` for the same effect.
Because if you didn't, you'd have to escape `\` with `\\` `@` is used to what's called [verbatim strings](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx)
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
Because if you didn't, you'd have to escape `\` with `\\` `@` is used to what's called [verbatim strings](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx)
Because the backslash is treated as an escape character and you would get an 'Unrecognised escape sequence' error if you didn't use '@'. Using '@' tells the compiler to ignore escape characters. [this](http://www.c-sharpcorner.com/uploadfile/hirendra_singh/verbatim-strings-in-C-Sharp-use-of-symbol-in-string-literals/) may be helpful.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
Because if you didn't, you'd have to escape `\` with `\\` `@` is used to what's called [verbatim strings](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx)
The [C# Language Specification](http://go.microsoft.com/fwlink/?LinkId=199552) 2.4.4.5 String literals states: > > C# supports two forms of string literals: regular string literals and > verbatim string literals. > > > A regular string literal consists of zero or more characters enclosed > in double quotes, as in "hello", and may include both simple escape > sequences (such as \t for the tab character), and hexadecimal and > Unicode escape sequences. > > > A verbatim string literal consists of an @ character followed by a > double-quote character, zero or more characters, and a closing > double-quote character. A simple example is @"hello". In a verbatim > string literal, the characters between the delimiters are interpreted > verbatim, the only exception being a quote-escape-sequence. In > particular, simple escape sequences, and hexadecimal and Unicode > escape sequences are not processed in verbatim string literals. A > verbatim string literal may span multiple lines. > > > The verbatim string literal, which uses the `@` character, makes it a little easier in practicality to escape almost all the characters that you would otherwise have to escape individually with the `\` character in a string. Note: the `"` char will still require escaping even with the verbatim mode. So I would use it to save time from having to go through a long string to escape all the necessary characters that needed escaping.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
The `@` in front of a string literal makes it a [*verbatim string literal*](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx), so the backslash `\` does not need to be doubled. You can use `"\\"` instead of `@"\"` for the same effect.
In C#, you can prefix a string with `@` to make it verbatim, so you don't need to escape special characters. ``` @"\" ``` is identical to ``` "\\" ```
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
The `@` in front of a string literal makes it a [*verbatim string literal*](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx), so the backslash `\` does not need to be doubled. You can use `"\\"` instead of `@"\"` for the same effect.
Because the backslash is treated as an escape character and you would get an 'Unrecognised escape sequence' error if you didn't use '@'. Using '@' tells the compiler to ignore escape characters. [this](http://www.c-sharpcorner.com/uploadfile/hirendra_singh/verbatim-strings-in-C-Sharp-use-of-symbol-in-string-literals/) may be helpful.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
The `@` in front of a string literal makes it a [*verbatim string literal*](http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx), so the backslash `\` does not need to be doubled. You can use `"\\"` instead of `@"\"` for the same effect.
The [C# Language Specification](http://go.microsoft.com/fwlink/?LinkId=199552) 2.4.4.5 String literals states: > > C# supports two forms of string literals: regular string literals and > verbatim string literals. > > > A regular string literal consists of zero or more characters enclosed > in double quotes, as in "hello", and may include both simple escape > sequences (such as \t for the tab character), and hexadecimal and > Unicode escape sequences. > > > A verbatim string literal consists of an @ character followed by a > double-quote character, zero or more characters, and a closing > double-quote character. A simple example is @"hello". In a verbatim > string literal, the characters between the delimiters are interpreted > verbatim, the only exception being a quote-escape-sequence. In > particular, simple escape sequences, and hexadecimal and Unicode > escape sequences are not processed in verbatim string literals. A > verbatim string literal may span multiple lines. > > > The verbatim string literal, which uses the `@` character, makes it a little easier in practicality to escape almost all the characters that you would otherwise have to escape individually with the `\` character in a string. Note: the `"` char will still require escaping even with the verbatim mode. So I would use it to save time from having to go through a long string to escape all the necessary characters that needed escaping.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
In C#, you can prefix a string with `@` to make it verbatim, so you don't need to escape special characters. ``` @"\" ``` is identical to ``` "\\" ```
Because the backslash is treated as an escape character and you would get an 'Unrecognised escape sequence' error if you didn't use '@'. Using '@' tells the compiler to ignore escape characters. [this](http://www.c-sharpcorner.com/uploadfile/hirendra_singh/verbatim-strings-in-C-Sharp-use-of-symbol-in-string-literals/) may be helpful.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
In C#, you can prefix a string with `@` to make it verbatim, so you don't need to escape special characters. ``` @"\" ``` is identical to ``` "\\" ```
The [C# Language Specification](http://go.microsoft.com/fwlink/?LinkId=199552) 2.4.4.5 String literals states: > > C# supports two forms of string literals: regular string literals and > verbatim string literals. > > > A regular string literal consists of zero or more characters enclosed > in double quotes, as in "hello", and may include both simple escape > sequences (such as \t for the tab character), and hexadecimal and > Unicode escape sequences. > > > A verbatim string literal consists of an @ character followed by a > double-quote character, zero or more characters, and a closing > double-quote character. A simple example is @"hello". In a verbatim > string literal, the characters between the delimiters are interpreted > verbatim, the only exception being a quote-escape-sequence. In > particular, simple escape sequences, and hexadecimal and Unicode > escape sequences are not processed in verbatim string literals. A > verbatim string literal may span multiple lines. > > > The verbatim string literal, which uses the `@` character, makes it a little easier in practicality to escape almost all the characters that you would otherwise have to escape individually with the `\` character in a string. Note: the `"` char will still require escaping even with the verbatim mode. So I would use it to save time from having to go through a long string to escape all the necessary characters that needed escaping.
12,249,437
> > **Possible Duplicate:** > > [What's the @ in front of a string in C#?](https://stackoverflow.com/questions/556133/whats-the-in-front-of-a-string-in-c) > > > why do we use `@` to replace `\` with another string using `string.replace(@"\","$$")` i'm using `C#` windows application
2012/09/03
[ "https://Stackoverflow.com/questions/12249437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426157/" ]
The [C# Language Specification](http://go.microsoft.com/fwlink/?LinkId=199552) 2.4.4.5 String literals states: > > C# supports two forms of string literals: regular string literals and > verbatim string literals. > > > A regular string literal consists of zero or more characters enclosed > in double quotes, as in "hello", and may include both simple escape > sequences (such as \t for the tab character), and hexadecimal and > Unicode escape sequences. > > > A verbatim string literal consists of an @ character followed by a > double-quote character, zero or more characters, and a closing > double-quote character. A simple example is @"hello". In a verbatim > string literal, the characters between the delimiters are interpreted > verbatim, the only exception being a quote-escape-sequence. In > particular, simple escape sequences, and hexadecimal and Unicode > escape sequences are not processed in verbatim string literals. A > verbatim string literal may span multiple lines. > > > The verbatim string literal, which uses the `@` character, makes it a little easier in practicality to escape almost all the characters that you would otherwise have to escape individually with the `\` character in a string. Note: the `"` char will still require escaping even with the verbatim mode. So I would use it to save time from having to go through a long string to escape all the necessary characters that needed escaping.
Because the backslash is treated as an escape character and you would get an 'Unrecognised escape sequence' error if you didn't use '@'. Using '@' tells the compiler to ignore escape characters. [this](http://www.c-sharpcorner.com/uploadfile/hirendra_singh/verbatim-strings-in-C-Sharp-use-of-symbol-in-string-literals/) may be helpful.
34,460,820
I've got several divs stacked up using ng-repeat. I'm using ng-leave to slide a div up when it is deleted. What I'd like is for all of the divs below the deleted one to slide up with the deleted one, so there is never any empty space. As I have it, the deleted div leaves an empty space where it was during the 1s transition, then the divs underneath all immediately move up. **FIDDLE:** <https://jsfiddle.net/c1huchuz/6/> **HTML:** ``` <body ng-app="myApp" ng-controller="myController"> <button ng-click="add_div()">Add Div</button><br/><br/> <div ng-repeat="x in random_array" class="slide"> {{$index}} <button ng-click="remove_div($index)">Delete</button> </div> </body> ``` **JS:** ``` var app = angular.module("myApp", ['ngAnimate']); app.controller("myController", ["$scope", function($scope) { $scope.random_array = [] $scope.add_div = function() { var i = $scope.random_array.length $scope.random_array.push(i) } $scope.remove_div = function(index) { $scope.random_array.splice(index, 1) } }]); ``` **CSS:** ``` div { position: relative; width: 90px; height: 30px; background-color: orange; border: 1px solid black; } .slide.ng-enter, .slide.ng-leave { transition: all 1s; } .slide.ng-enter, .slide.ng-leave.ng-leave-active { top: -30px; z-index: -1; } .slide.ng-enter.ng-enter-active, .slide.ng-leave { top: 0px; z-index: -1; } ``` I tried using the following ng-move to slide up all the divs whose indices change, but it doesn't have any effect. ``` .slide.ng-move { transition: all 1s; top: 0px; } .slide.ng-move.ng-move-active { top: -31px; } ```
2015/12/25
[ "https://Stackoverflow.com/questions/34460820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5585657/" ]
With Git 2.20 Q4 2018), [`git submodule`](https://git-scm.com/docs/git-submodule) will be notably *faster* because "`git submodule update`" is getting rewritten piece-by-piece into C. See [commit ee69b2a](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac), [commit 74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (13 Aug 2018), and [commit c94d9dc](https://github.com/git/git/commit/c94d9dc286027e0343ffd58b5f7f2899691f6747), [commit f1d1571](https://github.com/git/git/commit/f1d15713faef54c0bcc5d35c9089efffa4c914a1), [commit 90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b), [commit 9eca701](https://github.com/git/git/commit/9eca701f69b1dfb857a0445ba8a78e2445e9aa2b), [commit ff03d93](https://github.com/git/git/commit/ff03d9306c7dbc2011c0a6660359d9074e4a3ab3) (03 Aug 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4d6d6ef](https://github.com/git/git/commit/4d6d6ef1fcce0e7d1fd2d3d38c2372998a105e96), 17 Sep 2018) --- Git 2.21 actually fixes a regression, since "`git submodule update`" ought to use a single job unless asked, but by mistake used multiple jobs, which has been fixed. See [commit e3a9d1a](https://github.com/git/git/commit/e3a9d1aca92d90f2fdfbefd29827f7d7d210947e) (13 Dec 2018) by [Junio C Hamano (`gitster`)](https://github.com/gitster). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4744d03](https://github.com/git/git/commit/4744d03a47d668e0e2ea45a637fd16d782e035b9), 18 Jan 2019) > > `submodule update`: run at most one fetch job unless otherwise set > ------------------------------------------------------------------ > > > In [a028a19](https://github.com/git/git/commit/a028a1930c6b4b848e8fb47cc92c30b23d99a75e) (fetching submodules: respect `submodule.fetchJobs` config option, 2016-02-29, Git v2.9.0-rc0), we made sure to keep the default behavior of fetching at most one submodule at once when not setting the newly introduced `submodule.fetchJobs` config. > > > This regressed in [90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b) (builtin/submodule--helper: factor out submodule updating, 2018-08-03, Git v2.20.0-rc0). Fix it. > > > --- And Git 2.21 fixes the `core.worktree` setting in a submodule repository, which should not be pointing at a directory when the submodule loses its working tree (e.g. getting deinit'ed), but the code did not properly maintain this invariant. See [commit 8eda5ef](https://github.com/git/git/commit/8eda5efa1269a6117b86a97a309eb3a195b5f087), [commit 820a647](https://github.com/git/git/commit/820a647e67ad21ecb1d23b2154c44ad13e794443), [commit 898c2e6](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93), [commit 98bf667](https://github.com/git/git/commit/98bf66748967a98b65a827d1d2021be98d550174) (14 Dec 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 3942920](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7), 18 Jan 2019) > > `submodule deinit`: unset `core.worktree` > ----------------------------------------- > > > When a submodule is deinit'd, the working tree is gone, so the setting of `core.worktree` is bogus. > > Unset it. > > As we covered the only other case in which a submodule loses its working tree in the earlier step (i.e. switching branches of top-level project to move to a commit that did not have the submodule), this makes the code always maintain `core.worktree` correctly unset when there is no working tree for a submodule. > > > This re-introduces [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) (`submodule deinit`: `unset core.worktree`, 2018-06-18, Git v2.19.0-rc0), which was reverted as part of [f178c13](https://github.com/git/git/commit/f178c13fdac42763a7aa58bf260aa67d9f4393ec) (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07, Git v2.19.0) > > > The whole series was reverted as the offending [commit e983175](https://github.com/git/git/commit/e98317508c02b7cc65bf5b28f27788e47096b166) (`submodule`: ensure `core.worktree` is set after update, 2018-06-18, Git v2.19.0-rc0) was relied on by other commits such as [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d). > > > Keep the offending commit reverted, but its functionality came back via 4d6d6ef (Merge branch 'sb/submodule-update-in-c', 2018-09-17), such that we can reintroduce [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) now. > > > --- Git 2.21 also includes "`git submodule update`" learning to abort early when `core.worktree` for the submodule is not set correctly to prevent spreading damage. See [commit 5d124f4](https://github.com/git/git/commit/5d124f419d1e9b7d22fae915627de7e463bf7c42) (18 Jan 2019) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit e524e44](https://github.com/git/git/commit/e524e44ecad731352102e85226daef61268494c6), 07 Feb 2019) > > `git-submodule`: abort if `core.worktree` could not be set correctly > > > [74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (`submodule--helper`: replace `connect-gitdir-workingtree` by > `ensure-core-worktree`, 2018-08-13, Git 2.20) forgot to exit the submodule operation if the helper could not ensure that `core.worktree` is set correctly. > > > --- Warning: CVE-2019-1387: Recursive clones are currently affected by a vulnerability that is caused by too-lax validation of submodule names, allowing very targeted attacks via remote code execution in recursive clones. Fixed in Git 2.24.1, 2.23.1, 2.22.2, 2.21.1, 2.20.2. 2.19.3, 2.18.2, 2.17.3, 2.16.6, 2.15.4 and 2.14.6 In conjunction with a vulnerability that was fixed in v2.20.2, `.gitmodules` is no longer allowed to contain entries of the form `submodule.<name>.update=!command`. > > [`submodule`](https://github.com/git/git/commit/e904deb89d9a9669a76a426182506a084d3f6308): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------------ > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), Git has been careful to avoid copying: > > > > ``` > [submodule "foo"] > update = !run an arbitrary scary command > > ``` > > from `.gitmodules` to a repository's local config, copying in the setting '`update = none`' instead. > > > The [gitmodules(5) manpage](https://git-scm.com/docs/gitmodules) documents the intention: > > > The `!command` form is intentionally ignored here for security reasons > > > Unfortunately, starting with v2.20.0-rc0 (which integrated [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac) (submodule--helper: introduce new update-module-mode helper, 2018-08-13, first released in v2.20.0-rc0)), there are scenarios where we *don't* ignore it: if the config store contains no `submodule.foo.update` setting, the submodule-config API falls back to reading `.gitmodules` and the repository-supplied `!command` gets run after all. > > > This was part of a general change over time in submodule support to read more directly from `.gitmodules`, since unlike `.git/config` it allows a project to change values between branches and over time (while still allowing `.git/config` to override things). > > > But it was never intended to apply to this kind of dangerous configuration. > > > The behavior change was not advertised in [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac)'s commit message and was missed in review. > > > Let's take the opportunity to make the protection more robust, even in Git versions that are technically not affected: instead of quietly converting 'update = !command' to 'update = none', noisily treat it as an error. > > > Allowing the setting but treating it as meaning something else was just confusing; users are better served by seeing the error sooner. > > > Forbidding the construct makes the semantics simpler and means we can check for it in `fsck` (in a separate patch, see below). > > > As a result, the submodule-config API cannot read this value from `.gitmodules` under any circumstance, and we can declare with confidence > > > For security reasons, the '`!command`' form is not accepted here. > > > And: > > [`fsck`](https://github.com/git/git/commit/bb92255ebe6bccd76227e023d6d0bc997e318ad0): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------- > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > This allows hosting providers to detect whether they are being used to attack users using malicious '`update = !command`' settings in `.gitmodules`. > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), in normal cases such settings have been treated as '`update = none`', so forbidding them should not produce any collateral damage to legitimate uses. > > > A quick search does not reveal any repositories making use of this construct, either. > > > And: > > [`submodule`](https://github.com/git/git/commit/c1547450748fcbac21675f2681506d2d80351a19): defend against `submodule.update = !command` in `.gitmodules` > -------------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > In v2.15.4, we started to reject `submodule.update` settings in `.gitmodules`. Let's raise a BUG if it somehow still made it through from anywhere but the Git config. > > > --- The "`--recurse-submodules`" option of various subcommands did not work well when run in an alternate worktree, which has been corrected with Git 2.25.2 (March 2020). See [commit a9472af](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704), [commit 129510a](https://github.com/git/git/commit/129510a0672a7f9fd6c1a2d1d6fa36a17ffb6d1c), [commit 4eaadc8](https://github.com/git/git/commit/4eaadc8493704357a4fac8d7dc8207340aa79019), [commit 773c60a](https://github.com/git/git/commit/773c60a45e01f1e6631afe1cce9da3ed67d37a3a) (21 Jan 2020) by [Philippe Blain (`phil-blain`)](https://github.com/phil-blain). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit ff5134b](https://github.com/git/git/commit/ff5134b2fffe202fb48498f15d6e47673f9bd6b2), 05 Feb 2020) > > [`submodule.c`](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704): use `get_git_dir()` instead of `get_git_common_dir()` > -------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Philippe Blain > > > Ever since [df56607dff](https://github.com/git/git/commit/df56607dff2d656043a1f77a647f97a0a6b5aec9) (`git-common-dir`: make "modules/" per-working-directory directory, 2014-11-30, Git v2.5.0-rc0), submodules in linked worktrees are cloned to `$GIT_DIR/modules,` i.e. `$GIT_COMMON_DIR/worktrees/<name>/modules`. > > > However, this convention was not followed when the worktree updater commands checkout, reset and read-tree learned to recurse into submodules. > > Specifically, [`submodule.c::submodule_move_head`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), introduced in [6e3c1595c6](https://github.com/git/git/commit/6e3c1595c66e2b192a2a516447c5645814766339) (`update submodules`: add `submodule_move_head,` 2017-03-14, Git v2.13.0-rc0) and [`submodule.c::submodule_unset_core_worktree`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), (re)introduced in [898c2e65b7](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93) ("`submodule`: unset `core.worktree` if no working tree is present", 2018-12-14, Git v2.21.0-rc0 -- [merge](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7) listed in [batch #3](https://github.com/git/git/commit/16a465bc018d09e9d7bbbdc5f40a7fb99c21f8ef)) use `get_git_common_dir()` instead of `get_git_dir()` to get the path of the submodule repository. > > > This means that, for example, '[`git checkout --recurse-submodules <branch>`](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---recurse-submodules)' in a linked worktree will correctly checkout `<branch>`, detach the submodule's HEAD at the commit recorded in `<branch>` and update the submodule working tree, but the submodule HEAD that will be moved is the one in `$GIT_COMMON_DIR/modules/<name>/,` i.e. the submodule repository of the main superproject working tree. > > It will also rewrite the gitfile in the submodule working tree of the linked worktree to point to `$GIT_COMMON_DIR/modules/<name>/`. > > This leads to an incorrect (and confusing!) state in the submodule working tree of the main superproject worktree. > > > Additionally, if switching to a commit where the submodule is not present, `submodule_unset_core_worktree` will be called and will incorrectly remove '`core.wortree`' from the config file of the submodule in the main superproject worktree, `$GIT_COMMON_DIR/modules/<name>/config`. > > > Fix this by constructing the path to the submodule repository using `get_git_dir()` in both `submodule_move_head` and `submodule_unset_core_worktree`. > > > --- Before Git 2.27 (Q2 2020), the "`git submodule`" command did not initialize a few variables it internally uses and was affected by variable settings leaked from the environment. See [commit 65d100c](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c) (02 Apr 2020) by [Li Xuejiang (`xuejiangLi`)](https://github.com/xuejiangLi). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 27dd34b](https://github.com/git/git/commit/27dd34b95e44b717e14e879a9b46ecdd5232632b), 28 Apr 2020) > > [`git-submodule.sh`](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c): setup uninitialized variables > ------------------------------------------------------------------------------------------------------------------------------- > > > Helped-by: Jiang Xin > > Signed-off-by: Li Xuejiang > > > We have an environment variable `jobs=16` defined in our CI system, and this environment makes our build job failed with the following message: > > > > ``` > error: pathspec '16' did not match any file(s) known to git > > ``` > > The pathspec '16' for Git command is from the environment variable "jobs". > > > This is because "`git submodule`" command is implemented in shell script, and environment variables may change its behavior. > > > Set values for uninitialized variables, such as "`jobs`" and "`recommend_shallow`" will fix this issue. > > >
Since there is no change to actually checkout and copy, that leaves two main root causes: * the url of the submodule is slow to respond * or `git submodule update` was optimized since the old git 1.9: see if the issue persists [with the latest git 2.6.4](https://launchpad.net/~git-core/+archive/ubuntu/ppa) found in the [launchpad ppa](https://launchpad.net/~git-core/+archive/ubuntu/ppa)
34,460,820
I've got several divs stacked up using ng-repeat. I'm using ng-leave to slide a div up when it is deleted. What I'd like is for all of the divs below the deleted one to slide up with the deleted one, so there is never any empty space. As I have it, the deleted div leaves an empty space where it was during the 1s transition, then the divs underneath all immediately move up. **FIDDLE:** <https://jsfiddle.net/c1huchuz/6/> **HTML:** ``` <body ng-app="myApp" ng-controller="myController"> <button ng-click="add_div()">Add Div</button><br/><br/> <div ng-repeat="x in random_array" class="slide"> {{$index}} <button ng-click="remove_div($index)">Delete</button> </div> </body> ``` **JS:** ``` var app = angular.module("myApp", ['ngAnimate']); app.controller("myController", ["$scope", function($scope) { $scope.random_array = [] $scope.add_div = function() { var i = $scope.random_array.length $scope.random_array.push(i) } $scope.remove_div = function(index) { $scope.random_array.splice(index, 1) } }]); ``` **CSS:** ``` div { position: relative; width: 90px; height: 30px; background-color: orange; border: 1px solid black; } .slide.ng-enter, .slide.ng-leave { transition: all 1s; } .slide.ng-enter, .slide.ng-leave.ng-leave-active { top: -30px; z-index: -1; } .slide.ng-enter.ng-enter-active, .slide.ng-leave { top: 0px; z-index: -1; } ``` I tried using the following ng-move to slide up all the divs whose indices change, but it doesn't have any effect. ``` .slide.ng-move { transition: all 1s; top: 0px; } .slide.ng-move.ng-move-active { top: -31px; } ```
2015/12/25
[ "https://Stackoverflow.com/questions/34460820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5585657/" ]
Since there is no change to actually checkout and copy, that leaves two main root causes: * the url of the submodule is slow to respond * or `git submodule update` was optimized since the old git 1.9: see if the issue persists [with the latest git 2.6.4](https://launchpad.net/~git-core/+archive/ubuntu/ppa) found in the [launchpad ppa](https://launchpad.net/~git-core/+archive/ubuntu/ppa)
Another thing worth trying is the `--progress` option which shows the usual percentage progress like `git clone` would: ``` git submodule update --progress ``` Related: [How to show progress for submodule fetching?](https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching)
34,460,820
I've got several divs stacked up using ng-repeat. I'm using ng-leave to slide a div up when it is deleted. What I'd like is for all of the divs below the deleted one to slide up with the deleted one, so there is never any empty space. As I have it, the deleted div leaves an empty space where it was during the 1s transition, then the divs underneath all immediately move up. **FIDDLE:** <https://jsfiddle.net/c1huchuz/6/> **HTML:** ``` <body ng-app="myApp" ng-controller="myController"> <button ng-click="add_div()">Add Div</button><br/><br/> <div ng-repeat="x in random_array" class="slide"> {{$index}} <button ng-click="remove_div($index)">Delete</button> </div> </body> ``` **JS:** ``` var app = angular.module("myApp", ['ngAnimate']); app.controller("myController", ["$scope", function($scope) { $scope.random_array = [] $scope.add_div = function() { var i = $scope.random_array.length $scope.random_array.push(i) } $scope.remove_div = function(index) { $scope.random_array.splice(index, 1) } }]); ``` **CSS:** ``` div { position: relative; width: 90px; height: 30px; background-color: orange; border: 1px solid black; } .slide.ng-enter, .slide.ng-leave { transition: all 1s; } .slide.ng-enter, .slide.ng-leave.ng-leave-active { top: -30px; z-index: -1; } .slide.ng-enter.ng-enter-active, .slide.ng-leave { top: 0px; z-index: -1; } ``` I tried using the following ng-move to slide up all the divs whose indices change, but it doesn't have any effect. ``` .slide.ng-move { transition: all 1s; top: 0px; } .slide.ng-move.ng-move-active { top: -31px; } ```
2015/12/25
[ "https://Stackoverflow.com/questions/34460820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5585657/" ]
With Git 2.20 Q4 2018), [`git submodule`](https://git-scm.com/docs/git-submodule) will be notably *faster* because "`git submodule update`" is getting rewritten piece-by-piece into C. See [commit ee69b2a](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac), [commit 74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (13 Aug 2018), and [commit c94d9dc](https://github.com/git/git/commit/c94d9dc286027e0343ffd58b5f7f2899691f6747), [commit f1d1571](https://github.com/git/git/commit/f1d15713faef54c0bcc5d35c9089efffa4c914a1), [commit 90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b), [commit 9eca701](https://github.com/git/git/commit/9eca701f69b1dfb857a0445ba8a78e2445e9aa2b), [commit ff03d93](https://github.com/git/git/commit/ff03d9306c7dbc2011c0a6660359d9074e4a3ab3) (03 Aug 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4d6d6ef](https://github.com/git/git/commit/4d6d6ef1fcce0e7d1fd2d3d38c2372998a105e96), 17 Sep 2018) --- Git 2.21 actually fixes a regression, since "`git submodule update`" ought to use a single job unless asked, but by mistake used multiple jobs, which has been fixed. See [commit e3a9d1a](https://github.com/git/git/commit/e3a9d1aca92d90f2fdfbefd29827f7d7d210947e) (13 Dec 2018) by [Junio C Hamano (`gitster`)](https://github.com/gitster). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4744d03](https://github.com/git/git/commit/4744d03a47d668e0e2ea45a637fd16d782e035b9), 18 Jan 2019) > > `submodule update`: run at most one fetch job unless otherwise set > ------------------------------------------------------------------ > > > In [a028a19](https://github.com/git/git/commit/a028a1930c6b4b848e8fb47cc92c30b23d99a75e) (fetching submodules: respect `submodule.fetchJobs` config option, 2016-02-29, Git v2.9.0-rc0), we made sure to keep the default behavior of fetching at most one submodule at once when not setting the newly introduced `submodule.fetchJobs` config. > > > This regressed in [90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b) (builtin/submodule--helper: factor out submodule updating, 2018-08-03, Git v2.20.0-rc0). Fix it. > > > --- And Git 2.21 fixes the `core.worktree` setting in a submodule repository, which should not be pointing at a directory when the submodule loses its working tree (e.g. getting deinit'ed), but the code did not properly maintain this invariant. See [commit 8eda5ef](https://github.com/git/git/commit/8eda5efa1269a6117b86a97a309eb3a195b5f087), [commit 820a647](https://github.com/git/git/commit/820a647e67ad21ecb1d23b2154c44ad13e794443), [commit 898c2e6](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93), [commit 98bf667](https://github.com/git/git/commit/98bf66748967a98b65a827d1d2021be98d550174) (14 Dec 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 3942920](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7), 18 Jan 2019) > > `submodule deinit`: unset `core.worktree` > ----------------------------------------- > > > When a submodule is deinit'd, the working tree is gone, so the setting of `core.worktree` is bogus. > > Unset it. > > As we covered the only other case in which a submodule loses its working tree in the earlier step (i.e. switching branches of top-level project to move to a commit that did not have the submodule), this makes the code always maintain `core.worktree` correctly unset when there is no working tree for a submodule. > > > This re-introduces [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) (`submodule deinit`: `unset core.worktree`, 2018-06-18, Git v2.19.0-rc0), which was reverted as part of [f178c13](https://github.com/git/git/commit/f178c13fdac42763a7aa58bf260aa67d9f4393ec) (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07, Git v2.19.0) > > > The whole series was reverted as the offending [commit e983175](https://github.com/git/git/commit/e98317508c02b7cc65bf5b28f27788e47096b166) (`submodule`: ensure `core.worktree` is set after update, 2018-06-18, Git v2.19.0-rc0) was relied on by other commits such as [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d). > > > Keep the offending commit reverted, but its functionality came back via 4d6d6ef (Merge branch 'sb/submodule-update-in-c', 2018-09-17), such that we can reintroduce [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) now. > > > --- Git 2.21 also includes "`git submodule update`" learning to abort early when `core.worktree` for the submodule is not set correctly to prevent spreading damage. See [commit 5d124f4](https://github.com/git/git/commit/5d124f419d1e9b7d22fae915627de7e463bf7c42) (18 Jan 2019) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit e524e44](https://github.com/git/git/commit/e524e44ecad731352102e85226daef61268494c6), 07 Feb 2019) > > `git-submodule`: abort if `core.worktree` could not be set correctly > > > [74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (`submodule--helper`: replace `connect-gitdir-workingtree` by > `ensure-core-worktree`, 2018-08-13, Git 2.20) forgot to exit the submodule operation if the helper could not ensure that `core.worktree` is set correctly. > > > --- Warning: CVE-2019-1387: Recursive clones are currently affected by a vulnerability that is caused by too-lax validation of submodule names, allowing very targeted attacks via remote code execution in recursive clones. Fixed in Git 2.24.1, 2.23.1, 2.22.2, 2.21.1, 2.20.2. 2.19.3, 2.18.2, 2.17.3, 2.16.6, 2.15.4 and 2.14.6 In conjunction with a vulnerability that was fixed in v2.20.2, `.gitmodules` is no longer allowed to contain entries of the form `submodule.<name>.update=!command`. > > [`submodule`](https://github.com/git/git/commit/e904deb89d9a9669a76a426182506a084d3f6308): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------------ > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), Git has been careful to avoid copying: > > > > ``` > [submodule "foo"] > update = !run an arbitrary scary command > > ``` > > from `.gitmodules` to a repository's local config, copying in the setting '`update = none`' instead. > > > The [gitmodules(5) manpage](https://git-scm.com/docs/gitmodules) documents the intention: > > > The `!command` form is intentionally ignored here for security reasons > > > Unfortunately, starting with v2.20.0-rc0 (which integrated [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac) (submodule--helper: introduce new update-module-mode helper, 2018-08-13, first released in v2.20.0-rc0)), there are scenarios where we *don't* ignore it: if the config store contains no `submodule.foo.update` setting, the submodule-config API falls back to reading `.gitmodules` and the repository-supplied `!command` gets run after all. > > > This was part of a general change over time in submodule support to read more directly from `.gitmodules`, since unlike `.git/config` it allows a project to change values between branches and over time (while still allowing `.git/config` to override things). > > > But it was never intended to apply to this kind of dangerous configuration. > > > The behavior change was not advertised in [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac)'s commit message and was missed in review. > > > Let's take the opportunity to make the protection more robust, even in Git versions that are technically not affected: instead of quietly converting 'update = !command' to 'update = none', noisily treat it as an error. > > > Allowing the setting but treating it as meaning something else was just confusing; users are better served by seeing the error sooner. > > > Forbidding the construct makes the semantics simpler and means we can check for it in `fsck` (in a separate patch, see below). > > > As a result, the submodule-config API cannot read this value from `.gitmodules` under any circumstance, and we can declare with confidence > > > For security reasons, the '`!command`' form is not accepted here. > > > And: > > [`fsck`](https://github.com/git/git/commit/bb92255ebe6bccd76227e023d6d0bc997e318ad0): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------- > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > This allows hosting providers to detect whether they are being used to attack users using malicious '`update = !command`' settings in `.gitmodules`. > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), in normal cases such settings have been treated as '`update = none`', so forbidding them should not produce any collateral damage to legitimate uses. > > > A quick search does not reveal any repositories making use of this construct, either. > > > And: > > [`submodule`](https://github.com/git/git/commit/c1547450748fcbac21675f2681506d2d80351a19): defend against `submodule.update = !command` in `.gitmodules` > -------------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > In v2.15.4, we started to reject `submodule.update` settings in `.gitmodules`. Let's raise a BUG if it somehow still made it through from anywhere but the Git config. > > > --- The "`--recurse-submodules`" option of various subcommands did not work well when run in an alternate worktree, which has been corrected with Git 2.25.2 (March 2020). See [commit a9472af](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704), [commit 129510a](https://github.com/git/git/commit/129510a0672a7f9fd6c1a2d1d6fa36a17ffb6d1c), [commit 4eaadc8](https://github.com/git/git/commit/4eaadc8493704357a4fac8d7dc8207340aa79019), [commit 773c60a](https://github.com/git/git/commit/773c60a45e01f1e6631afe1cce9da3ed67d37a3a) (21 Jan 2020) by [Philippe Blain (`phil-blain`)](https://github.com/phil-blain). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit ff5134b](https://github.com/git/git/commit/ff5134b2fffe202fb48498f15d6e47673f9bd6b2), 05 Feb 2020) > > [`submodule.c`](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704): use `get_git_dir()` instead of `get_git_common_dir()` > -------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Philippe Blain > > > Ever since [df56607dff](https://github.com/git/git/commit/df56607dff2d656043a1f77a647f97a0a6b5aec9) (`git-common-dir`: make "modules/" per-working-directory directory, 2014-11-30, Git v2.5.0-rc0), submodules in linked worktrees are cloned to `$GIT_DIR/modules,` i.e. `$GIT_COMMON_DIR/worktrees/<name>/modules`. > > > However, this convention was not followed when the worktree updater commands checkout, reset and read-tree learned to recurse into submodules. > > Specifically, [`submodule.c::submodule_move_head`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), introduced in [6e3c1595c6](https://github.com/git/git/commit/6e3c1595c66e2b192a2a516447c5645814766339) (`update submodules`: add `submodule_move_head,` 2017-03-14, Git v2.13.0-rc0) and [`submodule.c::submodule_unset_core_worktree`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), (re)introduced in [898c2e65b7](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93) ("`submodule`: unset `core.worktree` if no working tree is present", 2018-12-14, Git v2.21.0-rc0 -- [merge](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7) listed in [batch #3](https://github.com/git/git/commit/16a465bc018d09e9d7bbbdc5f40a7fb99c21f8ef)) use `get_git_common_dir()` instead of `get_git_dir()` to get the path of the submodule repository. > > > This means that, for example, '[`git checkout --recurse-submodules <branch>`](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---recurse-submodules)' in a linked worktree will correctly checkout `<branch>`, detach the submodule's HEAD at the commit recorded in `<branch>` and update the submodule working tree, but the submodule HEAD that will be moved is the one in `$GIT_COMMON_DIR/modules/<name>/,` i.e. the submodule repository of the main superproject working tree. > > It will also rewrite the gitfile in the submodule working tree of the linked worktree to point to `$GIT_COMMON_DIR/modules/<name>/`. > > This leads to an incorrect (and confusing!) state in the submodule working tree of the main superproject worktree. > > > Additionally, if switching to a commit where the submodule is not present, `submodule_unset_core_worktree` will be called and will incorrectly remove '`core.wortree`' from the config file of the submodule in the main superproject worktree, `$GIT_COMMON_DIR/modules/<name>/config`. > > > Fix this by constructing the path to the submodule repository using `get_git_dir()` in both `submodule_move_head` and `submodule_unset_core_worktree`. > > > --- Before Git 2.27 (Q2 2020), the "`git submodule`" command did not initialize a few variables it internally uses and was affected by variable settings leaked from the environment. See [commit 65d100c](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c) (02 Apr 2020) by [Li Xuejiang (`xuejiangLi`)](https://github.com/xuejiangLi). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 27dd34b](https://github.com/git/git/commit/27dd34b95e44b717e14e879a9b46ecdd5232632b), 28 Apr 2020) > > [`git-submodule.sh`](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c): setup uninitialized variables > ------------------------------------------------------------------------------------------------------------------------------- > > > Helped-by: Jiang Xin > > Signed-off-by: Li Xuejiang > > > We have an environment variable `jobs=16` defined in our CI system, and this environment makes our build job failed with the following message: > > > > ``` > error: pathspec '16' did not match any file(s) known to git > > ``` > > The pathspec '16' for Git command is from the environment variable "jobs". > > > This is because "`git submodule`" command is implemented in shell script, and environment variables may change its behavior. > > > Set values for uninitialized variables, such as "`jobs`" and "`recommend_shallow`" will fix this issue. > > >
The way I debug the process of updating submodules: ``` GIT_TRACE=1 GIT_CURL_VERBOSE=1 git submodule update ```
34,460,820
I've got several divs stacked up using ng-repeat. I'm using ng-leave to slide a div up when it is deleted. What I'd like is for all of the divs below the deleted one to slide up with the deleted one, so there is never any empty space. As I have it, the deleted div leaves an empty space where it was during the 1s transition, then the divs underneath all immediately move up. **FIDDLE:** <https://jsfiddle.net/c1huchuz/6/> **HTML:** ``` <body ng-app="myApp" ng-controller="myController"> <button ng-click="add_div()">Add Div</button><br/><br/> <div ng-repeat="x in random_array" class="slide"> {{$index}} <button ng-click="remove_div($index)">Delete</button> </div> </body> ``` **JS:** ``` var app = angular.module("myApp", ['ngAnimate']); app.controller("myController", ["$scope", function($scope) { $scope.random_array = [] $scope.add_div = function() { var i = $scope.random_array.length $scope.random_array.push(i) } $scope.remove_div = function(index) { $scope.random_array.splice(index, 1) } }]); ``` **CSS:** ``` div { position: relative; width: 90px; height: 30px; background-color: orange; border: 1px solid black; } .slide.ng-enter, .slide.ng-leave { transition: all 1s; } .slide.ng-enter, .slide.ng-leave.ng-leave-active { top: -30px; z-index: -1; } .slide.ng-enter.ng-enter-active, .slide.ng-leave { top: 0px; z-index: -1; } ``` I tried using the following ng-move to slide up all the divs whose indices change, but it doesn't have any effect. ``` .slide.ng-move { transition: all 1s; top: 0px; } .slide.ng-move.ng-move-active { top: -31px; } ```
2015/12/25
[ "https://Stackoverflow.com/questions/34460820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5585657/" ]
With Git 2.20 Q4 2018), [`git submodule`](https://git-scm.com/docs/git-submodule) will be notably *faster* because "`git submodule update`" is getting rewritten piece-by-piece into C. See [commit ee69b2a](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac), [commit 74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (13 Aug 2018), and [commit c94d9dc](https://github.com/git/git/commit/c94d9dc286027e0343ffd58b5f7f2899691f6747), [commit f1d1571](https://github.com/git/git/commit/f1d15713faef54c0bcc5d35c9089efffa4c914a1), [commit 90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b), [commit 9eca701](https://github.com/git/git/commit/9eca701f69b1dfb857a0445ba8a78e2445e9aa2b), [commit ff03d93](https://github.com/git/git/commit/ff03d9306c7dbc2011c0a6660359d9074e4a3ab3) (03 Aug 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4d6d6ef](https://github.com/git/git/commit/4d6d6ef1fcce0e7d1fd2d3d38c2372998a105e96), 17 Sep 2018) --- Git 2.21 actually fixes a regression, since "`git submodule update`" ought to use a single job unless asked, but by mistake used multiple jobs, which has been fixed. See [commit e3a9d1a](https://github.com/git/git/commit/e3a9d1aca92d90f2fdfbefd29827f7d7d210947e) (13 Dec 2018) by [Junio C Hamano (`gitster`)](https://github.com/gitster). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 4744d03](https://github.com/git/git/commit/4744d03a47d668e0e2ea45a637fd16d782e035b9), 18 Jan 2019) > > `submodule update`: run at most one fetch job unless otherwise set > ------------------------------------------------------------------ > > > In [a028a19](https://github.com/git/git/commit/a028a1930c6b4b848e8fb47cc92c30b23d99a75e) (fetching submodules: respect `submodule.fetchJobs` config option, 2016-02-29, Git v2.9.0-rc0), we made sure to keep the default behavior of fetching at most one submodule at once when not setting the newly introduced `submodule.fetchJobs` config. > > > This regressed in [90efe59](https://github.com/git/git/commit/90efe595c53f4bb1851371344c35eff71f604d2b) (builtin/submodule--helper: factor out submodule updating, 2018-08-03, Git v2.20.0-rc0). Fix it. > > > --- And Git 2.21 fixes the `core.worktree` setting in a submodule repository, which should not be pointing at a directory when the submodule loses its working tree (e.g. getting deinit'ed), but the code did not properly maintain this invariant. See [commit 8eda5ef](https://github.com/git/git/commit/8eda5efa1269a6117b86a97a309eb3a195b5f087), [commit 820a647](https://github.com/git/git/commit/820a647e67ad21ecb1d23b2154c44ad13e794443), [commit 898c2e6](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93), [commit 98bf667](https://github.com/git/git/commit/98bf66748967a98b65a827d1d2021be98d550174) (14 Dec 2018) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 3942920](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7), 18 Jan 2019) > > `submodule deinit`: unset `core.worktree` > ----------------------------------------- > > > When a submodule is deinit'd, the working tree is gone, so the setting of `core.worktree` is bogus. > > Unset it. > > As we covered the only other case in which a submodule loses its working tree in the earlier step (i.e. switching branches of top-level project to move to a commit that did not have the submodule), this makes the code always maintain `core.worktree` correctly unset when there is no working tree for a submodule. > > > This re-introduces [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) (`submodule deinit`: `unset core.worktree`, 2018-06-18, Git v2.19.0-rc0), which was reverted as part of [f178c13](https://github.com/git/git/commit/f178c13fdac42763a7aa58bf260aa67d9f4393ec) (Revert "Merge branch 'sb/submodule-core-worktree'", 2018-09-07, Git v2.19.0) > > > The whole series was reverted as the offending [commit e983175](https://github.com/git/git/commit/e98317508c02b7cc65bf5b28f27788e47096b166) (`submodule`: ensure `core.worktree` is set after update, 2018-06-18, Git v2.19.0-rc0) was relied on by other commits such as [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d). > > > Keep the offending commit reverted, but its functionality came back via 4d6d6ef (Merge branch 'sb/submodule-update-in-c', 2018-09-17), such that we can reintroduce [984cd77](https://github.com/git/git/commit/984cd77ddbf0eea7371a18ad7124120473b6bb2d) now. > > > --- Git 2.21 also includes "`git submodule update`" learning to abort early when `core.worktree` for the submodule is not set correctly to prevent spreading damage. See [commit 5d124f4](https://github.com/git/git/commit/5d124f419d1e9b7d22fae915627de7e463bf7c42) (18 Jan 2019) by [Stefan Beller (`stefanbeller`)](https://github.com/stefanbeller). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit e524e44](https://github.com/git/git/commit/e524e44ecad731352102e85226daef61268494c6), 07 Feb 2019) > > `git-submodule`: abort if `core.worktree` could not be set correctly > > > [74d4731](https://github.com/git/git/commit/74d4731da1fd61e3705e808bcd496979ef8ddf5a) (`submodule--helper`: replace `connect-gitdir-workingtree` by > `ensure-core-worktree`, 2018-08-13, Git 2.20) forgot to exit the submodule operation if the helper could not ensure that `core.worktree` is set correctly. > > > --- Warning: CVE-2019-1387: Recursive clones are currently affected by a vulnerability that is caused by too-lax validation of submodule names, allowing very targeted attacks via remote code execution in recursive clones. Fixed in Git 2.24.1, 2.23.1, 2.22.2, 2.21.1, 2.20.2. 2.19.3, 2.18.2, 2.17.3, 2.16.6, 2.15.4 and 2.14.6 In conjunction with a vulnerability that was fixed in v2.20.2, `.gitmodules` is no longer allowed to contain entries of the form `submodule.<name>.update=!command`. > > [`submodule`](https://github.com/git/git/commit/e904deb89d9a9669a76a426182506a084d3f6308): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------------ > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), Git has been careful to avoid copying: > > > > ``` > [submodule "foo"] > update = !run an arbitrary scary command > > ``` > > from `.gitmodules` to a repository's local config, copying in the setting '`update = none`' instead. > > > The [gitmodules(5) manpage](https://git-scm.com/docs/gitmodules) documents the intention: > > > The `!command` form is intentionally ignored here for security reasons > > > Unfortunately, starting with v2.20.0-rc0 (which integrated [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac) (submodule--helper: introduce new update-module-mode helper, 2018-08-13, first released in v2.20.0-rc0)), there are scenarios where we *don't* ignore it: if the config store contains no `submodule.foo.update` setting, the submodule-config API falls back to reading `.gitmodules` and the repository-supplied `!command` gets run after all. > > > This was part of a general change over time in submodule support to read more directly from `.gitmodules`, since unlike `.git/config` it allows a project to change values between branches and over time (while still allowing `.git/config` to override things). > > > But it was never intended to apply to this kind of dangerous configuration. > > > The behavior change was not advertised in [ee69b2a9](https://github.com/git/git/commit/ee69b2a90c5031bffb3341c5e50653a6ecca89ac)'s commit message and was missed in review. > > > Let's take the opportunity to make the protection more robust, even in Git versions that are technically not affected: instead of quietly converting 'update = !command' to 'update = none', noisily treat it as an error. > > > Allowing the setting but treating it as meaning something else was just confusing; users are better served by seeing the error sooner. > > > Forbidding the construct makes the semantics simpler and means we can check for it in `fsck` (in a separate patch, see below). > > > As a result, the submodule-config API cannot read this value from `.gitmodules` under any circumstance, and we can declare with confidence > > > For security reasons, the '`!command`' form is not accepted here. > > > And: > > [`fsck`](https://github.com/git/git/commit/bb92255ebe6bccd76227e023d6d0bc997e318ad0): reject `submodule.update = !command` in `.gitmodules` > ------------------------------------------------------------------------------------------------------------------------------------------- > > > Reported-by: Joern Schneeweisz > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > This allows hosting providers to detect whether they are being used to attack users using malicious '`update = !command`' settings in `.gitmodules`. > > > Since [ac1fbbda2013](https://github.com/git/git/commit/ac1fbbda2013416b6c6a93d65c5dcf6662a60579) ("`submodule`: do not copy unknown update mode from .gitmodules", 2013-12-02, Git v1.8.5.1 -- [merge](https://github.com/git/git/commit/be38bee862d628e29043b3f680580ceb24a6ba1e)), in normal cases such settings have been treated as '`update = none`', so forbidding them should not produce any collateral damage to legitimate uses. > > > A quick search does not reveal any repositories making use of this construct, either. > > > And: > > [`submodule`](https://github.com/git/git/commit/c1547450748fcbac21675f2681506d2d80351a19): defend against `submodule.update = !command` in `.gitmodules` > -------------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Jonathan Nieder > > Signed-off-by: Johannes Schindelin > > > In v2.15.4, we started to reject `submodule.update` settings in `.gitmodules`. Let's raise a BUG if it somehow still made it through from anywhere but the Git config. > > > --- The "`--recurse-submodules`" option of various subcommands did not work well when run in an alternate worktree, which has been corrected with Git 2.25.2 (March 2020). See [commit a9472af](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704), [commit 129510a](https://github.com/git/git/commit/129510a0672a7f9fd6c1a2d1d6fa36a17ffb6d1c), [commit 4eaadc8](https://github.com/git/git/commit/4eaadc8493704357a4fac8d7dc8207340aa79019), [commit 773c60a](https://github.com/git/git/commit/773c60a45e01f1e6631afe1cce9da3ed67d37a3a) (21 Jan 2020) by [Philippe Blain (`phil-blain`)](https://github.com/phil-blain). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit ff5134b](https://github.com/git/git/commit/ff5134b2fffe202fb48498f15d6e47673f9bd6b2), 05 Feb 2020) > > [`submodule.c`](https://github.com/git/git/commit/a9472afb6328e22cdaea4225d3b36b97d2e9e704): use `get_git_dir()` instead of `get_git_common_dir()` > -------------------------------------------------------------------------------------------------------------------------------------------------- > > > Signed-off-by: Philippe Blain > > > Ever since [df56607dff](https://github.com/git/git/commit/df56607dff2d656043a1f77a647f97a0a6b5aec9) (`git-common-dir`: make "modules/" per-working-directory directory, 2014-11-30, Git v2.5.0-rc0), submodules in linked worktrees are cloned to `$GIT_DIR/modules,` i.e. `$GIT_COMMON_DIR/worktrees/<name>/modules`. > > > However, this convention was not followed when the worktree updater commands checkout, reset and read-tree learned to recurse into submodules. > > Specifically, [`submodule.c::submodule_move_head`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), introduced in [6e3c1595c6](https://github.com/git/git/commit/6e3c1595c66e2b192a2a516447c5645814766339) (`update submodules`: add `submodule_move_head,` 2017-03-14, Git v2.13.0-rc0) and [`submodule.c::submodule_unset_core_worktree`](https://github.com/git/git/blob/a9472afb6328e22cdaea4225d3b36b97d2e9e704/submodule.c), (re)introduced in [898c2e65b7](https://github.com/git/git/commit/898c2e65b7743f7d56bf50b4ba8bf4f59a0caf93) ("`submodule`: unset `core.worktree` if no working tree is present", 2018-12-14, Git v2.21.0-rc0 -- [merge](https://github.com/git/git/commit/3942920966b4392c52c09f66dda391d9c330f0f7) listed in [batch #3](https://github.com/git/git/commit/16a465bc018d09e9d7bbbdc5f40a7fb99c21f8ef)) use `get_git_common_dir()` instead of `get_git_dir()` to get the path of the submodule repository. > > > This means that, for example, '[`git checkout --recurse-submodules <branch>`](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---recurse-submodules)' in a linked worktree will correctly checkout `<branch>`, detach the submodule's HEAD at the commit recorded in `<branch>` and update the submodule working tree, but the submodule HEAD that will be moved is the one in `$GIT_COMMON_DIR/modules/<name>/,` i.e. the submodule repository of the main superproject working tree. > > It will also rewrite the gitfile in the submodule working tree of the linked worktree to point to `$GIT_COMMON_DIR/modules/<name>/`. > > This leads to an incorrect (and confusing!) state in the submodule working tree of the main superproject worktree. > > > Additionally, if switching to a commit where the submodule is not present, `submodule_unset_core_worktree` will be called and will incorrectly remove '`core.wortree`' from the config file of the submodule in the main superproject worktree, `$GIT_COMMON_DIR/modules/<name>/config`. > > > Fix this by constructing the path to the submodule repository using `get_git_dir()` in both `submodule_move_head` and `submodule_unset_core_worktree`. > > > --- Before Git 2.27 (Q2 2020), the "`git submodule`" command did not initialize a few variables it internally uses and was affected by variable settings leaked from the environment. See [commit 65d100c](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c) (02 Apr 2020) by [Li Xuejiang (`xuejiangLi`)](https://github.com/xuejiangLi). (Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 27dd34b](https://github.com/git/git/commit/27dd34b95e44b717e14e879a9b46ecdd5232632b), 28 Apr 2020) > > [`git-submodule.sh`](https://github.com/git/git/commit/65d100c4ddbe83953870be2e08566086e4b1cd3c): setup uninitialized variables > ------------------------------------------------------------------------------------------------------------------------------- > > > Helped-by: Jiang Xin > > Signed-off-by: Li Xuejiang > > > We have an environment variable `jobs=16` defined in our CI system, and this environment makes our build job failed with the following message: > > > > ``` > error: pathspec '16' did not match any file(s) known to git > > ``` > > The pathspec '16' for Git command is from the environment variable "jobs". > > > This is because "`git submodule`" command is implemented in shell script, and environment variables may change its behavior. > > > Set values for uninitialized variables, such as "`jobs`" and "`recommend_shallow`" will fix this issue. > > >
Another thing worth trying is the `--progress` option which shows the usual percentage progress like `git clone` would: ``` git submodule update --progress ``` Related: [How to show progress for submodule fetching?](https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching)
34,460,820
I've got several divs stacked up using ng-repeat. I'm using ng-leave to slide a div up when it is deleted. What I'd like is for all of the divs below the deleted one to slide up with the deleted one, so there is never any empty space. As I have it, the deleted div leaves an empty space where it was during the 1s transition, then the divs underneath all immediately move up. **FIDDLE:** <https://jsfiddle.net/c1huchuz/6/> **HTML:** ``` <body ng-app="myApp" ng-controller="myController"> <button ng-click="add_div()">Add Div</button><br/><br/> <div ng-repeat="x in random_array" class="slide"> {{$index}} <button ng-click="remove_div($index)">Delete</button> </div> </body> ``` **JS:** ``` var app = angular.module("myApp", ['ngAnimate']); app.controller("myController", ["$scope", function($scope) { $scope.random_array = [] $scope.add_div = function() { var i = $scope.random_array.length $scope.random_array.push(i) } $scope.remove_div = function(index) { $scope.random_array.splice(index, 1) } }]); ``` **CSS:** ``` div { position: relative; width: 90px; height: 30px; background-color: orange; border: 1px solid black; } .slide.ng-enter, .slide.ng-leave { transition: all 1s; } .slide.ng-enter, .slide.ng-leave.ng-leave-active { top: -30px; z-index: -1; } .slide.ng-enter.ng-enter-active, .slide.ng-leave { top: 0px; z-index: -1; } ``` I tried using the following ng-move to slide up all the divs whose indices change, but it doesn't have any effect. ``` .slide.ng-move { transition: all 1s; top: 0px; } .slide.ng-move.ng-move-active { top: -31px; } ```
2015/12/25
[ "https://Stackoverflow.com/questions/34460820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5585657/" ]
The way I debug the process of updating submodules: ``` GIT_TRACE=1 GIT_CURL_VERBOSE=1 git submodule update ```
Another thing worth trying is the `--progress` option which shows the usual percentage progress like `git clone` would: ``` git submodule update --progress ``` Related: [How to show progress for submodule fetching?](https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching)
48,802,412
I am getting error Unexpected request processing error when trying to get rates in sabre soap api. Here is my request xml: ``` <soapenv:Body> <ns:HotelRateDescriptionRQ ReturnHostCommand="false" Version="2.3.0"> <ns:AvailRequestSegment> <!--Optional:--> <ns:GuestCounts Count="2"/> <!--Optional:--> <ns:HotelSearchCriteria> <ns:Criterion> <ns:HotelRef HotelCode="46333"/> </ns:Criterion> </ns:HotelSearchCriteria> <!--Optional:--> <!--Optional:--> <ns:RatePlanCandidates> <ns:RatePlanCandidate CurrencyCode="USD"/> </ns:RatePlanCandidates> <!--Optional:--> <ns:TimeSpan End="12-28" Start="12-25"/> </ns:AvailRequestSegment> </ns:HotelRateDescriptionRQ> </soapenv:Body> ``` But i got error response: ``` <soap-env:Body> <HotelRateDescriptionRS xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:stl="http://services.sabre.com/STL/v01" Version="2.3.0"> <stl:ApplicationResults status="NotProcessed"> <stl:Error type="Application" timeStamp="2018-02-15T01:50:26-06:00"> <stl:SystemSpecificResults> <stl:Message>Unexpected request processing error</stl:Message> <stl:ShortText>ERR.SWS.PROVIDER.REQUEST_HANDLER_ERROR</stl:ShortText> </stl:SystemSpecificResults> </stl:Error> </stl:ApplicationResults> </HotelRateDescriptionRS> </soap-env:Body> ``` so what am i doing wrong here?
2018/02/15
[ "https://Stackoverflow.com/questions/48802412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2391947/" ]
I have fixed this problem, the problem because i use token from service TokenCreateRQ, it should use service SessionCreateRS
Possible Solutions: 1) have you set the ns: arrcordingly ? `xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"` 2) Did you set the service type in the header accordingly? `<eb:Service eb:type="OTA">HotelPropertyDescriptionLLSRQ</eb:Service>` `<eb:Action>HotelPropertyDescriptionLLSRQ</eb:Action>` Let me know if this works for you
51,578,339
I would like to get the class of Foo< T >.class (exactly Foo < T>, neither T.class nor Foo.class) ``` public class A extends B<C<D>>{ public A() { super(C<D>.class); // not work } } ``` On StackOverflow has a instruction for obtaining generic class by injecting into constructor but it's not my case because C< D>.class (e.g List< String>.class) is syntax error. At here it seems relate to syntax more than code structure. To show more detail, higher level view, the original code is the following, its HATEOAS module in Spring framework: ``` public class CustomerGroupResourceAssembler extends ResourceAssemblerSupport<CustomerGroup, CustomerGroupResource>{ public CustomerGroupResourceAssembler() { super(CustomerGroupController.class, CustomerGroupResource.class); } } public class CustomerGroupResource extends ResourceSupport { private CustomerGroup data; } ``` But now I want to parameterize the CustomerGroupResource to ``` public class Resource<T> extends ResourceSupport { private T data; } ``` and then ``` public class CustomerGroupResourceAssembler extends ResourceAssemblerSupport<CustomerGroup, Resource<CustomerGroup>>{ public CustomerGroupResourceAssembler() { super(CustomerGroupController.class, Resource<CustomerGroup>.class); // not work here, even Resource.class } } ```
2018/07/29
[ "https://Stackoverflow.com/questions/51578339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4800811/" ]
Check the below code:- ``` private void addStampToImage(Bitmap originalBitmap) { int extraHeight = (int) (originalBitmap.getHeight() * 0.15); Bitmap newBitmap = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight() + extraHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawColor(Color.BLUE); canvas.drawBitmap(originalBitmap, 0, 0, null); Resources resources = getResources(); float scale = resources.getDisplayMetrics().density; String text = "Maulik"; Paint pText = new Paint(); pText.setColor(Color.WHITE); setTextSizeForWidth(pText,(int) (originalBitmap.getHeight() * 0.10),text); Rect bounds = new Rect(); pText.getTextBounds(text, 0, text.length(), bounds); int x= ((newBitmap.getWidth()-(int)pText.measureText(text))/2); int h=(extraHeight+bounds.height())/2; int y=(originalBitmap.getHeight()+h); canvas.drawText(text, x, y, pText); imageView.setImageBitmap(newBitmap); } private void setTextSizeForWidth(Paint paint, float desiredHeight, String text) { // Pick a reasonably large value for the test. Larger values produce // more accurate results, but may cause problems with hardware // acceleration. But there are workarounds for that, too; refer to // http://stackoverflow.com/questions/6253528/font-size-too-large-to-fit-in-cache final float testTextSize = 48f; // Get the bounds of the text, using our testTextSize. paint.setTextSize(testTextSize); Rect bounds = new Rect(); paint.getTextBounds(text, 0, text.length(), bounds); // Calculate the desired size as a proportion of our testTextSize. float desiredTextSize = testTextSize * desiredHeight / bounds.height(); // Set the paint for that size. paint.setTextSize(desiredTextSize); } ``` **Edit:-** Instead of above addStampToImage method you can also use your updated addStampToImage method like below:- ``` private void addStampToImage(Bitmap originalBitmap) { int extraHeight = (int) (originalBitmap.getHeight() * 0.15); Bitmap newBitmap = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight() + extraHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawColor(Color.BLUE); canvas.drawBitmap(originalBitmap, 0, 0, null); Resources resources = getResources(); float scale = resources.getDisplayMetrics().density; String text = "Maulik"; Paint pText = new Paint(); pText.setColor(Color.WHITE); setTextSizeForWidth(pText,(int) (originalBitmap.getHeight() * 0.10),text); Rect bounds = new Rect(); pText.getTextBounds(text, 0, text.length(), bounds); Rect textHeightWidth = new Rect(); pText.getTextBounds(text, 0, text.length(), textHeightWidth); canvas.drawText(text, (canvas.getWidth() / 2) - (textHeightWidth.width() / 2), originalBitmap.getHeight() + (extraHeight / 2) + (textHeightWidth.height() / 2), pText); imageView.setImageBitmap(newBitmap); } ```
try this one i think help to you /\*\* \* FOR WATER-MARK \*/ ``` public static Bitmap waterMark(Bitmap src, String watermark, Point location, int color, int alpha, int size, boolean underline) { int[] pixels = new int[100]; //get source image width and height int widthSreen = src.getWidth(); // 1080L // 1920 int heightScreen = src.getHeight(); // 1343L // 2387 Bitmap result = Bitmap.createBitmap(widthSreen, heightScreen, src.getConfig()); //create canvas object Canvas canvas = new Canvas(result); //draw bitmap on canvas canvas.drawBitmap(src, 0, 0, null); //create paint object Paint paint = new Paint(); // //apply color // paint.setColor(color); // //set transparency // paint.setAlpha(alpha); // //set text size size = ((widthSreen * 5) / 100); paint.setTextSize(size); // paint.setAntiAlias(true); // //set should be underlined or not // paint.setUnderlineText(underline); // // //draw text on given location // //canvas.drawText(watermark, w / 4, h / 2, paint); Paint.FontMetrics fm = new Paint.FontMetrics(); paint.setColor(Color.WHITE); // paint.setTextSize(18.0f); paint.getFontMetrics(fm); int margin = 5; canvas.drawRect(50 - margin, 50 + fm.top - margin, 50 + paint.measureText(watermark) + margin, 50 + fm.bottom + margin, paint); paint.setColor(Color.RED); canvas.drawText(watermark, 50, 50, paint); return result; } ``` call this method on your onActivityResult ``` Bitmap bitmapp = waterMark(bitmap, your_string, p, Color.RED, 90, 90, true); ```
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
You can use the `screen` application and enter copy mode with `Ctrl`+`a`, `Esc`. Start selecting text with `Space` and end selecting text with `Space`. Insert text with `Ctrl`+`a`, `]`
Screen and Emacs `M-x shell`, for example, allow for keyboard access to the scrollback buffer. This was also one of the features of Plan 9 (but I guess it was mouse-oriented, at least primarily); you might want to take a look at `9term` and/or Sam, the Plan 9 editor.
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
You can use the `screen` application and enter copy mode with `Ctrl`+`a`, `Esc`. Start selecting text with `Space` and end selecting text with `Space`. Insert text with `Ctrl`+`a`, `]`
Daniel Micay's [Termite](https://github.com/thestinger/termite/) sports a "selection mode". Pressing `Ctrl`+`Shift`+`Space` will activate it. It's got vim-like key bindings. `v` or `V` will select à la `vim`'s visual mode, `y` will yank, `Esc` will exit selection mode.
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
You can use the `screen` application and enter copy mode with `Ctrl`+`a`, `Esc`. Start selecting text with `Space` and end selecting text with `Space`. Insert text with `Ctrl`+`a`, `]`
`$ emacs -g '80x24' --eval '(term "/bin/bash")'` ``` C-c C-k char mode C-c C-j line mode C-space Selecting text in terminal without using the mouse M-w copy to X11 clipboard ``` C - Ctrl M - Alt
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
Daniel Micay's [Termite](https://github.com/thestinger/termite/) sports a "selection mode". Pressing `Ctrl`+`Shift`+`Space` will activate it. It's got vim-like key bindings. `v` or `V` will select à la `vim`'s visual mode, `y` will yank, `Esc` will exit selection mode.
Screen and Emacs `M-x shell`, for example, allow for keyboard access to the scrollback buffer. This was also one of the features of Plan 9 (but I guess it was mouse-oriented, at least primarily); you might want to take a look at `9term` and/or Sam, the Plan 9 editor.
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
Screen and Emacs `M-x shell`, for example, allow for keyboard access to the scrollback buffer. This was also one of the features of Plan 9 (but I guess it was mouse-oriented, at least primarily); you might want to take a look at `9term` and/or Sam, the Plan 9 editor.
`$ emacs -g '80x24' --eval '(term "/bin/bash")'` ``` C-c C-k char mode C-c C-j line mode C-space Selecting text in terminal without using the mouse M-w copy to X11 clipboard ``` C - Ctrl M - Alt
1,536,757
If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using `Ctrl` + `Shift` + `C`, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop. For example I often need to copy results from a mysql query and then google them.
2009/10/08
[ "https://Stackoverflow.com/questions/1536757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186248/" ]
Daniel Micay's [Termite](https://github.com/thestinger/termite/) sports a "selection mode". Pressing `Ctrl`+`Shift`+`Space` will activate it. It's got vim-like key bindings. `v` or `V` will select à la `vim`'s visual mode, `y` will yank, `Esc` will exit selection mode.
`$ emacs -g '80x24' --eval '(term "/bin/bash")'` ``` C-c C-k char mode C-c C-j line mode C-space Selecting text in terminal without using the mouse M-w copy to X11 clipboard ``` C - Ctrl M - Alt
258,999
The following code runs perfectly fine when using the regular `latex` command. ``` \documentclass[a4paper,11pt]{book} \usepackage{hyperref} \renewcommand{\sectionautorefname}[1]{Section~} \begin{document} Test \end{document} ``` When running with `htlatex` however, the hyperref package stops early, and the `sectionautorefname` command is not defined. Full log output: ``` This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian) (format=latex 2015.3.16) 6 AUG 2015 12:02 entering extended mode restricted \write18 enabled. %&-line parsing enabled. **\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCo de"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c. {\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\ documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{ \HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode .a.b.c.\input test2.tex (./test2.tex (/usr/share/texlive/texmf-dist/tex/latex/base/book.cls Document Class: book 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo File: bk10.clo 2007/10/19 v1.4h Standard LaTeX file (size option) ) \c@part=\count79 \c@chapter=\count80 \c@section=\count81 \c@subsection=\count82 \c@subsubsection=\count83 \c@paragraph=\count84 \c@subparagraph=\count85 \c@figure=\count86 \c@table=\count87 \abovecaptionskip=\skip41 \belowcaptionskip=\skip42 \bibindent=\dimen102 ) (/usr/share/texmf/tex/generic/tex4ht/tex4ht.sty version 2008-10-27-17:23 Package: tex4ht -------------------------------------- --- Note --- for _ at preamble, use the command line option `early_' -------------------------------------- -------------------------------------- --- Note --- for ^ at preamble, use the command line option `early^' -------------------------------------- \tmp:toks=\toks14 ) (/usr/share/texmf/tex/generic/tex4ht/usepackage.4ht version 2009-05-21-09:32 ) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty Package: hyperref 2012/11/06 v6.83m Hypertext links for LaTeX (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty Package: hobsub-hyperref 2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty Package: hobsub-generic 2012/05/28 v1.13 Bundle oberdiek, subset generic (HO) Package: hobsub 2012/05/28 v1.13 Construct package bundles (HO) Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO) Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO) Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO) Package ifluatex Info: LuaTeX not detected. Package: ifvtex 2010/03/01 v1.5 Detect VTeX and its facilities (HO) Package ifvtex Info: VTeX not detected. Package: intcalc 2007/09/27 v1.1 Expandable calculations with integers (HO) Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO) Package ifpdf Info: pdfTeX in PDF mode is not detected. Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO) Package etexcmds Info: Could not find \expanded. (etexcmds) That can mean that you are not using pdfTeX 1.50 or (etexcmds) that some package has redefined \expanded. (etexcmds) In the latter case, load this package earlier. Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO) Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO) Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO ) Package pdftexcmds Info: LuaTeX not detected. Package pdftexcmds Info: \pdf@primitive is available. Package pdftexcmds Info: \pdf@ifprimitive is available. Package pdftexcmds Info: \pdfdraftmode is ignored in DVI mode. Package: pdfescape 2011/11/25 v1.13 Implements pdfTeX's escape features (HO) Package: bigintcalc 2012/04/08 v1.3 Expandable calculations on big integers (HO ) Package: bitset 2011/01/30 v1.1 Handle bit-vector datatype (HO) Package: uniquecounter 2011/01/30 v1.2 Provide unlimited unique counter (HO) ) Package hobsub Info: Skipping package `hobsub' (already loaded). Package: letltxmacro 2010/09/02 v1.4 Let assignment for LaTeX macros (HO) Package: hopatch 2012/05/28 v1.2 Wrapper for package hooks (HO) Package: xcolor-patch 2011/01/30 xcolor patch Package: atveryend 2011/06/30 v1.8 Hooks at the very end of document (HO) Package atveryend Info: \enddocument detected (standard20110627). Package: atbegshi 2011/10/05 v1.16 At begin shipout hook (HO) Package: refcount 2011/10/16 v3.4 Data extraction from label references (HO) Package: hycolor 2011/01/30 v1.7 Color options for hyperref/bookmark (HO) ) (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty Package: keyval 1999/03/16 v1.13 key=value parser (DPC) \KV@toks@=\toks15 ) (/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional ) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty Package: auxhook 2011/03/04 v1.3 Hooks for auxiliary files (HO) Package auxhook Warning: Cannot patch \document, (auxhook) using \AtBeginDocument instead. ) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO) ) \@linkdim=\dimen103 \Hy@linkcounter=\count88 \Hy@pagecounter=\count89 (/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def File: pd1enc.def 2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO) ) \Hy@SavedSpaceFactor=\count90 (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive ) Package hyperref Info: Option `colorlinks' set `true' on input line 4319. Package hyperref Info: Hyper figures OFF on input line 4443. Package hyperref Info: Link nesting OFF on input line 4448. Package hyperref Info: Hyper index ON on input line 4451. Package hyperref Info: Plain pages OFF on input line 4458. Package hyperref Info: Backreferencing OFF on input line 4463. Package hyperref Info: Implicit mode ON; LaTeX internals redefined. Package hyperref Info: Bookmarks ON on input line 4688. \c@Hy@tempcnt=\count91 (/usr/share/texlive/texmf-dist/tex/latex/url/url.sty \Urlmuskip=\muskip10 Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc. ) LaTeX Info: Redefining \url on input line 5041. \XeTeXLinkMargin=\dimen104 \Fld@menulength=\count92 \Field@Width=\dimen105 \Fld@charsize=\dimen106 \Field@toks=\toks16 Package hyperref Info: Hyper figures OFF on input line 6295. Package hyperref Info: Link nesting OFF on input line 6300. Package hyperref Info: Hyper index ON on input line 6303. Package hyperref Info: backreferencing OFF on input line 6310. Package hyperref Info: Link coloring ON on input line 6313. Package hyperref Info: Link coloring with OCG OFF on input line 6320. Package hyperref Info: PDF/A mode OFF on input line 6325. LaTeX Info: Redefining \ref on input line 6365. LaTeX Info: Redefining \pageref on input line 6369. \Hy@abspage=\count93 Package hyperref Message: Stopped early. ) Package hyperref Message: Driver: htex4ht. (/usr/share/texlive/texmf-dist/tex/latex/hyperref/htex4ht.def File: htex4ht.def 2012/11/06 v6.83m Hyperref driver for TeX4ht Package hyperref Info: tex4ht is already loaded. ) ! LaTeX Error: \sectionautorefname undefined. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.3 \renewcommand{\sectionautorefname} [1]{Section~} ? ! Interruption. \GenericError ... \endgroup l.3 \renewcommand{\sectionautorefname} [1]{Section~} ? X Here is how much of TeX's memory you used: 3787 strings out of 495029 56141 string characters out of 6181523 128583 words of memory out of 5000000 7043 multiletter control sequences out of 15000+600000 3640 words of font info for 14 fonts, out of 8000000 for 9000 14 hyphenation exceptions out of 8191 33i,0n,27p,661b,36s stack positions out of 5000i,500n,10000p,200000b,80000s No pages of output. ``` This is on Ubuntu 14.04, and I ran `tlmgr update --all` which indicates that no updates are available.
2015/08/06
[ "https://tex.stackexchange.com/questions/258999", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/37967/" ]
Try to move your redefinition after preamble, lot of stuff is done after preamble in `tex4ht`: ``` \documentclass[a4paper,11pt]{book} \usepackage{hyperref} \begin{document} \renewcommand{\sectionautorefname}[1]{my section~} \section{hello}\label{sec:hello} Test \autoref{sec:hello} \end{document} ``` [![enter image description here](https://i.stack.imgur.com/KWZML.png)](https://i.stack.imgur.com/KWZML.png)
I've used `\ifcsdef` which tests if a command is already defined (without `\`). If it's defined then use `\renewcommand` else `\newcommand` or `\providecommand`. ``` \documentclass[a4paper,11pt]{book} \usepackage{etoolbox} \usepackage{hyperref} \ifcsdef{sectionautorefname}{% \renewcommand{\sectionautorefname}[1]{Section~} }{% \providecommand{\sectionautorefname}[1]{Section~} } \begin{document} \chapter{First chapter} \section{First} \label{First} Test \clearpage \section{Second} \label{Second} In \autoref{First} we saw... \end{document} ``` [![enter image description here](https://i.stack.imgur.com/QKI4n.jpg)](https://i.stack.imgur.com/QKI4n.jpg)
2,342,358
I'm interested in the $F$-algebra $$F[x\_1, \dots, x\_n]/(x\_1^2, \dots, x\_n^2).$$ and its representations. Is there a name for this algebra? I was led to this while searching for commuting matrices $A\_1, \dots, A\_n$ such that $A\_i^2 = 0$ for each $i$, and $$A\_1 A\_2 \cdots A\_n \neq 0.$$ It's easy to find such matrices of size $2^n$ by considering the matrices of $x\_1, \dots, x\_n$ in the regular representation of the above algebra, but I would like to find smaller matrices, if possible.
2017/06/30
[ "https://math.stackexchange.com/questions/2342358", "https://math.stackexchange.com", "https://math.stackexchange.com/users/125932/" ]
When we say the group $\mathbb{Z}\_4$, we're actually talking about $(\mathbb{Z}\_4, +)$, meaning the operation over the group is $+$, not $\times$. Thus, 1 is a generator, because every element of $\mathbb{Z}\_4$ can be written as $n \times 1= 1+1+1 + \dots$ Now you may ask, why wouldnt we give $\mathbb{Z}\_4$ the $\times$ operation ? Well, what would be the inverse if 0 ? Of 2 ?
The number $1$ generates $\mathbb{Z}\_4$ because $\mathbb{Z}\_4=\{1,1+1,1+1+1,1+1+1+1\}$.
2,342,358
I'm interested in the $F$-algebra $$F[x\_1, \dots, x\_n]/(x\_1^2, \dots, x\_n^2).$$ and its representations. Is there a name for this algebra? I was led to this while searching for commuting matrices $A\_1, \dots, A\_n$ such that $A\_i^2 = 0$ for each $i$, and $$A\_1 A\_2 \cdots A\_n \neq 0.$$ It's easy to find such matrices of size $2^n$ by considering the matrices of $x\_1, \dots, x\_n$ in the regular representation of the above algebra, but I would like to find smaller matrices, if possible.
2017/06/30
[ "https://math.stackexchange.com/questions/2342358", "https://math.stackexchange.com", "https://math.stackexchange.com/users/125932/" ]
The number $1$ generates $\mathbb{Z}\_4$ because $\mathbb{Z}\_4=\{1,1+1,1+1+1,1+1+1+1\}$.
Formally speaking, we *define* a group to be an **ordered pair** of a set $G$ coupled with a binary operation $\*$ and satisfies the group axioms, which we write as $(G,\*)$. In this case, our set is $\mathbb{Z}\_4$ (set of residues modulo $4$) and our operation is $+$, so we can write the group as $(\mathbb{Z}\_4,+)$. It is imperative to specify the binary operation on the set, as it is intrinsic to the definition of group. In general, it is easy to see that for any additive group $\mathbb{Z}\_n$ with $n \in \mathbb{Z}\_{\geq 2}$, $1$ must be a generator as we can execute the addition operation $1, 2, ..., n-1$ times, where at the $(n-1)$-th iteration, we reduce modulo $n$ to get $0$.
2,342,358
I'm interested in the $F$-algebra $$F[x\_1, \dots, x\_n]/(x\_1^2, \dots, x\_n^2).$$ and its representations. Is there a name for this algebra? I was led to this while searching for commuting matrices $A\_1, \dots, A\_n$ such that $A\_i^2 = 0$ for each $i$, and $$A\_1 A\_2 \cdots A\_n \neq 0.$$ It's easy to find such matrices of size $2^n$ by considering the matrices of $x\_1, \dots, x\_n$ in the regular representation of the above algebra, but I would like to find smaller matrices, if possible.
2017/06/30
[ "https://math.stackexchange.com/questions/2342358", "https://math.stackexchange.com", "https://math.stackexchange.com/users/125932/" ]
When we say the group $\mathbb{Z}\_4$, we're actually talking about $(\mathbb{Z}\_4, +)$, meaning the operation over the group is $+$, not $\times$. Thus, 1 is a generator, because every element of $\mathbb{Z}\_4$ can be written as $n \times 1= 1+1+1 + \dots$ Now you may ask, why wouldnt we give $\mathbb{Z}\_4$ the $\times$ operation ? Well, what would be the inverse if 0 ? Of 2 ?
Formally speaking, we *define* a group to be an **ordered pair** of a set $G$ coupled with a binary operation $\*$ and satisfies the group axioms, which we write as $(G,\*)$. In this case, our set is $\mathbb{Z}\_4$ (set of residues modulo $4$) and our operation is $+$, so we can write the group as $(\mathbb{Z}\_4,+)$. It is imperative to specify the binary operation on the set, as it is intrinsic to the definition of group. In general, it is easy to see that for any additive group $\mathbb{Z}\_n$ with $n \in \mathbb{Z}\_{\geq 2}$, $1$ must be a generator as we can execute the addition operation $1, 2, ..., n-1$ times, where at the $(n-1)$-th iteration, we reduce modulo $n$ to get $0$.
66,878,014
Im working on a larger project but I'm trying out a simpler version of countdown timer with only seconds and not minutes. Code below description So basically I have 60 seconds in html(id="initial"). I have button with a function called timer. In javascript i get the value in the h3 tag, by using parseint on the variable and of course innerHTML to get the text inside the tag itself. Then I create a new variable called newTime and basically set it to newTime = initial--; Then I update the initial with innerHTMl, like initial.inneHTML = newTime. It doesnt work, however. Anyways heres the code: ```js setInterval(setUp, 1000); function setUp(){ var initial = parseInt(document.getElementById("initial").innerHTML); var newTime = initial--; initial.innerHTML = newTime; } ``` ```html <button onclick="setUp()">Activate timer</button> <h3 id="initial">60</h3> ```
2021/03/30
[ "https://Stackoverflow.com/questions/66878014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13076656/" ]
They can run the script by running it from the directory where it is saved: ``` cd dir/with/script ./script.sh ``` Or ``` ~/bin/script.sh ``` If the script is saved in the bin directory in the home of the user.
Define a shell alias. For example, the following alias is called `x` and it executes `ls -alF *.py`: ```sh $ alias x="ls -alF *.py" ``` No files need to be written in order for a shell alias to be defined or used. Now you can type `x` into a shell prompt in the shell where you defined the alias, and it will return a detailed list of your Python source files. ```sh $ alias x="ls -alF *.py" $ x -rwxrwxr-x 1 mslinn mslinn 653 Feb 19 17:19 django-admin.py* -rwxrwxr-x 1 mslinn mslinn 1675 Sep 19 2020 jp.py* -rwxrwxr-x 1 mslinn mslinn 594 Sep 19 2020 rst2html.py* -rwxrwxr-x 1 mslinn mslinn 6413 Sep 19 2020 wsdump.py* ``` If you want to be able to specify the pattern for the files to list, do not include that in the alias. For example: ```sh $ alias y="ls -alF" $ y *.md -rw-rw-r-- 1 mslinn mslinn 606 Nov 17 20:31 README.md ``` You can even just define default parameters, and add more: ```sh $ alias z="ls -a" $ z -lF *.md -rw-rw-r-- 1 mslinn mslinn 606 Nov 17 20:31 README.md ```
66,878,014
Im working on a larger project but I'm trying out a simpler version of countdown timer with only seconds and not minutes. Code below description So basically I have 60 seconds in html(id="initial"). I have button with a function called timer. In javascript i get the value in the h3 tag, by using parseint on the variable and of course innerHTML to get the text inside the tag itself. Then I create a new variable called newTime and basically set it to newTime = initial--; Then I update the initial with innerHTMl, like initial.inneHTML = newTime. It doesnt work, however. Anyways heres the code: ```js setInterval(setUp, 1000); function setUp(){ var initial = parseInt(document.getElementById("initial").innerHTML); var newTime = initial--; initial.innerHTML = newTime; } ``` ```html <button onclick="setUp()">Activate timer</button> <h3 id="initial">60</h3> ```
2021/03/30
[ "https://Stackoverflow.com/questions/66878014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13076656/" ]
They can run the script by running it from the directory where it is saved: ``` cd dir/with/script ./script.sh ``` Or ``` ~/bin/script.sh ``` If the script is saved in the bin directory in the home of the user.
Your script can call a script within the same folder, to add an alias to the bash session and create variables for your script to run, this would be available for the duration of the bash session. Once you have ended this bash session, the alias and the variables, the script created would be lost.
4,160,007
I finished an application and the users want to "sex up the interaction feeling" by adding some sound samples that should be played when some specified acitons occur. For the programming point of view that isn't too difficult, but how do I get some good audio samples? How do you solve this problem? Create your own sound files? How? Which software should I use? Or is there a big database in the Internet that offers free sound samples (I did a google search but almost all results are just useless sites). Or do you convince your customers that sound is overrated? Do you even think that sound is necessary in an well-done application?
2010/11/11
[ "https://Stackoverflow.com/questions/4160007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can get some decent sounds from [flashkit](http://www.flashkit.com/soundfx/) - there is also some on [findsounds](http://www.findsounds.com/) and [freesounds](http://www.freesound.org/). Use these in conjunction with a simple audio editing program. I use [audacity](http://audacity.sourceforge.net/) (its for mac only).
What kind of sound samples are you looking to find? Like individual instruments, like a drum kit, or sound effects? As far as editing goes, Reaper is the best free sound editor you can find.
4,160,007
I finished an application and the users want to "sex up the interaction feeling" by adding some sound samples that should be played when some specified acitons occur. For the programming point of view that isn't too difficult, but how do I get some good audio samples? How do you solve this problem? Create your own sound files? How? Which software should I use? Or is there a big database in the Internet that offers free sound samples (I did a google search but almost all results are just useless sites). Or do you convince your customers that sound is overrated? Do you even think that sound is necessary in an well-done application?
2010/11/11
[ "https://Stackoverflow.com/questions/4160007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What kind of sound samples are you looking to find? Like individual instruments, like a drum kit, or sound effects? As far as editing goes, Reaper is the best free sound editor you can find.
We used a site called spinboom for some buttons and powerup sounds for an indie game with some friends. Not free though.. <https://www.spinboom.com/index.php/sound>
4,160,007
I finished an application and the users want to "sex up the interaction feeling" by adding some sound samples that should be played when some specified acitons occur. For the programming point of view that isn't too difficult, but how do I get some good audio samples? How do you solve this problem? Create your own sound files? How? Which software should I use? Or is there a big database in the Internet that offers free sound samples (I did a google search but almost all results are just useless sites). Or do you convince your customers that sound is overrated? Do you even think that sound is necessary in an well-done application?
2010/11/11
[ "https://Stackoverflow.com/questions/4160007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can get some decent sounds from [flashkit](http://www.flashkit.com/soundfx/) - there is also some on [findsounds](http://www.findsounds.com/) and [freesounds](http://www.freesound.org/). Use these in conjunction with a simple audio editing program. I use [audacity](http://audacity.sourceforge.net/) (its for mac only).
We used a site called spinboom for some buttons and powerup sounds for an indie game with some friends. Not free though.. <https://www.spinboom.com/index.php/sound>
8,406,305
I am struggling to find a way to perform better linear regression. I have been using the [Moore-Penrose pseudoinverse](http://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse) and [QR decomposition](http://en.wikipedia.org/wiki/Qr_decomposition) with [JAMA library](http://math.nist.gov/javanumerics/jama/), but the results are not satisfactory. Would [ojAlgo](http://ojalgo.org/) be useful? I have been hitting accuracy limits that I know should not be there. The algorithm should be capable of reducing the impact of an input variable to zero. Perhaps this takes the form of iteratively reweighted least squares, but I do not know that algorithm and cannot find a library for it. The output should be a weight matrix or vector such that matrix multiplication of the input matrix by the weight matrix will yield a prediction matrix. My input matrix will almost always have more rows than columns. Thank you for your help.
2011/12/06
[ "https://Stackoverflow.com/questions/8406305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062571/" ]
I don't fully understand your question, but I've used [Apache Commons Math](http://commons.apache.org/math/userguide/stat.html#a1.4_Simple_regression) to do linear regressions before.
If you want to use a more generic external tool for this, use Octave. I think it's more suitable for these kind of things. If not, take a look to: [Logistic Regression in Java](https://stackoverflow.com/questions/7182748/logistic-regression-in-java) Specifically: <http://commons.apache.org/math/userguide/overview.html> or <http://mallet.cs.umass.edu/optimization.php> <http://mahout.apache.org/>
7,200,475
I've tried many ways to manage RenderTransform within ScrollViewer (Windows Phone 7 Silverlight), but it seems to me almost impossible now. What I got is Grid with with its sizes inside ScrollViewer and I want to change grid's content size from code by RenderTransform by it do nothing! ``` <ScrollViewer x:Name="scrollViewer" Width="800" Height="480" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> <Grid x:Name="grid" Width="1600" Height="960" HorizontalAlignment="Left" VerticalAlignment="Top"> <Grid.RenderTransform> <CompositeTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1"/> </Grid.RenderTransform> <Image x:Name="backgroundImage" Source="/Images/backgrounds/Happy rainbow.png" Stretch="Fill"/> </Grid> </ScrollViewer> ``` In code: ``` private void button_Click(object sender, RoutedEventArgs e) { (grid.RenderTransform as CompositeTransform ).CenterX = 0; (grid.RenderTransform as CompositeTransform ).CenterY = 0; (grid.RenderTransform as CompositeTransform ).ScaleX = 0.5; (grid.RenderTransform as CompositeTransform ).ScaleY = 0.5; grid.UpdateLayout(); } ``` Binding on Scale and Visual states do nothig too. I really would appreciate your help.
2011/08/26
[ "https://Stackoverflow.com/questions/7200475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676653/" ]
Better idea... put your Grid content into an ItemsControl, and perform a ScaleTransform on the ItemsControl. ``` <Grid> <ItemsControl x:Name="ContentScaler"> <Image x:Name="backgroundImage" Source="/Images/backgrounds/Happy rainbow.png" Stretch="Fill"/> </ItemsControl> </Grid> ``` And in the code-behind... ``` ContentScaler.RenderTransform = new ScaleTransform() { ScaleX = 0.5, ScaleY = 0.5, CenterX = 0, CenterY = 0 }; ``` Depending on what else you may need to do, you may need to do something like set a WrapPanel as the ItemsPanelTemplate and/or resize the ItemsControl when you do your scaling. It can get a little tricky, but hopefully this will get you pointed in the right direction. The use of Grid in Silverlight tends to be a bit overused also, IMHO, unless one needs to break things into a table type layout. A Canvas may be better suited for what you are doing.
I'm not sure if this is exactly what you need but if you insert an extra grid like this... ``` <ScrollViewer Grid.Row="1" x:Name="scrollViewer" Width="800" Height="480" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> <Grid x:Name="grid" HorizontalAlignment="Left" VerticalAlignment="Top"> <Grid Width="1600" Height="960"> <Grid.RenderTransform> <CompositeTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1" /> </Grid.RenderTransform> <Image x:Name="backgroundImage" Source="ApplicationIcon.png" Stretch="Fill" /> </Grid> </Grid> </ScrollViewer> ``` at least the contents will get scaled..
5,185,137
I had an argument with my colleagues over the difference between 32-bit and 64-bit Excel 2007. I said the main difference is that in 64-bit version, we'll be able to add more than 65536 rows where as in 32-bit we won't be able to add more than 65536 rows. Please clarify this.
2011/03/03
[ "https://Stackoverflow.com/questions/5185137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/643517/" ]
No, both 32 and 64 bit versions support more than 65536 rows, and have done since Excel 2007 was released. The main difference is that you can work with very large workbooks in the 64 bit version. The downside of the 64 bit version is that, at present, there is poor support from 3rd party add-ins. **Update** This was written back in 2011. I'm sure that support for 3rd party add-ins is better now. However, it may still be an issue, and before installing the 64 bit version it is worth checking that all your required tools that are built on top of Excel are compatible with the 64 bit version.
The main difference is that the 32 bit version only has access to 2GB of memory. Very large integer calculations *might* also be faster in the 64 bit version. Both versions can deal with more than 65536 rows.
5,185,137
I had an argument with my colleagues over the difference between 32-bit and 64-bit Excel 2007. I said the main difference is that in 64-bit version, we'll be able to add more than 65536 rows where as in 32-bit we won't be able to add more than 65536 rows. Please clarify this.
2011/03/03
[ "https://Stackoverflow.com/questions/5185137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/643517/" ]
No, both 32 and 64 bit versions support more than 65536 rows, and have done since Excel 2007 was released. The main difference is that you can work with very large workbooks in the 64 bit version. The downside of the 64 bit version is that, at present, there is poor support from 3rd party add-ins. **Update** This was written back in 2011. I'm sure that support for 3rd party add-ins is better now. However, it may still be an issue, and before installing the 64 bit version it is worth checking that all your required tools that are built on top of Excel are compatible with the 64 bit version.
Excel 2007 has only a 32-bit version. Excel 2010 introduced the 64-bit option, which Microsoft actually doesn't recommend unless you really really need it for huge databases.
5,185,137
I had an argument with my colleagues over the difference between 32-bit and 64-bit Excel 2007. I said the main difference is that in 64-bit version, we'll be able to add more than 65536 rows where as in 32-bit we won't be able to add more than 65536 rows. Please clarify this.
2011/03/03
[ "https://Stackoverflow.com/questions/5185137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/643517/" ]
Excel 2007 has only a 32-bit version. Excel 2010 introduced the 64-bit option, which Microsoft actually doesn't recommend unless you really really need it for huge databases.
The main difference is that the 32 bit version only has access to 2GB of memory. Very large integer calculations *might* also be faster in the 64 bit version. Both versions can deal with more than 65536 rows.
5,735,712
I am new to Grails and Groovy however my problem is a simple but strange one. I am making calls to a remote web service as follows: ``` public Boolean addInvites(eventid,sessionkey ){ String url = this.API_URL+"AddInvites?apikey=${sessionkey}&eventid=${eventid}&userids[]=5&userids[]=23"; def callurl = new URL(url); println callurl; def jsonResponse = callurl.getText(); println jsonResponse; def jsonParsedObject = JSON.parse(jsonResponse); if(jsonParsedObject){ println jsonParsedObject; if(jsonParsedObject.code == 200){ return true; } } } return false; ``` } The API\_URL here is a "https://api..com/" Normally making these calls works fine. Json gets returned and parsed. However with the above method, if I add only one userids[]=5 then it works fine but if i add a second one everything hangs after the "println callurl;" I've checked on the webservice side and the call happens and everything works as expected. If I call it in the browser it works fine. but from the grails web app it simply hangs. I know I'm probably doing something silly here, but I am really stuck. Hope you guys can help.
2011/04/20
[ "https://Stackoverflow.com/questions/5735712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425810/" ]
Edit the first location and then use `.` to repeat the action at each additional location.
I'd reverse the order of your steps. Instead of marking each location, then performing the change on all at once, just edit the first location, then use `.` to do the same to each of the others. This doesn't add any keystrokes to your use case; instead of hitting some key to mark a spot beforehand, you hit `.` afterward. If you suspect you might accidentally do some other things in between usages, you could record a macro using `q<register>` the first time, and play it back with `@<register>` each of the others.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
I just shot them. It "alarms" people, but they get over it, and it doesn't count as being "detected". I habitually alarm people in order to draw them away from their friends so I can put the beat down on them. I tried sneaking up on them a couple of times, but it didn't work worth a damn for me...I think partly because I didn't realize there was a mine against the wall I was trying to sneak from. If you're going to sneak through this bit, go all the way to the dead end on the right, and proceed from there. That might work better.
You can just shoot the mines and hide until alert passes
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
It's not hard at all if you take these steps. In fact, if you do the following you can't even set them off accidentally (unless you jump or knock something over). 1. Press Caps Lock, or whatever key you've mapped for "Toggle Walk", to switch from fast movement to slow movement. 2. Crouch. 3. Shuffle over to the mine while crouched. 4. Highlight the mine. 5. Press whatever key you've mapped to "activate object". This will disable the mine. 6. If you want to take the mine, "activate object" again.
I just shot them. It "alarms" people, but they get over it, and it doesn't count as being "detected". I habitually alarm people in order to draw them away from their friends so I can put the beat down on them. I tried sneaking up on them a couple of times, but it didn't work worth a damn for me...I think partly because I didn't realize there was a mine against the wall I was trying to sneak from. If you're going to sneak through this bit, go all the way to the dead end on the right, and proceed from there. That might work better.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
The solution to disabling mines is to walk incredibly slowly (as slowly as possible, then slower). You'll be able to disable and pick up the mine for placement/selling later. You could also disable them via explosion (see @Chris and @OrigamiRobot's answers), but that is not preferable for stealth.
You can just shoot the mines and hide until alert passes
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
It's not hard at all if you take these steps. In fact, if you do the following you can't even set them off accidentally (unless you jump or knock something over). 1. Press Caps Lock, or whatever key you've mapped for "Toggle Walk", to switch from fast movement to slow movement. 2. Crouch. 3. Shuffle over to the mine while crouched. 4. Highlight the mine. 5. Press whatever key you've mapped to "activate object". This will disable the mine. 6. If you want to take the mine, "activate object" again.
You can just shoot the mines and hide until alert passes
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
It's not hard at all if you take these steps. In fact, if you do the following you can't even set them off accidentally (unless you jump or knock something over). 1. Press Caps Lock, or whatever key you've mapped for "Toggle Walk", to switch from fast movement to slow movement. 2. Crouch. 3. Shuffle over to the mine while crouched. 4. Highlight the mine. 5. Press whatever key you've mapped to "activate object". This will disable the mine. 6. If you want to take the mine, "activate object" again.
The solution to disabling mines is to walk incredibly slowly (as slowly as possible, then slower). You'll be able to disable and pick up the mine for placement/selling later. You could also disable them via explosion (see @Chris and @OrigamiRobot's answers), but that is not preferable for stealth.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
It's not hard at all if you take these steps. In fact, if you do the following you can't even set them off accidentally (unless you jump or knock something over). 1. Press Caps Lock, or whatever key you've mapped for "Toggle Walk", to switch from fast movement to slow movement. 2. Crouch. 3. Shuffle over to the mine while crouched. 4. Highlight the mine. 5. Press whatever key you've mapped to "activate object". This will disable the mine. 6. If you want to take the mine, "activate object" again.
I believe EMP grenades will disable them, but you would need quite a few of them to pull it off.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
I cannot find a way to disable mines either. In that spot, I picked up a barrel and threw it down the hall to safely trigger all the mines. This will alert a lot of people, however.
I just shot them. It "alarms" people, but they get over it, and it doesn't count as being "detected". I habitually alarm people in order to draw them away from their friends so I can put the beat down on them. I tried sneaking up on them a couple of times, but it didn't work worth a damn for me...I think partly because I didn't realize there was a mine against the wall I was trying to sneak from. If you're going to sneak through this bit, go all the way to the dead end on the right, and proceed from there. That might work better.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
It's not hard at all if you take these steps. In fact, if you do the following you can't even set them off accidentally (unless you jump or knock something over). 1. Press Caps Lock, or whatever key you've mapped for "Toggle Walk", to switch from fast movement to slow movement. 2. Crouch. 3. Shuffle over to the mine while crouched. 4. Highlight the mine. 5. Press whatever key you've mapped to "activate object". This will disable the mine. 6. If you want to take the mine, "activate object" again.
I cannot find a way to disable mines either. In that spot, I picked up a barrel and threw it down the hall to safely trigger all the mines. This will alert a lot of people, however.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
I believe EMP grenades will disable them, but you would need quite a few of them to pull it off.
I just shot them. It "alarms" people, but they get over it, and it doesn't count as being "detected". I habitually alarm people in order to draw them away from their friends so I can put the beat down on them. I tried sneaking up on them a couple of times, but it didn't work worth a damn for me...I think partly because I didn't realize there was a mine against the wall I was trying to sneak from. If you're going to sneak through this bit, go all the way to the dead end on the right, and proceed from there. That might work better.
28,699
I'm at a hallway filled with proximity mines and things are **not** going well. ![DANGER, DANGER](https://i.stack.imgur.com/bTseM.png) I've tried to crouch past them or in between them but they're very sensitive and I don't think that's a possibility. Shooting them sets them off without me getting killed but it's alarming to the bad guys nearby and that's not good - it is a last resort if I need it. Is there another way to disable or get past these mines without setting them off?
2011/08/25
[ "https://gaming.stackexchange.com/questions/28699", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/1070/" ]
I believe EMP grenades will disable them, but you would need quite a few of them to pull it off.
You can just shoot the mines and hide until alert passes
26,600,987
I am getting an error on the first line of the below code. The error is ``` error: expected ‘,’ or ‘...’ before ‘distances’ ``` and I don't get what is actually wrong with it. I am using ideone, if that helps, but I don't think that is causing the problem. ``` vector<string> Most(bitset<4> treasure, int distance, string path, int p, int[] distances, string[] paths){ for(int i = 1; i<4; i++){ if(100>=distances[p*4+1+i]+distances[i*5+1]){ Most(treasure, distance+distances[p*4+1+i], path.append(paths[p*4+1+i]),i, distances, paths); } } vector<string> test; return test; } ```
2014/10/28
[ "https://Stackoverflow.com/questions/26600987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4188360/" ]
Change these parameter declarations ``` int[] distances, string[] paths ``` to ``` int distances[], string paths[] ``` The syntax you use is valid in C# not in C++. Are you sure that the function is valid? It is always returns an empty vector. And take into account that original object used as argument path will not be changed because it is passed by value to the function
This compiles.. although I am not sure what it should do: ``` #include <vector> #include <string> #include <bitset> using namespace std; // I modified the function signature from "string[] paths" to "string* paths", // the same for `int[] distances` vector<string> Most(bitset<4> treasure, int distance, string path, int p, int* distances, string* paths) { for(int i = 1; i<4; i++){ if(100>=distances[p*4+1+i]+distances[i*5+1]){ Most(treasure, distance+distances[p*4+1+i], path.append(paths[p*4+1+i]),i, distances, paths); } } vector<string> test; return test; } // it is better if you post runnable code int main() { } ``` If you still have troubles, try to modify your code to be minimal, but runnable. ;)