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
39,871
I've started to teach myself how to play the piano, and one of the difficulties I've found is trying to get both hands to do things at once. I either forget one hand entirely, or have one hand trying to mimic the other. This reminded me of many years ago when I was taught to play the viola. For many weeks, we did not use the bow, instead focusing on getting the left hand to do the things it was supposed to, and learning to read music. In hindsight, this makes sense to me, as it's often important to get used to some fundamentals before attempting to do everything at once. So I was wondering, when learning the piano, is it better to learn each hand on their own, or muddle through the difficulties of synchronizing them from the beginning? Or, if there are arguments for both methods, what are the pros/cons of each? What problems may develop, or what difficulties might be avoided? Or is there perhaps a happy medium that has proven the most successful? For my personal musical background, I have about nine years' experience with the viola, though I haven't played it in about five years (stopped after high school). I also play the guitar, but never learned to read music for it.
2015/12/01
[ "https://music.stackexchange.com/questions/39871", "https://music.stackexchange.com", "https://music.stackexchange.com/users/24978/" ]
When I was taking piano lessons I learned each piece three times: Once with the right hand, once with the left hand, and the third time putting both together. After a while, the third "learning" came a lot more quickly, and after a few years I would start to slowly sight read both parts together. Today I will still practice the hard pieces one handed from time to time, especially when the timing is really disconnected between the two hands and I need at least one to go on automatic pilot. There are some pieces (*Leyenda* by Albeniz comes to mind) where the two parts are so intertwined it never makes sense to try to learn them alone. Usually that's clear from the beginning when it's the case.
I have never heard of one-handed practice actually being *harmful* for any piece of music, nor that it might teach you something you would later have to unlearn. Slow practice and one-handed practice have both been essential to me on the piano, (although separating the limbs doesn't seem to help me on drums, interestingly), and one thing that helps very much in combination with them is dividing a bar up into a larger number of sub-beats, to understand it. Imagine trying to tap out 2 beats per bar evenly on one hand, and 3 beats per bar evenly on your other hand. If you subdivide the bar into 6 then one hand takes beats 1 and 4 while the other takes beats 1, 3 and 5. Many rhythms can be understood more easily that way, and practiced more slowly, on pretty much any instrument. Large books full of short, graded exercises will not only strengthen your little fingers but prepare you for all sorts of confusingly counterpointed melodies.
39,871
I've started to teach myself how to play the piano, and one of the difficulties I've found is trying to get both hands to do things at once. I either forget one hand entirely, or have one hand trying to mimic the other. This reminded me of many years ago when I was taught to play the viola. For many weeks, we did not use the bow, instead focusing on getting the left hand to do the things it was supposed to, and learning to read music. In hindsight, this makes sense to me, as it's often important to get used to some fundamentals before attempting to do everything at once. So I was wondering, when learning the piano, is it better to learn each hand on their own, or muddle through the difficulties of synchronizing them from the beginning? Or, if there are arguments for both methods, what are the pros/cons of each? What problems may develop, or what difficulties might be avoided? Or is there perhaps a happy medium that has proven the most successful? For my personal musical background, I have about nine years' experience with the viola, though I haven't played it in about five years (stopped after high school). I also play the guitar, but never learned to read music for it.
2015/12/01
[ "https://music.stackexchange.com/questions/39871", "https://music.stackexchange.com", "https://music.stackexchange.com/users/24978/" ]
When I was taking piano lessons I learned each piece three times: Once with the right hand, once with the left hand, and the third time putting both together. After a while, the third "learning" came a lot more quickly, and after a few years I would start to slowly sight read both parts together. Today I will still practice the hard pieces one handed from time to time, especially when the timing is really disconnected between the two hands and I need at least one to go on automatic pilot. There are some pieces (*Leyenda* by Albeniz comes to mind) where the two parts are so intertwined it never makes sense to try to learn them alone. Usually that's clear from the beginning when it's the case.
I generally only practice certain passages one hand at a time, typically when I'm having trouble with something in one of the hands. The more general rule is to isolate technical difficulties and work on them, which sometimes means working only one hand. I especially do this when I'm working out what fingering to use on a passage. I also find that, as I'm right-handed, I have to put more time into the left hand. So, I often work with just the left hand. Chopin Nocturnes are a good example, because there are lots of leaps in the left hand that I tend to get sloppy with if I'm paying attention to the melody. I wouldn't recommend going over just one hand in a really long passage all at once, though. It's easy to lose your sense of the music, which can make the final result sound mechanical.
39,871
I've started to teach myself how to play the piano, and one of the difficulties I've found is trying to get both hands to do things at once. I either forget one hand entirely, or have one hand trying to mimic the other. This reminded me of many years ago when I was taught to play the viola. For many weeks, we did not use the bow, instead focusing on getting the left hand to do the things it was supposed to, and learning to read music. In hindsight, this makes sense to me, as it's often important to get used to some fundamentals before attempting to do everything at once. So I was wondering, when learning the piano, is it better to learn each hand on their own, or muddle through the difficulties of synchronizing them from the beginning? Or, if there are arguments for both methods, what are the pros/cons of each? What problems may develop, or what difficulties might be avoided? Or is there perhaps a happy medium that has proven the most successful? For my personal musical background, I have about nine years' experience with the viola, though I haven't played it in about five years (stopped after high school). I also play the guitar, but never learned to read music for it.
2015/12/01
[ "https://music.stackexchange.com/questions/39871", "https://music.stackexchange.com", "https://music.stackexchange.com/users/24978/" ]
The mantra in learning piano is: "start slowly." How slow is slow? So slow you are unable to make mistakes, and then a little slower than that. Invariably when I have to choose a speed at which I think I can't make a mistake, at first I think: "come on, this is ridiculous!, of course I can't make a mistake"... and then I make a mistake. As for the specific problem of hand coördination: In the very beginning it helped me to practice away from the piano at first with my hands on my knees. For every note in my left hand I slapped my hand on my left knee and vice versa. When I could do that, I played the right hand on the piano and simultaneously moved my left hand in the air (or slapped it on my knee). After that I switched roles. The next step was playing with both hands at the same time, slowly. After several weeks this kind of exercise wasn't needed anymore, but in the beginning I found it helpful to 'rewire my brain' so to speak. Concerning hands separate versus hands together: For any piece 'at your level' beginning with practising hands separate is needed. It's being used to tackle problems of reading, fingering, dynamics,..., before adding the extra complexity of having two hands to control. But what I experience is that playing hands together after having practiced hands separate can feel as starting completely over. What I mean is that passages that were comfortable hands separate, are feeling clumsy again when starting hands together. Sometimes it is like having to learn the piece all over again. So the need to start slowly (and even slower than that) is there again but now hands together. Because of that in my experience it is not efficient to practice towards 'perfection' hands separate before beginning hands together. Of course the process of practicing hands together is greatly shortened (or even possible), because of the knowledge you gained from the practice hands separate, and that's what I use it for: orientation, experimentation and planning. But really learning the piece only starts with hands together.
I cannot gauge your piano level very well, but if you are having difficulties playing both hands at the same time, then the piece is may be too difficult for your level. For piano players that are beyond the elementary level, I believe most players usually start learning the song both hands at the same time. This does help you get to learn the timing of the right and left hand right from the get go, instead of having to piece them together later on. Learning each separately and then piecing together later may actually be slower (depends on the piece) because of complex interweaving melodies, etc... However, the practice is often done separately as needed. My piano teacher used to say if you cannot play the one hand alone, you definitely cannot play it properly with two hands. When practicing one-handedly, it will often reveal mistakes that you don't really notice while playing with two hands. For elementary players, (at least from my experience), usually the learning process is just: * right handed songs; * primarily right handed songs with some added notes on the bass clef * more difficult songs with a more involved bass line for the left hand That's why as I said earlier, perhaps if you are having difficulties of left and right handed songs, then maybe you are playing songs with a bass line that is too difficult at the moment for you. One thing you can do to improve independent motor control with your hands is practice your left and right brain. The left brain controls the right hand and right brain for left hand. One exercise I was taught is to try rubbing your right hand on your thigh in a forward and backward motion (relative to a sitting position), and with your left hand do a upward and downward motion in a fist. Switch it up to have right hand as a fist, and left hand doing the rubbing. I know it sounds and looks retarded, but some people actually have difficulty because it involves independent directional motion.
39,871
I've started to teach myself how to play the piano, and one of the difficulties I've found is trying to get both hands to do things at once. I either forget one hand entirely, or have one hand trying to mimic the other. This reminded me of many years ago when I was taught to play the viola. For many weeks, we did not use the bow, instead focusing on getting the left hand to do the things it was supposed to, and learning to read music. In hindsight, this makes sense to me, as it's often important to get used to some fundamentals before attempting to do everything at once. So I was wondering, when learning the piano, is it better to learn each hand on their own, or muddle through the difficulties of synchronizing them from the beginning? Or, if there are arguments for both methods, what are the pros/cons of each? What problems may develop, or what difficulties might be avoided? Or is there perhaps a happy medium that has proven the most successful? For my personal musical background, I have about nine years' experience with the viola, though I haven't played it in about five years (stopped after high school). I also play the guitar, but never learned to read music for it.
2015/12/01
[ "https://music.stackexchange.com/questions/39871", "https://music.stackexchange.com", "https://music.stackexchange.com/users/24978/" ]
When I first started learning piano I also used to practice one hand at a time. I think it is important because then in the end it's all about coordination and if you want your hands to be well coordinated you first need each hand to know what it has to do. Putting it all together is then a completely different story, you'll have to focus on the coordination and not on the single hand anymore plus you'll have to read 2 staff at a time (which might be tricky for someone which is not used to that), but indeed the practice that you gained playing with separate hands will help. With experience and practice you'll do that more quickly and start putting it all together soon, however I still give a shot at each hand separately, I think it helps a lot. Of course with increasing difficulty of the piece you want to play you'll spend much more time practicing with two hands together. At times you'll have to focus on a small amount of bars when you'll have some difficult phrase (and then there are many ways which might help studying a single piece depending on the technique involved), which is also recommended when there are some particularly difficult parts in the piece (but I think this applies to the viola as well).
I have never heard of one-handed practice actually being *harmful* for any piece of music, nor that it might teach you something you would later have to unlearn. Slow practice and one-handed practice have both been essential to me on the piano, (although separating the limbs doesn't seem to help me on drums, interestingly), and one thing that helps very much in combination with them is dividing a bar up into a larger number of sub-beats, to understand it. Imagine trying to tap out 2 beats per bar evenly on one hand, and 3 beats per bar evenly on your other hand. If you subdivide the bar into 6 then one hand takes beats 1 and 4 while the other takes beats 1, 3 and 5. Many rhythms can be understood more easily that way, and practiced more slowly, on pretty much any instrument. Large books full of short, graded exercises will not only strengthen your little fingers but prepare you for all sorts of confusingly counterpointed melodies.
39,871
I've started to teach myself how to play the piano, and one of the difficulties I've found is trying to get both hands to do things at once. I either forget one hand entirely, or have one hand trying to mimic the other. This reminded me of many years ago when I was taught to play the viola. For many weeks, we did not use the bow, instead focusing on getting the left hand to do the things it was supposed to, and learning to read music. In hindsight, this makes sense to me, as it's often important to get used to some fundamentals before attempting to do everything at once. So I was wondering, when learning the piano, is it better to learn each hand on their own, or muddle through the difficulties of synchronizing them from the beginning? Or, if there are arguments for both methods, what are the pros/cons of each? What problems may develop, or what difficulties might be avoided? Or is there perhaps a happy medium that has proven the most successful? For my personal musical background, I have about nine years' experience with the viola, though I haven't played it in about five years (stopped after high school). I also play the guitar, but never learned to read music for it.
2015/12/01
[ "https://music.stackexchange.com/questions/39871", "https://music.stackexchange.com", "https://music.stackexchange.com/users/24978/" ]
It's very normal to have issues playing with both hands at first, but if you're finding yourself completely unable to do so at all, then maybe you're attempting to play music that's too hard for you. This is a common problem for people that have significant experience on one instrument and then start another. It feels embarrassing to go all the way back to basics and play stuff that you feel like is meant for 5-year-olds, but it really has to be done. You're gonna play some Mary Had A Little Lamb, with the melody in the right hand, and single whole notes in the left. There are some method books out there that have slightly more dignified music, if that helps. Some struggle is good (it's the only way to grow), but hitting a wall isn't productive.
Independence of both hands can be practiced by exercises of kinesiology e.g. cross-crawl. There are many helpful links: <https://www.holistic-reflexology.co.uk/cross-crawl.html> A good exercise will also be to tap with one hand on your head while drawing circles with the other hand on your breast. Every rhythm practice on your knees will also be beneficial. Start two hands Piano playing with prelude no. 1 by Bach.
73,149,174
I'm running both my Jenkins & GitLab server on two difference EC2 instances. Is there away that I can grant GitLab access an integration with my Jenkins over my Jenkins private ip address?
2022/07/28
[ "https://Stackoverflow.com/questions/73149174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14608702/" ]
The **problem** is that you've forward declared class `C` in global namespace instead of class scope `A`. This means that there are two different class named `C` one of which is declared to be in the global namespace `::C` and the second one as an inner class `A::C`. To **solve** this, just move the forward declaration of `class C` to inside class scope `A` as shown below: **header.h** ``` class A { public: class C;// forward declaration moved here inside class scope A class B { public: B(C* arg) { ptr = arg; } C* ptr; }; class C { public: }; }; ``` [Working demo](https://onlinegdb.com/FFS-LfKB-) --- Also, be careful about other logical bugs like memory leak(if any) in your program.
``` class A { public: class C; class B { public: B(C* arg) { ptr = arg; } C* ptr; }; class C { public: ... }; }; ```
11,095,776
I have an application that supports several different combinations of viewable items. each view can be toggled on and of by clicking on its corresponding tree node. The problem is that I do not want to store each individual node.checked boolean in a seperate boolean in my .settings file. So I am currently attempting to use a bit mask, however I do not know how to add that type to the selectable types of the settings file Editor. What should I do to make that a selectable type for saving?
2012/06/19
[ "https://Stackoverflow.com/questions/11095776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/613483/" ]
An enum type is an Int32 behind the scenes - in fact variables of enum types can be assigned any integer values, even if those values are not in the original enum. If you used an integer type in the setting, you could cast it to your defined enum type to use it. There is no checking that the integer value is defined by the enum. Be careful using a bitmask for this in a settings file though as it might get difficult to work out the value for the setting. If you wanted bits 1 and 3 set to true, for example, the value you would have to put in the settings file would be "5", since this is the integer that has the first and third bits set to 1. In code you can use the bitshift operator `<<` to make reading the value easier, or `Enum.HasFlag` (<http://msdn.microsoft.com/en-us/library/system.enum.hasflag.aspx>) in .NET 4 and above.
You can use just `Int32` type. Bitmasks are sets of nonzero bits in a integer number (4 bytes) or other specified integer type (e.g. `Int16`)
11,095,776
I have an application that supports several different combinations of viewable items. each view can be toggled on and of by clicking on its corresponding tree node. The problem is that I do not want to store each individual node.checked boolean in a seperate boolean in my .settings file. So I am currently attempting to use a bit mask, however I do not know how to add that type to the selectable types of the settings file Editor. What should I do to make that a selectable type for saving?
2012/06/19
[ "https://Stackoverflow.com/questions/11095776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/613483/" ]
An enum type is an Int32 behind the scenes - in fact variables of enum types can be assigned any integer values, even if those values are not in the original enum. If you used an integer type in the setting, you could cast it to your defined enum type to use it. There is no checking that the integer value is defined by the enum. Be careful using a bitmask for this in a settings file though as it might get difficult to work out the value for the setting. If you wanted bits 1 and 3 set to true, for example, the value you would have to put in the settings file would be "5", since this is the integer that has the first and third bits set to 1. In code you can use the bitshift operator `<<` to make reading the value easier, or `Enum.HasFlag` (<http://msdn.microsoft.com/en-us/library/system.enum.hasflag.aspx>) in .NET 4 and above.
If you want your custom type to be *settable* in the winforms settings you have to define a [TypeConverter](http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter%28v=vs.100%29.aspx) to convert from and back to string.
10,504,243
I've been using the following jquery plugin to set my font sizes based on the width of the container divs: <http://www.zachleat.com/web/bigtext-makes-text-big/> I have been able to get it working with different fonts when I define the fonts in the css as ``` .bigtext{ font-family:Arial } ``` see <http://jsfiddle.net/pF5bQ/3/> however, if I define the css with a parent class ``` .theme .bigtext{ font-family:Arial } ``` It sets the font too big. see <http://jsfiddle.net/pF5bQ/4/> The app I'm working on features various themes that use different fonts so I need to be able to define different styles for the bigtext based on the parent class. Any ideas?
2012/05/08
[ "https://Stackoverflow.com/questions/10504243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387285/" ]
Not a 'true' solution but the work around I ended up discovering was that if I applied my theme class to the same div as the big text, I'd get the desired result. ``` .theme.bigtext{ font-family:Arial } ``` It feels really hack-y because in the project I'm working on, I need to do the class switching and what not in javascript, but it gets the job done. <http://jsfiddle.net/pF5bQ/7/>
well you can try this hack I did lol <http://jsfiddle.net/pF5bQ/4/> ``` .bigtext{ font-family:arial } .theme .bigtext{ font-family:arial; color:red; } ``` edit: so if you put the .theme line inside of your theme css or whatever way you implement it, I think it will work as long as you have the original line lol This is all I can offer, I never used bigtext before
69,370,494
Title poorly describes the issue, sorry. I have div's ("cards") in my website that contain a lot of content. One of the important thing's I wanted was to have an image covering the "cards", however every time I've attempted to fit them properly, they either don't change from their current setup or they take on massive size relative to the page size and not the "card" size. I've read other threads regarding *similar* issues, but I haven't gotten anything to work yet. [Image not fitting into Card correctly](https://i.stack.imgur.com/6HgUk.png) ```css /* Entire div for card base + image inside it */ .card { display: flex; flex-flow: row no-wrap; justify-content: space-between; width: 275px; height: 150px; font-size: 25px; padding: 20px; background-color: #f1f1f1; border-radius: 30px; box-shadow: 0px 0px 18px #888888; transition: all 0.5s ease; } .card:hover { background-color: #daeaf5; } .card-image { display: flex; justify-content: center; align-items: center; overflow: hidden } .card-img:hover { -webkit-filter: grayscale(0%); filter: greyscale(0%); } .card-img { width: 100%; height: 100%; flex-shrink: 0; min-width: 100%; min-height: 100%; border-radius: 30px; -webkit-filter: grayscale(100%); filter: greyscale(100%); -webkit-mask-image:-webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0))); mask-image: linear-gradient(to left, rgba(0,0,0,1), rgba(0,0,0,0)); transition: all 0.5s ease; } /* ignore this stuff, it's just styling for the rest of the card */ .card-title { font-size: 10px; } .card-content { font-size: 18px; margin-bottom: 5px; white-space: nowrap; } .card-a { color: black; text-decoration: none; border-radius: 30px; margin: 15px; } .main { margin-left: 10px; } .flex-container { display: flex; flex-flow: row wrap; justify-content: flex-start; align-items: flex-start; align-content: flex-start; } ``` ```html /* Entire card div, yes I know my code looks like a goblin wrote it, I am a goblin. */ /*So far, this was the only way I have found to get it to work how I wanted to*/ <div class="main"> <ul type="none"> <div class="flex-container"> <a class="card-a" href="###"> <li> <div class="card"> <div class="left-side"> <div class="card-title">Make</div> <div class="card-content">Template</div> <div class="card-title">Model</div> <div class="card-content">Temp</div> <div class="card-title">Trim</div> <div class="card-content">Temp</div> <div class="card-title">Year</div> <div class="card-content">Temp</div> </div> <div class="right-side"> <img class="card-img" src="https://static.turbosquid.com/Preview/001308/648/FU/_D.jpg" alt="Temporary Picture provided by Turbosquid 1308648"/> </div> </div> </li> </a> </div> </ul> </div> ``` Ideally I want the image to fit snugly into the card, hence the corners on the image matching the corners on the card. I've tried to relocate the image into various places, re-sorting the div's and attempting to structure everything differently. Unfortunately, every time I've tried that, I get farther and farther away from the ideal card design. Yes I know, the code looks like chicken scratch compared to anyone else's work, please excuse my poor man's amount of experience.
2021/09/29
[ "https://Stackoverflow.com/questions/69370494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17030146/" ]
You can use a intermediate `orders` dataframe, created from `df` dataframe and that contains only information about orders, which are columns `customer_id`, `order_id` and `order_date`. Then you first inner join `df_address` dataframe with this `orders` dataframe, to link each couple `(customer_id, address_id)` to orders-specific information, and then left join the resulting dataframe with `df` dataframe to get `order_share` per address, then replace `null` value in `order_share` column with `0.0`. Here is the complete code: ```py from pyspark.sql import functions as F # Orders dataframe that contains only orders-specific information orders = df.select('customer_id', 'order_id', 'order_date').distinct() df_address.join(orders, ['customer_id']) \ # link addresses with orders .join(df.drop('order_date'), ['customer_id', 'address_id', 'order_id'], 'left_outer') \ # link orders/addresses with order shares .withColumn('order_share', F.when(F.col('order_share').isNotNull(), F.col('order_share')).otherwise(F.lit(0.0))) \ # replace null in order_share column with 0.0 .orderBy('customer_id', 'order_id', 'address_id') \ # optional, to reorder dataframe ``` ### Details *Note: I reordered all dataframes here by `order_id` and `address_id` for readability purpose* Starting from `df` dataframe in your question, we get the following `orders` dataframe: ``` +-----------+--------+----------+ |customer_id|order_id|order_date| +-----------+--------+----------+ |c1 |1 |2021-01-23| |c2 |2 |2021-03-20| |c1 |3 |2021-02-20| +-----------+--------+----------+ ``` Then we join this `orders` dataframe with the `df_address` dataframe: ``` +-----------+----------+------------+--------+----------+ |customer_id|address_id|created_date|order_id|order_date| +-----------+----------+------------+--------+----------+ |c1 |a1 |2020-12-31 |1 |2021-01-23| |c1 |a2 |2020-04-23 |1 |2021-01-23| |c1 |a3 |2020-03-23 |1 |2021-01-23| |c1 |a4 |2020-01-16 |1 |2021-01-23| |c2 |a5 |2020-12-28 |2 |2021-03-20| |c2 |a6 |2020-05-16 |2 |2021-03-20| |c2 |a7 |2020-03-04 |2 |2021-03-20| |c1 |a1 |2020-12-31 |3 |2021-02-20| |c1 |a2 |2020-04-23 |3 |2021-02-20| |c1 |a3 |2020-03-23 |3 |2021-02-20| |c1 |a4 |2020-01-16 |3 |2021-02-20| +-----------+----------+------------+--------+----------+ ``` And with a last join with `df` dataframe without column `order_date`, we get: ``` +-----------+----------+--------+------------+----------+-----------+ |customer_id|address_id|order_id|created_date|order_date|order_share| +-----------+----------+--------+------------+----------+-----------+ |c1 |a1 |1 |2020-12-31 |2021-01-23|0.5 | |c1 |a2 |1 |2020-04-23 |2021-01-23|0.2 | |c1 |a3 |1 |2020-03-23 |2021-01-23|0.3 | |c1 |a4 |1 |2020-01-16 |2021-01-23|null | |c2 |a5 |2 |2020-12-28 |2021-03-20|0.4 | |c2 |a6 |2 |2020-05-16 |2021-03-20|0.6 | |c2 |a7 |2 |2020-03-04 |2021-03-20|null | |c1 |a1 |3 |2020-12-31 |2021-02-20|0.3 | |c1 |a2 |3 |2020-04-23 |2021-02-20|0.3 | |c1 |a3 |3 |2020-03-23 |2021-02-20|0.4 | |c1 |a4 |3 |2020-01-16 |2021-02-20|null | +-----------+----------+--------+------------+----------+-----------+ ``` We then just have to replace `null` with `0.0` and we get our expected dataframe: ``` +-----------+----------+--------+------------+----------+-----------+ |customer_id|address_id|order_id|created_date|order_date|order_share| +-----------+----------+--------+------------+----------+-----------+ | c1| a1| 1| 2020-12-31|2021-01-23| 0.5| | c1| a2| 1| 2020-04-23|2021-01-23| 0.2| | c1| a3| 1| 2020-03-23|2021-01-23| 0.3| | c1| a4| 1| 2020-01-16|2021-01-23| 0.0| | c2| a5| 2| 2020-12-28|2021-03-20| 0.4| | c2| a6| 2| 2020-05-16|2021-03-20| 0.6| | c2| a7| 2| 2020-03-04|2021-03-20| 0.0| | c1| a1| 3| 2020-12-31|2021-02-20| 0.3| | c1| a2| 3| 2020-04-23|2021-02-20| 0.3| | c1| a3| 3| 2020-03-23|2021-02-20| 0.4| | c1| a4| 3| 2020-01-16|2021-02-20| 0.0| +-----------+----------+--------+------------+----------+-----------+ ```
I tried a `full outer` join with the `DataFrames` to get the missing `c_id` and `a_id` combination & further utilising **when** with **isNull** for `Null` column values coming from `df` and replacing when them values from `df_address` below are the results - ### Data Preparation ``` input_str1 = """ c1| a1| 1|2021-01-23| 0.5| c1| a2| 1|2021-01-23| 0.2| c1| a3| 1|2021-01-23| 0.3| c2| a5| 2|2021-03-20| 0.4| c2| a6| 2|2021-03-20| 0.6| c1| a1| 3|2021-02-20| 0.3| c1| a2| 3|2021-02-20| 0.3| c1| a3| 3|2021-02-20| 0.4 """.split("|") input_values1 = list(map(lambda x: x.strip() if x.strip() != '' else None, input_str1)) cols1 = list(map(lambda x: x.strip() if x.strip() != '' else None, "c_id|a_id|order_id|order_date|order_share".split("|"))) n = len(input_values1) n_col1 = 5 input_list1 = [tuple(input_values1[i:i+n_col1]) for i in range(0,n,n_col1)] sparkDF1 = sql.createDataFrame(input_list1, cols1) sparkDF1.show() +----+----+--------+----------+-----------+ |c_id|a_id|order_id|order_date|order_share| +----+----+--------+----------+-----------+ | c1| a1| 1|2021-01-23| 0.5| | c1| a2| 1|2021-01-23| 0.2| | c1| a3| 1|2021-01-23| 0.3| | c2| a5| 2|2021-03-20| 0.4| | c2| a6| 2|2021-03-20| 0.6| | c1| a1| 3|2021-02-20| 0.3| | c1| a2| 3|2021-02-20| 0.3| | c1| a3| 3|2021-02-20| 0.4| +----+----+--------+----------+-----------+ input_str2 = """ c1| a1| 2020-12-31| c1| a2| 2020-04-23| c1| a3| 2020-03-23| c1| a4| 2020-01-16| c2| a5| 2020-12-28| c2| a6| 2020-05-16| c2| a7| 2020-03-04 """.split("|") input_values2 = list(map(lambda x: x.strip() if x.strip() != '' else None, input_str2)) cols2 = list(map(lambda x: x.strip() if x.strip() != '' else None, "c_id|a_id|created_date".split("|"))) n = len(input_values2) n_col2 = 3 input_list2 = [tuple(input_values2[i:i+n_col2]) for i in range(0,n,n_col2)] sparkDF2 = sql.createDataFrame(input_list2, cols2) sparkDF2.show() +----+----+------------+ |c_id|a_id|created_date| +----+----+------------+ | c1| a1| 2020-12-31| | c1| a2| 2020-04-23| | c1| a3| 2020-03-23| | c1| a4| 2020-01-16| | c2| a5| 2020-12-28| | c2| a6| 2020-05-16| | c2| a7| 2020-03-04| +----+----+------------+ ``` ### Full Join Renaming Column values coming from SparkDF2 , which will be further used to populate null values to avoid ambiguous column names ``` finalDF = sparkDF1.join(sparkDF2 , (sparkDF1['c_id'] == sparkDF2['c_id']) & (sparkDF1['a_id'] == sparkDF2['a_id']) ,'full' ).select(sparkDF1['*'] ,sparkDF2['c_id'].alias('c_id_address') ,sparkDF2['a_id'].alias('a_id_address') ,sparkDF2['created_date'] ) finalDF.show() +----+----+--------+----------+-----------+------------+------------+------------+ |c_id|a_id|order_id|order_date|order_share|c_id_address|a_id_address|created_date| +----+----+--------+----------+-----------+------------+------------+------------+ | c1| a3| 1|2021-01-23| 0.3| c1| a3| 2020-03-23| | c1| a3| 3|2021-02-20| 0.4| c1| a3| 2020-03-23| | c2| a5| 2|2021-03-20| 0.4| c2| a5| 2020-12-28| |null|null| null| null| null| c2| a7| 2020-03-04| | c1| a2| 1|2021-01-23| 0.2| c1| a2| 2020-04-23| | c1| a2| 3|2021-02-20| 0.3| c1| a2| 2020-04-23| | c1| a1| 1|2021-01-23| 0.5| c1| a1| 2020-12-31| | c1| a1| 3|2021-02-20| 0.3| c1| a1| 2020-12-31| |null|null| null| null| null| c1| a4| 2020-01-16| | c2| a6| 2|2021-03-20| 0.6| c2| a6| 2020-05-16| +----+----+--------+----------+-----------+------------+------------+------------+ ``` ### When isNull ``` finalDF = finalDF.withColumn('c_id',F.when(F.col('c_id').isNull() ,F.col('c_id_address')).otherwise(F.col('c_id')) )\ .withColumn('a_id',F.when(F.col('a_id').isNull() ,F.col('a_id_address')).otherwise(F.col('a_id')) )\ .withColumn('order_share',F.when(F.col('order_share').isNull() ,0.0).otherwise(F.col('order_share')) ) finalDF.show() +----+----+--------+----------+-----------+------------+------------+------------+ |c_id|a_id|order_id|order_date|order_share|c_id_address|a_id_address|created_date| +----+----+--------+----------+-----------+------------+------------+------------+ | c1| a3| 1|2021-01-23| 0.3| c1| a3| 2020-03-23| | c1| a3| 3|2021-02-20| 0.4| c1| a3| 2020-03-23| | c2| a5| 2|2021-03-20| 0.4| c2| a5| 2020-12-28| | c2| a7| null| null| 0.0| c2| a7| 2020-03-04| | c1| a2| 1|2021-01-23| 0.2| c1| a2| 2020-04-23| | c1| a2| 3|2021-02-20| 0.3| c1| a2| 2020-04-23| | c1| a1| 1|2021-01-23| 0.5| c1| a1| 2020-12-31| | c1| a1| 3|2021-02-20| 0.3| c1| a1| 2020-12-31| | c1| a4| null| null| 0.0| c1| a4| 2020-01-16| | c2| a6| 2|2021-03-20| 0.6| c2| a6| 2020-05-16| +----+----+--------+----------+-----------+------------+------------+------------+ ``` **Note - `order_id` and `order_date` are null as there is not value present in for the `c_id` and `a_id` combination in `sparkDF2`** This example is provide a approach , towards getting your required solution , you can further improvise if required to populate the order missing values
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
Let's think about this: **Either the company was shockingly incompetent in hiring you or intentionally misleading**. Despite having accountants, solicitors, and an HR department, they apparently did not figure out the cost of employing you before offering you a written contract? That is quite a mistake to make, but I suppose it is possible. A more worrying possibility is that this was a bait-and-switch, and they never intended to hire you on the basis of the original contract. Ultimately, you can't know which of these is true, but it doesn't reflect well on the company either way. **Their response after making a mistake has been combative.** I would expect a mistake of this magnitude to be followed by a much more conciliatory response. Some of the problems I see: * **They refused to just take the financial hit and hire you anyway.** A company that values its employees should just bear this cost, as it was their mistake, rather than trying to back out of a signed contract--unless they legitimately can't afford to pay. But being unable to afford one extra year of your salary is hard to believe: they seem like a pretty good sized organization, based on your description of the situation, and surely your salary is not *that* big! * **They are tone-deaf to your situation.** Insisting they are being "generous", after they just messed up in a way that will clearly cost you big time, is quite worrying. They ought to be apologetic, but instead they are trying claim your unhappiness with their huge mistake is your problem! * **They are nickel-and-diming you** by not being flexible at all on covering your extra expenses. * **They have no problem turning up the pressure in contract negotiations**, treating you as an adversary rather than a new team member that they value. Adding a new clause about suing you seems like a pressure tactic. The refusal to add any protections is worrying. All in all, this adds up to a situation in which **I would be worried about my future working for this company, no matter how these negotiations turn out.** Therefore I would take a less "friendly" approach to the negotiations. Two options I see: **Fight for the original contract, contacting a solicitor to assess your options.** I'm not qualified to give legal advice. But it seems quite possible that what they are doing is not legal. * They may be failing to honor the contract (even if there is a probationary period where they can swiftly terminate you, they appear to have been acting in bad faith). I don't know the right technical terms for this, but I would be surprised if there was no basis for challenging this in UK employment law. * They also appear to be pushing [to classify you (wrongly) as self-employed](https://www.gov.uk/employment-status/selfemployed-contractor). This is not just something that can be designated arbitrarily. You have to actually *function as self-employed* to be classified this way. It's possible that raising the illegality of their actions might convince them to retreat and offer the original contract. Or, in the event that things can't be worked out, you may be able to take them to court and collect damages (whether the size of the damages would be worth the hassle is not something I can answer). Another option is to **go the self-employed route, but insist on being *really* self-employed**. State that if you are going to be self-employed, you want to send them a quote for the agreed work, with a price that you set, and that they can negotiate from that as a starting point. Also, if you are self employed you need freedom to do the work when and where you please, and take other clients. You can point out that UK tax law requires this sort of thing--these aren't unreasonable demands you are making. This will give you more freedom to seek other opportunities. It will also give you more control of the situation, making it harder for them to further take advantage of you in the future. **Both of these options carry some risk.** If you really feel you can't walk away from this job, it limits your negotiating options, but the second one is less risky, and you can do that one more mildly if you choose (the first option is pretty much all-or-nothing).
I am not a lawyer. **You need a lawyer.** The legalities in the UK of unilaterally changing a contract of employment are complex. The UK is not the US, and employment is not generally "at-will". Changing a contract you have agreed to on day one, with no notice at all, is certainly bad practice and [probably illegal in the UK](https://www.gov.uk/your-employment-contract-how-it-can-be-changed). "We didn't expect the expenses we're incurring" is surely [not a valid reason to change a contract on day 1](https://www.gov.uk/dismissal/reasons-you-can-be-dismissed) and the courts will almost certainly take a dim view of it because due diligence should have been undertaken in drawing up the contract. Unexpected expenses *may* be a valid reason to give you your contractual notice of dismissal, if there is one (the statutory notice period only [kicks in after a month](https://www.gov.uk/redundant-your-rights/notice-periods)). You could attempt to enforce the contract you originally signed. You could accept the new contract. You could accept their abrogation of the original contract, not accept their new contract, and walk away, possibly to rejoin your previous employer. You **must** get the advice of an employment lawyer.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
> > they added a new clause where the company might sue me to hell and back if they find it appropriate > > > That's a contract that I might be disinclined to sign. For example as an employee I wouldn't expect to be *sued* if someone finds a fault in software that I've written (because I expect them to test it too, etc.) ... but as an contractor (perhaps a.k.a. "independent supplier") I'm not so sure. What if they were sued by *their* client, and they tried to deflect the liability onto me? They may allow you to tweak the wording of the contract slightly (before you sign it, assuming your request is reasonable and they want to employ you). For example I once altered a contract so that it said I could expect to be sued in the case of "gross negligence", instead of just "negligence" (I decided there's a difference between negligence and gross negligence and the latter would be more difficult to prove). If you are going to be self-employed, here's quite an interesting video I watched recently on the subject of legalities -- [Mike Monteiro: F\*ck You, Pay Me](https://www.youtube.com/watch?v=jVkLVRt6c1U)
At first sight it looks like there is a good legal case against the USA Company. However UK employment law gives very little protection to someone until they have been in a job for some time. Assuming the notice period on the employment offer was 1 month, the most you are likely to win from the company in a legal case is 1 month’s wages. (But you may get them to pay you 3 months wages, if they don’t wish their name to be all over the papers.) **But trying to force a company outside of the UK to pay up, even when ordered by a UK court is expensive and likely to fail.** Don’t sign a consultant contract with them in your personal name without getting very good legal advice! Tell them you will need to consult with a UK lawyer on your return to the UK before you agree to anything. Get them to pay ALL your expensive for the trip the USA cleared in your bank account, before rejecting any offer they make! If you create a limited company in the UK, and only sign any contracts in the company name you can protect yourself from most risks of them suing you. **To cover the costs of running the company etc, expect to get “paid” double what you would in a “job”.** Personally I would get as much compensation out of them as possible due to them misleading you about the job and you leaving your past job, then find some other work. **Life is too short to a setup as complex as what they are trying to get you into.**
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
As you've already pushed back on the T&Cs for the consultant role, it sounds like what you've got is pretty much their final offer, so it's now up to you to decide what you want to do. You've got three options: * Take the consultant role, with the intention of staying in the role long-term. * Take the consultant role, but start looking for a new role ASAP. * Reject the consultant role. Any of these can be handled in a professional manner: the first is easy, the last is simply "Sorry, I'm looking for a role as a permanent employee". The second is perhaps the trickiest, but so long as you do your job as well as you can for the period you're working for your employer, it's going to be "just one of those things". Your potential employer has screwed this one up *massively*, so you shouldn't be expected to go out of your way to deal with their HR mess, and you've got to earn money in the meantime.
* I would find it hard to work for that company after these events. So forcing yourself into it should probably not be what you want. * The issue is pretty clear; they stepped out of the contract on day 1. What does your contract say about how that works? Does it have a clause where they have to keep you on for at least XXX amount of time? * Signed contracts cannot simple be "changed" by one party. Get a lawyer, get at least your costs back from them (that means the missed income during the time you are without job, etc.), and make perfectly clear that you will not be their victim. Depending on whether U.S. or U.K. law applies (both of which I'm not terribly familiar with) you might have more or less leverage.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
Let's think about this: **Either the company was shockingly incompetent in hiring you or intentionally misleading**. Despite having accountants, solicitors, and an HR department, they apparently did not figure out the cost of employing you before offering you a written contract? That is quite a mistake to make, but I suppose it is possible. A more worrying possibility is that this was a bait-and-switch, and they never intended to hire you on the basis of the original contract. Ultimately, you can't know which of these is true, but it doesn't reflect well on the company either way. **Their response after making a mistake has been combative.** I would expect a mistake of this magnitude to be followed by a much more conciliatory response. Some of the problems I see: * **They refused to just take the financial hit and hire you anyway.** A company that values its employees should just bear this cost, as it was their mistake, rather than trying to back out of a signed contract--unless they legitimately can't afford to pay. But being unable to afford one extra year of your salary is hard to believe: they seem like a pretty good sized organization, based on your description of the situation, and surely your salary is not *that* big! * **They are tone-deaf to your situation.** Insisting they are being "generous", after they just messed up in a way that will clearly cost you big time, is quite worrying. They ought to be apologetic, but instead they are trying claim your unhappiness with their huge mistake is your problem! * **They are nickel-and-diming you** by not being flexible at all on covering your extra expenses. * **They have no problem turning up the pressure in contract negotiations**, treating you as an adversary rather than a new team member that they value. Adding a new clause about suing you seems like a pressure tactic. The refusal to add any protections is worrying. All in all, this adds up to a situation in which **I would be worried about my future working for this company, no matter how these negotiations turn out.** Therefore I would take a less "friendly" approach to the negotiations. Two options I see: **Fight for the original contract, contacting a solicitor to assess your options.** I'm not qualified to give legal advice. But it seems quite possible that what they are doing is not legal. * They may be failing to honor the contract (even if there is a probationary period where they can swiftly terminate you, they appear to have been acting in bad faith). I don't know the right technical terms for this, but I would be surprised if there was no basis for challenging this in UK employment law. * They also appear to be pushing [to classify you (wrongly) as self-employed](https://www.gov.uk/employment-status/selfemployed-contractor). This is not just something that can be designated arbitrarily. You have to actually *function as self-employed* to be classified this way. It's possible that raising the illegality of their actions might convince them to retreat and offer the original contract. Or, in the event that things can't be worked out, you may be able to take them to court and collect damages (whether the size of the damages would be worth the hassle is not something I can answer). Another option is to **go the self-employed route, but insist on being *really* self-employed**. State that if you are going to be self-employed, you want to send them a quote for the agreed work, with a price that you set, and that they can negotiate from that as a starting point. Also, if you are self employed you need freedom to do the work when and where you please, and take other clients. You can point out that UK tax law requires this sort of thing--these aren't unreasonable demands you are making. This will give you more freedom to seek other opportunities. It will also give you more control of the situation, making it harder for them to further take advantage of you in the future. **Both of these options carry some risk.** If you really feel you can't walk away from this job, it limits your negotiating options, but the second one is less risky, and you can do that one more mildly if you choose (the first option is pretty much all-or-nothing).
You can start your one-man limited liability company in the UK and use it to maximise your income by being tax-efficient. Instead of a monthly salary, you would agree on a daily rate. I'd say that £100 gross daily rate (that is you pay all your cost, taxes, etc out of that rate) is equivalent to about £15,000 annual pre-tax income (your official income where the employee withholds tax and employee's national insurance). Any threats of suing you are void, as long as you make sure any contract is between them and your limited liability company, and that there is no money in the company by paying out everything as dividends. Which is not optimal for tax purposes, but what can you do. BTW. No need to handle this professionally. You need to handle this in the way that is most beneficial to you.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
As you've already pushed back on the T&Cs for the consultant role, it sounds like what you've got is pretty much their final offer, so it's now up to you to decide what you want to do. You've got three options: * Take the consultant role, with the intention of staying in the role long-term. * Take the consultant role, but start looking for a new role ASAP. * Reject the consultant role. Any of these can be handled in a professional manner: the first is easy, the last is simply "Sorry, I'm looking for a role as a permanent employee". The second is perhaps the trickiest, but so long as you do your job as well as you can for the period you're working for your employer, it's going to be "just one of those things". Your potential employer has screwed this one up *massively*, so you shouldn't be expected to go out of your way to deal with their HR mess, and you've got to earn money in the meantime.
Have they increased the monetary value of their offer now they are asking you to be a contractor? Being self employed means that you lose the benefits of having an employer: you will need to pay your own employer's national insurance and you won't get holiday or sick pay, etc. etc. As a rule of thumb, as a contractor you should be looking for roughly double the salary that you would receive as a full time employee.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
I am not a lawyer. **You need a lawyer.** The legalities in the UK of unilaterally changing a contract of employment are complex. The UK is not the US, and employment is not generally "at-will". Changing a contract you have agreed to on day one, with no notice at all, is certainly bad practice and [probably illegal in the UK](https://www.gov.uk/your-employment-contract-how-it-can-be-changed). "We didn't expect the expenses we're incurring" is surely [not a valid reason to change a contract on day 1](https://www.gov.uk/dismissal/reasons-you-can-be-dismissed) and the courts will almost certainly take a dim view of it because due diligence should have been undertaken in drawing up the contract. Unexpected expenses *may* be a valid reason to give you your contractual notice of dismissal, if there is one (the statutory notice period only [kicks in after a month](https://www.gov.uk/redundant-your-rights/notice-periods)). You could attempt to enforce the contract you originally signed. You could accept the new contract. You could accept their abrogation of the original contract, not accept their new contract, and walk away, possibly to rejoin your previous employer. You **must** get the advice of an employment lawyer.
So yes, they've broken your original contract and they're trying to make things even worse by strong-arming you into a situation that adds a ton of uncertainty. The natural answer here is **sue them for lost earnings, emotional damage, etc and go back to your last employer**. But there are a couple of separate issues: * Getting money out of them will be hard. We're talking a tribunal here and then chasing them across the planet to get that enforced in their jurisdiction. This isn't easy or cheap. * Your old employer is under no obligation to talk to you ever again. If your leaving hurt them or there's any animosity, you can expect a demotion and a pay cut. So by all means talk to your old employer and ask for a firm, *written* offer of employment and a lawyer **because you have been wronged**, just don't expect these to put everything right. --- Just as a quick sidebar, there *are* significant issues when hiring somebody full time in the UK. I say that speaking as somebody who works exclusively as a self-employed contractor for small companies here. They avoid a lot of taxes and paperwork by keeping me out of their PAYE schedule. A foreign company with no other presence here has a ton of stuff to set up. They've probably done the sums, looked at what the worst-case outcome of being sued for lost earnings from breach of contract and have worked out that it would be cheaper to take that risk and push you toward a cheaper way of working. They've been both stupid and nasty in a small amount of time, but given the climate of zero-hours contracts, unpaid internships, etc... They're neither the nastiest or the most unfair employer in history. There might be something to salvage here. And if you can forgive past sins/idiocy (or your old employer won't touch you) you can make this a lot more favourable by doing one simple thing: Get paid up front (demand an advance) ------------------------------------- Contracts clearly mean zip for them but you can have them insure themselves against this sort of nonsense and demand as much certainty as you need **in advance**. If halfway through your "contract" they say they don't need you any more, that's A-Okay. You've already been paid. So as a little not-too-silly, not-too-risky example, you could ask them to structure your payments as so: ``` Day 0 12 months salary Months 1-9 Zero. Nada. Months 10+ Normal monthly salary ``` If they stop paying you at any point, they breach, contract over, and you at least 3 months severance. I'm front-loading that by 12 months above because that's when companies are their most fickle. If you need more certainty than that, ask but expect them to nibble this back. If they start getting stupid again, you can wave your offer of work back at them, the breached contract and tell them that if they try to pursue you, you have considerable UK and EU law on your side. --- If buying a house is the most important thing, being employed is the most important thing here. Spend too long away from it and you'll either count as self-employed or between jobs (which can be a 6-month penalty with some lenders). Brokers can help explain your contract to banks' underwriters but you might have to put your plans on ice for a year or two. It seems *likely* you might incur a loss of some description here, so if you do, please seek the opinion of a solicitor. I'm not a lawyer and your chances of pursuing crappy contracts internationally might be much better/cheaper than I'm saying.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
Tell them that **this is not what you signed up for**. They have gone back on your agreement and violated your contract, before you've even started work. Say **you regretfully must decline to work with them**. And when they come back at you with nonsense about how you've signed a contract, remind them what that contract says. No court is going to side with them defending a contract that you're walking away from *because they have completely broken it already*. Any further discussion takes place through your lawyer, *only*. In the meantime, **call up your old supervisor, tell him it didn't work out, and ask whether there is room for you to return**. It hasn't been very long, so that may very well be possible. It might sound strange but **there's really no shame** in simply returning to your job. I work with three people who have gone off and varyingly worked for other companies for a bit (later realising their mistake) since they first became my colleagues.
At first sight it looks like there is a good legal case against the USA Company. However UK employment law gives very little protection to someone until they have been in a job for some time. Assuming the notice period on the employment offer was 1 month, the most you are likely to win from the company in a legal case is 1 month’s wages. (But you may get them to pay you 3 months wages, if they don’t wish their name to be all over the papers.) **But trying to force a company outside of the UK to pay up, even when ordered by a UK court is expensive and likely to fail.** Don’t sign a consultant contract with them in your personal name without getting very good legal advice! Tell them you will need to consult with a UK lawyer on your return to the UK before you agree to anything. Get them to pay ALL your expensive for the trip the USA cleared in your bank account, before rejecting any offer they make! If you create a limited company in the UK, and only sign any contracts in the company name you can protect yourself from most risks of them suing you. **To cover the costs of running the company etc, expect to get “paid” double what you would in a “job”.** Personally I would get as much compensation out of them as possible due to them misleading you about the job and you leaving your past job, then find some other work. **Life is too short to a setup as complex as what they are trying to get you into.**
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
Tell them that **this is not what you signed up for**. They have gone back on your agreement and violated your contract, before you've even started work. Say **you regretfully must decline to work with them**. And when they come back at you with nonsense about how you've signed a contract, remind them what that contract says. No court is going to side with them defending a contract that you're walking away from *because they have completely broken it already*. Any further discussion takes place through your lawyer, *only*. In the meantime, **call up your old supervisor, tell him it didn't work out, and ask whether there is room for you to return**. It hasn't been very long, so that may very well be possible. It might sound strange but **there's really no shame** in simply returning to your job. I work with three people who have gone off and varyingly worked for other companies for a bit (later realising their mistake) since they first became my colleagues.
Have they increased the monetary value of their offer now they are asking you to be a contractor? Being self employed means that you lose the benefits of having an employer: you will need to pay your own employer's national insurance and you won't get holiday or sick pay, etc. etc. As a rule of thumb, as a contractor you should be looking for roughly double the salary that you would receive as a full time employee.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
You can start your one-man limited liability company in the UK and use it to maximise your income by being tax-efficient. Instead of a monthly salary, you would agree on a daily rate. I'd say that £100 gross daily rate (that is you pay all your cost, taxes, etc out of that rate) is equivalent to about £15,000 annual pre-tax income (your official income where the employee withholds tax and employee's national insurance). Any threats of suing you are void, as long as you make sure any contract is between them and your limited liability company, and that there is no money in the company by paying out everything as dividends. Which is not optimal for tax purposes, but what can you do. BTW. No need to handle this professionally. You need to handle this in the way that is most beneficial to you.
Have they increased the monetary value of their offer now they are asking you to be a contractor? Being self employed means that you lose the benefits of having an employer: you will need to pay your own employer's national insurance and you won't get holiday or sick pay, etc. etc. As a rule of thumb, as a contractor you should be looking for roughly double the salary that you would receive as a full time employee.
66,520
I was offered a job by a US software company. On my first day at work they told me they couldn't actually hire me for legal and technical reasons. So, now they want me to be a consultant and to become self-employed. I had plans to buy a house in UK soon, and now I won't be able to do it unless I provide at least 24 months of invoices as self-employed. Nobody is taking responsibility, they are blaming their 'solicitors'. Therefore, my question is: how can I handle this situation (sudden request to change contract) in a professional way?
2016/05/05
[ "https://workplace.stackexchange.com/questions/66520", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/49496/" ]
> > they added a new clause where the company might sue me to hell and back if they find it appropriate > > > That's a contract that I might be disinclined to sign. For example as an employee I wouldn't expect to be *sued* if someone finds a fault in software that I've written (because I expect them to test it too, etc.) ... but as an contractor (perhaps a.k.a. "independent supplier") I'm not so sure. What if they were sued by *their* client, and they tried to deflect the liability onto me? They may allow you to tweak the wording of the contract slightly (before you sign it, assuming your request is reasonable and they want to employ you). For example I once altered a contract so that it said I could expect to be sued in the case of "gross negligence", instead of just "negligence" (I decided there's a difference between negligence and gross negligence and the latter would be more difficult to prove). If you are going to be self-employed, here's quite an interesting video I watched recently on the subject of legalities -- [Mike Monteiro: F\*ck You, Pay Me](https://www.youtube.com/watch?v=jVkLVRt6c1U)
The contract appears to be a bait-and-switch, in that they tempted you away from your previous employment with a very generous sum, only to rescind said contract after you accepted, which I believe violates good faith in terms of legality, and certainly illegal. Now they have you in an unfavourable situation, they will attempt to whittle down and remove the benefits and hope the pressure of needing a job forces you to accept the now unfair and dubious terms. The fact they continue to, like a classic Nigerian scam email, offer you generous sums whilst whittling down your rights (being self-employed means they can terminate you at any time, and the lawsuit clause means they can sue you like a third party: basically, they intend to get you to work for them, then sue back the 'generous' money they give you) is highly suspicious and a red flag for underhanded approaches. This is a malicious company, and I would actually go so far as to recommend detailing your experiences online publicly and outing the company so other people do not fall for this trap. Such underhanded practices should not be tolerated nor disguised.
27,577,477
I am Developing a code using php . In which I am importing two files (header.php and footer.php) in another php file index.php. Now I want that header.php and footer.php should be fixed while scrolling horizontally. can you suggest me the code. I am using the following code ``` Header.php code here footer.php code here ``` index.php ``` <?php include("header.php"); ?> welcome to index file welcome to index file welcome to index file <?php include("footer.php"); ?> ``` In this file index.php, I want that header and footer should be fixed while scrolling horizontally and others css should also not be disturbed.
2014/12/20
[ "https://Stackoverflow.com/questions/27577477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1960524/" ]
Try this ``` <?php $dir = 'apps/'; $result = array(); if (is_dir($dir)) { $iterator = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { if (!$file->isFile()) { $path = $file->getPath(); if(in_array($path, $result)) { continue ; } $result = $path."<br>"; echo $result; } } } ?> ```
You can use hash array for checking if path already in list ``` <?php $dir = 'apps/'; $result = array(); $hash=array(); if (is_dir($dir)) { $iterator = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { if (!$file->isFile()) { $path = $file->getPath(); if(isset($hash[$path])) { continue ; } $hash[$path]=1; $result[] = $path; echo $path."<br>"; } } } ?> ```
27,577,477
I am Developing a code using php . In which I am importing two files (header.php and footer.php) in another php file index.php. Now I want that header.php and footer.php should be fixed while scrolling horizontally. can you suggest me the code. I am using the following code ``` Header.php code here footer.php code here ``` index.php ``` <?php include("header.php"); ?> welcome to index file welcome to index file welcome to index file <?php include("footer.php"); ?> ``` In this file index.php, I want that header and footer should be fixed while scrolling horizontally and others css should also not be disturbed.
2014/12/20
[ "https://Stackoverflow.com/questions/27577477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1960524/" ]
Try this ``` <?php $dir = 'apps/'; $result = array(); if (is_dir($dir)) { $iterator = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { if (!$file->isFile()) { $path = $file->getPath(); if(in_array($path, $result)) { continue ; } $result = $path."<br>"; echo $result; } } } ?> ```
use `array_unique()` ``` <?php $dir = 'apps/'; $result = array(); if(is_dir($dir)){ $iterator = new RecursiveDirectoryIterator($dir); foreach(new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file){ if(!$file->isFile()){ $result[] = $file->getPath(); } } $uniqueResult = array_unique($result); if(!empty($uniqueResult)){ foreach($uniqueResult as $v){ // don't use 'for' use 'foreach' here. echo $v.'<br>'; } } } ```
38,366,233
This is my MySQL query. How can I run this query in Oracle? Right now it's not working. ``` SELECT * FROM mytable WHERE id IN (1,2,3,4) ORDER BY FIELD(id,3,2,1,4); ```
2016/07/14
[ "https://Stackoverflow.com/questions/38366233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900658/" ]
Here is a stupid solution: (:-D) ``` SELECT * FROM mytable WHERE id IN (1,2,3,4) ORDER BY CASE id WHEN 3 THEN 1 WHEN 2 THEN 2 WHEN 1 THEN 3 WHEN 4 THEN 4 END; ``` Or use `DECODE` function: ``` SELECT * FROM mytable WHERE id IN (1,2,3,4) ORDER BY DECODE(id, 3, 1, 2, 2, 1, 3, 4, 4, 0) ```
Oracle does not have a `FIELD` function but you can create your own instead ``` create TYPE T_VAR IS TABLE OF varchar2(4000); / create or replace function FIELD(p_val varchar2, p_var t_var) return number is begin for i in 1..p_var.count loop if p_val = p_var(i) then return i; end if; end loop; return p_var.count + 1; end FIELD; / ``` Query ``` SELECT t.* FROM mytable t WHERE id IN (1, 2, 3, 4) order by FIELD(id,T_VAR(3,2,1,4)) ``` **NOTE**: You should create one more function `FIELD` with this signature `FIELD (p_val number, p_var t_var)` for explicit data type conversation. Function before is universal but can be cause of some bizarre effects.
7,116,291
I am a new to C#, I need a small help on how can I pass multiple parameters between the classes? Below is a small example but my parameters will more than the 10. Is there another way to this? ``` public StreamStructure(String name, string id, string classname, int number) { this.name = name; this.id = id; this.classname = classname; this.number = number; } ``` List ------ ``` List<abc> don = new List<abc>(); foreach (XmlElement abc_cdb in abc_cdbs) { abc.Name = abc_cdb.GetAttribute("NAME"); abc.Id = abc_cdb.GetAttribute("id"); abc.Clssname = abc_cdb.GetAttribute("classname"); abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number")); don.Add(abc); } ``` I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?
2011/08/19
[ "https://Stackoverflow.com/questions/7116291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834597/" ]
Sure, use DTO's (data transfer objects). That is, create a class that has all the fields you want to send and use an instance of it as a parameter. Added bonus is that your method signature won't change even if you change your DTO class.
You could pass a domain object that represents the item you are manipulating. ``` public class Widget { public string Name {get;set;} public int Id {get;set;} public string ClassName {get;set;} public int Number {get;set;} } var myWidget = new Widget(); myWidget.Name = "Blue Widget"; //etc StreamStructure(myWidget); ```
7,116,291
I am a new to C#, I need a small help on how can I pass multiple parameters between the classes? Below is a small example but my parameters will more than the 10. Is there another way to this? ``` public StreamStructure(String name, string id, string classname, int number) { this.name = name; this.id = id; this.classname = classname; this.number = number; } ``` List ------ ``` List<abc> don = new List<abc>(); foreach (XmlElement abc_cdb in abc_cdbs) { abc.Name = abc_cdb.GetAttribute("NAME"); abc.Id = abc_cdb.GetAttribute("id"); abc.Clssname = abc_cdb.GetAttribute("classname"); abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number")); don.Add(abc); } ``` I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?
2011/08/19
[ "https://Stackoverflow.com/questions/7116291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834597/" ]
You are probably better off using [C# Initializers](http://msdn.microsoft.com/en-us/library/bb384062.aspx) or a [Data Transfer Object](http://msdn.microsoft.com/en-us/library/ff649585.aspx) than a large number of constructor parameters. Or combine the two. ``` public class MyDTO { String Name { get; set; } String Id { get; set; } String ClassName { get; set; } int Number { get; set; } } var MyDTO = new MyDTO() { Name = Name, Id = Id, ClassName = ClassName, Number = Number } var stream = new StreamStructure(MyDTO) ``` To create a list of these objects as in your example, create a new DTO within the loop body. ``` var don = new List<MyDTO>(); foreach (XmlElement abc_cdb in abc_cdbs) { var abc = new MyDTO() { Name = abc_cdb.GetAttribute("NAME"); Id = abc_cdb.GetAttribute("id"); ClassName = abc_cdb.GetAttribute("classname"); Number = Convert.ToInt32(abc_cdb.GetAttribute("number")); }; don.Add( abc ); } ```
You could pass a domain object that represents the item you are manipulating. ``` public class Widget { public string Name {get;set;} public int Id {get;set;} public string ClassName {get;set;} public int Number {get;set;} } var myWidget = new Widget(); myWidget.Name = "Blue Widget"; //etc StreamStructure(myWidget); ```
7,116,291
I am a new to C#, I need a small help on how can I pass multiple parameters between the classes? Below is a small example but my parameters will more than the 10. Is there another way to this? ``` public StreamStructure(String name, string id, string classname, int number) { this.name = name; this.id = id; this.classname = classname; this.number = number; } ``` List ------ ``` List<abc> don = new List<abc>(); foreach (XmlElement abc_cdb in abc_cdbs) { abc.Name = abc_cdb.GetAttribute("NAME"); abc.Id = abc_cdb.GetAttribute("id"); abc.Clssname = abc_cdb.GetAttribute("classname"); abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number")); don.Add(abc); } ``` I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?
2011/08/19
[ "https://Stackoverflow.com/questions/7116291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834597/" ]
You could pass a domain object that represents the item you are manipulating. ``` public class Widget { public string Name {get;set;} public int Id {get;set;} public string ClassName {get;set;} public int Number {get;set;} } var myWidget = new Widget(); myWidget.Name = "Blue Widget"; //etc StreamStructure(myWidget); ```
You should write a new class that contains the properties you want to pass to the method, and change your method to include just that new class. For your example, write a new class like this: ``` public class RequestObject { public string Name { get; set; } public string ID { get; set; } public string ClassName { get; set; } public int Number { get; set; } } ``` Then change your method like this: ``` public StreamStructure(RequestObject requestObject) { //DoStuff } ```
7,116,291
I am a new to C#, I need a small help on how can I pass multiple parameters between the classes? Below is a small example but my parameters will more than the 10. Is there another way to this? ``` public StreamStructure(String name, string id, string classname, int number) { this.name = name; this.id = id; this.classname = classname; this.number = number; } ``` List ------ ``` List<abc> don = new List<abc>(); foreach (XmlElement abc_cdb in abc_cdbs) { abc.Name = abc_cdb.GetAttribute("NAME"); abc.Id = abc_cdb.GetAttribute("id"); abc.Clssname = abc_cdb.GetAttribute("classname"); abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number")); don.Add(abc); } ``` I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?
2011/08/19
[ "https://Stackoverflow.com/questions/7116291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834597/" ]
Sure, use DTO's (data transfer objects). That is, create a class that has all the fields you want to send and use an instance of it as a parameter. Added bonus is that your method signature won't change even if you change your DTO class.
You should write a new class that contains the properties you want to pass to the method, and change your method to include just that new class. For your example, write a new class like this: ``` public class RequestObject { public string Name { get; set; } public string ID { get; set; } public string ClassName { get; set; } public int Number { get; set; } } ``` Then change your method like this: ``` public StreamStructure(RequestObject requestObject) { //DoStuff } ```
7,116,291
I am a new to C#, I need a small help on how can I pass multiple parameters between the classes? Below is a small example but my parameters will more than the 10. Is there another way to this? ``` public StreamStructure(String name, string id, string classname, int number) { this.name = name; this.id = id; this.classname = classname; this.number = number; } ``` List ------ ``` List<abc> don = new List<abc>(); foreach (XmlElement abc_cdb in abc_cdbs) { abc.Name = abc_cdb.GetAttribute("NAME"); abc.Id = abc_cdb.GetAttribute("id"); abc.Clssname = abc_cdb.GetAttribute("classname"); abc.number = Convert.ToInt32(abc_cdb.GetAttribute("number")); don.Add(abc); } ``` I have used as suggested in ans but I am trying to create a list in C# my first record gets replaced with the 2nd one, since the fields in MyDTO are defined as public. Do you have any idea how to fix this?
2011/08/19
[ "https://Stackoverflow.com/questions/7116291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/834597/" ]
You are probably better off using [C# Initializers](http://msdn.microsoft.com/en-us/library/bb384062.aspx) or a [Data Transfer Object](http://msdn.microsoft.com/en-us/library/ff649585.aspx) than a large number of constructor parameters. Or combine the two. ``` public class MyDTO { String Name { get; set; } String Id { get; set; } String ClassName { get; set; } int Number { get; set; } } var MyDTO = new MyDTO() { Name = Name, Id = Id, ClassName = ClassName, Number = Number } var stream = new StreamStructure(MyDTO) ``` To create a list of these objects as in your example, create a new DTO within the loop body. ``` var don = new List<MyDTO>(); foreach (XmlElement abc_cdb in abc_cdbs) { var abc = new MyDTO() { Name = abc_cdb.GetAttribute("NAME"); Id = abc_cdb.GetAttribute("id"); ClassName = abc_cdb.GetAttribute("classname"); Number = Convert.ToInt32(abc_cdb.GetAttribute("number")); }; don.Add( abc ); } ```
You should write a new class that contains the properties you want to pass to the method, and change your method to include just that new class. For your example, write a new class like this: ``` public class RequestObject { public string Name { get; set; } public string ID { get; set; } public string ClassName { get; set; } public int Number { get; set; } } ``` Then change your method like this: ``` public StreamStructure(RequestObject requestObject) { //DoStuff } ```
24,904,060
Hi I am trying to set the size of JPanel in JFrame but I am unable to achieve this. How can I achieve my desired output? Here is my code: ``` import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Sample extends JFrame { private JPanel panel; private JLabel label1; public Sample() { panel = new JPanel(); panel.setBackground(Color.YELLOW); panel.setBounds(100, 100, 100, 100); ImageIcon icon1 = new ImageIcon("E:\\image\\ZooDelhi\\1.jpg"); label1 = new JLabel(icon1); label1.setLocation(0,0); panel.add(label1); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.getContentPane().add(panel); this.setSize(500,500); this.setVisible(true); setLayout(null); } public static void main (String[] args) { new Sample(); } } ``` Thanks in advance.
2014/07/23
[ "https://Stackoverflow.com/questions/24904060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3852674/" ]
I think that it doesn't matter if you have layout or don't. Not having layout wouldn't harm changing size of JPanel. Try to use this: ``` myPanel.setPreferredSize(new Dimension(500, 500)); ``` I hope it'll help ;)
Per the Oracle documentation: <http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html> 1. Set the container's layout manager to null by calling setLayout(null). 2. Call the Component class's setbounds method for each of the container's children. 3. Call the Component class's repaint method. SUGGESTION: try calling "setLayout(null)" *first*. Also try looking at the sample code in the link above. 'Hope that helps!
24,904,060
Hi I am trying to set the size of JPanel in JFrame but I am unable to achieve this. How can I achieve my desired output? Here is my code: ``` import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Sample extends JFrame { private JPanel panel; private JLabel label1; public Sample() { panel = new JPanel(); panel.setBackground(Color.YELLOW); panel.setBounds(100, 100, 100, 100); ImageIcon icon1 = new ImageIcon("E:\\image\\ZooDelhi\\1.jpg"); label1 = new JLabel(icon1); label1.setLocation(0,0); panel.add(label1); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.getContentPane().add(panel); this.setSize(500,500); this.setVisible(true); setLayout(null); } public static void main (String[] args) { new Sample(); } } ``` Thanks in advance.
2014/07/23
[ "https://Stackoverflow.com/questions/24904060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3852674/" ]
**i will advise not to re-size your panel** If you just use the layout managers correctly, they will take care of panel sizes. To avoid having your components stretched out all over the screen when the user increases the window size, have an outermost panel with a left-aligned FlowLayout and the rest of the UI as its single child - that will give the UI its preferred size and any surplus is filled with the background color. Check reference to understand more. [Reference](http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html)
Per the Oracle documentation: <http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html> 1. Set the container's layout manager to null by calling setLayout(null). 2. Call the Component class's setbounds method for each of the container's children. 3. Call the Component class's repaint method. SUGGESTION: try calling "setLayout(null)" *first*. Also try looking at the sample code in the link above. 'Hope that helps!
63,856,888
It's simply to remove duplicates in a list of immutable objects by simply keeping a memo of `seen` objects. ```py nums = [1, 1, 2, 3, 4, 4] duplicates_removed seen = dict() for n in nums: if n not in seen: duplicates_removed.append(n) seen[n] = True ``` But for mutable objects, you cannot hash them into a dictionary. What is an elegant way to quickly remove duplicates (defined by some custom logic in `__eq__` of the object class) in a list?
2020/09/12
[ "https://Stackoverflow.com/questions/63856888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10256611/" ]
You *can* store mutable objects in hash tables, you just probably *shouldn’t* because if you have a pointer to an object, you store the object in the hash table, you mutate the object, and then you attempt to look it up via the pointer, you (almost certainly) won’t find it because the hash has now changed. However, if your specific use case is to remove duplicates like this, the most efficient method will be a hash. If you’re not using multithreading and this duplicate removal is self contained, you could safely get away with using a hash table (either a `dict` like you have or a `set`) because the data is effectively immutable. The only risk in that case is adding a `__hash__` function that is generally not useful. One option could be to make a thin wrapper class that implements `__hash__`, wrap your data in it to remove the duplicates, and then unwrap it, something like this: ```py class Wrapper(object): __init__(self, wrapped): self.wrapped = wrapped __eq__(self, other): if not isinstance(other, Wrapper): return False return self.wrapped == other.wrapped __hash__(self): # custom logic here, e.g. return 31 * sum(hash(item) for item in self.wrapped) def without_duplicate_lists(lists): wrappers = (Wrapper(l) for l in lists) result = [] seen = set() for w in wrappers: if w not in seen: seen.add(w) result.append(w) return [w.wrapped for w in wrappers] ``` There are some other ways you could do this without computing a hash, such as using a binary search tree (tree map). However, the hash isn’t the inherent problem with storing mutable data in maps, but rather that if you change the key in any way, you’ve lost your value. With hash tables, the key is the hash. With a binary search tree, it’s the ordering, which is defined by the key itself. If the key itself changes, you can’t look it up whatever method you use. Also, note that in my example calculating the hash is an O(n) operation, so if you are removing duplicates of `list`s or `set`s or `dict`s, it may just be cleaner to convert them (or their keys) to `tuple`s or `frozenset`s which are immutable and can be used in the `set` without worry (same even applies to other objects). If for some reason there is a middle ground where you think removing duplicates of mutable data via a hash is a bad idea but you still think removing duplicates of mutable data is fine, probably the next most efficient option is to sort the data. This way, instead of O(n^2) for the naive solution of nested iterating, you can sort in O(n\*log(n)) time and then iterate through, only keeping items where the current value doesn’t equal the last value. This will require you to implement `__eq__`, `__gt__`, and `__lt__` (or one of the latter and use `@total_ordering`): ```py def without_duplicates_sorted(objs): objs = sorted(objs) last = objs[0] result = [last] for current in objs[1:]: if current != last: result.append(current) last = current return result ``` For completeness’ sake, the naive solution: ```py def without_duplicates_naive(objs): result = [] for obj in objs: if obj not in objs[i+1:]: result.append(obj1) return result ```
I don't know it it's *elegant*, but you can often convert non-hashable items to hashable object like a [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset) or tuple. For example, you can convert the items() of dict like this: ``` nums = [{'a':1}, {'a':1}, {'a':2, 'c':3}, {'a':3}, {'c':3, 'a':2}, {'b':4}, {'a':4}] duplicates_removed = [] seen = set() for n in nums: n_s = frozenset(n.items()) if n_s not in seen: duplicates_removed.append(n) seen.add(n_s) duplicates_removed # [{'a': 1}, {'a': 2, 'c': 3}, {'a': 3}, {'b': 4}, {'a': 4}] ```
63,856,888
It's simply to remove duplicates in a list of immutable objects by simply keeping a memo of `seen` objects. ```py nums = [1, 1, 2, 3, 4, 4] duplicates_removed seen = dict() for n in nums: if n not in seen: duplicates_removed.append(n) seen[n] = True ``` But for mutable objects, you cannot hash them into a dictionary. What is an elegant way to quickly remove duplicates (defined by some custom logic in `__eq__` of the object class) in a list?
2020/09/12
[ "https://Stackoverflow.com/questions/63856888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10256611/" ]
You *can* store mutable objects in hash tables, you just probably *shouldn’t* because if you have a pointer to an object, you store the object in the hash table, you mutate the object, and then you attempt to look it up via the pointer, you (almost certainly) won’t find it because the hash has now changed. However, if your specific use case is to remove duplicates like this, the most efficient method will be a hash. If you’re not using multithreading and this duplicate removal is self contained, you could safely get away with using a hash table (either a `dict` like you have or a `set`) because the data is effectively immutable. The only risk in that case is adding a `__hash__` function that is generally not useful. One option could be to make a thin wrapper class that implements `__hash__`, wrap your data in it to remove the duplicates, and then unwrap it, something like this: ```py class Wrapper(object): __init__(self, wrapped): self.wrapped = wrapped __eq__(self, other): if not isinstance(other, Wrapper): return False return self.wrapped == other.wrapped __hash__(self): # custom logic here, e.g. return 31 * sum(hash(item) for item in self.wrapped) def without_duplicate_lists(lists): wrappers = (Wrapper(l) for l in lists) result = [] seen = set() for w in wrappers: if w not in seen: seen.add(w) result.append(w) return [w.wrapped for w in wrappers] ``` There are some other ways you could do this without computing a hash, such as using a binary search tree (tree map). However, the hash isn’t the inherent problem with storing mutable data in maps, but rather that if you change the key in any way, you’ve lost your value. With hash tables, the key is the hash. With a binary search tree, it’s the ordering, which is defined by the key itself. If the key itself changes, you can’t look it up whatever method you use. Also, note that in my example calculating the hash is an O(n) operation, so if you are removing duplicates of `list`s or `set`s or `dict`s, it may just be cleaner to convert them (or their keys) to `tuple`s or `frozenset`s which are immutable and can be used in the `set` without worry (same even applies to other objects). If for some reason there is a middle ground where you think removing duplicates of mutable data via a hash is a bad idea but you still think removing duplicates of mutable data is fine, probably the next most efficient option is to sort the data. This way, instead of O(n^2) for the naive solution of nested iterating, you can sort in O(n\*log(n)) time and then iterate through, only keeping items where the current value doesn’t equal the last value. This will require you to implement `__eq__`, `__gt__`, and `__lt__` (or one of the latter and use `@total_ordering`): ```py def without_duplicates_sorted(objs): objs = sorted(objs) last = objs[0] result = [last] for current in objs[1:]: if current != last: result.append(current) last = current return result ``` For completeness’ sake, the naive solution: ```py def without_duplicates_naive(objs): result = [] for obj in objs: if obj not in objs[i+1:]: result.append(obj1) return result ```
We can compare each element with the previous one.If they are not same we add it to the new list containing unique values. ``` def remove_dups(nums): duplicates_removed = [] duplicates_removed.append(nums[0]) for i in range(1,len(nums)): if(nums[i]!=nums[i-1]): duplicates_removed.append(nums[i]) lst1 = [1, 1, 2, 3, 4, 4] remove_dups(lst1) // Output: [1, 2, 3, 4] lst2 = [{'a':1}, {'a':1}, {'c':3}, {'d':4, 'a':1}, {'d':4, 'a': 1}] remove_dups(lst2) // Output: [{'a': 1}, {'c': 3}, {'a': 1, 'd': 4}] ```
63,856,888
It's simply to remove duplicates in a list of immutable objects by simply keeping a memo of `seen` objects. ```py nums = [1, 1, 2, 3, 4, 4] duplicates_removed seen = dict() for n in nums: if n not in seen: duplicates_removed.append(n) seen[n] = True ``` But for mutable objects, you cannot hash them into a dictionary. What is an elegant way to quickly remove duplicates (defined by some custom logic in `__eq__` of the object class) in a list?
2020/09/12
[ "https://Stackoverflow.com/questions/63856888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10256611/" ]
You *can* store mutable objects in hash tables, you just probably *shouldn’t* because if you have a pointer to an object, you store the object in the hash table, you mutate the object, and then you attempt to look it up via the pointer, you (almost certainly) won’t find it because the hash has now changed. However, if your specific use case is to remove duplicates like this, the most efficient method will be a hash. If you’re not using multithreading and this duplicate removal is self contained, you could safely get away with using a hash table (either a `dict` like you have or a `set`) because the data is effectively immutable. The only risk in that case is adding a `__hash__` function that is generally not useful. One option could be to make a thin wrapper class that implements `__hash__`, wrap your data in it to remove the duplicates, and then unwrap it, something like this: ```py class Wrapper(object): __init__(self, wrapped): self.wrapped = wrapped __eq__(self, other): if not isinstance(other, Wrapper): return False return self.wrapped == other.wrapped __hash__(self): # custom logic here, e.g. return 31 * sum(hash(item) for item in self.wrapped) def without_duplicate_lists(lists): wrappers = (Wrapper(l) for l in lists) result = [] seen = set() for w in wrappers: if w not in seen: seen.add(w) result.append(w) return [w.wrapped for w in wrappers] ``` There are some other ways you could do this without computing a hash, such as using a binary search tree (tree map). However, the hash isn’t the inherent problem with storing mutable data in maps, but rather that if you change the key in any way, you’ve lost your value. With hash tables, the key is the hash. With a binary search tree, it’s the ordering, which is defined by the key itself. If the key itself changes, you can’t look it up whatever method you use. Also, note that in my example calculating the hash is an O(n) operation, so if you are removing duplicates of `list`s or `set`s or `dict`s, it may just be cleaner to convert them (or their keys) to `tuple`s or `frozenset`s which are immutable and can be used in the `set` without worry (same even applies to other objects). If for some reason there is a middle ground where you think removing duplicates of mutable data via a hash is a bad idea but you still think removing duplicates of mutable data is fine, probably the next most efficient option is to sort the data. This way, instead of O(n^2) for the naive solution of nested iterating, you can sort in O(n\*log(n)) time and then iterate through, only keeping items where the current value doesn’t equal the last value. This will require you to implement `__eq__`, `__gt__`, and `__lt__` (or one of the latter and use `@total_ordering`): ```py def without_duplicates_sorted(objs): objs = sorted(objs) last = objs[0] result = [last] for current in objs[1:]: if current != last: result.append(current) last = current return result ``` For completeness’ sake, the naive solution: ```py def without_duplicates_naive(objs): result = [] for obj in objs: if obj not in objs[i+1:]: result.append(obj1) return result ```
You don't need a dict. ``` nums = [1, 1, 2, 3, 4, 4] duplicates_removed = [] for n in nums: if n not in duplicates_removed: duplicates_removed.append(n) ``` The same works for custom classes ``` class X: def __init__(self, n): self.n = n def __eq__(self, cmp): return cmp.n == self.n def __ne__(self, cmp): return cmp.n != self.n def __repr__(self): return f"X({self.n})" nums = [X(1), X(1), X(2), X(4), X(4), X(5)] nodups = [] for n in nums: if n not in nodups: nodups.append(n) print(nodups) ```
5,243,661
A WP user with the role "Author" can post articles. On the blog in question I have the requirement, that these users' articles have to be **live** immediately but **not publicly visible** (i.e., for anonymous visitors or Subscribers). We use WP 3.0.5. We already have a plugin running, that allows to **hide categories** from anonymous and Subscribers. So the most straight-forward method I came up with so far is: *New blog posts by Authors should be automatically put in a category. Then I hide that category from anonymous users.* Does anyone know: a) how to automatically put an article by "Author" users in a certain category, or b) how the requirement "live but not public" could be achieved more elegantly for those posts? (Plugin suggestions are welcome, too.)
2011/03/09
[ "https://Stackoverflow.com/questions/5243661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113195/" ]
What you probably want to do is write function to do this in your theme's `functions.php` file, and then use `add_action` to trigger that function when a post is saved. For example: ``` function update_category_on_save($post_id) { // Get post $post = wp_get_single_post($post_id) // Map author IDs to category IDs $mapping = array( 1 => array(123), 2 => array(234), ); // Update the post $new_category = $mapping[$post->post_author]; $u_post = array(); $u_post['ID'] = $post_id; $u_post['post_category'] = $new_category; // Only update if category changed if($post->post_category != $new_category[0]) { wp_update_post($u_post); } } add_action('category_save_pre', 'update_category_on_save'); ``` Hope that makes sense, and gives you a hint as to how to do this — I'm afraid I haven't been able to test it.
The following code will change posts made by an author to private automatically. ``` function change_author_posts_to_private( $post_status ) { // if the user is just saving a draft, we want to keep it a draft if ( $post_status == 'draft' ) return $post_status; $this_user = new WP_User( $_POST[ 'post_author' ] ); // this is assuming the user has just one role, which is standard if ( $this_user->roles[0] == 'author' ) return 'private'; else return $post_status; } add_filter( 'status_save_pre', 'change_author_posts_to_private' ); ``` it filters the status on the post save, looks to see who the author is from the post variables, fetches their first role and sees if it's author, if it is, then it returns 'private', otherwise it returns the natural status. No need to use categories to do it when you can do it directly here.
1,570
While related to [an early discussion on retro gaming](https://gaming.meta.stackexchange.com/questions/433/what-defines-retro-gaming), this isn't the same. I noticed a question got retagged to [old-games](https://gaming.stackexchange.com/questions/tagged/old-games "show questions tagged 'old-games'"), which investigation led me to see that it has a 66 questions (excluding two closed game-rec). 26 of them are not [identify-this-game](https://gaming.stackexchange.com/questions/tagged/identify-this-game "show questions tagged 'identify-this-game'"), making 40 of them exceptionally redundant - the majority of identification questions are about old games, otherwise you probably didn't forget it. Those 26 range from [how to deal with or run "old" games](https://gaming.stackexchange.com/questions/8420/cpu-or-framerate-limiting-on-older-games "How to play on modern systems, often.") and [where to find "old" games](https://gaming.stackexchange.com/questions/12219/where-to-get-help-choosing-older-pc-games "Both finding stores and finding about remakes, it seems.") to [gameplay and story questions for "old" games](https://gaming.stackexchange.com/questions/6125/what-happens-at-the-end-of-impossible-mission-ii). We lack a consistency in the application of this tag. There's also no real definition for what constitutes "old" games that we can use to build any consistency. There is a danger associated with certain age definitions, the same which makes [upcoming-games](https://gaming.stackexchange.com/questions/tagged/upcoming-games "show questions tagged 'upcoming-games'") [a particularly dangerous tag](https://gaming.meta.stackexchange.com/questions/1339/how-should-we-deal-with-out-of-date-questions-answers/1341#1341 "You only need to care about the first paragraph"): tags that change over time cause a lot of problems. We could use a definition to the purpose of this tag. To me, the tag mostly conflicts with the usage of platform tags. One knows that an NES game is old by virtue of it being on the NES, and anything modern-made for an old platform probably stands out more by its own name than by the fact it lacks an old-games tag. Its primary usage that makes sense to me is for generic questions about older games that can be asked without any particular platform being of concern. In that case, there are a lot of questions with it that should have it removed. What does everyone else think? What does [old-games](https://gaming.stackexchange.com/questions/tagged/old-games "show questions tagged 'old-games'") give us?
2010/12/27
[ "https://gaming.meta.stackexchange.com/questions/1570", "https://gaming.meta.stackexchange.com", "https://gaming.meta.stackexchange.com/users/85/" ]
Personally I think the tag should be removed entirely, since I don't find it very useful to filter on anything and it would require extensive maintenance in the years to come. If we do manage to stick a definition on it, say "games that came out 15 years ago", then past a certain point in time we'll have to go back and tag *many* of the questions on this site under [old-games]. At the rate we're gaining questions that's simply not feasible, and it just sounds like a massive headache for what appears to me to have been of such little benefit.
I have always thought of this tag as "Games that no longer natively run on modern hardware/operative systems or need compatibility tweaking to run properly," for use in questions that deal with said compatibility settings and/or emulation techniques and/or future proofing.
49,705,192
I am developing an application which uses a chatbot. It will partly run on LUIS dataset that I have trained and partly on AIML, in case i don't have any relevant response. Here is a piece of code from the file. I am basically trying to fetch entity type from LUIS and if it returns nothing, then trying to run AIML. But it keeps throwing an unhandled exception: *An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null.* I have taken this AIML code from another project. Here's the link: <https://github.com/Gr8z/ChatBotProject> Exception occurs in line: `AimlBot.loadSettings();` Here's the stack trace of the exception: ``` at System.IO.Path.Combine(String path1,String path2) at AIMLbot.Bot.get_PathToConfigFiles(); at AIMLbot.Bot.loadSettings(String pathToSettings) at WDB.Chatbot.AIMLChatbot.Initialize() in E:\WDB-master\WDB\manishChatBot.cs:line 229 ``` And the source code: ``` #region LUIS Link private string luisLink(string usrInput) { string input = usrInput; string op = wb.DownloadString("https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/15c6bd2a-ecdc-41de-a054-0cce461e13a3?subscription-key=b72bdbb572fe4e90837647eb9c82b1c0&verbose=true&timezoneOffset=0&q=" + input); var jsonParse = JsonConvert.DeserializeObject<JClass>(op); if (jsonParse.entities.Count != 0) { entity = jsonParse.entities[0].type; return entity; } else { AIMLChatBot a = new AIMLChatBot(); string aiml_response = a.getOutput(input); return aiml_response; } } #endregion #region AIML public class AIMLChatBot { const string UserId = "szabist"; private Bot AimlBot; private User myUser; public AIMLChatBot() { AimlBot = new Bot(); myUser = new User(UserId, AimlBot); Initialize(); } // Loads all the AIML files in the \AIML folder public void Initialize() { AimlBot.loadSettings(); //Exception on this line AimlBot.isAcceptingUserInput = false; AimlBot.loadAIMLFromFiles(); AimlBot.isAcceptingUserInput = true; } // Given an input string, finds a response using AIMLbot lib public String getOutput(String input) { Request r = new Request(input, myUser, AimlBot); Result res = AimlBot.Chat(r); return (res.Output); } } #endregion ```
2018/04/07
[ "https://Stackoverflow.com/questions/49705192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6877294/" ]
I followed the given link: <https://github.com/Gr8z/ChatBotProject> and downloaded the `AIMLBot.dll` file which has the implementation of the method `AimlBot.loadSettings();`. On personally DE-Compiling the file, I found the implementation which looks something like this: > > [![enter image description here](https://i.stack.imgur.com/WWIvm.png)](https://i.stack.imgur.com/WWIvm.png) > > > *So, what I suggest is to check whether you have **config/Settings.xml** file in your ../bin/Debug/ or the directory where your program resides.* The program is unable to find the location of that file because of which it gives you a Null Argument Exception.
As @Shivam Som has shown, the method needs one argument which specifies the location of settings. In order to solve this issue, you need to copy your `config` folder which contains AIML settings to the `Debug` folder where the C# application runs. In case you don't have the necessary files for AIML configuration, you can download them by going to <https://www.effacestudios.com/wp-content/uploads/2018/04/AIMLBot.zip>
414,471
I run AVG Antivirus (version 8.5, I believe). Now I want to install "Dragon Naturally Speaking", a speech recognition software. During installation I'm told that I need to temporarily disable my antivirus. How do I temporarily disable it?
2012/04/19
[ "https://superuser.com/questions/414471", "https://superuser.com", "https://superuser.com/users/129190/" ]
As @Eroen already said, this might not be necessary. Most programs install just fine with the antivirus enabled. If they don't, either the installer or the antivirus is poorly written. From [Disabling AVG temporarily | FAQ | AVG Worldwide](http://www.avg.com/ww-en/faq.num-3857): > > The AVG software protects your computer on multiple levels. **In case you need to disable all AVG components at once** please follow the steps below: > > > 1. Open the AVG Program. > 2. On the **Tools** menu, click **Advanced settings**. > 3. Click **Temporarily disable AVG protection** in the menu on the left side. > 4. Select the **Temporarily disable AVG protection** check box, and then click **OK**. > 5. Choose how long you want the protection to be disabled and whether to disable the Firewall as well, and then click **Disable real-time protection**. > > > Since you only disable it temporarily, there is no need to manually enable it afterwards. It will do so automatically.
1. Control Panel>Administrative Tools>System Configuration 2. Click on the Startup tab 3. Uncheck AVG 4. Click restart 5. do what you need to 6. repeat 1&2 7. recheck AVG, click restart again
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Another unusual approach that just saved me in this situation and hence should be mentioned here, is, that GRUB2 can boot ISO images directly! The Ubuntu help describes it as such: 1. Install `grml-rescueboot`. 2. Place your ISO in `/boot/grml/`. 3. Run `sudo update-grub` This will automatically create a boot entry for every ISO in that directory, using loopback and chain-loading. So as long as you got a working Linux partition of any kind that has GRUB2 (wich is much easier and reliable to achieve), you can boot any ISO, even if it’s a problematic one. Saving a normal Linux user from even needing any external medium. (Though loopbacks can boot isos from other partitions/media too, if you are willing to not use grml-rescueboot and do the GRUB2 config manually.)
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Another unusual approach that just saved me in this situation and hence should be mentioned here, is, that GRUB2 can boot ISO images directly! The Ubuntu help describes it as such: 1. Install `grml-rescueboot`. 2. Place your ISO in `/boot/grml/`. 3. Run `sudo update-grub` This will automatically create a boot entry for every ISO in that directory, using loopback and chain-loading. So as long as you got a working Linux partition of any kind that has GRUB2 (wich is much easier and reliable to achieve), you can boot any ISO, even if it’s a problematic one. Saving a normal Linux user from even needing any external medium. (Though loopbacks can boot isos from other partitions/media too, if you are willing to not use grml-rescueboot and do the GRUB2 config manually.)
Grub 2 - Tutorial Format your USB-Stick with FAT32 and: 1. Open a terminal and type `sudo su` // or `su` to get root access 2. Type `fdisk -l` (and note which device is your USB) 3. Type `mkdir /mnt/USB && mount /dev/sdx1 /mnt/USB` (replacing **x** with your actual usb device) 4. Type `grub-install --force --removable --boot-directory=/mnt/USB/boot /dev/sdx` (replacing **x** with your actual USB device) 5. Type `cd /mnt/USB/boot/grub` 6. Create a file **/mnt/USB/boot/grub/grub.cfg** with the following content: ``` set default=0 menuentry "HBCD" { linux16 /grub.exe --config-file="find --set-root /HBCD/menu.lst; configfile /HBCD/menu.lst" } ``` 7. Copy the content of the hirens.iso to the root directory of your USB-Stick (like /mnt/USB/ ) Greetings Tom
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
There is a easy way of installing Hiren's Boot CD 15.2 on Linux (Ubuntu, Linuxmint, etc.). Download the Universal USB Installer <https://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/> and open in WINE. Choose Hirens Boot CD and everything is working like you would do it under Windows.
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Open the Software Center and install [UNetbootin ![](https://hostmar.co/software-small)](https://apps.ubuntu.com/cat/applications/unetbootin/). From there you just run it and the rest explains itself.
Ok I found a solution [here](http://www.linuxquestions.org/questions/linux-newbie-8/boot-hirens-boot-iso-from-grub2-4175452264/) This approach use grub2 and so it is very convenient if you want to do a multi boot usb 1. install grub 2 on the usb driver ( `grub-install --force --no-floppy --boot-directory=[PATH_TO_USB] /dev/sd[X]` 2. extract Hiren iso files on the usb ( you should have a folder /HBCD in the root of the usb ) 3. copy grub.exe (can be found in hbcd\dos\dos.gz, inside the .img file) 4. copy menu.lst from the hbcd folder to the root of the usb drive 5. add the following menu entry to grub.cfg on the usb: Here the menu entry: ``` menuentry "HBCD" { linux16 /grub.exe --config-file="find --set-root /HBCD/menu.lst; configfile /HBCD/menu.lst" } ``` Once compleated you can reboot or test it with qemu: `qemu-system-x86_64 -hda /dev/sd[X]`
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
None of the below methods will work. Although you will get a bootable USB, it doesn't chainload anything out of the Grub Menu. This is especially true for the 'revised' edition of Hiren's Boot CD (the one with the mini-version of Windows XP) Here is the correct procedure: Insert your USB drive into your PC and start Ubuntu's partition Manager. Format the drive to FAT32, primairy partition and give a nice label. While you are at it, note the device's mount location (for example /dev/sdb) When it is done, close the partition manager and start a terminal. ``` sudo grub-install /dev/device location ``` Where 'device location' is the location of your USB drive you noted earlier. Now place the Hirens Boot CD iso-file in a new folder. Right-click the file and choose 'extract here' When it is done, delete the iso file and copy all the rest of the content to the root your USB drive. There should be 1 folder called HBCD on the drive now, and 4 small other files. Now open the folder called HBCD and copy the files 'grldr' and 'menu.lst' to the root of the drive. Be sure to **copy** them, **do not cut**. That is it, you're done. It should work now as a bootable USB drive aswel as a tool you can use inside a MS Windows environment.
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Unetbootin does the job of making a bootable USB, but for recent versions of Hiren's CD to work, [a small fix](https://www.raymond.cc/blog/how-to-put-hirens-bootcd-on-flash-memory/) must be made for the menu to work: * Open the Software Center and install [UNetbootin ![](https://hostmar.co/software-small)](https://apps.ubuntu.com/cat/applications/unetbootin/). * Create the bootable USB using the `Diskimage` option and selecting the downloaded ISO. * After the USB is created, mount it in Nautilus (just click the USB drive icon), go into the `HBCD` folder, *rename the `isolinux.cfg` file to `syslinux.cfg`* and *copy it to the root of the USB*, overwriting the existing file. Change the first line of `syslinux.cfg` from `DEFAULT /HBCD/Boot/menu.c32` to `DEFAULT menu.c32`. Now the USB boots and menu works fine :)
None of the below methods will work. Although you will get a bootable USB, it doesn't chainload anything out of the Grub Menu. This is especially true for the 'revised' edition of Hiren's Boot CD (the one with the mini-version of Windows XP) Here is the correct procedure: Insert your USB drive into your PC and start Ubuntu's partition Manager. Format the drive to FAT32, primairy partition and give a nice label. While you are at it, note the device's mount location (for example /dev/sdb) When it is done, close the partition manager and start a terminal. ``` sudo grub-install /dev/device location ``` Where 'device location' is the location of your USB drive you noted earlier. Now place the Hirens Boot CD iso-file in a new folder. Right-click the file and choose 'extract here' When it is done, delete the iso file and copy all the rest of the content to the root your USB drive. There should be 1 folder called HBCD on the drive now, and 4 small other files. Now open the folder called HBCD and copy the files 'grldr' and 'menu.lst' to the root of the drive. Be sure to **copy** them, **do not cut**. That is it, you're done. It should work now as a bootable USB drive aswel as a tool you can use inside a MS Windows environment.
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
get hiren's Iso into your HDD. insert your USB pendrive or whatever, download rufus <http://rufus.akeo.ie/> and proceed with burning the hiren.ISO file into the USB. once you succeeded, you need to restart your pc and check that your BIOS is configured in such a way that your boot order has your harddrive as the last thing to boot from. Also make sure, that as you reboot your pc again, and you have your USB burned and plugged, you dont have anything else that your pc might boot from. Hope it helps (btw, i just did this 30 minutes ago...) Cheers!
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Unetbootin does the job of making a bootable USB, but for recent versions of Hiren's CD to work, [a small fix](https://www.raymond.cc/blog/how-to-put-hirens-bootcd-on-flash-memory/) must be made for the menu to work: * Open the Software Center and install [UNetbootin ![](https://hostmar.co/software-small)](https://apps.ubuntu.com/cat/applications/unetbootin/). * Create the bootable USB using the `Diskimage` option and selecting the downloaded ISO. * After the USB is created, mount it in Nautilus (just click the USB drive icon), go into the `HBCD` folder, *rename the `isolinux.cfg` file to `syslinux.cfg`* and *copy it to the root of the USB*, overwriting the existing file. Change the first line of `syslinux.cfg` from `DEFAULT /HBCD/Boot/menu.c32` to `DEFAULT menu.c32`. Now the USB boots and menu works fine :)
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
Ok I found a solution [here](http://www.linuxquestions.org/questions/linux-newbie-8/boot-hirens-boot-iso-from-grub2-4175452264/) This approach use grub2 and so it is very convenient if you want to do a multi boot usb 1. install grub 2 on the usb driver ( `grub-install --force --no-floppy --boot-directory=[PATH_TO_USB] /dev/sd[X]` 2. extract Hiren iso files on the usb ( you should have a folder /HBCD in the root of the usb ) 3. copy grub.exe (can be found in hbcd\dos\dos.gz, inside the .img file) 4. copy menu.lst from the hbcd folder to the root of the usb drive 5. add the following menu entry to grub.cfg on the usb: Here the menu entry: ``` menuentry "HBCD" { linux16 /grub.exe --config-file="find --set-root /HBCD/menu.lst; configfile /HBCD/menu.lst" } ``` Once compleated you can reboot or test it with qemu: `qemu-system-x86_64 -hda /dev/sd[X]`
You can make a bootable USB on Ubuntu from any (bootable) .ISO image using `dd` command: ``` dd if=./someisofile.iso of=/dev/sdb ``` however, I'd like to warn you that `dd` is a very dangerous command and you should only proceed if you fully understand the meaning of its parameters, in particular, the `of` one. If you google for something like "dd iso usb", you'll fins quite a few tutorials, for example [this one from Fedora](http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#Using_dd_for_a_direct_copy), [this one from Linux Mint](http://community.linuxmint.com/tutorial/view/744), or [this one from ArchLinux](https://wiki.archlinux.org/index.php/USB_Installation_Media)
146,127
Trying to create a [Hiren's BootCD](http://www.hiren.info/pages/bootcd) on a USB. Not needing anything else such as a dual boot of Ubuntu and Haren or Window's and Haren. All the programs that I can find to complete this either end up directing me on how to create a Ubuntu boot on a usb, or how to do it on Windows. But since it is my Windows computer that I'm trying to fix I need an alternative. Please Help?
2012/06/04
[ "https://askubuntu.com/questions/146127", "https://askubuntu.com", "https://askubuntu.com/users/68196/" ]
None of the below methods will work. Although you will get a bootable USB, it doesn't chainload anything out of the Grub Menu. This is especially true for the 'revised' edition of Hiren's Boot CD (the one with the mini-version of Windows XP) Here is the correct procedure: Insert your USB drive into your PC and start Ubuntu's partition Manager. Format the drive to FAT32, primairy partition and give a nice label. While you are at it, note the device's mount location (for example /dev/sdb) When it is done, close the partition manager and start a terminal. ``` sudo grub-install /dev/device location ``` Where 'device location' is the location of your USB drive you noted earlier. Now place the Hirens Boot CD iso-file in a new folder. Right-click the file and choose 'extract here' When it is done, delete the iso file and copy all the rest of the content to the root your USB drive. There should be 1 folder called HBCD on the drive now, and 4 small other files. Now open the folder called HBCD and copy the files 'grldr' and 'menu.lst' to the root of the drive. Be sure to **copy** them, **do not cut**. That is it, you're done. It should work now as a bootable USB drive aswel as a tool you can use inside a MS Windows environment.
get hiren's Iso into your HDD. insert your USB pendrive or whatever, download rufus <http://rufus.akeo.ie/> and proceed with burning the hiren.ISO file into the USB. once you succeeded, you need to restart your pc and check that your BIOS is configured in such a way that your boot order has your harddrive as the last thing to boot from. Also make sure, that as you reboot your pc again, and you have your USB burned and plugged, you dont have anything else that your pc might boot from. Hope it helps (btw, i just did this 30 minutes ago...) Cheers!
72,061,993
I am making a "Treasure hunt" trails app. A user can go to a location and when they reach that location an action will happen. To monitor the users location I am using Gelocation.watchposition() from "react-native-geolocation-service". The point of interest (trailLocation) is got from our API and I set the "trailLocation" state with this, it updates correctly and all looks good. `(initialTrailLocation passed from previous screen)` ``` const [trailLocation, setTrailLocation] = useState(initialTrailLocation); /** * Function to get the next trail location */ let getNextLocation = async () => { setIsLoading(true); const credentials = await Keychain.getGenericPassword(); await axios.get(BACKEND_URL + 'api/v1/trails/' + trail.id + '/user/' + credentials.username + '/next-location?include=trail_location_ar_object.ar_object.ar_object_resources', { headers: { Authorization: 'Bearer ' + credentials.password, }, }, ) .then(response => { setTrailLocation(response.data.data.trail_location); setIsLoading(false); setUserWithinRange(false); }) .catch(error => { console.log(error); }); }; /** * Function called when the position changes */ function newPositionHandler(data) { console.log("new position handler"); let radius = 1000; let ky = 40000 / 360; console.log(trailLocation); let kx = Math.cos((Math.PI * trailLocation.lat) / 180.0) * ky; let dx = Math.abs(trailLocation.lon - data.coords.longitude) * kx; let dy = Math.abs(trailLocation.lat - data.coords.latitude) * ky; setDistance(Math.sqrt(dx * dx + dy * dy)); console.log(Math.sqrt(dx * dx + dy * dy)); console.log('-------------------'); if(Math.sqrt(dx * dx + dy * dy) <= radius / 1000) { setUserWithinRange(true); } else { setUserWithinRange(false) } }; /** Function called to initialise the watch position functionality */ async function watchPosition() { console.log("watch position"); Geolocation.watchPosition((data) => newPositionHandler(data), (error) => console.log(error),{ enableHighAccuracy: false, timeout: 10000, maximumAge: 1000, distanceFilter: 5, }, ); }; ``` However, when the success function from watchposition is triggered, it uses the original value of the "trailLocation" state and hence calculates the wrong distance between the user location and new trailLocation point. I can't understand why this is as all other functions use the correct state value. I log the values out and I can clearly see it using the initial state, but all other actions use the current state and the new trailLocation parameters are displayed on the screen. Any help would be greatly appreciated. I can provide more details, it's my first question so cut me some slack ;) Thanks
2022/04/29
[ "https://Stackoverflow.com/questions/72061993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16427053/" ]
The data in your function is outdated - what's often referred to as a "stale closure". When you write `Geolocation.watchPosition((data) => newPositionHandler(data), ...`, the function is created with the state that exists at the time. When the function runs, this data has become outdated. You can read more about solutions to this problem in this related question: [How To Solve The React Hook Closure Issue?](https://stackoverflow.com/questions/62806541/how-to-solve-the-react-hook-closure-issue)
1. Remove await ``` axios.get(BACKEND_URL + 'api/v1/trails/' + trail.id + '/user/' + credentials.username + '/next-location?include=trail_location_ar_object.ar_object.ar_object_resources', { headers: { Authorization: 'Bearer ' + credentials.password, }, }, ) .then(response => { setTrailLocation(response.data.data.trail_location); setIsLoading(false); setUserWithinRange(false); }) .catch(error => { console.log(error); }); ``` or 2. ``` let getNextLocation = async () => { setIsLoading(true); const credentials = await Keychain.getGenericPassword(); const response = await axios.get(BACKEND_URL + 'api/v1/trails/' + trail.id + '/user/' + credentials.username + '/next-location?include=trail_location_ar_object.ar_object.ar_object_resources', { headers: { Authorization: 'Bearer ' + credentials.password, }, }, ) if(response?.data?.data?.trail_location){ setTrailLocation(response.data.data.trail_location); } setIsLoading(false); setUserWithinRange(false); }; ```
67,826,261
The standard library utility `declval` is [defined](http://wg21.link/declval) as: ```cpp template<class T> add_rvalue_reference_t<T> declval() noexcept; ``` To add a *rvalue reference* here seemed like a good idea, if you think about the language when it was introduced in *C++11*: Returning a value involved a temporary, that was subsequently moved from. Now *C++17* introduced *guaranteed copy elision* and this does not apply any more. As [cppref](https://en.cppreference.com/w/cpp/language/copy_elision) puts it: > > C++17 core language specification of prvalues and temporaries is > fundamentally different from that of the earlier C++ revisions: there > is no longer a temporary to copy/move from. Another way to describe > C++17 mechanics is "unmaterialized value passing": prvalues are > returned and used without ever materializing a temporary. > > > This has some consequences on other utilities implemented in terms of `declval`. Have a look at this example (view on [godbolt.org](https://godbolt.org/z/YTTv36ndv)): ```cpp #include <type_traits> struct Class { explicit Class() noexcept {} Class& operator=(Class&&) noexcept = delete; }; Class getClass() { return Class(); } void test() noexcept { Class c{getClass()}; // succeeds in C++17 because of guaranteed copy elision } static_assert(std::is_constructible<Class, Class>::value); // fails because move ctor is deleted ``` Here we have a *nonmovable* class. Because of *guaranteed copy elision*, it can be returned from a function and then locally materialised in `test()`. However the `is_construtible` type trait suggests this is not possible, because it is [defined](http://wg21.link/meta.unary.prop#8) in terms of `declval`: > > The predicate condition for a template specialization > `is_­constructible<T, Args...>` shall be satisfied if and only if the > following variable definition would be well-formed for some invented > variable `t`: > > `T t(declval<Args>()...);` > > > So in our example, the type trait states if `Class` can be constructed from a hypothetical function that returns `Class&&`. Whether the the line in `test()` is allowed cannot be predicted by any of the current type traits, despite the naming suggests that `is_constructible` does. This means, in all situations where *guaranteed copy elision* would actually save the day, `is_constructible` misleads us by telling us the answer to "Would it be constructible *in C++11*?". This is not limited to `is_constructible`. Extend the example above with (view on [godbolt.org](https://godbolt.org/z/dzbvjW3Ms)) ```cpp void consume(Class) noexcept {} void test2() { consume(getClass()); // succeeds in C++17 because of guaranteed copy elision } static_assert(std::is_invocable<decltype(consume), Class>::value); // fails because move ctor is deleted ``` This shows that `is_invocable` is similarly affected. The most straightforward solution to this would be to change `declval` to ```cpp template<class T> T declval_cpp17() noexcept; ``` Is this a defect in the C++17 (and subsequent, i.e. C++20) standard? Or am I missing a point why these `declval`, `is_constructible` and `is_invocable` specifications are still the best solution we can have?
2021/06/03
[ "https://Stackoverflow.com/questions/67826261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9167702/" ]
> > However the `is_construtible` type trait suggests this is not possible, because it is defined in terms of `declval`: > > > `Class` is not *constructible* from an instance of its own type. So `is_constructible` should not say that it is. If a type `T` satisfies `is_constructible<T, T>`, the expectation is that you can make a `T` given an object of type `T`, *not* that you can make a `T` specifically from a prvalue of type `T`. This is not a quirk of using `declval`; it is what the question `is_constructible` means. What you're suggesting is that `is_constructible` should answer a different question than the one it is intended to answer. And it should be noted, guaranteed elision means that *all types* are "constructible" from a prvalue of its own type. So if that was what you wanted to ask, you already have the answer.
The `std::declval` function is primarily meant for forwarding. Here's an example: ``` template<typename... Ts> auto f(Ts&&... args) -> decltype(g(std::declval<Ts>()...)) { return g(std::forward<Args>(args)...); } ``` In that common case, having `std::declval` returning a prvalue is wrong, since there's no good way to forward a prvalue.
6,394,581
Hello I am using GDI+ to do some image processing. I am having it run from the command line with two arguments. The reason for this is the program is being called from VBA Excel 2007. A Open file dialog is run from VBA and gives the first argument. The first arguement is the original image to be processed and the second is where to save the image. Everything works just fine when the two arguments come from a drive with a letter, i.e. C:. It was not working with network folders, i.e. \server\folder. I overcame this by mounting the folder to a drive letter before trying to load the image. I have a problem now when the incoming image is on a usb camera. The file path of the file on the camera ends up being COMPUTER\Canon\DCIM\image.jpg. Windows is not mounting the camera to a lettered drive so it is not working correctly for me. Before trying to load the image I add and extra '\' so that they are all double \. I am not sure at all how to get this to work and have looked all over. Thanks. ``` int main(int argc, char* argv[]) { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // INITIALIZE GDI+ GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); wchar_t tin[200] = L""; wchar_t in[200] = L""; wchar_t out[200] = L""; wchar_t tout[200] = L""; NETRESOURCE nr; DWORD dwRetVal; nr.dwType = RESOURCETYPE_DISK; nr.lpLocalName = "M:"; nr.lpRemoteName = "\\\\server\\folder"; nr.lpProvider = NULL; // Map the mugshots folder dwRetVal = WNetAddConnection2(&nr, NULL, NULL, CONNECT_TEMPORARY); // Convert to a wchar_t* from command line argument size_t origsize = strlen(argv[1]) + 1; mbstowcs( tin, argv[1], origsize); //Add an extra \ for directory int j = 0; for (int i = 0 ; i < int(origsize) ; i++) { if(tin[i] == '\\') { in[j] = '\\'; j++; in[j] = '\\'; j++; } else { in[j] = tin[i]; j++; } } // Convert to a wchar_t* from command line argument origsize = strlen(argv[2]) + 1; mbstowcs(tout, argv[2], origsize); //Add an extra \ for directory out[0] = 'M'; out[1] = ':'; out[2] = '\\'; out[3] = '\\'; j = 4; for (int i = 0 ; i < int(origsize) ; i++) { if(tout[i] == '\\') { out[j] = '\\'; j++; out[j] = '\\'; j++; } else { out[j] = tout[i]; j++; } } Bitmap b(in); Process image CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); image2->Save(out, &pngClsid, NULL); return 0; } ```
2011/06/18
[ "https://Stackoverflow.com/questions/6394581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804297/" ]
Please take a look at the sample: [GetImage Sample: Demonstrates the Windows Image Acquisition API](http://msdn.microsoft.com/en-us/library/7eh90ebz%28v=vs.90%29.aspx): > > The sample application has a single command on its File menu, named > From scanner or camera. When a WIA device (or a device emulator) is > attached, the menu item becomes enabled. When the user selects the > menu command, the sample will sequentially display the WIA Device > Selection dialog box, Image Selection dialog box, and Image Transfer > dialog box. The device and image selection dialog boxes are the common > dialog boxes supplied by the system, and the transfer dialog box is > implemented in this sample. Finally, the sample will display the > transferred image(s) in child window(s). > > > Hope this helps.
You need to look into how shell handles the special paths, a good start is here: <http://msdn.microsoft.com/en-us/library/bb773559%28v=vs.85%29.aspx> For a lot of what you are doing, you should be using PathCanonicalize() or something along these lines. Unsure if this helps you with your camera, you may need to access image acquisition APIs directly to get files out of some cameras.
5,210,941
I am looking for equivalent of following vi command **:! nl %** this runs nl command on currently open file What is emacs way to detect name of open file ? M-X shell-commnad nl I am not able find determine value of current open/buffer and substitute. Thx/Mahesh
2011/03/06
[ "https://Stackoverflow.com/questions/5210941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/280476/" ]
EDIT: Misread your question as wanting to apply that change to the file you're working on. If you just want to run a shell command against a buffer, you can use `shell-command-on-region`, which is usually bound to `M-|`. If you're just trying to get to a particular line number, `M-x goto-line` works. I bind that to `C-x C-l` by putting `(define-key global-map "\C-x\C-l" 'goto-line)` in my `~/.emacs`. --- Try this (in your `~/.emacs` file): ``` ;;; Run a shell command on all text between the mark and the point and ;;; replace with the output. (defun shell-command-in-region (start end command &optional flag interactive) "Execute shell-command-on-region and replace the region with the output of the shell command." (interactive (list (region-beginning) (region-end) (read-from-minibuffer "Shell command in region: " nil nil nil 'shell-command-history) current-prefix-arg (prefix-numeric-value current-prefix-arg))) (shell-command-on-region (point) (mark) command t) ) (define-key esc-map "#" 'shell-command-in-region) ``` Invoke it by selecting a region you want to operate on and then doing `M-#`.
If you always want the buffer's file name to be inserted for the shell command, you can use this advice: ``` (defadvice read-shell-command (before read-shell-command-with-filename activate) "force the initial contents to contain the buffer's filename" (if (and (null (ad-get-arg 1)) buffer-file-name) (ad-set-arg 1 buffer-file-name))) ``` Once you've added the above code, `M-x shell-command` will always start with the buffer's file name, so you can use it in the command.
5,210,941
I am looking for equivalent of following vi command **:! nl %** this runs nl command on currently open file What is emacs way to detect name of open file ? M-X shell-commnad nl I am not able find determine value of current open/buffer and substitute. Thx/Mahesh
2011/03/06
[ "https://Stackoverflow.com/questions/5210941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/280476/" ]
EDIT: Misread your question as wanting to apply that change to the file you're working on. If you just want to run a shell command against a buffer, you can use `shell-command-on-region`, which is usually bound to `M-|`. If you're just trying to get to a particular line number, `M-x goto-line` works. I bind that to `C-x C-l` by putting `(define-key global-map "\C-x\C-l" 'goto-line)` in my `~/.emacs`. --- Try this (in your `~/.emacs` file): ``` ;;; Run a shell command on all text between the mark and the point and ;;; replace with the output. (defun shell-command-in-region (start end command &optional flag interactive) "Execute shell-command-on-region and replace the region with the output of the shell command." (interactive (list (region-beginning) (region-end) (read-from-minibuffer "Shell command in region: " nil nil nil 'shell-command-history) current-prefix-arg (prefix-numeric-value current-prefix-arg))) (shell-command-on-region (point) (mark) command t) ) (define-key esc-map "#" 'shell-command-in-region) ``` Invoke it by selecting a region you want to operate on and then doing `M-#`.
I use this: ``` (defun my-shell-command-on-current-file (command &optional output-buffer error-buffer) "Run a shell command on the current file (or marked dired files). In the shell command, the file(s) will be substituted wherever a '%' is." (interactive (list (read-from-minibuffer "Shell command: " nil nil nil 'shell-command-history) current-prefix-arg shell-command-default-error-buffer)) (cond ((buffer-file-name) (setq command (replace-regexp-in-string "%" (buffer-file-name) command nil t))) ((and (equal major-mode 'dired-mode) (save-excursion (dired-move-to-filename))) (setq command (replace-regexp-in-string "%" (mapconcat 'identity (dired-get-marked-files) " ") command nil t)))) (shell-command command output-buffer error-buffer)) (global-set-key (kbd "M-!") 'my-shell-command-on-current-file) ``` Then you can do `M-! nl %`
56,448,276
I'm doing some R&D with a power BI Visual Studio solution and I'm struggling to programmatically embed content. I have the Power BI Pro trial. From the [Embed Setup](https://app.powerbi.com/embedsetup) webpage, I created an application ("User owns Data" with sample data) and downloaded the sample VS solution which comes configured with the GUIDs for the app that was just created. The app appears in my Power BI web interface and when I run the VS web app, I get three buttons (embed report | embed dashboard | embed tile). This works - I can view the embedded report. My problem is when I install an app using the Power BI interface and then try to run my VS project using the appId of the app I just installed. For example - I installed the Github app and chose to use sample data. If I plug in the appId, workspace Id and report Id into my VS project, I get the following message when I run it and click the "Embed Report" button ``` AADSTS700016: Application with identifier '5c7d26d1-006d-43ac-9eb7-6aa3e1f6b364' was not found in the directory 'foo.onmicrosoft.com'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Trace ID: e77376aa-b7ca-4c09-9184-31f96eea9800 Correlation ID: d42a0b9c-c93d-4601-87d6-05d9cca70e0d Timestamp: 2019-06-04 15:59:58Z ``` Why is it that an app I created using the "Embed Setup" page works, but a different app's Ids fail with that error? I am using the same login credentials in the VS project as I am logging into the Power BI website with, as well as when I created an app with the "Embed Setup" page. Could it be that it is looking for an app that is registered in my Azure portal under the Active directory > App Registrations? If so, why does the other Power BI app work (Embed Setup route)? When I tested creating an app using "App Owns Data", the application was registered in my Azure AD As a side note - is there an easy way to get app, workspace and report Ids for an app? AppId is easy enough to grab from the URL, but workspace Id never seems to appear **UPDATE** After using the 'onboarding embed tool' as suggested @Andrey, I do see the application registered in Azure, but if I replace the `applicationId` web.config key with the Id of the Azure application, I get a different error message (below). I'm confident that the `applicationId` int the web.config of the generated project is specifically the (Power BI) App Id and not the Azure Application Id (not confusing at all, Microsoft!). Using the Azure Application Id, I get the following error: ``` Error AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'. Trace ID: 5e8391c2-4681-4c8e-9294-a99fd56dbb00 Correlation ID: 10d48927-d5ec-45bd-a5b3-e9c1e147f97c Timestamp: 2019-06-05 15:29:44Z ``` I feel like there is documentation that I need but can't find. I've created the Application that appears in Azure (I had done this before, but could not find any connection between this application and my PowerBI page). I've created apps, workspaces, and reports in Power BI. All I want to do is use the .Net SDK to pull in visualisations from a specific Power BI installation i.e. insert a visualisation of a client's data onto their website. I'll keep digging and update when I find a solution
2019/06/04
[ "https://Stackoverflow.com/questions/56448276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2261245/" ]
You are mixing two different "app ids". First app ID (also called client ID) is the one that you are registering in the onboarding embed tool (<https://dev.powerbi.com/apps>), which I believe is what you called "Embed Setup" (or embed setup is something on top of that). This app registrations will be visible in Azure AD after that. The other "app" that you mention is "[Power BI App](https://learn.microsoft.com/en-us/power-bi/service-create-distribute-apps)", i.e. a collection of reports that are packed together in an app. These two "apps" are completely different and you can't use the ID of the later one when embedding Power BI elements. When you open a report saved in a workspace, the URL will be in the following format: ``` https://app.powerbi.com/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/reports/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/ReportSection ``` First guid (the x-es after `groups`) is the workspace ID (also called group ID). The later one (after `reports`) is the report ID. There is no "workspace and report Ids for an app", because your app (the one that you registered and is visible in Azure AD) can access various reports in various workspaces. The reports packed in a "Power BI app" should be embedded from their original workspace, not from the app.
I eventually found the [solution](https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/App%20Owns%20Data) I was looking for. Essentially you use the PowerBI C# SDK to authenticate and return your PowerBI data - like collections of reports, which you can then embed using the JS API ``` private async Task<AuthenticationResult> DoAuthentication() { AuthenticationResult authenticationResult = null; if (AuthenticationType.Equals("MasterUser")) { var authenticationContext = new AuthenticationContext(AuthorityUrl); // Authentication using master user credentials var credential = new UserPasswordCredential(Username, Password); authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential).Result; } else { // For app only authentication, we need the specific tenant id in the authority url var tenantSpecificURL = AuthorityUrl.Replace("common", Tenant); var authenticationContext = new AuthenticationContext(tenantSpecificURL); // Authentication using app credentials var credential = new ClientCredential(ApplicationId, ApplicationSecret); authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, credential); } return authenticationResult; } ``` then, to get a list of reports ``` public IList<Report> GetReportsByGroup(string groupId) { if (_reports == null) { var Client = new PowerBIClient(new Uri(ApiUrl), new TokenCredentials(AccessToken, "Bearer")); _reports = Client.Reports.GetReportsInGroup(groupId).Value; } return _reports; } ```
499,370
Mark Zuckerberg said, "Our mission has, really, always been to connect the world." My questions is: Can we say "Our mission ***is,*** really, always to connect the world"? What's the difference between "has always been" and "is always" in this context? Thank you for your help!
2019/05/22
[ "https://english.stackexchange.com/questions/499370", "https://english.stackexchange.com", "https://english.stackexchange.com/users/349045/" ]
"has always been" means that the mission was always like this in the past. "is always" is less emphatic about the past, and stresses the current and future mission. If the mission were actually changing significantly, this could be made even clearer by saying "is now".
When you use: "has....to connect" it means their mission is trying continuously to connect the world. On the other hand,when you use:"is.....to connect" it means their mission is made up to connect the world.
7,351,744
I would like to know if there is any built in function in python to break the string in to 2 parts, based on the last occurrence of a separator. for eg: consider the string "a b c,d,e,f" , after the split over separator ",", i want the output as "a b c,d,e" and "f". I know how to manipulate the string to get the desired output, but i want to know if there is any in built function in python.
2011/09/08
[ "https://Stackoverflow.com/questions/7351744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/809117/" ]
Use `rpartition(s)`. It does exactly that. You can also use `rsplit(s, 1)`.
``` >>> "a b c,d,e,f".rsplit(',',1) ['a b c,d,e', 'f'] ```
7,351,744
I would like to know if there is any built in function in python to break the string in to 2 parts, based on the last occurrence of a separator. for eg: consider the string "a b c,d,e,f" , after the split over separator ",", i want the output as "a b c,d,e" and "f". I know how to manipulate the string to get the desired output, but i want to know if there is any in built function in python.
2011/09/08
[ "https://Stackoverflow.com/questions/7351744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/809117/" ]
Use `rpartition(s)`. It does exactly that. You can also use `rsplit(s, 1)`.
You can split a string by the last occurrence of a separator with [`rsplit`](http://docs.python.org/library/stdtypes.html#str.rsplit): > > Returns a list of the words in the string, separated by the delimiter string (starting from right). > > > To split by the last comma: ``` >>> "a b c,d,e,f".rsplit(',', 1) ['a b c,d,e', 'f'] ```
3,522,062
I've written a two short programs that use anonymous pipes to communicate. The parent process shares the pipe handles by setting the standard IO handles for the child: ``` // -- Set STARTUPINFO for the spawned process ------------------------- ZeroMemory(&m_ChildSI, sizeof(STARTUPINFO)); GetStartupInfo(&m_ChildSI); m_ChildSI.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; m_ChildSI.wShowWindow = SW_HIDE; m_ChildSI.hStdError = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdOutput = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdInput = m_pipeParent.ReadPipeHandle(); ``` The child acquires a read pipe handle with a call to [GetStdHandle](http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx): ``` hReadPipe = GetStdHandle(STD_INPUT_HANDLE) ``` My question is: The pipe handles are created by the parent process that calls [CloseHandle](http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx)() on them, once parent and child have finished communication. Does the child also have to call CloseHandle() also? I was thinking that because these are the standard IO handles, that they'd be automatically deallocated when the process folds. thanks!
2010/08/19
[ "https://Stackoverflow.com/questions/3522062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I just read in the document [Pipe Handle Inheritance](http://msdn.microsoft.com/en-us/library/aa365782(v=VS.85).aspx) on MSDN that: "When the child has finished with the pipe, it should close the pipe handle by calling CloseHandle or by terminating, which automatically closes the handle."
Any handle can be left unclosed when application terminates, Windows will free resources automatically. But it is better practice to close them manually so everything is logical and coherent. Leaving handles opened can lead to bugs and leaks when the code is reused or modernized.
3,522,062
I've written a two short programs that use anonymous pipes to communicate. The parent process shares the pipe handles by setting the standard IO handles for the child: ``` // -- Set STARTUPINFO for the spawned process ------------------------- ZeroMemory(&m_ChildSI, sizeof(STARTUPINFO)); GetStartupInfo(&m_ChildSI); m_ChildSI.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; m_ChildSI.wShowWindow = SW_HIDE; m_ChildSI.hStdError = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdOutput = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdInput = m_pipeParent.ReadPipeHandle(); ``` The child acquires a read pipe handle with a call to [GetStdHandle](http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx): ``` hReadPipe = GetStdHandle(STD_INPUT_HANDLE) ``` My question is: The pipe handles are created by the parent process that calls [CloseHandle](http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx)() on them, once parent and child have finished communication. Does the child also have to call CloseHandle() also? I was thinking that because these are the standard IO handles, that they'd be automatically deallocated when the process folds. thanks!
2010/08/19
[ "https://Stackoverflow.com/questions/3522062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
On Win32, kernel objects such as pipes are references by one or more user mode handles. When all handles are closed, the underlying object can be closed. The handles in each process, while they might have the same value, and might refer to the same object, are different handles, and should be closed separately.
I just read in the document [Pipe Handle Inheritance](http://msdn.microsoft.com/en-us/library/aa365782(v=VS.85).aspx) on MSDN that: "When the child has finished with the pipe, it should close the pipe handle by calling CloseHandle or by terminating, which automatically closes the handle."
3,522,062
I've written a two short programs that use anonymous pipes to communicate. The parent process shares the pipe handles by setting the standard IO handles for the child: ``` // -- Set STARTUPINFO for the spawned process ------------------------- ZeroMemory(&m_ChildSI, sizeof(STARTUPINFO)); GetStartupInfo(&m_ChildSI); m_ChildSI.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; m_ChildSI.wShowWindow = SW_HIDE; m_ChildSI.hStdError = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdOutput = m_pipeChild.WritePipeHandle(); m_ChildSI.hStdInput = m_pipeParent.ReadPipeHandle(); ``` The child acquires a read pipe handle with a call to [GetStdHandle](http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx): ``` hReadPipe = GetStdHandle(STD_INPUT_HANDLE) ``` My question is: The pipe handles are created by the parent process that calls [CloseHandle](http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx)() on them, once parent and child have finished communication. Does the child also have to call CloseHandle() also? I was thinking that because these are the standard IO handles, that they'd be automatically deallocated when the process folds. thanks!
2010/08/19
[ "https://Stackoverflow.com/questions/3522062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
On Win32, kernel objects such as pipes are references by one or more user mode handles. When all handles are closed, the underlying object can be closed. The handles in each process, while they might have the same value, and might refer to the same object, are different handles, and should be closed separately.
Any handle can be left unclosed when application terminates, Windows will free resources automatically. But it is better practice to close them manually so everything is logical and coherent. Leaving handles opened can lead to bugs and leaks when the code is reused or modernized.
13,051,632
just switched from single to dual monitors have managed to utilise both screens with emacs by using `C-x 5 f` to open a file in a buffer in a new frame, i can drag that frame on to the 2nd monitor and enjoy my extra real-estate Prob I now have is how to efficiently switch between buffers in different frames I'm used to using `C-x o` to switch between buffers in a split frame on a single monitor but this doesn't work for multiple frames Having to use the more cumbersome `C-x 5 b <buf-name>` which is painful in comparison Anyone have any top-tips on how to make buffer switching more efficient across dual monitors? Ideally I would like to cycle across all buffers using a single simple keyboard shortcut regardless of frames
2012/10/24
[ "https://Stackoverflow.com/questions/13051632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041868/" ]
With separate frames, I use the following to get mac osx style "same-app" switching with cmd-backtick. If you're on linux / windows you could do the same thing with alt-tilda: ``` (defined-key global-map (kbd "M-`") 'other-frame) ``` I like this because it keeps the action of switching frames separate from switching buffers. With multiple screens, it's usually some kind of context switch when you want to change which one has focus.
Turning my comment above into an answer as it seems to be what the OP is after: ``` (defun other-window-visible () (interactive) (other-window 0 'visible)) (global-set-key "\C-xo" 'other-window-visible) ```
13,051,632
just switched from single to dual monitors have managed to utilise both screens with emacs by using `C-x 5 f` to open a file in a buffer in a new frame, i can drag that frame on to the 2nd monitor and enjoy my extra real-estate Prob I now have is how to efficiently switch between buffers in different frames I'm used to using `C-x o` to switch between buffers in a split frame on a single monitor but this doesn't work for multiple frames Having to use the more cumbersome `C-x 5 b <buf-name>` which is painful in comparison Anyone have any top-tips on how to make buffer switching more efficient across dual monitors? Ideally I would like to cycle across all buffers using a single simple keyboard shortcut regardless of frames
2012/10/24
[ "https://Stackoverflow.com/questions/13051632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041868/" ]
I'd expect `C-x 5 o` to switch to the other frame, tho I don't have such a dual-screen setup to verify.
Turning my comment above into an answer as it seems to be what the OP is after: ``` (defun other-window-visible () (interactive) (other-window 0 'visible)) (global-set-key "\C-xo" 'other-window-visible) ```
13,051,632
just switched from single to dual monitors have managed to utilise both screens with emacs by using `C-x 5 f` to open a file in a buffer in a new frame, i can drag that frame on to the 2nd monitor and enjoy my extra real-estate Prob I now have is how to efficiently switch between buffers in different frames I'm used to using `C-x o` to switch between buffers in a split frame on a single monitor but this doesn't work for multiple frames Having to use the more cumbersome `C-x 5 b <buf-name>` which is painful in comparison Anyone have any top-tips on how to make buffer switching more efficient across dual monitors? Ideally I would like to cycle across all buffers using a single simple keyboard shortcut regardless of frames
2012/10/24
[ "https://Stackoverflow.com/questions/13051632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041868/" ]
I'd expect `C-x 5 o` to switch to the other frame, tho I don't have such a dual-screen setup to verify.
With separate frames, I use the following to get mac osx style "same-app" switching with cmd-backtick. If you're on linux / windows you could do the same thing with alt-tilda: ``` (defined-key global-map (kbd "M-`") 'other-frame) ``` I like this because it keeps the action of switching frames separate from switching buffers. With multiple screens, it's usually some kind of context switch when you want to change which one has focus.
13,051,632
just switched from single to dual monitors have managed to utilise both screens with emacs by using `C-x 5 f` to open a file in a buffer in a new frame, i can drag that frame on to the 2nd monitor and enjoy my extra real-estate Prob I now have is how to efficiently switch between buffers in different frames I'm used to using `C-x o` to switch between buffers in a split frame on a single monitor but this doesn't work for multiple frames Having to use the more cumbersome `C-x 5 b <buf-name>` which is painful in comparison Anyone have any top-tips on how to make buffer switching more efficient across dual monitors? Ideally I would like to cycle across all buffers using a single simple keyboard shortcut regardless of frames
2012/10/24
[ "https://Stackoverflow.com/questions/13051632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041868/" ]
With separate frames, I use the following to get mac osx style "same-app" switching with cmd-backtick. If you're on linux / windows you could do the same thing with alt-tilda: ``` (defined-key global-map (kbd "M-`") 'other-frame) ``` I like this because it keeps the action of switching frames separate from switching buffers. With multiple screens, it's usually some kind of context switch when you want to change which one has focus.
Maybe ``` (global-set-key (kbd "C-x o") 'next-multiframe-window) ``` (Though as spike mentioned, I think keeping `C-x o` bound to `other-window` and binding `next-multiframe-window` to something different makes sense.)
13,051,632
just switched from single to dual monitors have managed to utilise both screens with emacs by using `C-x 5 f` to open a file in a buffer in a new frame, i can drag that frame on to the 2nd monitor and enjoy my extra real-estate Prob I now have is how to efficiently switch between buffers in different frames I'm used to using `C-x o` to switch between buffers in a split frame on a single monitor but this doesn't work for multiple frames Having to use the more cumbersome `C-x 5 b <buf-name>` which is painful in comparison Anyone have any top-tips on how to make buffer switching more efficient across dual monitors? Ideally I would like to cycle across all buffers using a single simple keyboard shortcut regardless of frames
2012/10/24
[ "https://Stackoverflow.com/questions/13051632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041868/" ]
I'd expect `C-x 5 o` to switch to the other frame, tho I don't have such a dual-screen setup to verify.
Maybe ``` (global-set-key (kbd "C-x o") 'next-multiframe-window) ``` (Though as spike mentioned, I think keeping `C-x o` bound to `other-window` and binding `next-multiframe-window` to something different makes sense.)
58,248,913
``` import csv price = [] score = [] numPrice = [] numScore = [] with open(r'C:\Users\Testing\Desktop\Test.csv') as f: reader = csv.DictReader(f) for row in reader: price.append(row['price']) score.append(row['helpfulness_score']) for item in price: numPrice.append(float(item)) for item in score: numScore.append(float(item)) finalDict = dict(zip(numScore,numPrice)) for k in finalDict: if k > 5: finalDict.pop(k) ``` How can I remove all key and values less than 5? Right now I get the error 'RuntimeError: dictionary changed size during iteration' And is there a way to make this more efficient?
2019/10/05
[ "https://Stackoverflow.com/questions/58248913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6016132/" ]
For starters the vector should be passed to the function by reference. Otherwise a redundant copy of the vector will be created. Moreover the parameter should be declared with constant reference because the vector itself is not changed in the function. For the sum you should use the type `long long int` because it is not excluded that there can be an overflow. This declaration ``` int length = sizeof(ar); ``` does not make sense. The variable `length` keeps the size of the object of the type `std::vector<int>` not the number of elements stored in the vector. So the function can be defined for example the following way ``` long long int simpleArraySum( const std::vector<int> & ar ) { long long int sum = 0; for ( const auto &item : ar ) sum += item; return sum; } ``` Another approach is to use the standard algorithm `std::accumulate` declared in the header `<numeric>`. For example ``` #include <vector> #include <iterator> #include <numeric> //... long long int simpleArraySum( const std::vector<int> & ar ) { return std::accumulate( std::begin( ar ), std::end( ar ), 0ll ); } ```
Use [`std::accumulate`](https://en.cppreference.com/w/cpp/algorithm/accumulate): ``` int simpleArraySum(vector<int> ar) { return std::accumulate(ar.begin(), ar.end(), 0); } ``` In any case, your `length` initialization is wrong, it should be: ``` int length = ar.size(); ``` If you are still having unexpected results, it is likely that you are either under/overflowing `sum` (likely, use a wider type) or that you have too many elements to fit in an `int` (unlikely, switch to `std::size_t` or use a range-for loop instead).
225,377
"For a celebrated actor, I was surprised at how ordinary he was." The "celebrated actor" refers, of course, to "he" (not "I"). However it seems to me the grammatical construction is wrong. By substituting the preposition "for" with "as" to read "As a celebrated actor, I was surprised at how ordinary he was," is now grammatically correct but drastically changes the meaning. How can I say what I want to say in plain conversational English?
2015/02/03
[ "https://english.stackexchange.com/questions/225377", "https://english.stackexchange.com", "https://english.stackexchange.com/users/108442/" ]
> > For a celebrated actor, I was surprised at how ordinary he was. > > > This is a [perfectly acceptable use of *for* indicating a comparison](http://dictionary.cambridge.org/dictionary/british/for#1-6), and it's pretty clear that *he* is the actor (although in theory it could refer to the *I*, in practice the choice of *for* over *as* would leave no doubt in the mind of the audience). If you wanted to make it doubly clear, you could change the order: > > I was surprised at how ordinary he was for a celebrated actor. > > >
In *writing*, I don't have a huge problem with your original formulation. I can't see a way to rearrange things that makes it clearer without making it more awkward. For *conversational* English though, its way too long-winded. If I was just talking to my buds, it would be more like, "I was shocked. He's just a regular guy, not some hoity-toity1 celebrity." 1 - Sprinkle expletives to taste.
225,377
"For a celebrated actor, I was surprised at how ordinary he was." The "celebrated actor" refers, of course, to "he" (not "I"). However it seems to me the grammatical construction is wrong. By substituting the preposition "for" with "as" to read "As a celebrated actor, I was surprised at how ordinary he was," is now grammatically correct but drastically changes the meaning. How can I say what I want to say in plain conversational English?
2015/02/03
[ "https://english.stackexchange.com/questions/225377", "https://english.stackexchange.com", "https://english.stackexchange.com/users/108442/" ]
> > For a celebrated actor, I was surprised at how ordinary he was. > > > This is a [perfectly acceptable use of *for* indicating a comparison](http://dictionary.cambridge.org/dictionary/british/for#1-6), and it's pretty clear that *he* is the actor (although in theory it could refer to the *I*, in practice the choice of *for* over *as* would leave no doubt in the mind of the audience). If you wanted to make it doubly clear, you could change the order: > > I was surprised at how ordinary he was for a celebrated actor. > > >
The way the sentence is written "for a celebrated actor" modifies "I", which is not the intended meaning. This is called a dangling modifier. The following sentences avoid this ambiguity: I was surprised that for a celebrated actor, he was pretty/rather/quite ordinary. I was surprised that he was such an ordinary guy, despite being a celebrated actor.
1,874,203
> > Writing $\left(\mathbf Z\big/2\oplus\mathbf Z\big/4\oplus\mathbf Z\big/8\right)\oplus\left(\mathbf Z\big/9\oplus\mathbf Z\big/27\right)$ in a different way > > > If $M$ is equal to above how can I find the ideals,(of course of the form $m\mathbf Z$) $I\_1,\dots I\_n$ such that $I\_1\supset I\_2\supset \dots I\_n$ and $M\simeq\mathbf Z\big/I\_1\oplus\dots\oplus\mathbf Z\big /I\_n$ (there should be only $1$ way of selecting such ideals, but I don't know how)
2016/07/28
[ "https://math.stackexchange.com/questions/1874203", "https://math.stackexchange.com", "https://math.stackexchange.com/users/337759/" ]
We have: $$M \cong Z/2 \oplus( Z/4 \oplus Z/9) \oplus (Z/8 \oplus Z/27) \cong Z/2 \oplus Z/36 \oplus Z/216$$
By Chinese Remainder Theorem if $I\_k$ and $I\_j$ are relatively prime ideals in a commutative ring $R$ then $R/I\_kI\_j \simeq R/I\_k \oplus R/I\_k$ (and one may generalize by induction). In your case there are many ways to split up $M$. You could write $$M \simeq \mathbb{Z}/2\mathbb{Z} \oplus \mathbb{Z}/72\mathbb{Z} \oplus \mathbb{Z}/108\mathbb{Z}$$
1,874,203
> > Writing $\left(\mathbf Z\big/2\oplus\mathbf Z\big/4\oplus\mathbf Z\big/8\right)\oplus\left(\mathbf Z\big/9\oplus\mathbf Z\big/27\right)$ in a different way > > > If $M$ is equal to above how can I find the ideals,(of course of the form $m\mathbf Z$) $I\_1,\dots I\_n$ such that $I\_1\supset I\_2\supset \dots I\_n$ and $M\simeq\mathbf Z\big/I\_1\oplus\dots\oplus\mathbf Z\big /I\_n$ (there should be only $1$ way of selecting such ideals, but I don't know how)
2016/07/28
[ "https://math.stackexchange.com/questions/1874203", "https://math.stackexchange.com", "https://math.stackexchange.com/users/337759/" ]
We have: $$M \cong Z/2 \oplus( Z/4 \oplus Z/9) \oplus (Z/8 \oplus Z/27) \cong Z/2 \oplus Z/36 \oplus Z/216$$
Just list the powers of each prime in increasing order right justified and multiply them vertically (using the Chinese Remainder Theorem): \begin{array}{rrr} 2 & 4 & 8 \\ & 9 & 27 \\ \hline 2 & 36 & 216 \\ \end{array} This gives the invariant factors $\mathbb Z/2 \oplus \mathbb Z/36 \oplus \mathbb Z/216$.
1,874,203
> > Writing $\left(\mathbf Z\big/2\oplus\mathbf Z\big/4\oplus\mathbf Z\big/8\right)\oplus\left(\mathbf Z\big/9\oplus\mathbf Z\big/27\right)$ in a different way > > > If $M$ is equal to above how can I find the ideals,(of course of the form $m\mathbf Z$) $I\_1,\dots I\_n$ such that $I\_1\supset I\_2\supset \dots I\_n$ and $M\simeq\mathbf Z\big/I\_1\oplus\dots\oplus\mathbf Z\big /I\_n$ (there should be only $1$ way of selecting such ideals, but I don't know how)
2016/07/28
[ "https://math.stackexchange.com/questions/1874203", "https://math.stackexchange.com", "https://math.stackexchange.com/users/337759/" ]
Just list the powers of each prime in increasing order right justified and multiply them vertically (using the Chinese Remainder Theorem): \begin{array}{rrr} 2 & 4 & 8 \\ & 9 & 27 \\ \hline 2 & 36 & 216 \\ \end{array} This gives the invariant factors $\mathbb Z/2 \oplus \mathbb Z/36 \oplus \mathbb Z/216$.
By Chinese Remainder Theorem if $I\_k$ and $I\_j$ are relatively prime ideals in a commutative ring $R$ then $R/I\_kI\_j \simeq R/I\_k \oplus R/I\_k$ (and one may generalize by induction). In your case there are many ways to split up $M$. You could write $$M \simeq \mathbb{Z}/2\mathbb{Z} \oplus \mathbb{Z}/72\mathbb{Z} \oplus \mathbb{Z}/108\mathbb{Z}$$
5,104,534
Can someone explain me IntelliJ IDEA's workflow of compilation, deployment and packaging with binded maven project ? I've encountered some misunderstanding when I'm starting tomcat server via IDEA's debug mode. For example I have one artifact - war archive. As I understand when I'm running debug mode - IDEA recompiles and updates changed code into war-archive. But what happens with packaged maven artifact ? Does IntelliJ updates it ? Or I have to set 'Buld maven before startup' option to be sure that changed code will be uploaded to environment ?
2011/02/24
[ "https://Stackoverflow.com/questions/5104534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71420/" ]
Intelli J doesn't use maven to build the project it uses its own build process. It uses the pom file as a description of the project. This means a couple of things, if you want to build an artifact such as a war file when running in tomcat then all you have to do is tell IntelliJ to build the war in the Run/Debug Configurations dialog. IntelliJ will automatically build any artifacts you specify under the deployment tab of your run/debug configuration. So if you specify the exploded war it will build the exploded war, if you specify the regular war it will build the regular war. Occasionally people need to run custom plugins or build targets in which case you can configure IntelliJ to run the custom maven goals. You can also tell intellIJ to run the maven package goal rather than build the artifact. IntelliJ will deploy whatever is under the target directory to tomcat. The important take away is IntellIJ is using two separate build systems. You need to tell each build system what to do. And you need to tell IntelliJ which build system to use for what. IntelliJ will by default use it's own build system once a project has been imported, unless you tell it to use maven for something. While IntelliJ will build the artifact you specify in the pom file it won't do things like deploy them your artifact repository (local or other wise) unless you click on the deploy target in the Maven tools window. Also if you change your pom file and don't have auto re-import enabled those changes won't be reflected in your project until you click the force re-import option from the maven tools window.
I think you are looking for that. [Maven IDEA Plugin](http://maven.apache.org/plugins/maven-idea-plugin/) The IDEA Plugin is used to generate files (ipr, iml, and iws) for a project so you can work on it using the IDE, IntelliJ IDEA. Hopes that helps
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
Probably whey you 'accidentally deleted' your project, you only deleted it from the Eclipse workspace, but not from the actual workspace folder on your hard-drive (as other people pointed out, Eclipse can arbitrarily map workspace projects to files on disk, so it is possible for a project to be 'deleted' from your Eclipse workspace but still exist on disk. The good news is the files you deleted are actually still there. Instead of importing your project from a zip, you may just want to import those files from the workspace folder back into your Eclipse workspace.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Make sure it is really not in workspace, also if there aren't any other projects with the same name. If not, just delete the `.metadata` folder or create a new workspace.
the problem is that when you delete a project maybe sts only close it. Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
I get this issue from time to time. Usually I just open a new workspace but sounds like you don't want to loose other projects. I simply open the.project file in my project and change the name of the project in name tag. Good Luck!
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
Generally this kind of problems not occurred you can go to Project option and clean and than restart STS. May be STS is not synched with the latest configured project.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Probably whey you 'accidentally deleted' your project, you only deleted it from the Eclipse workspace, but not from the actual workspace folder on your hard-drive (as other people pointed out, Eclipse can arbitrarily map workspace projects to files on disk, so it is possible for a project to be 'deleted' from your Eclipse workspace but still exist on disk. The good news is the files you deleted are actually still there. Instead of importing your project from a zip, you may just want to import those files from the workspace folder back into your Eclipse workspace.
the problem is that when you delete a project maybe sts only close it. Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
Make sure it is really not in workspace, also if there aren't any other projects with the same name. If not, just delete the `.metadata` folder or create a new workspace.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Generally this kind of problems not occurred you can go to Project option and clean and than restart STS. May be STS is not synched with the latest configured project.
the problem is that when you delete a project maybe sts only close it. Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
When you launch Spring Tools Suite, it will ask you to **Select directory as workspace** as below: [![spring tools suite launcher](https://i.stack.imgur.com/RAdzR.png)](https://i.stack.imgur.com/RAdzR.png) If the directory you selected here (i.e., workspace directory) is the same as the directory where the project that you are going to import resides, then you will get **Some projects cannot be imported because they already exist in the workspace**. Therefore, to solve the issue, * Close Spring Tool Suite * Create a new directory * Launch Spring Tool Suite again * And, select that as your workspace * Launch the application and you would be able to import as you mentioned in your question It solved my problem. Hope it helps.. Happy Coding!!
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I get this issue from time to time. Usually I just open a new workspace but sounds like you don't want to loose other projects. I simply open the.project file in my project and change the name of the project in name tag. Good Luck!
the problem is that when you delete a project maybe sts only close it. Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.
28,507,487
Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says *Some projects cannot be imported because they already exist in the workspace* Following is the way I tried to import file->import->general->existing projects into worspace->select archive file and after browse when I select the zip project *Some projects cannot be imported because they already exist in the workspace* and the finish button and next button are in disabled state.Please help me
2015/02/13
[ "https://Stackoverflow.com/questions/28507487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc. To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard. It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.
Check if you still have the project in folder of the workspace on disk. You may have deleted in STS, without checking 'Delete on disk'. So, the project may be still there in the workspace folder though its deleted in STS.
59,532,836
I have a String like this: ``` Test+${user}100,very important text ``` I am trying to remove the part `+${user}100` Why my code isn't working? ``` noSpecialSigns = noSpecialSigns.replaceAll("\\+$\\{user}\\d",""); ```
2019/12/30
[ "https://Stackoverflow.com/questions/59532836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5359846/" ]
``` @Document(collation="company") ``` This looks like a typo and the cause of your issue. You try to set collection name, but instead of [`collection`](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/Document.html#collection--) you use [`collation`](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/Document.html#collation--) property: <https://docs.mongodb.com/manual/reference/collation/> The correct form of annotation would be: ``` @Document(collection = "company") public class Company { // ... } ``` Or simpler – since `value` is an alias for `collection`: ``` @Document("company") public class Company { // ... } ``` You can even completely omit collection name. In that case Spring will use class name as collection name: ``` @Document // name of collection wil be "company", as per class name public class Company { // ... } ``` The last example is why this was working for you with e.g. count queries, even though you did not provide collection name explicitly.
This sometime happens when you miss annotated entity class with annotation @Document * Wrong @Document(collation = "department") * Right @Document(collection = "department")
59,532,836
I have a String like this: ``` Test+${user}100,very important text ``` I am trying to remove the part `+${user}100` Why my code isn't working? ``` noSpecialSigns = noSpecialSigns.replaceAll("\\+$\\{user}\\d",""); ```
2019/12/30
[ "https://Stackoverflow.com/questions/59532836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5359846/" ]
``` @Document(collation="company") ``` This looks like a typo and the cause of your issue. You try to set collection name, but instead of [`collection`](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/Document.html#collection--) you use [`collation`](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/Document.html#collation--) property: <https://docs.mongodb.com/manual/reference/collation/> The correct form of annotation would be: ``` @Document(collection = "company") public class Company { // ... } ``` Or simpler – since `value` is an alias for `collection`: ``` @Document("company") public class Company { // ... } ``` You can even completely omit collection name. In that case Spring will use class name as collection name: ``` @Document // name of collection wil be "company", as per class name public class Company { // ... } ``` The last example is why this was working for you with e.g. count queries, even though you did not provide collection name explicitly.
On my side i used `@Document(collection = "products")` and worked. Use `collection` instead of `collation` in `@Document`.
59,532,836
I have a String like this: ``` Test+${user}100,very important text ``` I am trying to remove the part `+${user}100` Why my code isn't working? ``` noSpecialSigns = noSpecialSigns.replaceAll("\\+$\\{user}\\d",""); ```
2019/12/30
[ "https://Stackoverflow.com/questions/59532836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5359846/" ]
This sometime happens when you miss annotated entity class with annotation @Document * Wrong @Document(collation = "department") * Right @Document(collection = "department")
On my side i used `@Document(collection = "products")` and worked. Use `collection` instead of `collation` in `@Document`.
134,179
How to get product **attribute group** in magento 2 from a **attribute set**. I want to show attribute on **listing page** by using a group so i can add more attributes in future
2016/09/01
[ "https://magento.stackexchange.com/questions/134179", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/40643/" ]
you simply get all product attribute by `$product->getAttributes();` ``` $productAttributes=$product->getAttributes(); $group_id=9; $attributeSetId=4; foreach ($productAttributes as $attribute) { if ($attribute->isInGroup($attributeSetId, $group_id)) { echo $attribute->getFrontendLabel().' : '.$attribute->getFrontend()->getValue($product).'<br />'; } } ```
We can use `getAttributeGroupId` method: *vendor/magento/module-catalog/Model/Config.php* ``` public function getAttributeGroupId($attributeSetId, $name) { ...... } ``` We can get attribute group id: ``` $obj = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\Config $config */ $config= $obj->get('Magento\Catalog\Model\Config'); $attributeGroupId = $config->getAttributeGroupId(1, 'General'); ``` Should take a look `eav_attribute_group`.
11,984,312
I am currently taking a course that gives an introduction to project planning. It is mostly about how to draw UML diagrams (blegh), but also has a few other topics. One part in particular keeps bugging me. In the course they describe a method for going from a set of requirements to an initial class diagram, but everything about the method gives me this feeling that it is most definitely not the way to go. Let me first give an example before proceeding. Let's consider a system that manages a greenhouse company. The company has multiple greenhouses, and every employee is assigned to his/her own greenhouse. A greenhouse has a location and a type of plant being grown in there. An employee has a name and phone number. Here's what according to the course's method the class diagram would look like: ![enter image description here](https://i.stack.imgur.com/OW5Pm.png) To me this looks like a database layout adapted for code. When I go about designing a program, I try to identify major abstractions. Like all the code that interacts with the database or the code that is responsible for the GUI are all different parts of the system. That would be what I consider to be an initial class diagram. I simply can not imagine that this is a common way to start designing the architecture of a project. The classes look ugly, since if you take a slightly larger example the classes will be flooded with responsibilities. To me they look like data objects that have functionality to them they shouldn't have. It does not give me a clue on how to continue from here and get a general architecture going. Everything about it seems obsolete. All I want to know if there's someone out there that can tell me if this is a common way to get a first class diagram on paper for reasons I am overlooking.
2012/08/16
[ "https://Stackoverflow.com/questions/11984312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383632/" ]
I would say it's reasonable to start with a logical model that's free of implementation constraints. That logical model is not necessarily concerned with physical implementation details (e.g. whether or not to use a database, what type of database, OS / UI choice, etc.) and thus represents just "real" business domain objects and processes. The similarity to a potential database implementation shouldn't be surprising for the simple example. By understanding your business domain (through the logical model you've started to construct), you will be better placed to subsequently identify, for example, which architectural patterns are appropriate, what screens you need to build, and database elements to design. Possibly, there will be another part of the course that will aid you in this stage. In practice, you will often know that you're intending to implement, say, a web-based application using MVC with a back-end database, and may look to model the implementation classes in parallel with your business items. For your course to use a method that emphasises the distinction between logical and physical stages doesn't sound unreasonable.
> > When I go about designing a program, I try to identify major > abstractions > > > Same principle in UML as well. You represent abstractions and their relationships and due to existing Visual Tools you can do a presentation of a system to stakeholders or even generate automatically stubs from your design.
383,487
I have a tab delimited file with information in it about genetic material. Some information is cut into a smaller tab file with some of the columns extracted, and uniq is used to ensure there are no duplicates. A count is stored which is important later down the pipeline. I want to change the basis of the uniq function from simply being based on the sequence in one field, to a regex from within another field. The field I want to extract from is in this format: ``` 14:50065421-50065521:12397472_t14_w100_x1 ``` but the bit after the 2nd colon changes depending on the file input. I want to use uniq on the basis of the first half, so: ``` 14:50065421-50065521 ``` I've tested the regex '((^[0-9]{0,2}|x|y|MT):[0-9]{0,9}-[0-9]{0,9}:)' and it works on a small sample of the data. I've found some ways using grep and a perl script which both work to remove rows based on the regex but none of them provide the count (which is why uniq is much more ideal). Is there any way to use a regex with uniq? Or is there a better way which will also store the count of those removed? The current code is this: ``` cat ${TAB_FILE} | \ sed -e '1,2d' | \ cut -f3,4 | \ sort -k1 -u | \ sort -k2 | \ uniq -cf1| \ sort -rn > t1 cat ${TAB_FILE} | \ sed -e '1,2d' | \ awk {'print $3"\t "$6"\t" $7"\t "$4'} | \ sort -k4 > t2 awk 'FNR==NR {C[$2]=$1;next}FNR==1 \ {print "Count Chromosome:Positions:QNAME Sequence Exon Transcript_ID"; next}$1 in C \ {print C[$1], $1, $4, $3, $2}' t1 t2 > t3 cat t3 | awk '{print "//NODECLASS\t\"" $2"_"$1 "\"\t\"Exon " $4 "\"\t\"" $5 "\""}' ``` From the first step it is column 1 of the cut that I would like to base my regex on, instead of using column 2. Any help would be greatly appreciated, please feel free to ask if you need me to clarify anything. Example of tab file: ``` queryHits subjectHits readname readSeq geneid transcriptid exonnumber genename biotype 350851 1 14:50065421-50065521:12397472_t14_w100_x1 CGCTGCCAGCTGCGCGCTCGGGGGAAAAGACGTTGCGCCCCCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCA ENSG00000165501 ENST00000298288 1 LRR1 protein_coding 350851 5 14:50065421-50065521:12397472_t14_w100_x1 CGCTGCCAGCTGCGCGCTCGGGGGAAAAGACGTTGCGCCCCCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCA ENSG00000165501 ENST00000318317 1 LRR1 protein_coding 350851 8 14:50065421-50065521:12397472_t14_w100_x1 CGCTGCCAGCTGCGCGCTCGGGGGAAAAGACGTTGCGCCCCCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCA ENSG00000165501 ENST00000554869 1 LRR1 protein_coding 350852 1 14:50065461-50065561:12655987_t14_w100_x1 CCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAG ENSG00000165501 ENST00000298288 1 LRR1 protein_coding 350852 5 14:50065461-50065561:12655987_t14_w100_x1 CCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAG ENSG00000165501 ENST00000318317 1 LRR1 protein_coding 350852 8 14:50065461-50065561:12655987_t14_w100_x1 CCGCCGACTGCCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAG ENSG00000165501 ENST00000554869 1 LRR1 protein_coding 350853 1 14:50065471-50065571:22679947_t13_w100_x1 CCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAGCCGTTTCCCG ENSG00000165501 ENST00000298288 1 LRR1 protein_coding 350853 5 14:50065471-50065571:22679947_t13_w100_x1 CCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAGCCGTTTCCCG ENSG00000165501 ENST00000318317 1 LRR1 protein_coding 350853 8 14:50065471-50065571:22679947_t13_w100_x1 CCGGTTTCCCGGGCGCGAGCCCGGATCCAGGTGGTCAGTCCCGGTACGCAACCACGGCGAGAACCCGGCCCTGCTAAGGGAGAAGGGAAGCCGTTTCCCG ENSG00000165501 ENST00000554869 1 LRR1 protein_coding ``` Example of output file where uniq hasn't been used, I want to be able to remove the duplicates such as those on lines 4, 5, and 6, or 8, 9, and 10: ``` //NODECLASS "Chromosome:Positions:QNAME_Count" "Exon Exon" "Transcript_ID" //NODECLASS "14:50067283-50067383:20149917_t14_w100_x1_1" "Exon 1" "ENST00000557531" //NODECLASS "14:50067284-50067366:14257122_t14_w100_x1_2" "Exon 1" "ENST00000557531" //NODECLASS "14:50067285-50067385:2072777_t12_w100_x1_1" "Exon 1" "ENST00000557531" //NODECLASS "14:50074262-50074362:4355312_t12_w100_x1_1" "Exon 3" "ENST00000298288" //NODECLASS "14:50074262-50074362:4355312_t12_w100_x1_1" "Exon 4" "ENST00000540712" //NODECLASS "14:50074262-50074362:4355312_t12_w100_x1_1" "Exon 4" "ENST00000554869" //NODECLASS "14:50067286-50067386:15839225_t12_w100_x1_3" "Exon 1" "ENST00000557531" //NODECLASS "14:50074263-50074363:8914169_t11_w100_x1_1" "Exon 3" "ENST00000298288" //NODECLASS "14:50074263-50074363:8914169_t11_w100_x1_1" "Exon 4" "ENST00000540712" //NODECLASS "14:50074263-50074363:8914169_t11_w100_x1_1" "Exon 4" "ENST00000554869" //NODECLASS "14:50067287-50067387:5439923_t13_w100_x1_1" "Exon 1" "ENST00000557531" //NODECLASS "14:50067287-50067387:14106336_t12_w100_x1_3" "Exon 1" "ENST00000557531" //NODECLASS "14:50074404-50074504:15492363_t11_w100_x1_1" "Exon 3" "ENST00000298288" //NODECLASS "14:50074404-50074504:15492363_t11_w100_x1_1" "Exon 4" "ENST00000540712" //NODECLASS "14:50074404-50074504:15492363_t11_w100_x1_1" "Exon 4" "ENST00000554869" //NODECLASS "14:50074135-50074235:11346262_t11_w100_x1_2" "Exon 3" "ENST00000298288" ```
2017/08/02
[ "https://unix.stackexchange.com/questions/383487", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/234238/" ]
`-cmin` and `-ls` are *predicates* that are part of the *expression*, not options. Note that you can mark the end of options with `--`, but predicates are still allowed after it. With GNU `find`, which allows omitting *paths*: ``` find -- -L ``` Would complain about the *unknown -L predicate* (even though `-L` is a valid *option* which actually has a `-follow` equivalent *predicate*). That's why while ``` find "$file" ``` like ``` wc "$file" ``` doesn't work correctly when `$file` starts with `-`. Doing `wc -- "$file"` fixes it for `wc` (except in the special case of `file='-'`) but not for `find -- "$file"`. FreeBSD `find` has `find -f "$file"` for that.
The `find` command is very old, dating back to [Unix V5](http://minnie.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s1/find.c). At the time, the command line syntax conventions weren't as firmly established as they are now. A few old programs deviate from these conventions. Originally, `find` didn't have options. It expected the first argument to be a directory to traverse, and the remaining arguments to be an expression. Evaluating the expression for each file indicates whether this file should be printed (or more generally indicates what to do with the file). The expression is made from operators and their operands. Find operators begin with `-` (except for a few punctuation symbols) for the same reason options begin with `-`: because it doesn't have any special meaning in the shell so it's easy to type, yet it is distinguishable from file names because reasonable people don't start a file name with `-`. Operators aren't options. Why? Because they don't have the syntax of options… They have the spelling of options (beginning with `-`) but they're used in a different context. Later `find` acquired a few things that could be considered options — global settings like `-depth` that don't really have any business being in the expression. These were put in the expression for consistency, because `find` didn't have options. Still later, `find` acquired a few options, with the usual option syntax: options before non-options. This was done to be consistent with many other programs that support the same options (`-H` and `-L` to configure symlink behavior). The synopsis tells you that `-H`, `-L` and the like *can* come first, then the path(s), then the expression. The synopsis syntax can't always express all possibilities. If it was complete, it would be unreadable, so all you know is that it gives one possibility. You need to read further if you want to know exactly what is possible and what isn't. For example, `-H`, `-L`, etc. can come in any order, as long as they're before the path.
16,735,721
I've been looking around and everyone says the solution is to take "send" out of the following code: `if ( empty( $value ) ) $value = __('send', 'wpcf7');` That's the first thing I did after I replaced my submit button with an image but 'Send' is still overlaid the submit button image, and I'm at a loss as to what to do. This is what my CSS code looks like: ``` /* Shortcode handler */ add_action( 'init', 'wpcf7_add_shortcode_submit', 5 ); function wpcf7_add_shortcode_submit() { wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); } function wpcf7_submit_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); $class = wpcf7_form_controls_class( $tag->type ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) $value = __(' ', 'wpcf7'); $atts['class'] = 'button'; $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<input %1$s />', $atts ); return $html; } ``` NB: I've taken "send" out, leaving a space like ' ' instead of '', in fact I've tried every combination but nothing. Would it have to do with how I created the submit button image? In the latest version of CF7 I had to add `$atts['class'] = 'button';` into my submit.php before adding the following into my CSS ``` .button { background-image: url("imageurl.gif"); background-repeat: no-repeat; margin: 0px 0px 0px 0px; padding: 0px; float: left; height: 35px; width: 133px; border: 0 none; cursor: pointer; } ``` Any help would be greatly appreciated.
2013/05/24
[ "https://Stackoverflow.com/questions/16735721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2259760/" ]
No Need to touch the code to change the message of the submit button. Go into your wp dashboard < Contact and change this line ``` <p>[submit "Send"]</p> ``` to ``` <p>[submit "Anything you would like here"]</p> ```
Trial and error. Replace everywhere it says "Submit" with something else like "Test" and change each one until it works. Then you will know exactly which one to change.
16,735,721
I've been looking around and everyone says the solution is to take "send" out of the following code: `if ( empty( $value ) ) $value = __('send', 'wpcf7');` That's the first thing I did after I replaced my submit button with an image but 'Send' is still overlaid the submit button image, and I'm at a loss as to what to do. This is what my CSS code looks like: ``` /* Shortcode handler */ add_action( 'init', 'wpcf7_add_shortcode_submit', 5 ); function wpcf7_add_shortcode_submit() { wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); } function wpcf7_submit_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); $class = wpcf7_form_controls_class( $tag->type ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) $value = __(' ', 'wpcf7'); $atts['class'] = 'button'; $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<input %1$s />', $atts ); return $html; } ``` NB: I've taken "send" out, leaving a space like ' ' instead of '', in fact I've tried every combination but nothing. Would it have to do with how I created the submit button image? In the latest version of CF7 I had to add `$atts['class'] = 'button';` into my submit.php before adding the following into my CSS ``` .button { background-image: url("imageurl.gif"); background-repeat: no-repeat; margin: 0px 0px 0px 0px; padding: 0px; float: left; height: 35px; width: 133px; border: 0 none; cursor: pointer; } ``` Any help would be greatly appreciated.
2013/05/24
[ "https://Stackoverflow.com/questions/16735721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2259760/" ]
If you're looking for a blank button using Contact Form 7 ``` [submit "&nbsp;"] ```
Trial and error. Replace everywhere it says "Submit" with something else like "Test" and change each one until it works. Then you will know exactly which one to change.
16,735,721
I've been looking around and everyone says the solution is to take "send" out of the following code: `if ( empty( $value ) ) $value = __('send', 'wpcf7');` That's the first thing I did after I replaced my submit button with an image but 'Send' is still overlaid the submit button image, and I'm at a loss as to what to do. This is what my CSS code looks like: ``` /* Shortcode handler */ add_action( 'init', 'wpcf7_add_shortcode_submit', 5 ); function wpcf7_add_shortcode_submit() { wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); } function wpcf7_submit_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); $class = wpcf7_form_controls_class( $tag->type ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) $value = __(' ', 'wpcf7'); $atts['class'] = 'button'; $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<input %1$s />', $atts ); return $html; } ``` NB: I've taken "send" out, leaving a space like ' ' instead of '', in fact I've tried every combination but nothing. Would it have to do with how I created the submit button image? In the latest version of CF7 I had to add `$atts['class'] = 'button';` into my submit.php before adding the following into my CSS ``` .button { background-image: url("imageurl.gif"); background-repeat: no-repeat; margin: 0px 0px 0px 0px; padding: 0px; float: left; height: 35px; width: 133px; border: 0 none; cursor: pointer; } ``` Any help would be greatly appreciated.
2013/05/24
[ "https://Stackoverflow.com/questions/16735721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2259760/" ]
No Need to touch the code to change the message of the submit button. Go into your wp dashboard < Contact and change this line ``` <p>[submit "Send"]</p> ``` to ``` <p>[submit "Anything you would like here"]</p> ```
In the the latest version (at the time of writing) in modules submit.php At line 27 Change ``` if ( empty( $value ) ) $value = __( 'Send', 'contact-form-7' ); ``` to ``` if ( empty( $value ) ) $value = __( ' ', 'contact-form-7' ); ```
16,735,721
I've been looking around and everyone says the solution is to take "send" out of the following code: `if ( empty( $value ) ) $value = __('send', 'wpcf7');` That's the first thing I did after I replaced my submit button with an image but 'Send' is still overlaid the submit button image, and I'm at a loss as to what to do. This is what my CSS code looks like: ``` /* Shortcode handler */ add_action( 'init', 'wpcf7_add_shortcode_submit', 5 ); function wpcf7_add_shortcode_submit() { wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); } function wpcf7_submit_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); $class = wpcf7_form_controls_class( $tag->type ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) $value = __(' ', 'wpcf7'); $atts['class'] = 'button'; $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<input %1$s />', $atts ); return $html; } ``` NB: I've taken "send" out, leaving a space like ' ' instead of '', in fact I've tried every combination but nothing. Would it have to do with how I created the submit button image? In the latest version of CF7 I had to add `$atts['class'] = 'button';` into my submit.php before adding the following into my CSS ``` .button { background-image: url("imageurl.gif"); background-repeat: no-repeat; margin: 0px 0px 0px 0px; padding: 0px; float: left; height: 35px; width: 133px; border: 0 none; cursor: pointer; } ``` Any help would be greatly appreciated.
2013/05/24
[ "https://Stackoverflow.com/questions/16735721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2259760/" ]
No Need to touch the code to change the message of the submit button. Go into your wp dashboard < Contact and change this line ``` <p>[submit "Send"]</p> ``` to ``` <p>[submit "Anything you would like here"]</p> ```
If you're looking for a blank button using Contact Form 7 ``` [submit "&nbsp;"] ```
16,735,721
I've been looking around and everyone says the solution is to take "send" out of the following code: `if ( empty( $value ) ) $value = __('send', 'wpcf7');` That's the first thing I did after I replaced my submit button with an image but 'Send' is still overlaid the submit button image, and I'm at a loss as to what to do. This is what my CSS code looks like: ``` /* Shortcode handler */ add_action( 'init', 'wpcf7_add_shortcode_submit', 5 ); function wpcf7_add_shortcode_submit() { wpcf7_add_shortcode( 'submit', 'wpcf7_submit_shortcode_handler' ); } function wpcf7_submit_shortcode_handler( $tag ) { $tag = new WPCF7_Shortcode( $tag ); $class = wpcf7_form_controls_class( $tag->type ); $atts = array(); $atts['class'] = $tag->get_class_option( $class ); $atts['id'] = $tag->get_option( 'id', 'id', true ); $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true ); $value = isset( $tag->values[0] ) ? $tag->values[0] : ''; if ( empty( $value ) ) $value = __(' ', 'wpcf7'); $atts['class'] = 'button'; $atts['type'] = 'submit'; $atts['value'] = $value; $atts = wpcf7_format_atts( $atts ); $html = sprintf( '<input %1$s />', $atts ); return $html; } ``` NB: I've taken "send" out, leaving a space like ' ' instead of '', in fact I've tried every combination but nothing. Would it have to do with how I created the submit button image? In the latest version of CF7 I had to add `$atts['class'] = 'button';` into my submit.php before adding the following into my CSS ``` .button { background-image: url("imageurl.gif"); background-repeat: no-repeat; margin: 0px 0px 0px 0px; padding: 0px; float: left; height: 35px; width: 133px; border: 0 none; cursor: pointer; } ``` Any help would be greatly appreciated.
2013/05/24
[ "https://Stackoverflow.com/questions/16735721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2259760/" ]
If you're looking for a blank button using Contact Form 7 ``` [submit "&nbsp;"] ```
In the the latest version (at the time of writing) in modules submit.php At line 27 Change ``` if ( empty( $value ) ) $value = __( 'Send', 'contact-form-7' ); ``` to ``` if ( empty( $value ) ) $value = __( ' ', 'contact-form-7' ); ```
444,200
I know that in a transformer the power is conserved on both sides, and hence there's no power amplification as such. That's fine! But if I instead want only a voltage amplification, then choosing proper turns ratio and connecting the load across the secondary would serve my purpose. So can you consider it as voltage amplifier? If yes, then why is it not used as one?
2019/06/18
[ "https://electronics.stackexchange.com/questions/444200", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/86971/" ]
Only for ideal transformers, power is conserved. Real transformers have losses, which may be load dependent. So, in that case, the 'output' voltage is not the gain times the 'input' voltage. For voltage amplifiers, you also want them to have unlimited (or at least large) current supply. This unlimited current is needed, so the output is not dependent to the load, i.e. the voltage should not collapse because of the load. For transformers, this 'output' current is dependent and limited.
Amplifiers typically provide input-output isolation. Changes in output energy need not require more input energy (tho the VDD rail must support the output demands) A transformer of course does not provide isolation.
444,200
I know that in a transformer the power is conserved on both sides, and hence there's no power amplification as such. That's fine! But if I instead want only a voltage amplification, then choosing proper turns ratio and connecting the load across the secondary would serve my purpose. So can you consider it as voltage amplifier? If yes, then why is it not used as one?
2019/06/18
[ "https://electronics.stackexchange.com/questions/444200", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/86971/" ]
It's just a subtlety of the terminology. If there's no (capability of) power amplification, then we don't call it an "amplifier" even though the output voltage might be higher than the input voltage. As others have pointed out, there are other functional differences between transformers and amplifiers, one being that power can flow both ways through a transformer but generally only one way through an amplifier. Finally, we already have a word for a device that can change voltages without providing power gain, so we don't need to call these things *amplifiers*. We can just call them *transformers*.
Amplifiers typically provide input-output isolation. Changes in output energy need not require more input energy (tho the VDD rail must support the output demands) A transformer of course does not provide isolation.
444,200
I know that in a transformer the power is conserved on both sides, and hence there's no power amplification as such. That's fine! But if I instead want only a voltage amplification, then choosing proper turns ratio and connecting the load across the secondary would serve my purpose. So can you consider it as voltage amplifier? If yes, then why is it not used as one?
2019/06/18
[ "https://electronics.stackexchange.com/questions/444200", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/86971/" ]
It's just a subtlety of the terminology. If there's no (capability of) power amplification, then we don't call it an "amplifier" even though the output voltage might be higher than the input voltage. As others have pointed out, there are other functional differences between transformers and amplifiers, one being that power can flow both ways through a transformer but generally only one way through an amplifier. Finally, we already have a word for a device that can change voltages without providing power gain, so we don't need to call these things *amplifiers*. We can just call them *transformers*.
Only for ideal transformers, power is conserved. Real transformers have losses, which may be load dependent. So, in that case, the 'output' voltage is not the gain times the 'input' voltage. For voltage amplifiers, you also want them to have unlimited (or at least large) current supply. This unlimited current is needed, so the output is not dependent to the load, i.e. the voltage should not collapse because of the load. For transformers, this 'output' current is dependent and limited.
26,494,858
So, because this is for a school project, I can't post actual source code for what is going on. Instead, I will try to explain what's going on and use some code snippets. For the project, a JPanel, contained by a JFrame, holds most of the Components of the overall GUI. I'll have like ``` JButton b1 = new Button("Option 1"); JButton b2 = new Button("Option 2"); JPanel p = new JPanel(); p.add(b1); p.add(b2); ``` Adding this to the JFrame object works just fine, but when I have ``` JMenuBar mb = new JMenuBar(); JPopupMenu pm = new JPopupMenu("File"); mb.add(pm); myJFrameObject.add(mb); ``` the menu bar is nowhere to be seen. Should I have used ``` myJFrameObject.setJMenuBar(mb); ``` instead? I remember that not really doing anything either. By the way, I have been using BoxLayout for the frame.
2014/10/21
[ "https://Stackoverflow.com/questions/26494858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3512478/" ]
The 3rd argument to [`open`](http://msdn.microsoft.com/en-us/library/ms763809(v=vs.85).aspx) should be a boolean, specifying whether or not the request should be asynchronous. ``` oServerXMLHTTPRequest.open bstrMethod, bstrUrl, bAsync, bstrUser, bstrPassword ``` > > **bstrMethod**The HTTP method used to open the connection, such as PUT or > PROPFIND. For ServerXMLHTTP, this parameter is case-sensitive and the > method name must be entered in all upper-case letters. **bstrUrl** The > requested URL. This can be either an absolute URL, such as > "<http://example.com/Mypath/Myfile.asp>", or a relative URL, such as > "../MyPath/MyFile.asp".**bAsync** (optional) Boolean. Indicator as to > whether the call is asynchronous. The default is False (the call does > not return immediately). **bstrUser** (optional) The name of the user for > authentication. **bstrPassword** (optional) The password for > authentication. This parameter is ignored if the user parameter is > Null or missing. > > > --- With a bit of experimentation and help from [another question](https://stackoverflow.com/questions/11573022/vba-serverxmlhttp-https-request-with-self-signed-certificate), I think you just need to change ``` xmlhttp.SetOption SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS, true ``` to ``` xmlhttp.SetOption 2, xmlhttp.GetOption(2) - SXH_OPTION_IGNORE_SERVER_SSL_CERT_ERROR_FLAGS ```
If you're using Windows 8, Windows 8.1 or Windows Server 2012/2012R2, you might have to apply the following HotFix, which fixed this problem for me in a similar scenario: <https://support.microsoft.com/en-us/help/2968741/error-0x80070057-when-sql-server-communicates-to-a-web-server-using-st> For further info you can also [read this post](http://www.ryadel.com/en/msxml2-xmlhttp-serverxmlhttp-error-0x80070057-parameter-incorrect-post-http-request-t-sql-server-2008-2012-sp-fix/) on my blog or take a look to [this other SO thread](https://stackoverflow.com/questions/26765782/msxml3-dll-in-context-sp-oamethod-send).
12,426,191
When iterating through a collection of all controls on a page (from `Page.Controls` and those control's children and their children's children etc), how can you tell if the control came from the Page's Master Page? The following seems to work, but feels a bit dirty. Is there a better way to get this information? Update: Sorry, missed some code out earlier. ``` List<Control> allControls = GetAllControls(this.Page) foreach (Control c in allControls) { bool isFromMaster = c.NamingContainer.TemplateControl.GetType().BaseType.BaseType == typeof(MasterPage); } ``` Where `GetAllControls` recursively gets all controls on a page Thanks
2012/09/14
[ "https://Stackoverflow.com/questions/12426191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299110/" ]
Given a reference to a `Control`, you could recursively look at the `Parent` property: ``` bool IsFromMasterPage(Control control) { while(control.Parent != null) { if (control.Parent is MasterPage) return true; control = control.Parent; } return false; } ```
The `Page.Controls` **only contain controls from the current page** If you want to check the MasterPage controls, use: ``` this.Master.Controls ``` On the other hand if you want to find the MasterPage controls on your page: ``` IEnumerable<MasterPage> masterPageControls = this.Page.Controls.OfType<MasterPage>(); ``` Although you can have only one MasterPage associated to your page
12,426,191
When iterating through a collection of all controls on a page (from `Page.Controls` and those control's children and their children's children etc), how can you tell if the control came from the Page's Master Page? The following seems to work, but feels a bit dirty. Is there a better way to get this information? Update: Sorry, missed some code out earlier. ``` List<Control> allControls = GetAllControls(this.Page) foreach (Control c in allControls) { bool isFromMaster = c.NamingContainer.TemplateControl.GetType().BaseType.BaseType == typeof(MasterPage); } ``` Where `GetAllControls` recursively gets all controls on a page Thanks
2012/09/14
[ "https://Stackoverflow.com/questions/12426191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299110/" ]
Solution turned out to be going through the controls from the master page, excluding the children of content place holders (as these give you the controls added from the page itself). ``` public static bool IsFromMasterPage(Control control) { if (control.Page.Master != null) { // Get all controls on the master page, excluding those from ContentPlaceHolders List<Control> masterPageControls = FindControlsExcludingPlaceHolderChildren(control.Page.Master); bool match = masterPageControls.Contains(control); return match; } return false; } public static List<Control> FindControlsExcludingPlaceHolderChildren(Control parent) { List<Control> controls = new List<Control>(); foreach (Control control in parent.Controls) { controls.Add(control); if (control.HasControls() && control.GetType() != typeof(ContentPlaceHolder)) { controls.AddRange(FindControlsExcludingPlaceHolderChildren(control)); } } return controls; } ```
The `Page.Controls` **only contain controls from the current page** If you want to check the MasterPage controls, use: ``` this.Master.Controls ``` On the other hand if you want to find the MasterPage controls on your page: ``` IEnumerable<MasterPage> masterPageControls = this.Page.Controls.OfType<MasterPage>(); ``` Although you can have only one MasterPage associated to your page
1,360,248
I'm trying to get Windows 10 to emulate the new "Digital Wellbeing" feature that Google released alongside Android 9. Basically it changes the screen to grey-scale at night-time to try and incentivize people to get off their phone and go to sleep. When I learned of Windows 10's "color filter" feature (which also allows you to set the color profile to grey-scale), I thought scripting this might be easy, but I can't seem to find a way to do this in a script directly. At the moment, I basically have it working by turning on the `Win`+`Ctrl`+`C` toggle hotkey, and have a scheduled task set to run an AutoHotkey script that essentially hits those keys to trigger the shortcut. This works ok, but I'd like to be able to leave the shortcut key disabled so I don't accidentally hit it, or have such an easy way to disable the feature (and weaken the "Digital Wellbeing" effect). Also, the script has no way to know what the state of the setting is. If it runs twice, it undoes itself. Currently I don't have the machine scripted to unset the feature, but if I created a task to do that, and I shut the machine off before the nightly trigger, it might go grey-scale in the morning. My question is to ask if there is any way I might be able to explicitly set "color filter on", or "color filter off" directly (via PowerShell, Batch, VBS, whatever) that doesn't depend on the shortcut key, and preferably that doesn't toggle?
2018/09/21
[ "https://superuser.com/questions/1360248", "https://superuser.com", "https://superuser.com/users/927750/" ]
So I was trying the same thing and ended up using: <https://zerowidthjoiner.net/negativescreen> in Grayscale mode, which is easy to trigger programmatically. --- Before I tried that, I ran into something interresting. I tried to set the registry entries to enable color filtering: ``` [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility] "Configuration"="colorfiltering" [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility\ATConfig] [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility\ATConfig\colorfiltering] "Active"=dword:00000001 "FilterType"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\ColorFiltering] "HotkeyEnabled"=dword:00000001 "Active"=dword:00000001 "FilterType"=dword:00000000 ``` This doesn't work on its own, because the setting is not applied. Interestingly though when I triggered a UAC popup, the color filter would be applied. So by calling ``` powershell Start-Process cmd.exe -Verb RunAs ``` the setting could be applied programmatically. This solution is terrible though, since an actual UAC popup is generated. But if anyone knows of another way to force a window redraw (or whatever happens when the UAC is opened) it should be possible to programmatically apply the changed setting.
I had exactly the same need. I used [AutoHotKey](https://www.autohotkey.com/) for this. This script checks every 10 min. If the time between 10:30 - 10:39 pm, it presses `Win`+`Ctrl`+`C`. ``` #Persistent SetTimer, ToggleGreyscaleFilter, 600000 ; Check every 10 min ToggleGreyscaleFilter: TheTime = %A_Hour%%A_Min% If TheTime Between 2230 and 2239 ; If it is between 10:30 and 10:39 pm { MsgBox, "Sleep" ; Optional popup message Send #^c ; Press Win-Ctrl-C to toggle greyscale } ``` For this to work, in Settings > Ease of Access > Color Filters: * Allow the shortcut key to toggle filter on or off (Win-Ctrl-C) * Select Greyscale filter
1,360,248
I'm trying to get Windows 10 to emulate the new "Digital Wellbeing" feature that Google released alongside Android 9. Basically it changes the screen to grey-scale at night-time to try and incentivize people to get off their phone and go to sleep. When I learned of Windows 10's "color filter" feature (which also allows you to set the color profile to grey-scale), I thought scripting this might be easy, but I can't seem to find a way to do this in a script directly. At the moment, I basically have it working by turning on the `Win`+`Ctrl`+`C` toggle hotkey, and have a scheduled task set to run an AutoHotkey script that essentially hits those keys to trigger the shortcut. This works ok, but I'd like to be able to leave the shortcut key disabled so I don't accidentally hit it, or have such an easy way to disable the feature (and weaken the "Digital Wellbeing" effect). Also, the script has no way to know what the state of the setting is. If it runs twice, it undoes itself. Currently I don't have the machine scripted to unset the feature, but if I created a task to do that, and I shut the machine off before the nightly trigger, it might go grey-scale in the morning. My question is to ask if there is any way I might be able to explicitly set "color filter on", or "color filter off" directly (via PowerShell, Batch, VBS, whatever) that doesn't depend on the shortcut key, and preferably that doesn't toggle?
2018/09/21
[ "https://superuser.com/questions/1360248", "https://superuser.com", "https://superuser.com/users/927750/" ]
So I was trying the same thing and ended up using: <https://zerowidthjoiner.net/negativescreen> in Grayscale mode, which is easy to trigger programmatically. --- Before I tried that, I ran into something interresting. I tried to set the registry entries to enable color filtering: ``` [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility] "Configuration"="colorfiltering" [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility\ATConfig] [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Accessibility\ATConfig\colorfiltering] "Active"=dword:00000001 "FilterType"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\ColorFiltering] "HotkeyEnabled"=dword:00000001 "Active"=dword:00000001 "FilterType"=dword:00000000 ``` This doesn't work on its own, because the setting is not applied. Interestingly though when I triggered a UAC popup, the color filter would be applied. So by calling ``` powershell Start-Process cmd.exe -Verb RunAs ``` the setting could be applied programmatically. This solution is terrible though, since an actual UAC popup is generated. But if anyone knows of another way to force a window redraw (or whatever happens when the UAC is opened) it should be possible to programmatically apply the changed setting.
For those who looking for simple solution on Windows: You may use [WinMagnification](https://pypi.org/project/WinMagnification/) Python 3.8+ lib. It supports a grayscale color effect, and also you can animate transition with it (by changing effect power over time). ``` import win_magnification as mag mag_api = mag.WinMagnificationAPI() # Set grayscale color filter mag_api.fullscreen.color_effect.raw = mag.const.COLOR_GRAYSCALE_EFFECT # Animate from normal to grayscale import time mag_api.fullscreen.color_effect.reset() mag_api.fullscreen.color_effect.make_transition( end=mag.const.COLOR_GRAYSCALE_EFFECT, initial_power=0, ) for i in range(100): mag_api.fullscreen.color_effect.transition_power += 0.01 time.sleep(0.05) ```