tyson0420/stack_llama_fil_ai
Text Generation • 7B • Updated • 90
qid int64 1 74.7M | question stringlengths 25 64.6k | date stringlengths 10 10 | metadata sequence | response_j stringlengths 0 115k | response_k stringlengths 3 61.5k |
|---|---|---|---|---|---|
52,903,968 | I'm building an app that needs to make HTTP requests to an API. I want to handle the network connection status , so when the network is not reachable it presents a popup dialog and when the network is reachable again the popup dismisses.
Currently I am able to do that , THE PROBLEM is that when the popup is dismissed ... | 2018/10/20 | [
"https://Stackoverflow.com/questions/52903968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10532311/"
] | You can set a flag when the https api network connection is started for the first time.
```
var networkFlag = true
```
In that case your program would know that you actually started a network call.
Next, when you are in between the request and internet connectivity is not reachable, it would give a popup.
Solution ... | Screenshots:

Internet connection OK
Reopening app. Internet connection: WRONG ( Airplane mode )


Internet con... |
1,569,507 | On a couple of projects now, I've used the SVN keywords to retrieve some information about the version of some core files. Something like this (PHP):
```
$revision = '$Revision: 1254 $'; // automatically updated each commit
$revision = preg_replace("/[^0-9]/", "");
echo "This file is at revision #" . $revision;
```
... | 2009/10/14 | [
"https://Stackoverflow.com/questions/1569507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Mm, that's veering into WTF world as far as I'm concerned.
Better off configuring those things as environment variables in a general place in your application. | In my opinion, using the SVN keywords to affect program logic is a little bit obscure. I don't feel it qualifies as pathological, but it would surely require some explanatory comments.
Also, in your example, you simply echo what amounts to version information. I take it from what you wrote that you intend actually to ... |
1,569,507 | On a couple of projects now, I've used the SVN keywords to retrieve some information about the version of some core files. Something like this (PHP):
```
$revision = '$Revision: 1254 $'; // automatically updated each commit
$revision = preg_replace("/[^0-9]/", "");
echo "This file is at revision #" . $revision;
```
... | 2009/10/14 | [
"https://Stackoverflow.com/questions/1569507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Mm, that's veering into WTF world as far as I'm concerned.
Better off configuring those things as environment variables in a general place in your application. | This is a really bad idea, IMO. If you need configuration management, do it using configuration files and conditionals. Don't depend on your source code control system for configuration management. |
1,569,507 | On a couple of projects now, I've used the SVN keywords to retrieve some information about the version of some core files. Something like this (PHP):
```
$revision = '$Revision: 1254 $'; // automatically updated each commit
$revision = preg_replace("/[^0-9]/", "");
echo "This file is at revision #" . $revision;
```
... | 2009/10/14 | [
"https://Stackoverflow.com/questions/1569507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Mm, that's veering into WTF world as far as I'm concerned.
Better off configuring those things as environment variables in a general place in your application. | Not a good idea. A much better way to achieve this would be to assign the version/build number as part of of a continuous integration or build process. This can be done in .Net by changing the AssemblyInfo.cs file before building. |
1,569,507 | On a couple of projects now, I've used the SVN keywords to retrieve some information about the version of some core files. Something like this (PHP):
```
$revision = '$Revision: 1254 $'; // automatically updated each commit
$revision = preg_replace("/[^0-9]/", "");
echo "This file is at revision #" . $revision;
```
... | 2009/10/14 | [
"https://Stackoverflow.com/questions/1569507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Mm, that's veering into WTF world as far as I'm concerned.
Better off configuring those things as environment variables in a general place in your application. | I would consider this unacceptable, because you may at some point in the future migrate to a different source control system, whereupon this house of cards would come crashing down. It would come crashing down in a way that was (a) hard to detect, and (b) hard to fix. |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | You can add those to the setup script:
```
[Files]
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall
[Run]
Filename: {tmp}\vcredist_x86.exe; \
Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; \
StatusMsg: "Installing VC++ 2008 Redistributables..."
```
Note that the run p... | I modified the above code as follows. Then I got it worked properly and the entire installation was pretty smooth and silent.
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/q /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
Check: VCRedistNeedsInstall; Wor... |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | I modified the above code as follows. Then I got it worked properly and the entire installation was pretty smooth and silent.
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/q /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
Check: VCRedistNeedsInstall; Wor... | Here is my solution:
```
Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."
``` |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | For a smooth install, check if it's necessary to install the redistributable. If the installed version is already up to date (quite likely), don't even unpack it.
```
[Files]
; VC++ redistributable runtime. Extracted by VC2017RedistNeedsInstall(), if needed.
Source: ".\Redist\VC_redist_2017.x64.exe"; DestDir: {tmp}; F... | I modified the above code as follows. Then I got it worked properly and the entire installation was pretty smooth and silent.
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/q /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
Check: VCRedistNeedsInstall; Wor... |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | You can add those to the setup script:
```
[Files]
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall
[Run]
Filename: {tmp}\vcredist_x86.exe; \
Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; \
StatusMsg: "Installing VC++ 2008 Redistributables..."
```
Note that the run p... | Here is my solution:
```
Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."
``` |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | For a smooth install, check if it's necessary to install the redistributable. If the installed version is already up to date (quite likely), don't even unpack it.
```
[Files]
; VC++ redistributable runtime. Extracted by VC2017RedistNeedsInstall(), if needed.
Source: ".\Redist\VC_redist_2017.x64.exe"; DestDir: {tmp}; F... | You can add those to the setup script:
```
[Files]
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall
[Run]
Filename: {tmp}\vcredist_x86.exe; \
Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; \
StatusMsg: "Installing VC++ 2008 Redistributables..."
```
Note that the run p... |
24,574,035 | How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my `[Run]` section's code:-
```
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /... | 2014/07/04 | [
"https://Stackoverflow.com/questions/24574035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355059/"
] | For a smooth install, check if it's necessary to install the redistributable. If the installed version is already up to date (quite likely), don't even unpack it.
```
[Files]
; VC++ redistributable runtime. Extracted by VC2017RedistNeedsInstall(), if needed.
Source: ".\Redist\VC_redist_2017.x64.exe"; DestDir: {tmp}; F... | Here is my solution:
```
Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."
``` |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | Go into the menu on your external monitor. If there's an option that allows one device to toggle the power on the other via HDMI, make sure this is deselected (honestly, I don't think this will have an effect as your laptop is doing the driving, but for the sake of troubleshooting...).
I too use an MBP Retina with ext... | I don't know if you can prevent it, but I use an app called [Stay](https://cordlessdog.com/stay/) by Cordless Dog ($15, free trial), which keeps windows in place between display configuration changes. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | Go into the menu on your external monitor. If there's an option that allows one device to toggle the power on the other via HDMI, make sure this is deselected (honestly, I don't think this will have an effect as your laptop is doing the driving, but for the sake of troubleshooting...).
I too use an MBP Retina with ext... | The brightness issue was a bug which was fixed in 10.15.4; the resizing and placement issue of windows is an HDMI problem and how the Mac sees it.
If you have a DisplayPort, use that connection. It solved all the problems! |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | Go into the menu on your external monitor. If there's an option that allows one device to toggle the power on the other via HDMI, make sure this is deselected (honestly, I don't think this will have an effect as your laptop is doing the driving, but for the sake of troubleshooting...).
I too use an MBP Retina with ext... | On recent versions of macOS set a user password to wake from sleep. The machine will then wake to a login screen and by the time you have entered the password, the external display will have been recognised and should then restore all the original window positions correctly. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | Go into the menu on your external monitor. If there's an option that allows one device to toggle the power on the other via HDMI, make sure this is deselected (honestly, I don't think this will have an effect as your laptop is doing the driving, but for the sake of troubleshooting...).
I too use an MBP Retina with ext... | I had this problem for a while and tried lots of apps to fix it. Finally found a solution which was to use a HDMI to USB-C cable instead of HDMI-HDMI. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | I don't know if you can prevent it, but I use an app called [Stay](https://cordlessdog.com/stay/) by Cordless Dog ($15, free trial), which keeps windows in place between display configuration changes. | The brightness issue was a bug which was fixed in 10.15.4; the resizing and placement issue of windows is an HDMI problem and how the Mac sees it.
If you have a DisplayPort, use that connection. It solved all the problems! |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | I don't know if you can prevent it, but I use an app called [Stay](https://cordlessdog.com/stay/) by Cordless Dog ($15, free trial), which keeps windows in place between display configuration changes. | On recent versions of macOS set a user password to wake from sleep. The machine will then wake to a login screen and by the time you have entered the password, the external display will have been recognised and should then restore all the original window positions correctly. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | I don't know if you can prevent it, but I use an app called [Stay](https://cordlessdog.com/stay/) by Cordless Dog ($15, free trial), which keeps windows in place between display configuration changes. | I had this problem for a while and tried lots of apps to fix it. Finally found a solution which was to use a HDMI to USB-C cable instead of HDMI-HDMI. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | The brightness issue was a bug which was fixed in 10.15.4; the resizing and placement issue of windows is an HDMI problem and how the Mac sees it.
If you have a DisplayPort, use that connection. It solved all the problems! | I had this problem for a while and tried lots of apps to fix it. Finally found a solution which was to use a HDMI to USB-C cable instead of HDMI-HDMI. |
179,928 | I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.
When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is tha... | 2015/04/07 | [
"https://apple.stackexchange.com/questions/179928",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/103560/"
] | On recent versions of macOS set a user password to wake from sleep. The machine will then wake to a login screen and by the time you have entered the password, the external display will have been recognised and should then restore all the original window positions correctly. | I had this problem for a while and tried lots of apps to fix it. Finally found a solution which was to use a HDMI to USB-C cable instead of HDMI-HDMI. |
10,441,077 | The company I'm working at is considering using RestKit. However, the JSON that our server returns is surrounded characters for security reasons. It's a pain. In another iPhone app, one that does not use RestKit and uses JSON only very little, I parse the string returned from the server, removing the characters precedi... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10441077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/258089/"
] | I wanted to find a fix that did not require me to change the RestKit codebase in any way and I found it. The answer was to create and register my own parser.
Parsers need to conform to the RKParser protocol. Basically what I needed to do was trim the server response and not parse the response into objects - there was... | Just wanted to note that nowadays you can implement your own retrieve/map operation by subclassing the
* `RKHTTPRequestOperation` [(doc)](http://restkit.org/api/0.20.3/Classes/RKHTTPRequestOperation.html) — for retrieving file from server
* `RKObjectRequestOperation` [(doc)](http://restkit.org/api/0.20.3/Classes/RKObj... |
28,859,289 | I have two models: Sites and Regions. A Region has many Sites.
```
class Site(models.Model):
name = models.CharField(max_length=200, unique=True)
class Region(models.Model):
name = models.CharField(max_length=200, unique=True)
sites = models.ManyToManyField('Site')
```
i would like to loop through the query... | 2015/03/04 | [
"https://Stackoverflow.com/questions/28859289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722798/"
] | Assign the result of `df.groupby('User_ID')['Datetime'].apply(lambda g: len(g)>1)` to a variable so you can perform boolean indexing and then use the index from this to call `isin` and filter your orig df:
```
In [366]:
users = df.groupby('User_ID')['Datetime'].apply(lambda g: len(g)>1)
users
Out[366]:
User_ID
18975... | first, make sure you have no duplicate entries:
```
df = df.drop_duplicates()
```
then, figure out the counts for each:
```
counts = df.groupby('User_ID').Datetime.count()
```
finally, figure out where the indexes overlap:
```
df[df.User_ID.isin(counts[counts > 1].index)]
``` |
28,299,144 | I have been trying out Three.js lately and i used the exporter addon for Blender to test out making models in blender and exporting so i can use them in a three.js program.
I included the add-on to blender, and using just the basic cube model of blender, exported it to .json as the exporter says. Then i imported the ... | 2015/02/03 | [
"https://Stackoverflow.com/questions/28299144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2283490/"
] | In my experience so far with the exporter, you have to be very careful which boxes you tick!
This length error is usually because you are either not exporting the vertexes, or exporting the scene rather the object. | I have the same issue with the new exporter.
If select SCENE then I usually get "Cannot read property 'length' of undefined"
If I select only the object and the materials and vertices. It usually just seems to get stuck forever.
UPDATE
Check this response to this issue!
[Threejs blender exporter exports in wrong... |
28,299,144 | I have been trying out Three.js lately and i used the exporter addon for Blender to test out making models in blender and exporting so i can use them in a three.js program.
I included the add-on to blender, and using just the basic cube model of blender, exported it to .json as the exporter says. Then i imported the ... | 2015/02/03 | [
"https://Stackoverflow.com/questions/28299144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2283490/"
] | In my experience so far with the exporter, you have to be very careful which boxes you tick!
This length error is usually because you are either not exporting the vertexes, or exporting the scene rather the object. | As roadkill stated earlier, exporting as Geometry instead of BufferedGeometry works.
Also note that loading JSON model loading is handled asyncronously (the callback is only called only when the operation is completed, the rest of your code keeps running). The model won't exist for the first frame or two, so check tha... |
28,299,144 | I have been trying out Three.js lately and i used the exporter addon for Blender to test out making models in blender and exporting so i can use them in a three.js program.
I included the add-on to blender, and using just the basic cube model of blender, exported it to .json as the exporter says. Then i imported the ... | 2015/02/03 | [
"https://Stackoverflow.com/questions/28299144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2283490/"
] | When you export, change the Type from buffergeometry to Geometry (Blender 2.76) | I have the same issue with the new exporter.
If select SCENE then I usually get "Cannot read property 'length' of undefined"
If I select only the object and the materials and vertices. It usually just seems to get stuck forever.
UPDATE
Check this response to this issue!
[Threejs blender exporter exports in wrong... |
28,299,144 | I have been trying out Three.js lately and i used the exporter addon for Blender to test out making models in blender and exporting so i can use them in a three.js program.
I included the add-on to blender, and using just the basic cube model of blender, exported it to .json as the exporter says. Then i imported the ... | 2015/02/03 | [
"https://Stackoverflow.com/questions/28299144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2283490/"
] | When you export, change the Type from buffergeometry to Geometry (Blender 2.76) | As roadkill stated earlier, exporting as Geometry instead of BufferedGeometry works.
Also note that loading JSON model loading is handled asyncronously (the callback is only called only when the operation is completed, the rest of your code keeps running). The model won't exist for the first frame or two, so check tha... |
62,008,063 | ```py
Code object
Area_name object
Inner/_Outer_London object
NEET object
Score object
Noparents object
Familyoffwork float64
TeensPragnancy object
dtype: object
```
* I tried several ways of converting from obje... | 2020/05/25 | [
"https://Stackoverflow.com/questions/62008063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13615020/"
] | I think I understand what you're trying to do. The following isnt very pretty code but it works. I grab all the permutations, and then check for sorted uniqueness against elements in a growing list to which I append new unique permutations:
```
from itertools import permutations
n = ['n1','n2','n3','n4','n5','n6']
#... | Reshape your arrays,
Sort them by pairs,
Convert to DataFrame,
and remove duplicates.
Assuming lol is your list of lists:
```
res=[]
for l in lol:
new_l = np.sort(np.reshape(l,(-1,2))).reshape(1,-1)[0]
res.append(new_l)
df=pd.DataFrame(res)
res = df.drop_duplicates().values.tolist()
```
example:
```
l... |
40,872,677 | I try to do the side menu that slides out from the left side.
I use a few guides, but my menu does not come out, but is immediately visible on the home screen.
The guides, when the side menu was at the center of the screen instead of the left side just added this line:
```
android:layout_gravity="start"
```
but in... | 2016/11/29 | [
"https://Stackoverflow.com/questions/40872677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7213272/"
] | It seems this is a duplicate of [THIS](https://stackoverflow.com/questions/3348460/csv-file-written-with-python-has-blank-lines-between-each-row) issue. I believe the answer there will help you solve your problem. HINT: newline='' | I didn't dig into your code in much detail, but on first glance it looks like if you want to remove the extra line between each row of data, remove the newline character '\n' from the end of the reorder\_receipt.write() function call.
In other words, modify:
`reorder_receipt.write(GTIN+' '+product+ ... +str(re_stock)... |
40,872,677 | I try to do the side menu that slides out from the left side.
I use a few guides, but my menu does not come out, but is immediately visible on the home screen.
The guides, when the side menu was at the center of the screen instead of the left side just added this line:
```
android:layout_gravity="start"
```
but in... | 2016/11/29 | [
"https://Stackoverflow.com/questions/40872677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7213272/"
] | It seems this is a duplicate of [THIS](https://stackoverflow.com/questions/3348460/csv-file-written-with-python-has-blank-lines-between-each-row) issue. I believe the answer there will help you solve your problem. HINT: newline='' | I guess the problem is with the `target=row[4]`.
May be "target" string is getting an extra \n. So stripping it might solve the problem.
`target.strip()` |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | In addition to Cristian's answer:
```
function is_valid_google_ip($ip) {
$hostname = gethostbyaddr($ip); //"crawl-66-249-66-1.googlebot.com"
return preg_match('/\.googlebot|google\.com$/i', $hostname);
}
function is_valid_google_request($ip=null,$agent=null){
if(is_null($ip)){
$ip=$_SERVER['RE... | ```
//The function
function is_google() {
return strpos($_SERVER['HTTP_USER_AGENT'],"Googlebot");
}
``` |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | The recommended way by Google is to do a reverse dns lookup (gethostbyaddr) in order to get the associated host name AND then resolve that name to an IP (gethostbyname) and compare it to the remote\_addr (because reverse lookups can be faked, too).
But beware, end lokups take time and can severely slow down your webpa... | ```
//The function
function is_google() {
return strpos($_SERVER['HTTP_USER_AGENT'],"Googlebot");
}
``` |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | ```php
function detectSearchBot($ip, $agent, &$hostname)
{
$hostname = $ip;
// check HTTP_USER_AGENT what not to touch gethostbyaddr in vain
if (preg_match('/(?:google|yandex)bot/iu', $agent)) {
// success - return host, fail - return ip or false
$hostname = gethostbyaddr($ip);
// ... | ```
//The function
function is_google() {
return strpos($_SERVER['HTTP_USER_AGENT'],"Googlebot");
}
``` |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | In addition to Cristian's answer:
```
function is_valid_google_ip($ip) {
$hostname = gethostbyaddr($ip); //"crawl-66-249-66-1.googlebot.com"
return preg_match('/\.googlebot|google\.com$/i', $hostname);
}
function is_valid_google_request($ip=null,$agent=null){
if(is_null($ip)){
$ip=$_SERVER['RE... | [How to verify Googlebot](http://googlewebmastercentral.blogspot.com/2006/09/how-to-verify-googlebot.html). |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | The recommended way by Google is to do a reverse dns lookup (gethostbyaddr) in order to get the associated host name AND then resolve that name to an IP (gethostbyname) and compare it to the remote\_addr (because reverse lookups can be faked, too).
But beware, end lokups take time and can severely slow down your webpa... | [How to verify Googlebot](http://googlewebmastercentral.blogspot.com/2006/09/how-to-verify-googlebot.html). |
3,077,862 | I'm going to block all bots except the big search engines. One of my blocking methods will be to check for "language": Accept-Language: If it has no Accept-Language the bot's IP address will be blocked until 2037. Googlebot does not have Accept-Language, I want to verify it with DNS lookup
```
<?php
gethostbyaddr($_SE... | 2010/06/20 | [
"https://Stackoverflow.com/questions/3077862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233286/"
] | ```php
function detectSearchBot($ip, $agent, &$hostname)
{
$hostname = $ip;
// check HTTP_USER_AGENT what not to touch gethostbyaddr in vain
if (preg_match('/(?:google|yandex)bot/iu', $agent)) {
// success - return host, fail - return ip or false
$hostname = gethostbyaddr($ip);
// ... | [How to verify Googlebot](http://googlewebmastercentral.blogspot.com/2006/09/how-to-verify-googlebot.html). |
23,747,958 | I'm trying to learn symfony PHP framework but unlike Ruby on Rails it is not really intuitive.
I'm rendering a form with newAction that looks like this
```
public function newAction()
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
... | 2014/05/19 | [
"https://Stackoverflow.com/questions/23747958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902570/"
] | No need for two actions, you can add this in the same action newAction
```
public function newAction()
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
$em = $this->getDoctrine()->getManager();
$request = $this->getRequest();
... | If I correctly understood you:
```
// ...
use Symfony\Component\HttpFoundation\Request;
// ...
public function createAction(Request $request)
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
$form->handleRequest($request);
if($form->isValid())
{
$em = $... |
23,747,958 | I'm trying to learn symfony PHP framework but unlike Ruby on Rails it is not really intuitive.
I'm rendering a form with newAction that looks like this
```
public function newAction()
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
... | 2014/05/19 | [
"https://Stackoverflow.com/questions/23747958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902570/"
] | No need for two actions, you can add this in the same action newAction
```
public function newAction()
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
$em = $this->getDoctrine()->getManager();
$request = $this->getRequest();
... | Something that can help you :
<http://www.leaseweblabs.com/2013/04/symfony2-crud-generator/>
Very useful short videos that explain how to use CRUD generator command lines. And then if you use CRUD generator which is in Symfony2 by default, you will have your action newAction self created and you'll be able to read co... |
23,747,958 | I'm trying to learn symfony PHP framework but unlike Ruby on Rails it is not really intuitive.
I'm rendering a form with newAction that looks like this
```
public function newAction()
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
... | 2014/05/19 | [
"https://Stackoverflow.com/questions/23747958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902570/"
] | Something that can help you :
<http://www.leaseweblabs.com/2013/04/symfony2-crud-generator/>
Very useful short videos that explain how to use CRUD generator command lines. And then if you use CRUD generator which is in Symfony2 by default, you will have your action newAction self created and you'll be able to read co... | If I correctly understood you:
```
// ...
use Symfony\Component\HttpFoundation\Request;
// ...
public function createAction(Request $request)
{
$product = new Product();
$form = $this->createForm(new ProductType(), $product);
$form->handleRequest($request);
if($form->isValid())
{
$em = $... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | USB 3.0 often has blue lining inside the port.
If you want to know specifically for your macbook air, go to apple support page <http://support.apple.com/specs/> - Click on "Browse by Product" and enter your Macbook Air serial number. It will show you the Tech Spec specifically for your Macbook Air series, and the tec... | You were looking in the right place, it does tell you there. Take a look at the highlighted part in my screenshot below.

A USB Hi-Speed bus is USB 2.0, A USB 'SuperSpeed' or USB '3.0 Hi-Speed' bus are both USB3. |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | USB 3.0 often has blue lining inside the port.
If you want to know specifically for your macbook air, go to apple support page <http://support.apple.com/specs/> - Click on "Browse by Product" and enter your Macbook Air serial number. It will show you the Tech Spec specifically for your Macbook Air series, and the tec... | Tap the black apple, then choose "About this Mac, followed by Support, then Specifications. Lots of info there, including number and type of USB port |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | USB 3.0 often has blue lining inside the port.
If you want to know specifically for your macbook air, go to apple support page <http://support.apple.com/specs/> - Click on "Browse by Product" and enter your Macbook Air serial number. It will show you the Tech Spec specifically for your Macbook Air series, and the tec... | (just updating an old question)
To cover all Mac's and the technology in general, USB 3.0 adds 5 pins and unique interfaces. Where the shape hasn't changed (like with type "A", the flat plain rectangle), just look for the extra 5 pads or contacts.
This should produce a positive ID across computers more reliably than ... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | USB 3.0 often has blue lining inside the port.
If you want to know specifically for your macbook air, go to apple support page <http://support.apple.com/specs/> - Click on "Browse by Product" and enter your Macbook Air serial number. It will show you the Tech Spec specifically for your Macbook Air series, and the tec... | Another approach, there are 3 things that confirm that you have only USB2:
1. USB High-Speed Bus
2. Driver: EHCI
3. Speed: 480Mb/s
>
>
> ```
> USB 1.0 Low Speed (1.5 Mbit/s), Full Speed (12 Mbit/s)
> USB 2.0 High Speed (480 Mbit/s)
> USB 3.0 SuperSpeed (5 Gbit/s)
> USB 3.1 SuperSpeed+ (10 Gbit/s)
>
> ... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | You were looking in the right place, it does tell you there. Take a look at the highlighted part in my screenshot below.

A USB Hi-Speed bus is USB 2.0, A USB 'SuperSpeed' or USB '3.0 Hi-Speed' bus are both USB3. | Tap the black apple, then choose "About this Mac, followed by Support, then Specifications. Lots of info there, including number and type of USB port |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | You were looking in the right place, it does tell you there. Take a look at the highlighted part in my screenshot below.

A USB Hi-Speed bus is USB 2.0, A USB 'SuperSpeed' or USB '3.0 Hi-Speed' bus are both USB3. | (just updating an old question)
To cover all Mac's and the technology in general, USB 3.0 adds 5 pins and unique interfaces. Where the shape hasn't changed (like with type "A", the flat plain rectangle), just look for the extra 5 pads or contacts.
This should produce a positive ID across computers more reliably than ... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | You were looking in the right place, it does tell you there. Take a look at the highlighted part in my screenshot below.

A USB Hi-Speed bus is USB 2.0, A USB 'SuperSpeed' or USB '3.0 Hi-Speed' bus are both USB3. | Another approach, there are 3 things that confirm that you have only USB2:
1. USB High-Speed Bus
2. Driver: EHCI
3. Speed: 480Mb/s
>
>
> ```
> USB 1.0 Low Speed (1.5 Mbit/s), Full Speed (12 Mbit/s)
> USB 2.0 High Speed (480 Mbit/s)
> USB 3.0 SuperSpeed (5 Gbit/s)
> USB 3.1 SuperSpeed+ (10 Gbit/s)
>
> ... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | Tap the black apple, then choose "About this Mac, followed by Support, then Specifications. Lots of info there, including number and type of USB port | Another approach, there are 3 things that confirm that you have only USB2:
1. USB High-Speed Bus
2. Driver: EHCI
3. Speed: 480Mb/s
>
>
> ```
> USB 1.0 Low Speed (1.5 Mbit/s), Full Speed (12 Mbit/s)
> USB 2.0 High Speed (480 Mbit/s)
> USB 3.0 SuperSpeed (5 Gbit/s)
> USB 3.1 SuperSpeed+ (10 Gbit/s)
>
> ... |
652,700 | How do I tell if my MacBook Air supports USB 3.0. I found
**About This Mac** → **More Info...** → **System Report...** → **Hardware** → **USB**
But nothing there clearly states version 2.0 or 3.0. How can I know for sure? In particular, I want to know if I can use an external hard drive that requires a "USB 3.0-read... | 2013/10/01 | [
"https://superuser.com/questions/652700",
"https://superuser.com",
"https://superuser.com/users/207377/"
] | (just updating an old question)
To cover all Mac's and the technology in general, USB 3.0 adds 5 pins and unique interfaces. Where the shape hasn't changed (like with type "A", the flat plain rectangle), just look for the extra 5 pads or contacts.
This should produce a positive ID across computers more reliably than ... | Another approach, there are 3 things that confirm that you have only USB2:
1. USB High-Speed Bus
2. Driver: EHCI
3. Speed: 480Mb/s
>
>
> ```
> USB 1.0 Low Speed (1.5 Mbit/s), Full Speed (12 Mbit/s)
> USB 2.0 High Speed (480 Mbit/s)
> USB 3.0 SuperSpeed (5 Gbit/s)
> USB 3.1 SuperSpeed+ (10 Gbit/s)
>
> ... |
36,951,231 | The Architecture of my software is,
WPF (Windows desktop application on users' computers) - WCF web role(Windows Communication Foundation) on Azure Cloud Service (Here, the connectionstring to Azure SQL database exists)- Azure SQL Server(Azure SQL database).
According to my knowledge, new feature like 'database.secur... | 2016/04/30 | [
"https://Stackoverflow.com/questions/36951231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5541055/"
] | I guess this line is giving issues
```
<li> ${results.testID + ""} </li>
```
I'm wondering what is the purpose of that. Why are you trying to concatenate an Integer with an empty String?
Concatenation in `el` is not achieved with the `+` operator. You just have to place to el expressions close to each other.
The f... | Most probably you defined Result.testID to be Integer (in Result class).
But in your database the testID column is String. Most data are numeric, so `result.setTestID(rs.getString("testID"));` does not usually fail, but you have some cases where database data in testID column is not numeric. Thus the "Cannot convert te... |
32,214,676 | I have a pulsing rectangle animated with animateWithDuration and `setAnimationRepeatCount()`.
I'm trying to add a sound effect in the animations block witch is "clicking" synchronously. But the sound effect is only playing once. I can't find any hint on this anywhere.
```
UIView.animateWithDuration(0.5,
... | 2015/08/25 | [
"https://Stackoverflow.com/questions/32214676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5265864/"
] | Providing the `UIViewAnimationOptions.Repeat` option does **NOT** cause the animation block to be called repeatedly. The animation is repeated on a `CoreAnimation` level. If you place a breakpoint in the animation block, you'll notice that it is only executed once.
If you want the animation to execute in a loop alongs... | Without seeing the implementation of the audio player some things I can think of include:
* The audio file is too long and perhaps has silence on the end of it so it is not playing the first part of the file which has the sound in it
* the audio file needs to be set to the beginning of the file every time (it could ju... |
260,212 | I have written a SOQL query that selects a look up field from a custom object.
My problem is it returns the uuid ( e.g. 1017800012NQqABAFD) and not the name (e.g.Joe Soap).
---
```
Select Name, Surname from Account
```
My result:
```
NAME
1545154151541SADDEEFF
SURNAME
1655466464648SDEDEFE
```
Why do I get the... | 2019/04/26 | [
"https://salesforce.stackexchange.com/questions/260212",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/56658/"
] | Relationship fields (lookup, master-detail) in the Salesforce UI display the `Name` field of the related record, but that's only due to UI magic.
In the backing data store, lookup fields are actually record Ids (as you are seeing).
If you want to get the name of a related record, you'll need to query for it.
```
Lis... | The return of the Id for the Name is usually caused by creating the object without specifying a Name field value - Salesforce ensures that a name is always set, using the Id allocated when needed. |
27,380,316 | I have an svg image made by path elements and the path elements are inside g tags which transform and apply the fill to the path elements. The fill I used was a pattern which was predefined in the defs tag. The pattern element contains image tags which link to oth
Now the problem: when i put the svg code directly into... | 2014/12/09 | [
"https://Stackoverflow.com/questions/27380316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123852/"
] | When used in an image context, i.e. via an `<img>` tag or css background image SVG files must be complete in a single file to protect user's privacy.
You need to embed the svg\_bg.png file into the SVG file as a data url to get this to work. | You should check the numbers in coordinates `x` and `y` everywhere and `href` to the `svb_bg.png`.
Demo for you code: <http://jsbin.com/diwoduheze/1/> |
26,643,911 | I have two tables, Location and Job
When I want to create a new job, I can select the location from a drop down list which is populated from the location table.
My create view:
```
public ActionResult Create(CreateJobViewModel model)
{
model.Locations = repository.GetAllLocations()
.Select(x => new S... | 2014/10/30 | [
"https://Stackoverflow.com/questions/26643911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610857/"
] | You should use view model in the create and then use custom mapping logic to make Job entity and send to your business or data layer.
You can use Auto mapper for mapping between the entities. | You are thinking about this wrong. Why do you have a Job view model and a Job business object?
Your view should only know about the view model, your controller should (how you have this setup) knows about both the view model and business model, and the repository only knows about the business model.
Have the Post act... |
26,643,911 | I have two tables, Location and Job
When I want to create a new job, I can select the location from a drop down list which is populated from the location table.
My create view:
```
public ActionResult Create(CreateJobViewModel model)
{
model.Locations = repository.GetAllLocations()
.Select(x => new S... | 2014/10/30 | [
"https://Stackoverflow.com/questions/26643911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610857/"
] | Here is some code of mine, similar to your problem, you can modify it by your requirements. Hope it helps.
Controller:
```
public ActionResult Create()
{
string selected = (from cat in dc.Category
join sub in dc.SubCategory on cat.Id equals sub.SubCategoryId
... | You are thinking about this wrong. Why do you have a Job view model and a Job business object?
Your view should only know about the view model, your controller should (how you have this setup) knows about both the view model and business model, and the repository only knows about the business model.
Have the Post act... |
1,323,556 | The site I am working on wants to generate its own shortened URLs rather than rely on a third party like tinyurl or bit.ly.
Obviously I could keep a running count new URLs as they are added to the site and use that to generate the short URLs. But I am trying to avoid that if possible since it seems like a lot of work ... | 2009/08/24 | [
"https://Stackoverflow.com/questions/1323556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113331/"
] | Not sure this is a good idea : if you have to change server, or change disk / reformat it, the inodes numbers of your files will most probably change... And all your short URL will be broken / lost !
Same thing if, for any reason, you need to move your files to another partition of your disk, btw.
Another idea might ... | Check out [Lessn](http://www.shauninman.com/archive/2009/08/17/less_n) by Sean Inman; Haven't played with it yet, but it's a self-hosted roll your own URL solution. |
1,323,556 | The site I am working on wants to generate its own shortened URLs rather than rely on a third party like tinyurl or bit.ly.
Obviously I could keep a running count new URLs as they are added to the site and use that to generate the short URLs. But I am trying to avoid that if possible since it seems like a lot of work ... | 2009/08/24 | [
"https://Stackoverflow.com/questions/1323556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113331/"
] | Not sure this is a good idea : if you have to change server, or change disk / reformat it, the inodes numbers of your files will most probably change... And all your short URL will be broken / lost !
Same thing if, for any reason, you need to move your files to another partition of your disk, btw.
Another idea might ... | Rather clever use of the filesystem there. If you are guaranteed that inode ids are unique its a quick way of generating the unique numbers. I wonder if this could work consistently over NFS, because obviously different machines will have different inode numbers. You'd then just serialize the link info in the file you ... |
1,323,556 | The site I am working on wants to generate its own shortened URLs rather than rely on a third party like tinyurl or bit.ly.
Obviously I could keep a running count new URLs as they are added to the site and use that to generate the short URLs. But I am trying to avoid that if possible since it seems like a lot of work ... | 2009/08/24 | [
"https://Stackoverflow.com/questions/1323556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113331/"
] | Rather clever use of the filesystem there. If you are guaranteed that inode ids are unique its a quick way of generating the unique numbers. I wonder if this could work consistently over NFS, because obviously different machines will have different inode numbers. You'd then just serialize the link info in the file you ... | Check out [Lessn](http://www.shauninman.com/archive/2009/08/17/less_n) by Sean Inman; Haven't played with it yet, but it's a self-hosted roll your own URL solution. |
38,501,570 | I am trying to send a message from addon (webextension) to a html page which is in the addon. The webextension API is using the chrome interface which is compatible with Chrome browser. I am using Firefox 48 beta.
This is the background script (the "initiate-page" message is important):
```
chrome.runtime.onMessage.a... | 2016/07/21 | [
"https://Stackoverflow.com/questions/38501570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1141649/"
] | Since it's an extension page, and not a content script, `chrome.tabs.sendMessage` is not going to reach it.
You need to broadcast your message with `chrome.runtime.sendMessage` to reach `chrome-extension://` pages such as an options page.
If you don't like the broadcast nature of `runtime.sendMessage`, you should use... | Thanks to Xan's explanation, I have found this works like charm
background script:
```
chrome.runtime.onMessage.addListener(
function(package, sender, sendResponse
){
switch (package.message){
case "open":
if (package.subject == "tab")
{
win = myNamespace.tabs[package.mod... |
44,795 | A similar story goes for two different cities.
Baijnath and Gokarna.
Which one is the correct one?
If both of them are true, did Ravana carry Shivlinga twice? | 2021/02/16 | [
"https://hinduism.stackexchange.com/questions/44795",
"https://hinduism.stackexchange.com",
"https://hinduism.stackexchange.com/users/21873/"
] | Karkati is one such example. She takes boon from Brahma and realizes later to become good and becomes Jivan muktha.
Her story is mentioned in [Part 3 - The Story of Karkaṭī](https://www.wisdomlib.org/hinduism/book/laghu-yoga-vasistha/d/doc209654.html) in `Utpatti-prakaraṇa` of Yoga-Vasistha
Initially, she performs an... | Vibhishana is an example. He asked for a boon that he should always be righteous and also obtain the light of divine knowledge from Brahma
<http://www.sacred-texts.com/hin/m03/m03273.htm>
>
> Brahma then addressed Vibhishana, 'O my son, I am much pleased with thee! Ask any boon thou pleasest!' Thereupon, Vibhishana ... |
15,635,640 | I have a problem to remove duplicate object in 2 list
```
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get; set; }
}
public void LoadPump()
{
var pumps = _pumpRepository.GetAll(); // 2 Pump
var pumpsActive = _pumpRepository.... | 2013/03/26 | [
"https://Stackoverflow.com/questions/15635640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1802473/"
] | Implement [`.Equals(object)`](http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx) and [`.GetHashCode()`](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx).
```
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get... | Imeplement
```
public class Pump: IEquatable<Pump>
{
public bool Equals(Pump other)
{
...
}
}
``` |
15,635,640 | I have a problem to remove duplicate object in 2 list
```
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get; set; }
}
public void LoadPump()
{
var pumps = _pumpRepository.GetAll(); // 2 Pump
var pumpsActive = _pumpRepository.... | 2013/03/26 | [
"https://Stackoverflow.com/questions/15635640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1802473/"
] | You could override `Equals` or you can try the following:
```
List<Pump> pumpsNonActive = pumps.Where(r => !pumpsActive
.Any(t => t.PumpID == r.PumpID))
.ToList();
```
This worked for the following dataset:
```
List<Pump> pumps = new Li... | Imeplement
```
public class Pump: IEquatable<Pump>
{
public bool Equals(Pump other)
{
...
}
}
``` |
15,635,640 | I have a problem to remove duplicate object in 2 list
```
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get; set; }
}
public void LoadPump()
{
var pumps = _pumpRepository.GetAll(); // 2 Pump
var pumpsActive = _pumpRepository.... | 2013/03/26 | [
"https://Stackoverflow.com/questions/15635640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1802473/"
] | You could override `Equals` or you can try the following:
```
List<Pump> pumpsNonActive = pumps.Where(r => !pumpsActive
.Any(t => t.PumpID == r.PumpID))
.ToList();
```
This worked for the following dataset:
```
List<Pump> pumps = new Li... | Implement [`.Equals(object)`](http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx) and [`.GetHashCode()`](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx).
```
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get... |
33,439,810 | I am trying to print the binary tree using networkx library in python.
But, I am unable to preserve the left and right childs. Is there a way to tell the Graph to print left child first and then the right child?
```
import networkx as nx
G = nx.Graph()
G.add_edges_from([(10,20), (11,20)])
nx.draw_networkx(G)
```
[!... | 2015/10/30 | [
"https://Stackoverflow.com/questions/33439810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4160889/"
] | I believe Networkx is not suited to binary trees but you can set the node positions yourself. I have wrote the following algorithm to setup node positions but it works fine for full or complete binary trees where key nodes are ordered [0,1,...].
```
def full_tree_pos(G):
n = G.number_of_nodes()
if n == 0 : ret... | **Note** If you use networkx version 1.11 or earlier, see the note at the end.
The following assumes that each node has an attribute assigned to it telling whether it is the left or right child of its parent. So you'll have to assign this - by default a graph does not have any concept of this. Perhaps it might be poss... |
25,815,449 | I'm chasing my tail here. All I'm looking to do is return a string from the $scope.getPlacesTextRaw function.
```
$scope.getPlacesTextRaw = function(selectedPlace){
mentionsFactory.getPlaceMetaData(selectedPlace).then(function(metadata) {
console.log("here is our metadata", metadata);
return metad... | 2014/09/12 | [
"https://Stackoverflow.com/questions/25815449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2438846/"
] | In both cases, a constant string of characters `"hello\0"` is allocated in a read-only section of the executable image.
In the case of `char* s="hello"`, the variable `s` is set to point to the location of that string in memory every time the function is called, so it can be used for read operations (`c = s[i]`), but ... | One is a pointer the other is an array.
An array defines data that stays in the current scope stack space.
A pointer defines a memory address that is in the current scope stack space, but which references memory from the heap. |
25,815,449 | I'm chasing my tail here. All I'm looking to do is return a string from the $scope.getPlacesTextRaw function.
```
$scope.getPlacesTextRaw = function(selectedPlace){
mentionsFactory.getPlaceMetaData(selectedPlace).then(function(metadata) {
console.log("here is our metadata", metadata);
return metad... | 2014/09/12 | [
"https://Stackoverflow.com/questions/25815449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2438846/"
] | When using `char s[] = "hello";`, the char array is created in the scope of the current function, hence the memory is allocated on the stack when entering the function.
When using `char *s = "hello";`, `s` is a pointer to a constant string which the compiler saves in a block of memory of the program which is blocked f... | One is a pointer the other is an array.
An array defines data that stays in the current scope stack space.
A pointer defines a memory address that is in the current scope stack space, but which references memory from the heap. |
25,815,449 | I'm chasing my tail here. All I'm looking to do is return a string from the $scope.getPlacesTextRaw function.
```
$scope.getPlacesTextRaw = function(selectedPlace){
mentionsFactory.getPlaceMetaData(selectedPlace).then(function(metadata) {
console.log("here is our metadata", metadata);
return metad... | 2014/09/12 | [
"https://Stackoverflow.com/questions/25815449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2438846/"
] | When using `char s[] = "hello";`, the char array is created in the scope of the current function, hence the memory is allocated on the stack when entering the function.
When using `char *s = "hello";`, `s` is a pointer to a constant string which the compiler saves in a block of memory of the program which is blocked f... | In both cases, a constant string of characters `"hello\0"` is allocated in a read-only section of the executable image.
In the case of `char* s="hello"`, the variable `s` is set to point to the location of that string in memory every time the function is called, so it can be used for read operations (`c = s[i]`), but ... |
70,926,877 | I currently have a bool mask vector generated in Eigen. I would like to use this binary mask similar as in Python `numpy`, where depending on the `True` value, i get a sub-matrix or a sub-vector, where i can further do some calculations on these.
To achieve this in Eigen, i currently "convert" the mask vector into ano... | 2022/01/31 | [
"https://Stackoverflow.com/questions/70926877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10840396/"
] | As far as I'm aware, there is no "out of the shelf" solution using Eigen's methods. However it is interesting to notice that (at least for Eigen versions greater or equal than `3.4.0`), you can using a `std::vector<int>` for indexing (see [this section](https://eigen.tuxfamily.org/dox/group__TutorialSlicingIndexing.htm... | I have found another way, which seems to be more elegant then comparing each element if it equals to `0`:
```
Eigen::SparseMatrix<bool> mask_sparse = mask.matrix().sparseView();
for (uint32_t k = 0; k<mask.outerSize(); ++k) {
for (Eigen::SparseMatrix<bool>::InnerIterator it(mask_sparse, k); it; ++it) {
std... |
37,569,973 | I have a kendo grid on Cordova app. Here on the grid, the scrolling is jagged due to the css rule 'k-grid tr:hover' in kendo css. If I disable this rule from developer tools, scrolling is smooth. Is there any way to disable this hover rule?
I don't want to override hover behaviour. I want to disable it.
Edit: The pro... | 2016/06/01 | [
"https://Stackoverflow.com/questions/37569973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6409808/"
] | You can use pointer-events: none property on the DOM element.
<https://developer.mozilla.org/en/docs/Web/CSS/pointer-events>
```
.k-grid tr {
pointer-events: none;
}
```
With this property, the hover event on that element will be completely ignored. | I took hint from Gabriel's answer but I applied pointer events none to the td elements inside .k-grid tr. But this is just a temporary fix as this removes the possibility of adding pointer events to those td elements. I am still looking for a better alternative. |
37,569,973 | I have a kendo grid on Cordova app. Here on the grid, the scrolling is jagged due to the css rule 'k-grid tr:hover' in kendo css. If I disable this rule from developer tools, scrolling is smooth. Is there any way to disable this hover rule?
I don't want to override hover behaviour. I want to disable it.
Edit: The pro... | 2016/06/01 | [
"https://Stackoverflow.com/questions/37569973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6409808/"
] | I've "solved" it by disabling the hover and then replicating the tr even background color:
```
.k-grid tr:hover {
background: none;
}
.k-grid tr.k-alt:hover {
background: none;
}
.k-grid tr.k-alt:nth-child(even) {
background-color: #f5f5f5;
}
```
of course you can play with the colors | I took hint from Gabriel's answer but I applied pointer events none to the td elements inside .k-grid tr. But this is just a temporary fix as this removes the possibility of adding pointer events to those td elements. I am still looking for a better alternative. |
58,373,282 | The below query doesn't list out all records that contain `null` value in `WFD_DETECTION_EPA` when we pass in some value in `S1_WFD_OPERATION_CODE` variable. Only records with `WFD_DETECTION_EPA` is not `null` appear in the result.
How to enhance this query?
```
AND UPPER (FD.WFD_DETECTION_EPA) LIKE
... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58373282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4877272/"
] | TS 4.2
------
allows [leading/middle rest elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-2/#non-trailing-rests) in tuple types. You can now write:
```
type WithLastQux = [...Bar[], Qux]
```
To allow an *optional* last `Qux` (thanks @last-child):
```
type WithLastQux = [...Bar[], Qux] |... | Since in Javascript the [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) are only allowed as the last parameter, the same approach was historically adopted for types in Typescript.
There are longstanding tickets to remove this limitation for types, see [h... |