qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
324,562
``` telnet www.ietf.org 80 GET /rfc.html HTTP/1.1 Host: www.ietf.org ``` This sequence of commands starts up a telnet (i.e., TCP) connection to port 80 on IETF’s Web server, www.ietf.org. Then comes the GET command naming the path of the URL and the protocol. Try servers and URLs of your choosing. The next line is th...
2016/11/19
[ "https://unix.stackexchange.com/questions/324562", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/674/" ]
To reconfigure the keyboard in Debian, run (as `root`, or using `sudo`): ``` dpkg-reconfigure keyboard-configuration ``` Link to official Debian documentation [here](https://wiki.debian.org/Keyboard). If your keys are "random" (I have been there, not fun!), try to find the characters needed to execute the command a...
I've come up with an alternate solution to my problem. Ultimately, my issue was the keyboard was registered as `gb` (great britain) instead of `us`. To fix this, I had the prerequisites of `keyboard-configuration` and `console-setup` installed (not sure if the latter is actually necessary) and changed the file `/etc/...
72,315,325
Using react native with typescript and redux toolkit Hi I'm bothering with render a list of messages via FlatList. By ScrollView everything rendering good but I need to implement infiniti scroll. So I'm doing something like this ``` const MessagesScreen = () => { const companyId = useAppSelector(getCompanyId); co...
2022/05/20
[ "https://Stackoverflow.com/questions/72315325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15032294/" ]
there is problem with your call back function: **you are not returning Messages component** **1:Remove curly braces** ```js return ( <FlatList data={messages} renderItem={() => <Messages messages={messages}/> } /> ); ``` **2:Add return statement** ```js return ( <FlatList data={mes...
Couple things: You're using the renderItem callback incorrectly: ``` <FlatList data={messages} renderItem={() => { // ^ ignoring the renderItem props return <Messages messages={messages} />; }} /> ``` Here, for each item in the messages array, you're rendering a component and pas...
33,576,572
[![Vector plot made in Python](https://i.stack.imgur.com/y4Odp.png)](https://i.stack.imgur.com/y4Odp.png) I am solving a lid-driven cavity flow problem. For creating the figure, I chose Python because it was the only language I know that has such a feature. For the figure, I have to plot streamlines and vector arrows....
2015/11/06
[ "https://Stackoverflow.com/questions/33576572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Based on the [answer provided here](https://stackoverflow.com/a/25343170/5067311), you can prune your input arrays into `quiver` by using strides, as in `x[::2,::2]` etc. to use only every second element of the arrays. To spare some writing, you can define a `slice` to do the bulk of the notation for you: ``` skip = (...
Based on @Andras Deak's excellent answer above, you can implement a similar slice for data from an `xarray` dataset. To explain further, if you use the positional indexing `x[skip],y[skip]`, you can potentially slice the wrong dimensions. For example, if the `u` variable has dimensions `(time,x,y)`, you could slice th...
64,632,871
hello everyone I have two dataframes and I'd like to join information from one df to another one in a specific way. I'm gonna explain better. Here is my first df where i'd like to add 6 columns (general col named col1, col2 and so on..): ``` res1 res4 aa1234 1 AAAAAA 1 4 IVGG 2 AAAAAA 8 ...
2020/11/01
[ "https://Stackoverflow.com/questions/64632871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14467368/" ]
All of this is not necessary. You can simply try to convert the input to a `float`. If it throws an error, it means that the input is not a valid number. You can catch this error using a `try-except` block and print `Invalid`: ``` while True: num1 = input("Enter First Number: ") try: num1 = float(num1)...
Instead of checking whether the string contains an alphabetic character or a special character, you can check directly whether it represents a number or not: ```py def input_number(prompt_msg, err_msg): we_got_a_number = False while not we_got_a_number: num_string = input(prompt_msg) try: num = int(n...
64,632,871
hello everyone I have two dataframes and I'd like to join information from one df to another one in a specific way. I'm gonna explain better. Here is my first df where i'd like to add 6 columns (general col named col1, col2 and so on..): ``` res1 res4 aa1234 1 AAAAAA 1 4 IVGG 2 AAAAAA 8 ...
2020/11/01
[ "https://Stackoverflow.com/questions/64632871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14467368/" ]
All of this is not necessary. You can simply try to convert the input to a `float`. If it throws an error, it means that the input is not a valid number. You can catch this error using a `try-except` block and print `Invalid`: ``` while True: num1 = input("Enter First Number: ") try: num1 = float(num1)...
Instead of warn for alpha, you can warn for non digit : ``` if !num1.isisdigit(): print("Invalid, Try Again.") continue ```
25,963,818
I have an issue that relates to threading, cleaning up unmanaged resources and shutting down my app. In the main UI thread I have a method that creates a new instance of class Worker. In Worker's constructor I start a new thread that has a while(Scanning) loop that updates some controls in my UI using Invoke() continu...
2014/09/21
[ "https://Stackoverflow.com/questions/25963818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4059350/" ]
Based on Hans Passant's answer [here](https://stackoverflow.com/questions/1731384/how-to-stop-backgroundworker-on-forms-closing-event/1732361#1732361), I created the below solution. It seems to be working very well. In UI class/thread: ``` private void Form1_FormClosing(object sender, FormClosingEventArgs e) { va...
Could you not better use the BackgroundWorker class/control? It is much easier to use because it has already a lot of synchronization stuff in it. But if you have a separate thread, in your FormClosing event, use: ``` yourThread.Abort(); yourThread.Join(); // or yourThread.Join(1000); where 1000 is some kind of tim...
25,963,818
I have an issue that relates to threading, cleaning up unmanaged resources and shutting down my app. In the main UI thread I have a method that creates a new instance of class Worker. In Worker's constructor I start a new thread that has a while(Scanning) loop that updates some controls in my UI using Invoke() continu...
2014/09/21
[ "https://Stackoverflow.com/questions/25963818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4059350/" ]
Based on Hans Passant's answer [here](https://stackoverflow.com/questions/1731384/how-to-stop-backgroundworker-on-forms-closing-event/1732361#1732361), I created the below solution. It seems to be working very well. In UI class/thread: ``` private void Form1_FormClosing(object sender, FormClosingEventArgs e) { va...
Disclaimer: *I do not advocate the use of `Thread`, `ManualResetEvent` and, above all, `volatile` in the .NET 4.5+ era, but since the .NET version was not specified I've done my best to address the problem while keeping things as backwards-compatible as possible.* Here's a solution which uses a polling variable and a ...
41,881
I would like to use the title color of my `beamer` presentation (some kind of blue) to write some inline text with the same color. Therefore I want to know the color definition. Is there a command for using the same color as the title? My preamble definitions are: ``` \mode<presentation> { \usetheme{Warsaw} } \usec...
2012/01/22
[ "https://tex.stackexchange.com/questions/41881", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/10529/" ]
You can copy the color from the frame title this way: ``` \caption*{\usebeamercolor[fg]{frametitle}{My table}} ```
The command `\usebeamercolor[fg]{title in head/foot}` (see p. 186 <http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf>) should provide you with the (text) color used in the header, even if you later decide to change your theme or change the title text color yourself in the preamble.
57,239,371
I want to disable caching or restrict the cache to 24 hours. My ApolloClient runs exclusively on the Server side. My environment: * apollo-boost 0.4.3 * graphql 14.1.1 * apollo-link-batch-http - 1.2.12 Right now, that's how I configure my `ApolloClient`. ``` new ApolloClient({ ssrMode: true, cache: new ...
2019/07/28
[ "https://Stackoverflow.com/questions/57239371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631086/" ]
This is where `pandas` library comes with real power and conciseness: with [`pandas.read_csv`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html)/[`pandas.Dataframe.to_csv`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html) one-liner: ``` import pan...
You don't have to worry about comma - csv will care of it ``` import csv with open('input.csv') as file_in, open('output.csv', 'w') as file_out: csv_in = csv.reader(file_in, delimiter=',') csv_out = csv.writer(file_out, delimiter=';') for row in csv_in: csv_out.writerow(row) ``` or even using `w...
11,415,365
I am fairly new to webworks. I am trying to get the camera api to work and I keep getting the error: Error in supported: TypeError: 'undefined' is not an object (evaluating 'blackberry.media.camera') The page I am trying to use is on a hosted server. The code is as follows: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD HTM...
2012/07/10
[ "https://Stackoverflow.com/questions/11415365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1515055/" ]
If using PlayBook, make sure to have the correct element(s) defined <https://developer.blackberry.com/html5/apis/blackberry.media.camera.html> otherwise, if you are trying to access the blackberry.media.camera API *from* a remote website, then you need to white list that correctly in config.xml like this: ``` <access...
What device are you running? The code seems fine and it should work. You can get the eventlogs from the device and see what exceptions are being thrown. Thanks Naveen M
61,160,922
I want to be able to import SVG files from the file system, layer them, change their fill colors, and then export them as a single vector file.
2020/04/11
[ "https://Stackoverflow.com/questions/61160922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7214070/" ]
The solution to this problem was simply to import the SVG data as a string, swap out constants for various properties, and then write the new string to the file system. For example, the following svg displays an orange circle: ```html <svg viewBox="0 0 1000 1000" xmlns="http://www.w3.org/2000/svg"> <circle cx="500"...
The best source to refer would be their official docs: <https://svgjs.dev/docs/3.0/getting-started/> The next in the line source would be stack-overflow's search by svg.js tag: <https://stackoverflow.com/questions/tagged/svg.js> Now a quick intro from my side. SVG.JS lets you work very extensively with SVGs. You can...
56,765,872
I am trying to achieve that C interprets my string as macro. Hey, let's suppose there is a defined macro as, ``` #define ABC 900 ``` If i define; ``` char* s[] = "ABC" ; ``` then, ``` printf("%d",s) ; ``` Is there any way the compiler understands that "ABC" as macro ABC and passes 900 integer value to prin...
2019/06/26
[ "https://Stackoverflow.com/questions/56765872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11701071/" ]
No, what you're trying to do is double impossible. You can't access variables by name at runtime (string -> variable) because the compiled machine code knows nothing about the names in your C code, and you can't access macros from the compiler because the compiler knows nothing about macros (they're expanded by the pre...
Macros are simple copy paste and they are pretty limited. A macro will not expand if it's quoted or commented. One solution would be: ``` #define ABC "900" char s[] = ABC; ``` But no, macros cannot be used for what you're trying to do. > > When i try the above code, instead of my desired output 15 , i get 64875...
3,571,792
I am trying to structure a database for optimal use. But I have no idea how to make that happen. Here is what i will have A category which will have many products and a count for each on of those products For example Restaurants will be the category and the products will be the computer system, cash register and ea...
2010/08/26
[ "https://Stackoverflow.com/questions/3571792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/223367/" ]
PRODUCTS -------- * PRODUCT\_ID (primary key) * PRODUCT\_NAME CATEGORIES ---------- * CATEGORY\_ID (primary key) * CATEGORY\_NAME PRODUCT\_CATEGORIES\_MAP ------------------------ * PRODUCT\_ID (primary key, foreign key to `PRODUCTS`) * CATEGORY\_ID (primary key, foreign key to `CATEGORIES`) * QUANTITY This'll al...
### Establishment * ID * Name * <address info> ### Product * ID * Name ### Estab\_Prod\_Bridge * ID\_Product * ID\_Establishment * Quantity ### Discounts * ID\_Establishment * Percent\_Purchase * Discount --- **Note:** 1. Establishment is a long word, I just used it here for example. You could easily replace...
31,895,473
I'm trying to compile and install an open source application on Ubuntu. I can make the application, make the installer, and make the package. I don't see any error during those steps. when I issue the dpkg -i to install it if fails with the following error. dpkg: error processing archive application.deb (--install): ...
2015/08/08
[ "https://Stackoverflow.com/questions/31895473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/719989/" ]
Following the description on <https://github.com/Brewtarget/brewtarget> on a newly installed Ubuntu 14.04.3 gives me a .deb that installs. These are the commands I ran: ``` $ sudo apt-get install cmake git qtbase5-dev qttools5-dev qttools5-dev-tools qtmultimedia5-dev libqt5webkit5-dev libqt5sql5-sqlite libqt5svg5 lib...
Try these commands ``` # sudo dpkg -i --force-overwrite application.deb ``` After that run ``` # sudo apt-get -f install ```
34,364,289
I'm trying out the new Core CLR type ASP.Net on my Mac and running in to no end of problems. I've managed to get StructureMap referenced and installed via dnu and dnu restore, but now I'm getting errors in VS Code stating that: ``` The type 'Object' is defined in an assembly that is not referenced. You must add a re...
2015/12/18
[ "https://Stackoverflow.com/questions/34364289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1333417/" ]
I tried a little and can suggest you two versions to fix the problem with compilation. The first way is removing `dnxcore50` and making some changes in `Startup.cs`. To be exactly one can use the following `project.json`: ```json { "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "...
I also get this error. I just deleted all the packages from dnx folder and restore all packages again by "dnu restore" and It is fix.
62,866,512
I am using the following CSS to centre the text on the page but it seems to be creating a large CLS (Cumulative Layout Shift), is there a more efficient way to centre the text? ``` @media only screen and (min-width: 1000px) { .page { width: 1000px; margin: 0 auto; font-s...
2020/07/12
[ "https://Stackoverflow.com/questions/62866512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203146/" ]
It turns out the cause of Cumulative Layout Shift was caused by an image incorrectly sized with the wrong width, I said 700 when the image was actually 702. Strangely, the error was being reported in the wrong place, the error was being reported in another div rather than where the image was. If you are looking for th...
You don't have a defined `width`, so the default setting `auto` applies to width, which is 100%. Centering a 100% wide element (with `margin: 0 auto`) in a parent element makes no sense: It takes the whole width of the parent. So you *need* to define a `width` for your mobile version.
68,891,149
can anyone help me on how to remove the huge white space between the two images? Both images are in their respective divs with layer effects when hovered. I have tried changing display to inline-block and setting font-size to 0 but nothing works. I also want the two images to be at the center when adjusted. I may have ...
2021/08/23
[ "https://Stackoverflow.com/questions/68891149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16713796/" ]
Like this? If so you just need to use `display: flex` and `align-items: flex-start` ```css *{ padding: 0; margin: 0; box-sizing: border-box; } .row { display: flex; align-items: flex-start } .campus-col{ flex-basis: 32%; border-radius: 10px; margin-bottom: 30px; position: relative; overflow:...
you can use bootstrap class for width .campus-col or use custom width
68,891,149
can anyone help me on how to remove the huge white space between the two images? Both images are in their respective divs with layer effects when hovered. I have tried changing display to inline-block and setting font-size to 0 but nothing works. I also want the two images to be at the center when adjusted. I may have ...
2021/08/23
[ "https://Stackoverflow.com/questions/68891149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16713796/" ]
Like this? If so you just need to use `display: flex` and `align-items: flex-start` ```css *{ padding: 0; margin: 0; box-sizing: border-box; } .row { display: flex; align-items: flex-start } .campus-col{ flex-basis: 32%; border-radius: 10px; margin-bottom: 30px; position: relative; overflow:...
You can use (`justify-content: center`) to *center* the `children` in the `flex` displayed `parent`, in short: center the `.img` in `.row`. Then you can add `margin` for spaces between them (the method used in the code below). Or you can use (`justtify-content: space-between`) and set the `width` of the *parent* (`.r...
68,891,149
can anyone help me on how to remove the huge white space between the two images? Both images are in their respective divs with layer effects when hovered. I have tried changing display to inline-block and setting font-size to 0 but nothing works. I also want the two images to be at the center when adjusted. I may have ...
2021/08/23
[ "https://Stackoverflow.com/questions/68891149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16713796/" ]
Try to make row flex container, then align content to center, with gap you can make space between images: ```css *{ padding: 0; margin: 0; box-sizing: border-box; } .row { display: flex; justify-content: center; gap: 1em; } .campus-col{ flex-basis: 32%; border-radius: 10px; margin-bottom: 30px; p...
you can use bootstrap class for width .campus-col or use custom width
68,891,149
can anyone help me on how to remove the huge white space between the two images? Both images are in their respective divs with layer effects when hovered. I have tried changing display to inline-block and setting font-size to 0 but nothing works. I also want the two images to be at the center when adjusted. I may have ...
2021/08/23
[ "https://Stackoverflow.com/questions/68891149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16713796/" ]
Try to make row flex container, then align content to center, with gap you can make space between images: ```css *{ padding: 0; margin: 0; box-sizing: border-box; } .row { display: flex; justify-content: center; gap: 1em; } .campus-col{ flex-basis: 32%; border-radius: 10px; margin-bottom: 30px; p...
You can use (`justify-content: center`) to *center* the `children` in the `flex` displayed `parent`, in short: center the `.img` in `.row`. Then you can add `margin` for spaces between them (the method used in the code below). Or you can use (`justtify-content: space-between`) and set the `width` of the *parent* (`.r...
17,538,167
I have a String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nice formatting plus syntax highlight. I don't want to use a web framework or web browser for such a simple thing. How do I do this? ``` | unformattedXml formattedXml | unformattedXml := '<tag><nested>hell...
2013/07/09
[ "https://Stackoverflow.com/questions/17538167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2562583/" ]
To pretty print your xml string you can use the following ``` xmlString := '<a><b><c></c></b></a>'. xml := XMLDOMParser parseDocumentFrom: xmlString. ^ String streamContents: [:stream| xml prettyPrintOn: stream ] ``` That should give you ``` <a> <b> <c /> </b> </a> ``` I don't know what would...
Take a look at the XML packages on [squeaksource.com](http://squeaksource.com), [ss3.gemstone.com](http://ss3.gemstone.com) and [smalltalkhub.com](http://smalltalkhub.com). There's bound to be something suitable for pretty printing. Syntax highlighting is a different story since it depends on the medium you want to p...
8,252,759
I am developing a taskmanager on Android 2.1. I want to reset date and time on clicking the reset button to current date and time. Help me with the code.. ``` public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final EditText next = (EditText) findViewBy...
2011/11/24
[ "https://Stackoverflow.com/questions/8252759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1031045/" ]
``` //get current time Time now = new Time(); now.setToNow(); //update the TimePicker tp.setHour(now.hour); tp.setMinute(now.minute); //update the DatePicker dp.updateDate(now.year, now.month, now.monthDay); ```
`Time` is now deprecated. Use `Calendar` instead: ``` Calendar calendar = Calendar.getInstance(); tp.setHour(calendar.get(Calendar.HOUR_OF_DAY)); tp.setMinute(calendar.get(Calendar.MINUTE)); dp.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); ```
7,029,870
I have this code for drawpath and nothing shows up and I cant figure out why. ``` //i move the path's starting point somewhere up here to a point. //get center x and y are the centers of a picture. it works when i //do drawline and store the different starting points //but i want it to look continuous not like a lot ...
2011/08/11
[ "https://Stackoverflow.com/questions/7029870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/782117/" ]
i had to add this to paint in order to make it work. dunno why. ``` mPaint.setDither(true); mPaint.setColor(0xFFFFFF00); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(3); ```
I think the best way to solve your problem is by changing the code as follows: ``` private final int strokeWidth = 50; path.lineTo(a.getCenterX() + strokewidth / 2, a.getCenterY() + strokeWidth / 2); path.moveTo(a.getCenterX(), a.getCenterY()); p.setStrokeWidth(strokeWidth); p.setColor(Color.BLACK); canvas.drawPath(...
7,029,870
I have this code for drawpath and nothing shows up and I cant figure out why. ``` //i move the path's starting point somewhere up here to a point. //get center x and y are the centers of a picture. it works when i //do drawline and store the different starting points //but i want it to look continuous not like a lot ...
2011/08/11
[ "https://Stackoverflow.com/questions/7029870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/782117/" ]
A new Paint instance only *fills* paths. To **stroke** paths, set the Paint style: ``` paint.setStyle(Paint.Style.STROKE); ``` If the background you're painting on is black, change the color, so you can see the paint: ``` paint.setColor(Color.RED); // something other than the background color ``` Optional: ``...
I think the best way to solve your problem is by changing the code as follows: ``` private final int strokeWidth = 50; path.lineTo(a.getCenterX() + strokewidth / 2, a.getCenterY() + strokeWidth / 2); path.moveTo(a.getCenterX(), a.getCenterY()); p.setStrokeWidth(strokeWidth); p.setColor(Color.BLACK); canvas.drawPath(...
346,195
So I've been looking all over the internet for a Decimal to Binary converter but all I've been able to find are Binary to Decimal converters, and Decimal to BCD circuits, does anyone have one?
2017/12/21
[ "https://electronics.stackexchange.com/questions/346195", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/172586/" ]
Yes, you'll struggle to find one. The reason for this is that there is no common reason for a BCD to binary converter. Where do the BCD digits come from that you need to convert? The purpose of the many binary to BCD converter ICs that are around are to support 7-segment displays in the pre-cheap-microcontroller era. ...
For a complete 3 digits BCD to binary converter you need 10 output bits for numbers from 0 to 999. 8 bits are good for numbers from 0 to 255. There was a TTL chip for that purpose, the SN74184A, see this [PDF](http://pdf.datasheetcatalog.com/datasheets/400/220358_DS.pdf) or that [PDF](https://www.utm.edu/staff/leeb/D...
346,195
So I've been looking all over the internet for a Decimal to Binary converter but all I've been able to find are Binary to Decimal converters, and Decimal to BCD circuits, does anyone have one?
2017/12/21
[ "https://electronics.stackexchange.com/questions/346195", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/172586/" ]
As has been pointed out in other answers, you can use the venerable (and I do mean venerable) 74184. Of course, those things have been obsolete for decades, so finding them is .... interesting. If you go on eBay, you can get 20 year old Russian knockoffs for a couple of bucks apiece. You'll need 6 for converting 0 to 2...
For a complete 3 digits BCD to binary converter you need 10 output bits for numbers from 0 to 999. 8 bits are good for numbers from 0 to 255. There was a TTL chip for that purpose, the SN74184A, see this [PDF](http://pdf.datasheetcatalog.com/datasheets/400/220358_DS.pdf) or that [PDF](https://www.utm.edu/staff/leeb/D...
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
I saw another related answer here, maybe this is a valid solution too? <https://github.com/jquense/yup/issues/1114> Copying code from there: ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() ...
this will help you ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() }) ``` })
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
You can set a additional boolean key where value is default false. Change it to true when you modify the value in step 1. And then if the value is true for that key then apply the validation. Something like this. ``` const initialSchema= { name: '', isEmail: false, // change this when you want to add...
this will help you ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() }) ``` })
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
this will help you ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() }) ``` })
You need to handle with manually, not with required. Just you need to keep a state of the each field. And check it if its value is present then you need to show it. Some like this ```js const [email, setEmail]= useState(null); const onChange=(e)=>{ setEmail(e.target.value) } return ( <input type="text" onChange={on...
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
You can set a additional boolean key where value is default false. Change it to true when you modify the value in step 1. And then if the value is true for that key then apply the validation. Something like this. ``` const initialSchema= { name: '', isEmail: false, // change this when you want to add...
I modify the schema on the fly with a transform ``` const updateUserValidator = yup.object().shape({ email: yup.string(), updateBy: yup.string() }).transform(function (current, original) { this.fields.email = original?.email?.length === undefined ? yup().string().email() : yup().string()....
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
this will help you ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() }) ``` })
I modify the schema on the fly with a transform ``` const updateUserValidator = yup.object().shape({ email: yup.string(), updateBy: yup.string() }).transform(function (current, original) { this.fields.email = original?.email?.length === undefined ? yup().string().email() : yup().string()....
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
You can set a additional boolean key where value is default false. Change it to true when you modify the value in step 1. And then if the value is true for that key then apply the validation. Something like this. ``` const initialSchema= { name: '', isEmail: false, // change this when you want to add...
I saw another related answer here, maybe this is a valid solution too? <https://github.com/jquense/yup/issues/1114> Copying code from there: ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() ...
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
You can set a additional boolean key where value is default false. Change it to true when you modify the value in step 1. And then if the value is true for that key then apply the validation. Something like this. ``` const initialSchema= { name: '', isEmail: false, // change this when you want to add...
You can use Cyclic Dependency for make this. Example: ``` const YOUR_SCHEMA_NAME = yup.object().shape({ email: yup.string().when('email', { is: (exists) => !!exists, then: yup.string().email(), otherwise: yup.string(), }), }, [['email', 'email']]); ```
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
this will help you ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() }) ``` })
You can use Cyclic Dependency for make this. Example: ``` const YOUR_SCHEMA_NAME = yup.object().shape({ email: yup.string().when('email', { is: (exists) => !!exists, then: yup.string().email(), otherwise: yup.string(), }), }, [['email', 'email']]); ```
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
You can set a additional boolean key where value is default false. Change it to true when you modify the value in step 1. And then if the value is true for that key then apply the validation. Something like this. ``` const initialSchema= { name: '', isEmail: false, // change this when you want to add...
You need to handle with manually, not with required. Just you need to keep a state of the each field. And check it if its value is present then you need to show it. Some like this ```js const [email, setEmail]= useState(null); const onChange=(e)=>{ setEmail(e.target.value) } return ( <input type="text" onChange={on...
65,613,573
Is it possible to validate a field only when it exists? I'm going to create an application. A field(email) may / may not display on step 2, it depends on the step 1's selected option. The problem is that I can't put `email: Yup.string().Required()`, it causes that the validation run all the time even the field is not ...
2021/01/07
[ "https://Stackoverflow.com/questions/65613573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5400365/" ]
I saw another related answer here, maybe this is a valid solution too? <https://github.com/jquense/yup/issues/1114> Copying code from there: ``` const schema = yup.object({ phone: yup.string().when('$exist', { is: exist => exist, then: yup.string().required(), otherwise: yup.string() ...
You can use Cyclic Dependency for make this. Example: ``` const YOUR_SCHEMA_NAME = yup.object().shape({ email: yup.string().when('email', { is: (exists) => !!exists, then: yup.string().email(), otherwise: yup.string(), }), }, [['email', 'email']]); ```
4,098,493
I need to find remote data such as RAM usage, swap usage, number of processors, etc, using a php script from the local computer and 10 other remote computers. How can I go about it? The remote computers are all running Linux, and they can run any service that is needed of the machine. What I have in mind is that I c...
2010/11/04
[ "https://Stackoverflow.com/questions/4098493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357538/" ]
I think you will probably want to look at PHP Expect, it allows you to do something like connect to a remote host, and provide input/responses to output on the remote. <http://us3.php.net/manual/en/book.expect.php>
Have you considered a monitoring suite like [Nagios](http://www.nagios.org/) instead of PHP? I think Nagios can give you all this data in a central web-based interface. As far as I know, it has a learning curve that is not entirely trivial, but it may still beat building a PHP solution.
4,098,493
I need to find remote data such as RAM usage, swap usage, number of processors, etc, using a php script from the local computer and 10 other remote computers. How can I go about it? The remote computers are all running Linux, and they can run any service that is needed of the machine. What I have in mind is that I c...
2010/11/04
[ "https://Stackoverflow.com/questions/4098493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357538/" ]
Have you considered a monitoring suite like [Nagios](http://www.nagios.org/) instead of PHP? I think Nagios can give you all this data in a central web-based interface. As far as I know, it has a learning curve that is not entirely trivial, but it may still beat building a PHP solution.
You can use PHP [sockets](http://www.php.net/manual/en/book.sockets.php) to communicate with servers remotely via [SNMP](http://php.net/manual/en/book.snmp.php). The remote servers need to have SNMP activated and configured to provide the data you need, such as hardware info, bandwidth, disk space, swap usage, etc.
4,098,493
I need to find remote data such as RAM usage, swap usage, number of processors, etc, using a php script from the local computer and 10 other remote computers. How can I go about it? The remote computers are all running Linux, and they can run any service that is needed of the machine. What I have in mind is that I c...
2010/11/04
[ "https://Stackoverflow.com/questions/4098493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357538/" ]
I think you will probably want to look at PHP Expect, it allows you to do something like connect to a remote host, and provide input/responses to output on the remote. <http://us3.php.net/manual/en/book.expect.php>
You can use PHP [sockets](http://www.php.net/manual/en/book.sockets.php) to communicate with servers remotely via [SNMP](http://php.net/manual/en/book.snmp.php). The remote servers need to have SNMP activated and configured to provide the data you need, such as hardware info, bandwidth, disk space, swap usage, etc.
9,909,932
Consider following code: ``` SwingWorker<Void, Void> sworker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { ExecutorService executor = Executors.newFixedThreadPool(5); try { for (int j = 0; j < 5; j++) { ...
2012/03/28
[ "https://Stackoverflow.com/questions/9909932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/699908/" ]
It is entirely dependent on your compiler and architecture. In your case it looks as if the fields are indeed being 8-byte-aligned, perhaps for performance reasons.
My guess is that by default everything on 64bit architecture will be aligned to 64bit boundaries same as on 32bit architecture everything is aligned to 4 bytes. You can specify packing pragma directives to get rid of the padding. For example ``` #pragma pack(0) ``` in gcc.
9,909,932
Consider following code: ``` SwingWorker<Void, Void> sworker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { ExecutorService executor = Executors.newFixedThreadPool(5); try { for (int j = 0; j < 5; j++) { ...
2012/03/28
[ "https://Stackoverflow.com/questions/9909932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/699908/" ]
My guess is that by default everything on 64bit architecture will be aligned to 64bit boundaries same as on 32bit architecture everything is aligned to 4 bytes. You can specify packing pragma directives to get rid of the padding. For example ``` #pragma pack(0) ``` in gcc.
On linux with gcc and a 64 bit CPU I get what you would expect; the size of a struct with two short ints, is 4, two 32 bit ints is 8 and two 64 bit ints is 16.
9,909,932
Consider following code: ``` SwingWorker<Void, Void> sworker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { ExecutorService executor = Executors.newFixedThreadPool(5); try { for (int j = 0; j < 5; j++) { ...
2012/03/28
[ "https://Stackoverflow.com/questions/9909932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/699908/" ]
It is entirely dependent on your compiler and architecture. In your case it looks as if the fields are indeed being 8-byte-aligned, perhaps for performance reasons.
On linux with gcc and a 64 bit CPU I get what you would expect; the size of a struct with two short ints, is 4, two 32 bit ints is 8 and two 64 bit ints is 16.
61,308,766
I have a requirement where i want to skip all the upcoming tasks if a "Release artifacts" task is run. Release artifact task runs only if one of the variable is set to "true" while running the pipeline. ``` parameters: release: $(release) - task: Bash@3 displayName: Release artifacts condition: and(succeede...
2020/04/19
[ "https://Stackoverflow.com/questions/61308766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768610/" ]
You may have a race condition which may cause undefined behavior. In create\_serv\_and\_init\_client() you define a local variable serv. The address of this variable is passed to the thread. When create\_serv\_and\_init\_client completes serv will go out of scope, even if the thread is still using it. As a result the v...
Note a multi-threaded program can really only `fork` to execute a new program using `execve`. For example from Linux manuals: > > * After a `fork()` in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls `execve(2)`. > > > `printf`...
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Let me take your last sentences to tell you my opinion: > > Sobald ich Zeit habe, werde ich dir helfen. > > Ich werde dir helfen, sobald ich Zeit habe. > > Ich werde dir, sobald ich Zeit habe, helfen. > > > The second sentence is the most common to use, I guess, followed by the first and then the third. P...
Actually, all of the above are correct. Especially the last three examples are all correct. You are safe using your first example - the one you came up with yourself. If you want to read about subordinate clauses in German, go to the following page: <http://www.mein-deutschbuch.de/lernen.php?menu_id=123>
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Don't let the third sentence type confuse you. The subordinate clause is an insertion and the outer sentence structure is not changed by it. The normal sentences would be > > Jeder ist für das verantwortlich. > > > Ich werde dir helfen. > > > The conjugated verb is at the second position as usual. The tricky pa...
Actually, all of the above are correct. Especially the last three examples are all correct. You are safe using your first example - the one you came up with yourself. If you want to read about subordinate clauses in German, go to the following page: <http://www.mein-deutschbuch.de/lernen.php?menu_id=123>
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Concerning "Jeder ist für das, was er gesagt hat, verantwortlich.": ------------------------------------------------------------------- Think about the "das, was er gesagt hat" as a noun. The whole phrase can be used anywhere a noun is used. It's called a noun phrase. Examples: > > **Das Auto** gefällt mir nicht. >...
Actually, all of the above are correct. Especially the last three examples are all correct. You are safe using your first example - the one you came up with yourself. If you want to read about subordinate clauses in German, go to the following page: <http://www.mein-deutschbuch.de/lernen.php?menu_id=123>
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Maybe this is also a matter of emphasis. When arguing with someone you sometimes want to point out something in particular. > > "Kein Argument, das du nennen kannst, wird mich überzeugen" (nice example, thank you) > > > "Kein Argument *(of all arguments in the world)*, das **du** nennen kannst *(pointing at the per...
Actually, all of the above are correct. Especially the last three examples are all correct. You are safe using your first example - the one you came up with yourself. If you want to read about subordinate clauses in German, go to the following page: <http://www.mein-deutschbuch.de/lernen.php?menu_id=123>
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Don't let the third sentence type confuse you. The subordinate clause is an insertion and the outer sentence structure is not changed by it. The normal sentences would be > > Jeder ist für das verantwortlich. > > > Ich werde dir helfen. > > > The conjugated verb is at the second position as usual. The tricky pa...
Let me take your last sentences to tell you my opinion: > > Sobald ich Zeit habe, werde ich dir helfen. > > Ich werde dir helfen, sobald ich Zeit habe. > > Ich werde dir, sobald ich Zeit habe, helfen. > > > The second sentence is the most common to use, I guess, followed by the first and then the third. P...
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Concerning "Jeder ist für das, was er gesagt hat, verantwortlich.": ------------------------------------------------------------------- Think about the "das, was er gesagt hat" as a noun. The whole phrase can be used anywhere a noun is used. It's called a noun phrase. Examples: > > **Das Auto** gefällt mir nicht. >...
Let me take your last sentences to tell you my opinion: > > Sobald ich Zeit habe, werde ich dir helfen. > > Ich werde dir helfen, sobald ich Zeit habe. > > Ich werde dir, sobald ich Zeit habe, helfen. > > > The second sentence is the most common to use, I guess, followed by the first and then the third. P...
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Don't let the third sentence type confuse you. The subordinate clause is an insertion and the outer sentence structure is not changed by it. The normal sentences would be > > Jeder ist für das verantwortlich. > > > Ich werde dir helfen. > > > The conjugated verb is at the second position as usual. The tricky pa...
Maybe this is also a matter of emphasis. When arguing with someone you sometimes want to point out something in particular. > > "Kein Argument, das du nennen kannst, wird mich überzeugen" (nice example, thank you) > > > "Kein Argument *(of all arguments in the world)*, das **du** nennen kannst *(pointing at the per...
17,877
I once asked a question if the sentence > > jeder muss dafür verantwortlich sein, was er gesagt hat > > > is correct and was told that it is acceptable and that the verb must go at the end of its own clause before any subordinate clause. However, I was also told by a native speaker that this sentence could als...
2014/11/18
[ "https://german.stackexchange.com/questions/17877", "https://german.stackexchange.com", "https://german.stackexchange.com/users/9721/" ]
Concerning "Jeder ist für das, was er gesagt hat, verantwortlich.": ------------------------------------------------------------------- Think about the "das, was er gesagt hat" as a noun. The whole phrase can be used anywhere a noun is used. It's called a noun phrase. Examples: > > **Das Auto** gefällt mir nicht. >...
Maybe this is also a matter of emphasis. When arguing with someone you sometimes want to point out something in particular. > > "Kein Argument, das du nennen kannst, wird mich überzeugen" (nice example, thank you) > > > "Kein Argument *(of all arguments in the world)*, das **du** nennen kannst *(pointing at the per...
64,606,542
Merge 2 dataframes. I have dataframe A that has a value in a non constant timestamp: ``` creation_time value_A 2020-09-22 00:00:35 83.0 2020-09-22 00:00:43 83.0 2020-09-22 00:02:20 82.0 2020-09-22 00:03:09 77.0 2020-09-22 00:03:04 77.0 2020-09-22 00:03:44 77.0 2020-09-22 00:07:10 71.0 ... 2020-10-23 11:42:31 136.0 ...
2020/10/30
[ "https://Stackoverflow.com/questions/64606542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6587020/" ]
Tensorflow isn't in the "defaults" anaconda channel. It is on conda-forge instead. In order to add conda-forge to your channels: 1. Click on "channels" (left of where you searched for tensorflow) 2. Click on "add" 3. Paste this URL in: <https://conda.anaconda.org/conda-forge/> 4. Press enter 5. Press "Update channels"...
Additionally to the steps described above (with the version @aysebilgegunduz mentioned), I also had to "Update index..." after adding "conda-forge" to the environment's channels. Afterwards, I found the desired package.
64,606,542
Merge 2 dataframes. I have dataframe A that has a value in a non constant timestamp: ``` creation_time value_A 2020-09-22 00:00:35 83.0 2020-09-22 00:00:43 83.0 2020-09-22 00:02:20 82.0 2020-09-22 00:03:09 77.0 2020-09-22 00:03:04 77.0 2020-09-22 00:03:44 77.0 2020-09-22 00:07:10 71.0 ... 2020-10-23 11:42:31 136.0 ...
2020/10/30
[ "https://Stackoverflow.com/questions/64606542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6587020/" ]
Tensorflow isn't in the "defaults" anaconda channel. It is on conda-forge instead. In order to add conda-forge to your channels: 1. Click on "channels" (left of where you searched for tensorflow) 2. Click on "add" 3. Paste this URL in: <https://conda.anaconda.org/conda-forge/> 4. Press enter 5. Press "Update channels"...
Tensorflow isn't in the "defaults" anaconda channel. It is on conda-forge instead. In order to add conda-forge to your channels: Click on "channels" (left of where you searched for tensorflow) Click on "add" Paste this URL in: <https://conda.anaconda.org/conda-forge/> Press enter Press "Update channels" Now searc...
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
You can use `typeof`, like this: ``` if (typeof something != "undefined") { // ... } ```
In [this article](http://flippinawesome.org/2013/12/09/exploring-the-abyss-of-null-and-undefined-in-javascript/) I read that frameworks like [Underscore.js](https://en.wikipedia.org/wiki/Underscore.js) use this function: ``` function isUndefined(obj){ return obj === void 0; } ```
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
**2020 Update** One of my reasons for preferring a `typeof` check (namely, that `undefined` can be redefined) became irrelevant with the mass adoption of ECMAScript 5. The other, that you can use `typeof` to check the type of an undeclared variable, was always niche. Therefore, I'd now recommend using a direct compari...
Since none of the other answers helped me, I suggest doing this. It worked for me in Internet Explorer 8: ``` if (typeof variable_name.value === 'undefined') { // variable_name is undefined } ```
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
Personally, I always use the following: ``` var x; if( x === undefined) { //Do something here } else { //Do something else here } ``` The window.undefined property is non-writable in all modern browsers (JavaScript 1.8.5 or later). From Mozilla's documentation: <https://developer.mozilla.org/en-US/docs/Web/Ja...
``` var x; if (x === undefined) { alert ("I am declared, but not defined.") }; if (typeof y === "undefined") { alert ("I am not even declared.") }; /* One more thing to understand: typeof ==='undefined' also checks for if a variable is declared, but no value is assigned....
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
``` if (typeof foo == 'undefined') { // Do something }; ``` Note that strict comparison (`!==`) is not necessary in this case, since `typeof` will always return a string.
I use it as a function parameter and exclude it on function execution that way I get the "real" undefined. Although it does require you to put your code inside a function. I found this while reading the jQuery source. ``` undefined = 2; (function (undefined) { console.log(undefined); // prints out undefined // ...
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
``` if (typeof foo == 'undefined') { // Do something }; ``` Note that strict comparison (`!==`) is not necessary in this case, since `typeof` will always return a string.
On the contrary of @Thomas Eding answer: If I forget to declare `myVar` in my code, then I'll get `myVar is not defined`. Let's take a real example: I've a variable name, but I am not sure if it is declared somewhere or not. Then @Anurag's answer will help: ``` var myVariableToCheck = 'myVar'; if (window[myVariabl...
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
The most reliable way I know of checking for `undefined` is to use `void 0`. This is compatible with newer and older browsers, alike, and cannot be overwritten like `window.undefined` can in some cases. ``` if( myVar === void 0){ //yup it's undefined } ```
Since none of the other answers helped me, I suggest doing this. It worked for me in Internet Explorer 8: ``` if (typeof variable_name.value === 'undefined') { // variable_name is undefined } ```
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
``` if (typeof foo == 'undefined') { // Do something }; ``` Note that strict comparison (`!==`) is not necessary in this case, since `typeof` will always return a string.
The most reliable way I know of checking for `undefined` is to use `void 0`. This is compatible with newer and older browsers, alike, and cannot be overwritten like `window.undefined` can in some cases. ``` if( myVar === void 0){ //yup it's undefined } ```
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
Update 2018-07-25 ================= It's been nearly five years since this post was first made, and JavaScript has come a long way. In repeating the tests in the original post, I found no consistent difference between the following test methods: * `abc === undefined` * `abc === void 0` * `typeof abc == 'undefined'` *...
``` // x has not been defined before if (typeof x === 'undefined') { // Evaluates to true without errors. // These statements execute. } if (x === undefined) { // Throws a ReferenceError } ```
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
**2020 Update** One of my reasons for preferring a `typeof` check (namely, that `undefined` can be redefined) became irrelevant with the mass adoption of ECMAScript 5. The other, that you can use `typeof` to check the type of an undeclared variable, was always niche. Therefore, I'd now recommend using a direct compari...
I use it as a function parameter and exclude it on function execution that way I get the "real" undefined. Although it does require you to put your code inside a function. I found this while reading the jQuery source. ``` undefined = 2; (function (undefined) { console.log(undefined); // prints out undefined // ...
3,390,403
I'm designing a website for an organization that's a state chapter of a national organization. The national organization has implemented a member login that I need to use for the state website. My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. I'm a total n...
2010/08/02
[ "https://Stackoverflow.com/questions/3390403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/389803/" ]
If it is undefined, it will not be equal to a string that contains the characters "undefined", as the string is not undefined. You can check the type of the variable: ``` if (typeof(something) != "undefined") ... ``` Sometimes you don't even have to check the type. If the value of the variable can't evaluate to fal...
``` var x; if (x === undefined) { alert ("I am declared, but not defined.") }; if (typeof y === "undefined") { alert ("I am not even declared.") }; /* One more thing to understand: typeof ==='undefined' also checks for if a variable is declared, but no value is assigned....
464,802
Take a look at this here: ``` \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \begin{document} \begin{align*} \Leftrightarrow \qquad P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} && (2.6)\\ \Leftrightarrow \qquad e^{\lambda t}P'_1(t)+\l...
2018/12/14
[ "https://tex.stackexchange.com/questions/464802", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/173831/" ]
Like so? ``` \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \Leftrightarrow&& P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} \tag{2.6} \\ \Leftrightarrow&& e^{\lambda t}P'_1(t)+\lambda e^{\lambda t}P_1(t)&=\lambda e^{\lambda t} e^{-\lambda t}=\lambda \notag \end{align} \end{document} ```...
You can also use `alignat`: [![enter image description here](https://i.stack.imgur.com/3UOxi.png)](https://i.stack.imgur.com/3UOxi.png) Code: ----- ``` \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \begin{document} \begin{alignat*}{4...
464,802
Take a look at this here: ``` \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \begin{document} \begin{align*} \Leftrightarrow \qquad P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} && (2.6)\\ \Leftrightarrow \qquad e^{\lambda t}P'_1(t)+\l...
2018/12/14
[ "https://tex.stackexchange.com/questions/464802", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/173831/" ]
Like so? ``` \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \Leftrightarrow&& P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} \tag{2.6} \\ \Leftrightarrow&& e^{\lambda t}P'_1(t)+\lambda e^{\lambda t}P_1(t)&=\lambda e^{\lambda t} e^{-\lambda t}=\lambda \notag \end{align} \end{document} ```...
You *don't* want to manually number your equations and not because of the fact that the numbers would be unaligned to each other, but because maintaining manual numbering is essentially impossible. Use the `\label`-`\ref` mechanism for this. Your problem can be solved with `alignedat`: ``` \documentclass[10pt,a4pape...
464,802
Take a look at this here: ``` \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \begin{document} \begin{align*} \Leftrightarrow \qquad P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} && (2.6)\\ \Leftrightarrow \qquad e^{\lambda t}P'_1(t)+\l...
2018/12/14
[ "https://tex.stackexchange.com/questions/464802", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/173831/" ]
Like so? ``` \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \Leftrightarrow&& P'_1(t)+\lambda P_1(t)&=\lambda e^{-\lambda t} \tag{2.6} \\ \Leftrightarrow&& e^{\lambda t}P'_1(t)+\lambda e^{\lambda t}P_1(t)&=\lambda e^{\lambda t} e^{-\lambda t}=\lambda \notag \end{align} \end{document} ```...
You also might be interested in the `ArrowBetweenLines` from `mathtools`: ``` \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{mathtools} \usepackage{amssymb} \numberwithin{equation}{section} \begin{document} \setcounter{section}{2}\setcounter{equation}{5} \begin{equation}\label{equiva...
40,368,293
I have a stylesheet that specifies a style for `<LABEL>`. But some `<LABEL>`s are special: Currently I inline style them like this: ``` <LABEL style="text-align:right; line-height:15pt"> <div style="padding-right:20px">My Label Text</div> </LABEL> ``` I suspect there's a way to specify a CSS class, perhaps call...
2016/11/01
[ "https://Stackoverflow.com/questions/40368293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2662901/" ]
Usually, faces stores indices of each triangle in the vertices array. So the first face is a triangle consisting of vertices[0], vertices[1], vertices[2]. The second one consists of vertices[3], vertices[4], vertices[5] and so on.
For triangular meshes, a face is a triangle defined by 3 vertices. Normally, a mesh is composed by a list of n vertices and m faces. For example: Vertices: ``` Point_0 = {0,0,0} Point_1 = {2,0,0} Point_3 = {0,2,0} Point_4 = {0,3,0} ... Point_n = {30,0,0} ``` Faces: ``` Face_0 = {Point_1, Point_4, Point_5} Face_1 =...
5,257,198
How can I measure time that ListView/ListActivity takes for rendering its list? I have a ListActivity that takes a long time to show (on older devices it's ~3s) and I'd like to optimize that. EDIT: I already have time between Activity1 and Activity2. During this time, Activity2 is doing some stuff (initializing). Am...
2011/03/10
[ "https://Stackoverflow.com/questions/5257198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133648/" ]
You could simply ouput the time. For example you could use the logcat ``` final long t0 = System.currentTimeMillis(); // code to measure Log.w(TAG, "TEXT" + System.currentTimeMillis()-t0); ``` Of course you could use any other system for the ouput like a dialog or stuff. Just use what you like. EDIT: If you don'...
I cannot tell if Java offers a better implementation using `System.currentTimeMillis()` or `System.nanoTime()`. Nevertheless, you should give the [TimingLogger](http://developer.android.com/reference/android/util/TimingLogger.html) class a try. Take a look at this [article describing the usage of the TimingLogger helpe...
26,871,085
I'm trying to save the contents of an entire Wordpress site using python and without ftp / server access. In other words, I want to save a "complete copy, or closest possible" of the Wordpress site to disk and I can't download everything from ftp / server. I've found some options to iterate through the various pages t...
2014/11/11
[ "https://Stackoverflow.com/questions/26871085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4114926/" ]
Not using python (although I'm sure you could hack up something -- or possibly find something on pypi), but why not just use wget. Something like: ``` wget -rkp -l3 -np -nH --cut-dirs=1 http://example.com ``` Of course if you REALLY want to do it in python, you could: ``` import subprocess subprocess.call(['wget', ...
If you can, and you should, mantain all WordPress modeling tables, you might want to use a WordPress feature (also plugin) called Migrate...You might have it, so, if you can go to your Administration Panel (aka /wp-admin) you can loggin and use <http://yourdomain.com/wp-admin/export.php> This way, you will get a XML th...
26,871,085
I'm trying to save the contents of an entire Wordpress site using python and without ftp / server access. In other words, I want to save a "complete copy, or closest possible" of the Wordpress site to disk and I can't download everything from ftp / server. I've found some options to iterate through the various pages t...
2014/11/11
[ "https://Stackoverflow.com/questions/26871085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4114926/" ]
If you really want to use Python and nothing else, you could use [wpull](http://wpull.readthedocs.org/en/master/index.html), which is a wget clone written in Python. They have an example for archiving/downloading an entire website in their docs. ``` wpull billy.blogsite.example --warc-file blogsite-billy \ --no-check-...
Not using python (although I'm sure you could hack up something -- or possibly find something on pypi), but why not just use wget. Something like: ``` wget -rkp -l3 -np -nH --cut-dirs=1 http://example.com ``` Of course if you REALLY want to do it in python, you could: ``` import subprocess subprocess.call(['wget', ...
26,871,085
I'm trying to save the contents of an entire Wordpress site using python and without ftp / server access. In other words, I want to save a "complete copy, or closest possible" of the Wordpress site to disk and I can't download everything from ftp / server. I've found some options to iterate through the various pages t...
2014/11/11
[ "https://Stackoverflow.com/questions/26871085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4114926/" ]
If you really want to use Python and nothing else, you could use [wpull](http://wpull.readthedocs.org/en/master/index.html), which is a wget clone written in Python. They have an example for archiving/downloading an entire website in their docs. ``` wpull billy.blogsite.example --warc-file blogsite-billy \ --no-check-...
If you can, and you should, mantain all WordPress modeling tables, you might want to use a WordPress feature (also plugin) called Migrate...You might have it, so, if you can go to your Administration Panel (aka /wp-admin) you can loggin and use <http://yourdomain.com/wp-admin/export.php> This way, you will get a XML th...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
Here's a very concise and recursive solution that allows you to input the size of the output permutations similar to the statistical operator nPr. "5 permutation 3". This allows you to get all possible permutations with a specific size. ``` function generatePermutations(list, size=list.length) { if (size > list.le...
here is a visualization for the recursive function => <https://recursion.vercel.app/> ``` var permute = function (nums) { let answer = []; var permuter = function (arr, permutation = []) { if (arr.length === 0) { return answer.push(permutation); } else { for (let i = 0; i < arr.length; i++) {...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
Most of the other answers do not utilize the new javascript generator functions which is a perfect solution to this type of problem. You probably only need one permutation at time in memory. Also, I prefer to generate a permutation of a range of indices as this allows me to index each permutation and jump straight to a...
``` function swap(array1, index1, index2) { var temp; temp = array1[index1]; array1[index1] = array1[index2]; array1[index2] = temp; } function permute(a, l, r) { var i; if (l == r) { console.log(a.join('')); } else { for (i = l; i <= r; i++) { swap(a, l, i); ...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
Answer without the need for a exterior array or additional function ``` function permutator (arr) { var permutations = []; if (arr.length === 1) { return [ arr ]; } for (var i = 0; i < arr.length; i++) { var subPerms = permutator(arr.slice(0, i).concat(arr.slice(i + 1))); for (var j = 0; j < sub...
This is just little bit more succinct version of delimited's ```js function permutator (inputArr) { const result = [] function permute (arr, m = []) { if (arr.length) { arr.forEach((item, i) => { const restArr = [...arr.slice(0, i), ...arr.slice(i + 1)] permute(restArr, [...m, item]) ...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
The following very efficient algorithm uses [Heap's method](http://homepage.math.uiowa.edu/~goodman/22m150.dir/2007/Permutation%20Generation%20Methods.pdf) to generate all permutations of N elements with runtime complexity in O(N!): ```js function permute(permutation) { var length = permutation.length, resul...
I wrote a [post](http://www.pixelstech.net/article/1316620955-Permutation-algorithm-with-JavaScript) to demonstrate how to permute an array in JavaScript. Here is the code which does this. ``` var count=0; function permute(pre,cur){ var len=cur.length; for(var i=0;i<len;i++){ var p=clone(pre); ...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
If you notice, the code actually splits the chars into an array prior to do any permutation, so you simply remove the join and split operation ```js var permArr = [], usedChars = []; function permute(input) { var i, ch; for (i = 0; i < input.length; i++) { ch = input.splice(i, 1)[0]; usedChars.pus...
``` #!/usr/bin/env node "use strict"; function perm(arr) { if(arr.length<2) return [arr]; var res = []; arr.forEach(function(x, i) { perm(arr.slice(0,i).concat(arr.slice(i+1))).forEach(function(a) { res.push([x].concat(a)); }); }); return res; } console.log(perm([1,2,3,...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
```js "use strict"; function getPermutations(arrP) { var results = []; var arr = arrP; arr.unshift(null); var length = arr.length; while (arr[0] === null) { results.push(arr.slice(1).join('')); let less = null; let lessIndex = null; for (let i = length -...
I think you'll may like this one: ``` const permute1 = (arr: any[]): any[][] => arr.reduce( (acc, curr) => acc.length > 0 ? acc .map((p) => Array.from({ length: p.length + 1 }, (_, i) => p.slice(0, i).concat(curr, p.slice(i)) ) ) ...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
The following very efficient algorithm uses [Heap's method](http://homepage.math.uiowa.edu/~goodman/22m150.dir/2007/Permutation%20Generation%20Methods.pdf) to generate all permutations of N elements with runtime complexity in O(N!): ```js function permute(permutation) { var length = permutation.length, resul...
Here's one I made... ``` const permute = (ar) => ar.length === 1 ? ar : ar.reduce( (ac,_,i) => {permute([...ar.slice(0,i),...ar.slice(i+1)]).map(v=>ac.push([].concat(ar[i],v))); return ac;},[]); ``` And here it is again but written less tersely!... ``` function permute(inputArray) { if (inputArray.length ==...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
Here's one I made... ``` const permute = (ar) => ar.length === 1 ? ar : ar.reduce( (ac,_,i) => {permute([...ar.slice(0,i),...ar.slice(i+1)]).map(v=>ac.push([].concat(ar[i],v))); return ac;},[]); ``` And here it is again but written less tersely!... ``` function permute(inputArray) { if (inputArray.length ==...
I think you'll may like this one: ``` const permute1 = (arr: any[]): any[][] => arr.reduce( (acc, curr) => acc.length > 0 ? acc .map((p) => Array.from({ length: p.length + 1 }, (_, i) => p.slice(0, i).concat(curr, p.slice(i)) ) ) ...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
``` var inputArray = [1, 2, 3]; var result = inputArray.reduce(function permute(res, item, key, arr) { return res.concat(arr.length > 1 && arr.slice(0, key) .concat(arr.slice(key + 1)) .reduce(permute, []) .map(function (perm) { return [item].concat(perm); }) || item); }...
here is a visualization for the recursive function => <https://recursion.vercel.app/> ``` var permute = function (nums) { let answer = []; var permuter = function (arr, permutation = []) { if (arr.length === 0) { return answer.push(permutation); } else { for (let i = 0; i < arr.length; i++) {...
9,960,908
I'm trying to write a function that does the following: * takes an array of integers as an argument (e.g. [1,2,3,4]) * creates an array of all the possible permutations of [1,2,3,4], with each permutation having a length of 4 the function below (I found it online) does this by taking a string as an argument, and retu...
2012/04/01
[ "https://Stackoverflow.com/questions/9960908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215474/" ]
``` function perm(xs) { return xs.length === 0 ? [[]] : perm(xs.slice(1)).reduce(function (acc, ys) { for (var i = 0; i < xs.length; i++) { acc.push([].concat(ys.slice(0, i), xs[0], ys.slice(i))); } return acc; }, []); } ``` Test it with: ``` console.log(JSON.str...
here is a visualization for the recursive function => <https://recursion.vercel.app/> ``` var permute = function (nums) { let answer = []; var permuter = function (arr, permutation = []) { if (arr.length === 0) { return answer.push(permutation); } else { for (let i = 0; i < arr.length; i++) {...
11,794,136
I'm facing the problem when i am creating database in SQL server management studio 2008. it is showing error that xpstar90.dll DLL find could not load (response 126).
2012/08/03
[ "https://Stackoverflow.com/questions/11794136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1556859/" ]
The error `undefined local variable or method 'params'` clearly indicates that `params` are not available in your model. Also, it's not a good idea to use params in your models. See this question [Rails How to pass params from controller to after\_save inside model](https://stackoverflow.com/questions/4725185/rails-ho...
Undefined local variable or method `params' for your user model
3,277,745
I have a layout that looks like this: ``` .-------------------.u |#content |u '-------------------'u .-------------------.u |#menu |u '-------------------'u .-------------------.u |#morecontent vu | vu | vu '-------------------'u ``` `u`'s represent th...
2010/07/19
[ "https://Stackoverflow.com/questions/3277745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Make sure that your div uses only max-height and min-height. Do not use height. If you want its height to go forever, don't set anything.
Use `position: fixed` to make the layout more concrete and Javascript to resize the #morecontent div. There is no way to make it resize when the other div does with XHTML/CSS.
3,277,745
I have a layout that looks like this: ``` .-------------------.u |#content |u '-------------------'u .-------------------.u |#menu |u '-------------------'u .-------------------.u |#morecontent vu | vu | vu '-------------------'u ``` `u`'s represent th...
2010/07/19
[ "https://Stackoverflow.com/questions/3277745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Take a look at this: <http://jsfiddle.net/9QNUG/> note: you did not say if the content above was dynamic, but i am assuming not from your description, you will need to play with the heights in the example to get them to match yours.
Use `position: fixed` to make the layout more concrete and Javascript to resize the #morecontent div. There is no way to make it resize when the other div does with XHTML/CSS.
40,181,608
I am trying to make simple page which will return values from MySQL table, but the problem is that if I want to use condotions in query then it doesn't work. My PHP page: ``` <?php $servername = "10.10.10.10"; $username = "username"; $password = "password"; $dbname = "GENERIC_TABLES"; // Create connection $conn ...
2016/10/21
[ "https://Stackoverflow.com/questions/40181608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6743748/" ]
As you realized, `WO_NUM+1` changes the column name in the resulting array, so use an alias `WO_NUM+1 as NEW_NUM`. However I would not bother with the sorting and limit. Consider `MAX()`: ``` SELECT max(WO_NUM)+1 as NEW_NUM from GENERIC_TABLES.WO_NUMBERS ```
As it has been pointed by AbraCadaver, I missed that if I am using WO\_NUM + 1 then column name changing so that is why i didn't get any output, so using alias solved problem.
11,340,696
How can I remove multiple "[" in HTML Tag ID attribute with Regex? For example ``` <div id="test[12][45][67]">test inline [for example]</div> ``` Change to ``` <div id="test12]45]67]">test inline [for example]</div> ```
2012/07/05
[ "https://Stackoverflow.com/questions/11340696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/409400/" ]
What you could (most likely should) do is to use a PHP HTML parser, such as [PHP Simple DOM Parser](http://simplehtmldom.sourceforge.net/) to go over the HTML, extract the ID value and then replace it using something like so: ``` <?php $string = <yourID> $pattern = '/\[/g'; $replacement = ''; echo preg_replace($patter...
using javascript: ``` function rem_open_square_brackets(_id) { if(_id) { return _id.replace(/[\[]*/g, ''); } return _id; } var _id = rem_open_square_brackets('test[12][45][67]'); document.write(_id); ``` you could find all your ids and past them to the function and replace them with the return va...
15,865,797
I want to add elements to my array through a user input. I know this can be done very easy using a list but i have to use an array. The problem with the code is that the array.lenght will always be 1. I want the array to have the same size as the total amount of elements in it, so size of the array shouldnt be set wh...
2013/04/07
[ "https://Stackoverflow.com/questions/15865797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197276/" ]
Use `List<int>` instead of an explicit array, which will dynamically size for you, and use the Add() method to add elements at the end.
Lists grow as you add elements to it. Arrays have a constant size. If you must use arrays, the easiest way to do it, is to create an array that is big enough to hold the entered elements. ``` private int[] _items = new int[100]; private int _count; public void Add(int x) { _items[_count++] = x; } ``` You also n...
15,865,797
I want to add elements to my array through a user input. I know this can be done very easy using a list but i have to use an array. The problem with the code is that the array.lenght will always be 1. I want the array to have the same size as the total amount of elements in it, so size of the array shouldnt be set wh...
2013/04/07
[ "https://Stackoverflow.com/questions/15865797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197276/" ]
I didn't test in VS. Here you go: ``` namespace ConsoleApplication1 { class Program { static int[] Item; //Fixed int Item[] to int[] Item static void Main(string[] args) { Add(3); Add(4); Add(6); } public static void Add(int x){ ...
Lists grow as you add elements to it. Arrays have a constant size. If you must use arrays, the easiest way to do it, is to create an array that is big enough to hold the entered elements. ``` private int[] _items = new int[100]; private int _count; public void Add(int x) { _items[_count++] = x; } ``` You also n...
58,178,675
My goal is to make a small program/macro in VBA Excel that fixes column names automatically. The way I would like to do this is having `Subs` for each individual column name `cell`. Each of these `Subs` has an `Array` of Strings, which contain the keywords that will be searched. If the cells value is exactly one of the...
2019/10/01
[ "https://Stackoverflow.com/questions/58178675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12130762/" ]
I'm not exactly sure why you are having issues, but this is working just fine for me. Since you were having issues with `ParamArray`, I went ahead and incorporated that into the code for demonstration purposes. ``` Sub FindCr(cell As Range) If FindMatch(cell, "Cr", "Bag ", " Dog") Then MsgBox "There was a...
You cannot affect an array of string in this way : ``` textArr = Array("Cr", "Bag ", " Dog") ``` To use that form of affectation, textArr must be a variant. If you still want to use string, use redim and single affectation. For example : ``` dim textArr() as String ... Redim Preserve textArr(1) textArr(0) = "Cr" ....
64,531,838
I have this string where I need to extract only one word to put into a new columns. ``` HELLO WORLD TEST SHOES1 PROJECT ``` The required string is SHOES, but it has '1' beside it. How can I extract the SHOES only? Thank you
2020/10/26
[ "https://Stackoverflow.com/questions/64531838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14122835/" ]
``` $("#franchise").change(function() { //alert( $( "#franchise" ).val() ); var f = $( "#franchise" ).val(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $.ajax({ type: 'POST', url : 'ajax/series', data : ({franchi...
just move your below code in document ready function ``` $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); ``` add `{{ csrf_field() }}` in your common layout file make sure your js code is in the same file not external js then use below js code ``` $("#...
64,531,838
I have this string where I need to extract only one word to put into a new columns. ``` HELLO WORLD TEST SHOES1 PROJECT ``` The required string is SHOES, but it has '1' beside it. How can I extract the SHOES only? Thank you
2020/10/26
[ "https://Stackoverflow.com/questions/64531838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14122835/" ]
``` $("#franchise").change(function() { //alert( $( "#franchise" ).val() ); var f = $( "#franchise" ).val(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $.ajax({ type: 'POST', url : 'ajax/series', data : ({franchi...
Your controller and route code are perfectly fine but your javaScript code has a little problem here, in laravel there is no need to add an ajax header field for CSRF token you can add CSRF token as the body of ajax like you have added franchise and the code will work absolutely fine. I have written the code for you t...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
Why have an exchange rate? Just deal in the local currency on whichever end of the trip I am at, and carry my wealth in the form of goods that will sell well at my next stop. Freight carriers don't like to run with empty holds, it is a waste of resources to sit still longer than necessary to unload and reload, and an ...
During the barter phase, when you were trading a ship full of grain for some crates of microprocessors, you established the relative values of the commodities. Now that you have this information you can start trading with tokens, like the federal reserve notes. The parties will have to establish a clearing house for tr...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
Comparing commodities. Money, after all, is just an abstract representation of goods and services. The only reason any form of fiat currency has power is its ability to be swapped for either a good or a service. A way to get an idea at what the exchange rate would be is to just compare a common and frequently used comm...
**I think the short answer is: you're missing a step.** **The next step in that picture *isn't* a currency exchange. If you've got a trader who's currently taking barter in exchange for their goods, the next step is to *take the local currency instead.*** Instead of taking on 500 kilos of sodium chloride in payment, y...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
Comparing commodities. Money, after all, is just an abstract representation of goods and services. The only reason any form of fiat currency has power is its ability to be swapped for either a good or a service. A way to get an idea at what the exchange rate would be is to just compare a common and frequently used comm...
OK, let's think about it: * we have roughly market economies on both sides * we have not united planets with already non uniform jurisdiction => they must already have some rules governing [conflict of laws](https://en.wikipedia.org/wiki/Conflict_of_laws) or [law of the sea](https://en.wikipedia.org/wiki/Law_of_the_se...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
You just pass laws on each world allowing the purchase and sale of the other world’s currency, with some sensible regulation to make sure people can’t get ripped off. Then the markets will establish the exchange rate and arrange the physical transport of any currency that actually needs to be moved, just like between t...
I was thinking, if they are different life beings and have different life standards and materials use, what they have in common? Because one of the civilizations could valerate gold, whereas the others simply don't care. But what they have in common? Both have difficulties and cost to travel between their two planets....
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
As bitcoin history shows, currency exchanges will emerge very quickly as soon as the currency is considered to have some nonzero value, despite exchange rate fluctuations. The rates on all these exchanges tend to quickly converge, and are used as a basis even for other people who trade directly. Even after failures of ...
I was thinking, if they are different life beings and have different life standards and materials use, what they have in common? Because one of the civilizations could valerate gold, whereas the others simply don't care. But what they have in common? Both have difficulties and cost to travel between their two planets....
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
I was thinking, if they are different life beings and have different life standards and materials use, what they have in common? Because one of the civilizations could valerate gold, whereas the others simply don't care. But what they have in common? Both have difficulties and cost to travel between their two planets....
During the barter phase, when you were trading a ship full of grain for some crates of microprocessors, you established the relative values of the commodities. Now that you have this information you can start trading with tokens, like the federal reserve notes. The parties will have to establish a clearing house for tr...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
Why have an exchange rate? Just deal in the local currency on whichever end of the trip I am at, and carry my wealth in the form of goods that will sell well at my next stop. Freight carriers don't like to run with empty holds, it is a waste of resources to sit still longer than necessary to unload and reload, and an ...
Comparing commodities. Money, after all, is just an abstract representation of goods and services. The only reason any form of fiat currency has power is its ability to be swapped for either a good or a service. A way to get an idea at what the exchange rate would be is to just compare a common and frequently used comm...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
As bitcoin history shows, currency exchanges will emerge very quickly as soon as the currency is considered to have some nonzero value, despite exchange rate fluctuations. The rates on all these exchanges tend to quickly converge, and are used as a basis even for other people who trade directly. Even after failures of ...
During the barter phase, when you were trading a ship full of grain for some crates of microprocessors, you established the relative values of the commodities. Now that you have this information you can start trading with tokens, like the federal reserve notes. The parties will have to establish a clearing house for tr...
154,695
There are two worlds of more or less equivalent technological level, say a difference of only a few decades and no more than 50 years. A first contact event occurs and after the hoopla dies down trading starts. Initially, barter is the primary form of trade but this quickly becomes cumbersome. How would the two econ...
2019/09/07
[ "https://worldbuilding.stackexchange.com/questions/154695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/5101/" ]
You just pass laws on each world allowing the purchase and sale of the other world’s currency, with some sensible regulation to make sure people can’t get ripped off. Then the markets will establish the exchange rate and arrange the physical transport of any currency that actually needs to be moved, just like between t...
During the barter phase, when you were trading a ship full of grain for some crates of microprocessors, you established the relative values of the commodities. Now that you have this information you can start trading with tokens, like the federal reserve notes. The parties will have to establish a clearing house for tr...