qid
int64
1
74.6M
question
stringlengths
45
24.2k
date
stringlengths
10
10
metadata
stringlengths
101
178
response_j
stringlengths
32
23.2k
response_k
stringlengths
21
13.2k
34,255,552
Say, I have a table named `buildings` which could be created by the following query: ``` create table buildings( building_id number primary key, building_name varchar2(32), shape sdo_geometry ); ``` I can insert a rectangle into it by the following query: ``` insert into buildings values( 4, -- index 'Reading Room', -- building_name sdo_geometry( 2003, --SDO_GTYPE: dltt - 2(2D)0(linear referencing)03(polygon) 8307, --SDO_SRID: coordinate system null, --SDO_POINT: it is for point inserting, if the next two field = null, then it could not be null. sdo_elem_info_array( --SDO_ELEM_INFO: 1, --SDO_STARTING_OFFSET: indicates from which index of the next param of SDO_GEOMETRY would be considered, starts from 1. 1003, --SDO_ETYPE: 1(exterior, interior - 2)003(this digits usually comes from SDO_GTYPE) 3), --SDO_INTERPRETATION: 1 - simple polygon, 2 - polygon connecting arcs, 3 - rectangle, 4 - circle etc. sdo_ordinate_array( 24.916312, 91.832393, 24.916392, 91.832678 ) --SDO_ORDINATES: co-ordinates of the geometry -- two corner points of the main diagonal ) ); ``` Here, two geodetic points came from real data as an object of `sdo_ordinate_array`. The following two points are inserted directly in the above query: 1. 24.916312, 91.832393 2. 24.916392, 91.832678 Now, I want to insert these two points coming from two different sub-query. Sub-queries would be like the following: ``` SELECT 180+SDO_GEOM.SDO_CENTROID(c.shape, m.diminfo).SDO_POINT.X, 180-SDO_GEOM.SDO_CENTROID(c.shape, m.diminfo).SDO_POINT.Y FROM buildings c, user_sdo_geom_metadata m WHERE m.table_name = 'BUILDINGS' AND m.column_name = 'SHAPE' AND c.building_name = 'IICT'; ``` So, the result of the query would be like: ``` X Y ---------- ---------- 24.9181097 91.83097409 ``` How can I convert this result to comma separated value, like: `24.9181097, 91.83097409`? So that I could replace the following code: ``` sdo_ordinate_array( 24.916312, 91.832393, 24.916392, 91.832678 ) --SDO_ORDINATES: co-ordinates of the geometry ``` with: ``` sdo_ordinate_array( (/*sub-query*/), (/*another-subquery*/) ) --SDO_ORDINATES: co-ordinates of the geometry ``` I had google it and explored several blogs but had no luck. ### N.B.: The title seemed inappropriate, but the straightforward versions of the sub-queries return the object of `SDO_GEOMETRY`. If you explored on oracle spatial queries, then it is clear to you that I just retrieve the value of X and Y from the returned object.
2015/12/13
['https://Stackoverflow.com/questions/34255552', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3555000/']
Edit: The Event object in jQuery has a parameter for ctrlKey, you could assign that as true, on click. ``` var e = jQuery.Event("click"); e.ctrlKey = true; $('#id').trigger(e); ``` Reference: [jquery trigger ctrl + click](https://stackoverflow.com/questions/9377046/jquery-trigger-ctrl-click)
This is a non-jQuery version to simulate keyboard events. This works in both Chrome (WebKit based) and Firefox (Gecko based): ``` var keyboardEvent = document.createEvent("KeyboardEvent"); var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; keyboardEvent[initMethod]( "keydown", // event type : keydown, keyup, keypress true, // bubbles true, // cancelable window, // viewArg: should be window false, // ctrlKeyArg false, // altKeyArg false, // shiftKeyArg false, // metaKeyArg 40, // keyCodeArg : unsigned long the virtual key code, else 0 0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0 ); document.dispatchEvent(keyboardEvent); ``` Or using jQuery, you can simulate by jQuery's `event` object: ``` jQuery.event.trigger({ type: 'keypress', which: character.charCodeAt(0) }); ```
34,255,552
Say, I have a table named `buildings` which could be created by the following query: ``` create table buildings( building_id number primary key, building_name varchar2(32), shape sdo_geometry ); ``` I can insert a rectangle into it by the following query: ``` insert into buildings values( 4, -- index 'Reading Room', -- building_name sdo_geometry( 2003, --SDO_GTYPE: dltt - 2(2D)0(linear referencing)03(polygon) 8307, --SDO_SRID: coordinate system null, --SDO_POINT: it is for point inserting, if the next two field = null, then it could not be null. sdo_elem_info_array( --SDO_ELEM_INFO: 1, --SDO_STARTING_OFFSET: indicates from which index of the next param of SDO_GEOMETRY would be considered, starts from 1. 1003, --SDO_ETYPE: 1(exterior, interior - 2)003(this digits usually comes from SDO_GTYPE) 3), --SDO_INTERPRETATION: 1 - simple polygon, 2 - polygon connecting arcs, 3 - rectangle, 4 - circle etc. sdo_ordinate_array( 24.916312, 91.832393, 24.916392, 91.832678 ) --SDO_ORDINATES: co-ordinates of the geometry -- two corner points of the main diagonal ) ); ``` Here, two geodetic points came from real data as an object of `sdo_ordinate_array`. The following two points are inserted directly in the above query: 1. 24.916312, 91.832393 2. 24.916392, 91.832678 Now, I want to insert these two points coming from two different sub-query. Sub-queries would be like the following: ``` SELECT 180+SDO_GEOM.SDO_CENTROID(c.shape, m.diminfo).SDO_POINT.X, 180-SDO_GEOM.SDO_CENTROID(c.shape, m.diminfo).SDO_POINT.Y FROM buildings c, user_sdo_geom_metadata m WHERE m.table_name = 'BUILDINGS' AND m.column_name = 'SHAPE' AND c.building_name = 'IICT'; ``` So, the result of the query would be like: ``` X Y ---------- ---------- 24.9181097 91.83097409 ``` How can I convert this result to comma separated value, like: `24.9181097, 91.83097409`? So that I could replace the following code: ``` sdo_ordinate_array( 24.916312, 91.832393, 24.916392, 91.832678 ) --SDO_ORDINATES: co-ordinates of the geometry ``` with: ``` sdo_ordinate_array( (/*sub-query*/), (/*another-subquery*/) ) --SDO_ORDINATES: co-ordinates of the geometry ``` I had google it and explored several blogs but had no luck. ### N.B.: The title seemed inappropriate, but the straightforward versions of the sub-queries return the object of `SDO_GEOMETRY`. If you explored on oracle spatial queries, then it is clear to you that I just retrieve the value of X and Y from the returned object.
2015/12/13
['https://Stackoverflow.com/questions/34255552', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3555000/']
In pure javascript, you can use the [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) for that: ``` document.getElementById("todo").dispatchEvent(new MouseEvent("click", {ctrlKey: true})); ``` To programatically open a new tab you can do that: ``` const a = document.createElement("a"); a.setAttribute("href", "https://www.google.com/"); a.dispatchEvent(new MouseEvent("click", {ctrlKey: true})); ```
This is a non-jQuery version to simulate keyboard events. This works in both Chrome (WebKit based) and Firefox (Gecko based): ``` var keyboardEvent = document.createEvent("KeyboardEvent"); var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; keyboardEvent[initMethod]( "keydown", // event type : keydown, keyup, keypress true, // bubbles true, // cancelable window, // viewArg: should be window false, // ctrlKeyArg false, // altKeyArg false, // shiftKeyArg false, // metaKeyArg 40, // keyCodeArg : unsigned long the virtual key code, else 0 0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0 ); document.dispatchEvent(keyboardEvent); ``` Or using jQuery, you can simulate by jQuery's `event` object: ``` jQuery.event.trigger({ type: 'keypress', which: character.charCodeAt(0) }); ```
1,808,887
This is a part of an exercise from "Algebra: Chapter 0" by Paolo Aluffi. First, I provide the necessary definitions. > > An **action** of a group $G$ on a set $A$ is a set-function > > > $\rho: G \times A \to A$ > > > such that $\forall g,h \in G \ \ \forall a \in A$ we have > > > $\rho(e\_G, a) = a, \ \ \ \rho(gh,a) = \rho(g, \rho(h,a))$ > > > or, alternatively, > > An **action** of a group $G$ on a set $A$ is a homomorphism > > > $\sigma: G \to S\_A$ > > > where $S\_A$ denotes the symmetric group of $A$. > > > We can call this a **left-action**. A **right-action** would be defined the same way expect for "associativity" axiom: > > $\forall a \in A \ \ \ \forall g,h \in G \ \ \ a(gh) = (ag)h$ > > > Next: > > An **opposite group** $G^{op}$ of a group $G$ is a group $(G, \times )$ where $a \times b = ba$. > > > I know that $G^{op} \cong G$ with $f, f(g) = g^{-1}$ being an isomorphism. **Now**, I need to show that giving a right-action of $G$ on a set A is the same as giving a homomorphism $G^{op} \to S\_A$, that is, a left-action of $G^{op}$ on $A$. Any ideas?
2016/06/01
['https://math.stackexchange.com/questions/1808887', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/229776/']
What “the same” means is that there exists a bijection between the set of left actions of $G$ on $A$ and the set of right actions of $G^{\mathrm{op}}$ on $A$. Thus we want to find a map $\lambda\mapsto\lambda^r$ and a map $\rho\mapsto\rho^l$ such that, for a left action $\lambda$, $\lambda^{rl}=\lambda$ and, for a right action, $\rho^{lr}=\rho$. Given a left action $\lambda$, define $\lambda^r\colon A\times G\to A$ by $$ \lambda^r(a,g)=\lambda(g^{-1},a) $$ Verifying that $\lambda^r$ is a right action is easy. The definition of $\rho^l$ is similar: $$ \rho^l(g,a)=\rho(a,g^{-1}) $$ The check that $\lambda^{rl}=\lambda$ and $\rho^{lr}=\rho$ is trivial. --- Doing it with homomorphisms is easy, too. If $\sigma\colon G\to S\_A$ is a group homomorphism, then $$ \sigma^\circ\colon G^{\mathrm{op}}\to S\_A $$ defined by $$ \sigma^{\circ}(g)=\sigma(g^{-1}) $$ is a group homomorphism. Finish up the argument. --- Associating to a left action $\lambda$ a homomorphism $\bar\lambda\colon G\to S\_A$ is easy: $\bar\lambda(g)$ is the map $A\to A$ sending $a$ to $\lambda(g,a)$. Similarly for associating to a right action a homomorphism $G^{\mathrm{op}}\to S\_A$.
I think the other answers are a bit misled into what the question is asking. It seems that they are answering the last bullet (the sixth bullet) in that exercise (chapter 2, exercise 9.3) in Aluffi's book. --- To answer your question (the fourth bullet in that exercise of Aluffi's book): If we have a right-action of $G$ on $A$, we have a map $\rho: G \times A \to A$ satisfying $\rho(1,a)=a$ and $\rho(gh,a)=\rho(h, \rho(g,a))$. Note that since this is a right-action, this $\rho$ behaves a bit differently than a left-action. So, define $G^\circ \to S\_A$ by $g \mapsto \sigma\_g$ where $\sigma\_g: A \to A$ is defined by $\sigma\_g(a)=\rho(g,a)$. Then, by the operation $\bullet$ in $G^\circ$, we have $$\sigma\_{g\bullet h}(a)=\sigma\_{hg}(a)=\rho(hg,a)=\rho(g, \rho(h,a))=\sigma\_g(\rho(h,a))=\sigma\_g\circ \sigma\_h(a).$$ So, we have a homomorphism $G^\circ \to S\_A$. Furthermore, define $\tau: G ^\circ \times A \to A$ via $\tau(g,a)=\sigma\_g(a)=\rho(g,a)$. Then, $$\tau(g\bullet h, a)=\tau(hg,a)=\rho(hg,a)=\rho(g, \rho(h,a))=\tau(g, \tau(h,a)).$$ Thus, $\tau$ is a left-action of $G^\circ$ on $A$.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
A way around this issue is to stop VS Code from redundantly printing to the `TERMINAL` during debugging in the first place. Since it prints to the `DEBUG CONSOLE` as well, you can use that instead. Change `console` to ~~`"none"`~~ `"internalConsole"` in each configuration in your project's `launch.json` file: ``` "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": "internalConsole" } ] ``` **May 2019 Update:** the `"none"` option was replaced by `"internalConsole"` so I edited my answer to reflect that. Here's the relevant [GitHub Issue](https://github.com/Microsoft/vscode-python/issues/4321).
Adding `"args": ["&&", "exit"],` to `launch.json` remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
A way around this issue is to stop VS Code from redundantly printing to the `TERMINAL` during debugging in the first place. Since it prints to the `DEBUG CONSOLE` as well, you can use that instead. Change `console` to ~~`"none"`~~ `"internalConsole"` in each configuration in your project's `launch.json` file: ``` "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": "internalConsole" } ] ``` **May 2019 Update:** the `"none"` option was replaced by `"internalConsole"` so I edited my answer to reflect that. Here's the relevant [GitHub Issue](https://github.com/Microsoft/vscode-python/issues/4321).
Actually you can **delete** all the instances of the **terminal** just by clicking on the **trash can icon** . If it does not work for the first time, **restart** the **VS Code** and try again.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
A way around this issue is to stop VS Code from redundantly printing to the `TERMINAL` during debugging in the first place. Since it prints to the `DEBUG CONSOLE` as well, you can use that instead. Change `console` to ~~`"none"`~~ `"internalConsole"` in each configuration in your project's `launch.json` file: ``` "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": "internalConsole" } ] ``` **May 2019 Update:** the `"none"` option was replaced by `"internalConsole"` so I edited my answer to reflect that. Here's the relevant [GitHub Issue](https://github.com/Microsoft/vscode-python/issues/4321).
Hopefully fixed in the Insiders Build and should be in v1.54. See [Debug opens a new integrated terminal for each Python session](https://github.com/microsoft/vscode/issues/112055). Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
A way around this issue is to stop VS Code from redundantly printing to the `TERMINAL` during debugging in the first place. Since it prints to the `DEBUG CONSOLE` as well, you can use that instead. Change `console` to ~~`"none"`~~ `"internalConsole"` in each configuration in your project's `launch.json` file: ``` "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": "internalConsole" } ] ``` **May 2019 Update:** the `"none"` option was replaced by `"internalConsole"` so I edited my answer to reflect that. Here's the relevant [GitHub Issue](https://github.com/Microsoft/vscode-python/issues/4321).
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently. I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals. Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a [VS Code/Python Extension defect](https://github.com/microsoft/vscode-python/issues/19696) about this. The initial response is that Git Bash is not officially supported currently. There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window. There is some additional background info and hacks to fix this from the past [in this answer](https://stackoverflow.com/a/58194881/6501141).
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
Adding `"args": ["&&", "exit"],` to `launch.json` remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
Actually you can **delete** all the instances of the **terminal** just by clicking on the **trash can icon** . If it does not work for the first time, **restart** the **VS Code** and try again.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
Adding `"args": ["&&", "exit"],` to `launch.json` remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
Hopefully fixed in the Insiders Build and should be in v1.54. See [Debug opens a new integrated terminal for each Python session](https://github.com/microsoft/vscode/issues/112055). Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
Adding `"args": ["&&", "exit"],` to `launch.json` remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently. I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals. Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a [VS Code/Python Extension defect](https://github.com/microsoft/vscode-python/issues/19696) about this. The initial response is that Git Bash is not officially supported currently. There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window. There is some additional background info and hacks to fix this from the past [in this answer](https://stackoverflow.com/a/58194881/6501141).
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently. I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals. Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a [VS Code/Python Extension defect](https://github.com/microsoft/vscode-python/issues/19696) about this. The initial response is that Git Bash is not officially supported currently. There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window. There is some additional background info and hacks to fix this from the past [in this answer](https://stackoverflow.com/a/58194881/6501141).
Actually you can **delete** all the instances of the **terminal** just by clicking on the **trash can icon** . If it does not work for the first time, **restart** the **VS Code** and try again.
53,974,212
Sorry I'm new to web server. I want to deploy a cloud server for user data: 1. User can login using web, with verification code sent to user's phone. 2. User can manipulate his data (add/modify/remove) when login. 3. Android/iPhone client can manipulate user data when login. 4. Server should have a database for storage, SQLLite or others. It would be good to use Amazon/Ali-cloud cloud service, provided it can speed up my deployment. I'm not sure if I need run into blobs such as H5, PHP/JSP, node.js or others. Can you provide a guide for me, web link or book? And, what's the most popular programming interface between Android/IOS app and cloud server? http post/get or other wrapper ?
2018/12/29
['https://Stackoverflow.com/questions/53974212', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/721441/']
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently. I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals. Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a [VS Code/Python Extension defect](https://github.com/microsoft/vscode-python/issues/19696) about this. The initial response is that Git Bash is not officially supported currently. There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window. There is some additional background info and hacks to fix this from the past [in this answer](https://stackoverflow.com/a/58194881/6501141).
Hopefully fixed in the Insiders Build and should be in v1.54. See [Debug opens a new integrated terminal for each Python session](https://github.com/microsoft/vscode/issues/112055). Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
8,841,575
I thought I could do it with the 'fs' module, but i couldnt find the right function.
2012/01/12
['https://Stackoverflow.com/questions/8841575', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1087995/']
``` fs = require('fs'); fs.exists(path, function( exists ) { console.log( ( exists ? "File is there" : "File is not there" ) ); }); ```
See the [documentation for the `fs` module](http://nodejs.org/docs/latest/api/fs.html), in particular the "`stat`" family of functions (stat, fstat, lstat, statSync, fstatSync, lstatSync).
32,977
I recently visited the Colosseum in Rome, where a tour guide explained about the different seating sections for the elite (senators and the like), nobles, ordinary citizens, and slaves/women. He also talked about the 80 different gates and said that entry "tickets" were numbered by gate. I later found discussion of all this on [Wikipedia](https://en.wikipedia.org/wiki/Colosseum). The tour made me wonder: what did it cost to go to an event at the Colosseum in Rome in the first century, soon after the Colosseum was built? That slaves and women attended means it was *possible* for people with little wealth to attend, but the existence of the tickets suggests that it wasn't a free-for-all (anybody can just come in). Or was it free, but you had to get a ticket first to prevent running out of spaces? While some of the events at the Colosseum were discretionary entertainment (so if it was too pricy for some that was ok), others seemed to be designed as public spectacles, like executions. So maybe there were different entry policies for different types of events? After all, a performance venue today doesn't always have one, fixed price. If there was a cost, I'd like to understand it in relation to other economic aspects. An answer like "N denari" isn't as helpful to me as something like "the cost of a loaf of bread" or "N days' wages for an ordinary citizen", because I don't know very much about ancient Roman economics.
2016/09/23
['https://history.stackexchange.com/questions/32977', 'https://history.stackexchange.com', 'https://history.stackexchange.com/users/2551/']
I have always understood they were free, paid for by the rich elite to woo/placate the general populace - hence the phrase "bread and circuses". According to the Wikipedia article you cite, the various levels were based on rank, not price. And IIRC, women were relegated to the topmost tier in case they got too... friendly.. with the gladiators - women were not all poor! **Edit re references** It seems even the experts disagree - with themselves! [In this article](http://www.ancient.eu/article/635/) Cartwright states that the games were "probably free", whereas [here](http://www.ancient.eu/Colosseum/) he states that tickets were sold for the Colosseum. Very confusing!
Many (maybe even most) events were free entrance, the entire cost covered by the sponsors (usually politicians, emperors, generals seeking influence, sometimes merchants). Seating was assigned based on social status rather than how much one could pay, the better seats going to the higher ranking members of society (and better could mean closer to the imperial lounge rather than better view of the arena). The same was generally true for other theaters and arenas, though no doubt sometimes tickets were sold as well (though for what price I couldn't tell, never seen such information. No doubt it'd vary greatly just as it does today).
32,977
I recently visited the Colosseum in Rome, where a tour guide explained about the different seating sections for the elite (senators and the like), nobles, ordinary citizens, and slaves/women. He also talked about the 80 different gates and said that entry "tickets" were numbered by gate. I later found discussion of all this on [Wikipedia](https://en.wikipedia.org/wiki/Colosseum). The tour made me wonder: what did it cost to go to an event at the Colosseum in Rome in the first century, soon after the Colosseum was built? That slaves and women attended means it was *possible* for people with little wealth to attend, but the existence of the tickets suggests that it wasn't a free-for-all (anybody can just come in). Or was it free, but you had to get a ticket first to prevent running out of spaces? While some of the events at the Colosseum were discretionary entertainment (so if it was too pricy for some that was ok), others seemed to be designed as public spectacles, like executions. So maybe there were different entry policies for different types of events? After all, a performance venue today doesn't always have one, fixed price. If there was a cost, I'd like to understand it in relation to other economic aspects. An answer like "N denari" isn't as helpful to me as something like "the cost of a loaf of bread" or "N days' wages for an ordinary citizen", because I don't know very much about ancient Roman economics.
2016/09/23
['https://history.stackexchange.com/questions/32977', 'https://history.stackexchange.com', 'https://history.stackexchange.com/users/2551/']
**SHORT ANSWER** 1. Entrance to the Colosseum was most likely free. 2. Spectators were sometimes given free food and gifts. 3. Tickets were probably distributed through patronage and / or were obtained through membership of a club or society. 4. Tickets had seat numbers. Seating was according to social status. --- **WERE THE GAMES FREE?** The general consensus among historians is that the games were most likely free. In [The Colosseum](https://books.google.co.uk/books/about/The_Colosseum.html?id=dBSCMu9juPcC), Keith Hopkins and Mary Beard state: > > So far as we know spectators did not pay for their tickets; attendance > was one of the perks of citizenship. > > > Two other sources, though, are more definite: this [Repubblica newspaper article](http://roma.repubblica.it/cronaca/2015/01/21/news/colosseo_sulle_arcate_scoperti_numeri_dipinti_di_rosso_indicavano_l_ingresso_degli_antichi_settori-105437629/), while [Tickets to the Colosseum](http://www.tribunesandtriumphs.org/colosseum/tickets-to-the-colosseum.htm) says: > > The tickets to the Colosseum were free but everyone had to have a > ticket or invitation to gain entry. > > > The article also says that: > > The games were extremely popular and as there were never enough > tickets to go round there was, no doubt, a black market operating > which sold tickets. > > > Perhaps one reason for the reluctance of many professional historians to state without reservations that entrance was free is that there were many events at the Colosseum, most of which we have no specific information on. Another reason may be that ancient sources don’t explicitly state ‘entrance to the Colosseum is free’ (perhaps because it was taken for granted). [Suetonius](http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Titus*.html), though, comes pretty close (referring to [Titus](https://en.wikipedia.org/wiki/Titus)): > > At the dedication of his amphitheatre and of the baths which were > hastily built near it he gave a most magnificent and costly > gladiatorial show. > > > [and also](http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Domitian*.html) this on [Domitian](https://en.wikipedia.org/wiki/Domitian): > > He constantly gave grand costly entertainments, both in the > amphitheatre and in the Circus, > > > At the very least, it is evident that the spectacles at the Colosseum were heavily subsidized (otherwise, how could slaves have afforded it?). They were a gift from the sponsor, a means of pleasing and placating the masses (‘bread and circuses’ as *TheHonRose* has already noted). This sponsor was usually the emperor - restrictions were placed on other 'worthies' sponsoring games, partly out of fear that someone might rival the emperor for popularity. There is no indication in any of the sources that there were tickets or tokens for different times of the day or for different shows ([see here](https://archive.archaeology.org/gladiators/arena.html) for example). --- **PROJECTING POWER, & GIFTS TO THE PEOPLE** The **Colosseum itself was a gift to the people** from a [Flavian dynasty](https://en.wikipedia.org/wiki/Flavian_dynasty) eager to legitimize itself. The first of the Flavians, [Vespasian](https://en.wikipedia.org/wiki/Vespasian), placed the Colosseum on what had previously been Nero’s private estate, a calculated populist move – land that was private and restricted now belonged to the people. At the same time, the Colosseum > > provided in the centre of Rome a permanent site for political > exhibition, confrontation and control... a venue for the cultivation > of'privileged visibility' (to use Greenblatt's phrase, cited by > Newlands) and the promotion of a divine distance between the > emperor (Titus, Domitian) and the Roman people > > > *Source: A. Boyle & W. Dominik, Flavian Rome* One could argue this was reason enough for entrance to the Colosseum to be free. And this was not all: sometimes **spectators were literally showered with [tokens for prizes](https://www.smithsonianmag.com/history/secrets-of-the-colosseum-75827047/)**, and / or provided with free food. On the inaugural games sponsored by Titus, there is this from [Cassius Dio](http://abacus.bates.edu/~mimber/blood/gladiator.sources.htm#): > > He would throw down into the theatre from aloft little wooden balls > variously inscribed, one designating some article of food, another > clothing, another a silver vessel or perhaps a gold one, or again > horses, pack-animals, cattle or slaves. Those who seized them were to > carry them to the dispensers of the bounty, from whom they would > receive the article named. > > > --- **DISTRIBUTION OF TICKETS** Spectators gained entrance with a token which had their seat number on it. How they acquired these tokens is uncertain. R.B.Abrams, in [The Colosseum: A History](https://books.google.com.ph/books/about/The_Colosseum_A_History.html?id=xkbUDgAAQBAJ&redir_esc=y), summarizes thus: > > Some scholars have suggested that senators and influential citizens > received blocks of tickets and passed them out as patronage; others > theorize that certain trade guilds were given tickets for their > members. > > > Hopkins and Beard also suggest both possibilities for the distribution of tokens or tickets: > > …how they were distributed is not clear. Given that everything in > ancient Rome, ‘free’ or not, had its price, then we should probably > imagine that people paid for membership of clubs and societies to > which free tickets were issued. Or men of influence, powerful patrons, > distributed tickets to their dependents and clients. > > > --- **STATUS & SEATING** Social status was the key to seating arrangement. The Classical archaeologist [Shelby Brown](https://archive.archaeology.org/gladiators/arena.html) says: > > The Roman arena functioned on one level as a display of the social > order, from the slaves and the dispossessed in the ring to the > powerful provider of the games at the top of the hierarchy. The > illustration of social status in the stands at public shows of all > kinds was an important aspect of public entertainment. > > > Katherine Welch, in [The Roman Amphitheatre](https://books.google.com.ph/books/about/The_Roman_Amphitheatre.html?id=zqphhOuZfBYC&redir_esc=y), says that spectators at the Colosseum were seated as follows: > > Senators and Vestal Virgins got front-row seats (as did the emperor > and his family). Wealthy equestrians sat above. Then came male Roman > citizens of the middle classes and finally women and slaves at the top of > the auditorium where the view was poorest….This hierarchical division > was achieved not only at the vertical level but also at a horizontal > level….the most important people…sat closest to the emperor and his > family (probably including the women). > > > *Other sources* *R. Laurence, Roman Passions: A History of Pleasure in Rome*
I have always understood they were free, paid for by the rich elite to woo/placate the general populace - hence the phrase "bread and circuses". According to the Wikipedia article you cite, the various levels were based on rank, not price. And IIRC, women were relegated to the topmost tier in case they got too... friendly.. with the gladiators - women were not all poor! **Edit re references** It seems even the experts disagree - with themselves! [In this article](http://www.ancient.eu/article/635/) Cartwright states that the games were "probably free", whereas [here](http://www.ancient.eu/Colosseum/) he states that tickets were sold for the Colosseum. Very confusing!
32,977
I recently visited the Colosseum in Rome, where a tour guide explained about the different seating sections for the elite (senators and the like), nobles, ordinary citizens, and slaves/women. He also talked about the 80 different gates and said that entry "tickets" were numbered by gate. I later found discussion of all this on [Wikipedia](https://en.wikipedia.org/wiki/Colosseum). The tour made me wonder: what did it cost to go to an event at the Colosseum in Rome in the first century, soon after the Colosseum was built? That slaves and women attended means it was *possible* for people with little wealth to attend, but the existence of the tickets suggests that it wasn't a free-for-all (anybody can just come in). Or was it free, but you had to get a ticket first to prevent running out of spaces? While some of the events at the Colosseum were discretionary entertainment (so if it was too pricy for some that was ok), others seemed to be designed as public spectacles, like executions. So maybe there were different entry policies for different types of events? After all, a performance venue today doesn't always have one, fixed price. If there was a cost, I'd like to understand it in relation to other economic aspects. An answer like "N denari" isn't as helpful to me as something like "the cost of a loaf of bread" or "N days' wages for an ordinary citizen", because I don't know very much about ancient Roman economics.
2016/09/23
['https://history.stackexchange.com/questions/32977', 'https://history.stackexchange.com', 'https://history.stackexchange.com/users/2551/']
**SHORT ANSWER** 1. Entrance to the Colosseum was most likely free. 2. Spectators were sometimes given free food and gifts. 3. Tickets were probably distributed through patronage and / or were obtained through membership of a club or society. 4. Tickets had seat numbers. Seating was according to social status. --- **WERE THE GAMES FREE?** The general consensus among historians is that the games were most likely free. In [The Colosseum](https://books.google.co.uk/books/about/The_Colosseum.html?id=dBSCMu9juPcC), Keith Hopkins and Mary Beard state: > > So far as we know spectators did not pay for their tickets; attendance > was one of the perks of citizenship. > > > Two other sources, though, are more definite: this [Repubblica newspaper article](http://roma.repubblica.it/cronaca/2015/01/21/news/colosseo_sulle_arcate_scoperti_numeri_dipinti_di_rosso_indicavano_l_ingresso_degli_antichi_settori-105437629/), while [Tickets to the Colosseum](http://www.tribunesandtriumphs.org/colosseum/tickets-to-the-colosseum.htm) says: > > The tickets to the Colosseum were free but everyone had to have a > ticket or invitation to gain entry. > > > The article also says that: > > The games were extremely popular and as there were never enough > tickets to go round there was, no doubt, a black market operating > which sold tickets. > > > Perhaps one reason for the reluctance of many professional historians to state without reservations that entrance was free is that there were many events at the Colosseum, most of which we have no specific information on. Another reason may be that ancient sources don’t explicitly state ‘entrance to the Colosseum is free’ (perhaps because it was taken for granted). [Suetonius](http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Titus*.html), though, comes pretty close (referring to [Titus](https://en.wikipedia.org/wiki/Titus)): > > At the dedication of his amphitheatre and of the baths which were > hastily built near it he gave a most magnificent and costly > gladiatorial show. > > > [and also](http://penelope.uchicago.edu/Thayer/E/Roman/Texts/Suetonius/12Caesars/Domitian*.html) this on [Domitian](https://en.wikipedia.org/wiki/Domitian): > > He constantly gave grand costly entertainments, both in the > amphitheatre and in the Circus, > > > At the very least, it is evident that the spectacles at the Colosseum were heavily subsidized (otherwise, how could slaves have afforded it?). They were a gift from the sponsor, a means of pleasing and placating the masses (‘bread and circuses’ as *TheHonRose* has already noted). This sponsor was usually the emperor - restrictions were placed on other 'worthies' sponsoring games, partly out of fear that someone might rival the emperor for popularity. There is no indication in any of the sources that there were tickets or tokens for different times of the day or for different shows ([see here](https://archive.archaeology.org/gladiators/arena.html) for example). --- **PROJECTING POWER, & GIFTS TO THE PEOPLE** The **Colosseum itself was a gift to the people** from a [Flavian dynasty](https://en.wikipedia.org/wiki/Flavian_dynasty) eager to legitimize itself. The first of the Flavians, [Vespasian](https://en.wikipedia.org/wiki/Vespasian), placed the Colosseum on what had previously been Nero’s private estate, a calculated populist move – land that was private and restricted now belonged to the people. At the same time, the Colosseum > > provided in the centre of Rome a permanent site for political > exhibition, confrontation and control... a venue for the cultivation > of'privileged visibility' (to use Greenblatt's phrase, cited by > Newlands) and the promotion of a divine distance between the > emperor (Titus, Domitian) and the Roman people > > > *Source: A. Boyle & W. Dominik, Flavian Rome* One could argue this was reason enough for entrance to the Colosseum to be free. And this was not all: sometimes **spectators were literally showered with [tokens for prizes](https://www.smithsonianmag.com/history/secrets-of-the-colosseum-75827047/)**, and / or provided with free food. On the inaugural games sponsored by Titus, there is this from [Cassius Dio](http://abacus.bates.edu/~mimber/blood/gladiator.sources.htm#): > > He would throw down into the theatre from aloft little wooden balls > variously inscribed, one designating some article of food, another > clothing, another a silver vessel or perhaps a gold one, or again > horses, pack-animals, cattle or slaves. Those who seized them were to > carry them to the dispensers of the bounty, from whom they would > receive the article named. > > > --- **DISTRIBUTION OF TICKETS** Spectators gained entrance with a token which had their seat number on it. How they acquired these tokens is uncertain. R.B.Abrams, in [The Colosseum: A History](https://books.google.com.ph/books/about/The_Colosseum_A_History.html?id=xkbUDgAAQBAJ&redir_esc=y), summarizes thus: > > Some scholars have suggested that senators and influential citizens > received blocks of tickets and passed them out as patronage; others > theorize that certain trade guilds were given tickets for their > members. > > > Hopkins and Beard also suggest both possibilities for the distribution of tokens or tickets: > > …how they were distributed is not clear. Given that everything in > ancient Rome, ‘free’ or not, had its price, then we should probably > imagine that people paid for membership of clubs and societies to > which free tickets were issued. Or men of influence, powerful patrons, > distributed tickets to their dependents and clients. > > > --- **STATUS & SEATING** Social status was the key to seating arrangement. The Classical archaeologist [Shelby Brown](https://archive.archaeology.org/gladiators/arena.html) says: > > The Roman arena functioned on one level as a display of the social > order, from the slaves and the dispossessed in the ring to the > powerful provider of the games at the top of the hierarchy. The > illustration of social status in the stands at public shows of all > kinds was an important aspect of public entertainment. > > > Katherine Welch, in [The Roman Amphitheatre](https://books.google.com.ph/books/about/The_Roman_Amphitheatre.html?id=zqphhOuZfBYC&redir_esc=y), says that spectators at the Colosseum were seated as follows: > > Senators and Vestal Virgins got front-row seats (as did the emperor > and his family). Wealthy equestrians sat above. Then came male Roman > citizens of the middle classes and finally women and slaves at the top of > the auditorium where the view was poorest….This hierarchical division > was achieved not only at the vertical level but also at a horizontal > level….the most important people…sat closest to the emperor and his > family (probably including the women). > > > *Other sources* *R. Laurence, Roman Passions: A History of Pleasure in Rome*
Many (maybe even most) events were free entrance, the entire cost covered by the sponsors (usually politicians, emperors, generals seeking influence, sometimes merchants). Seating was assigned based on social status rather than how much one could pay, the better seats going to the higher ranking members of society (and better could mean closer to the imperial lounge rather than better view of the arena). The same was generally true for other theaters and arenas, though no doubt sometimes tickets were sold as well (though for what price I couldn't tell, never seen such information. No doubt it'd vary greatly just as it does today).
3,449,465
I work in Linux. In Linux with stat function, we can extract the permissions of a file. Similarly how can we extract the permissions of a file in windows. \_stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. <http://msdn.microsoft.com/en-us/library/14h5k7ff%28VS.71%29.aspx>
2010/08/10
['https://Stackoverflow.com/questions/3449465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/266836/']
Windows uses an ACL (Access Control List) to control access to a file (or other kernel object). You can get the ACL for a file with [`GetFileSecurity`](http://msdn.microsoft.com/en-us/library/aa446639(VS.85).aspx) (you want the DACL, not the SACL). You can then get the actual permissions (rights) from that with [`GetEffectiveRightsFromAcl`](http://msdn.microsoft.com/en-us/library/aa446637(VS.85).aspx). This has a race condition, so it's rarely a good idea though. In particular, between the time you retrieve the DACL and the time you try to do something with the file, the DACL may have changed, so what you retrieved is no longer correct.
I read in the link you provided that among others, file permissions as implemented in `_stat` and friends are UNIX specific and are left unused for NTFS, FAT and other Windows filesystems. I think you will have more luck reading file permissions using the classic [FindFirstFile](http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx) and related functions. You'll need to process the handle returned with functions described [here](http://msdn.microsoft.com/en-us/library/aa364399(v=VS.85).aspx) These are highly unportable, but as C++ has no filesystem support, they are the only good choice.
3,449,465
I work in Linux. In Linux with stat function, we can extract the permissions of a file. Similarly how can we extract the permissions of a file in windows. \_stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. <http://msdn.microsoft.com/en-us/library/14h5k7ff%28VS.71%29.aspx>
2010/08/10
['https://Stackoverflow.com/questions/3449465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/266836/']
The struct stat structure does *not* contain any file permission info on Windows. Windows security is far more convoluted, you'd need GetFileSecurity() to retrieve the DACL for the file. That's rarely done in a Windows program, you'd typically let Windows evaluate the effective permissions and deal with the "you can't do it" error return. ERROR\_ACCESS\_DENIED from GetLastError().
I read in the link you provided that among others, file permissions as implemented in `_stat` and friends are UNIX specific and are left unused for NTFS, FAT and other Windows filesystems. I think you will have more luck reading file permissions using the classic [FindFirstFile](http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx) and related functions. You'll need to process the handle returned with functions described [here](http://msdn.microsoft.com/en-us/library/aa364399(v=VS.85).aspx) These are highly unportable, but as C++ has no filesystem support, they are the only good choice.
3,449,465
I work in Linux. In Linux with stat function, we can extract the permissions of a file. Similarly how can we extract the permissions of a file in windows. \_stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. <http://msdn.microsoft.com/en-us/library/14h5k7ff%28VS.71%29.aspx>
2010/08/10
['https://Stackoverflow.com/questions/3449465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/266836/']
Windows uses an ACL (Access Control List) to control access to a file (or other kernel object). You can get the ACL for a file with [`GetFileSecurity`](http://msdn.microsoft.com/en-us/library/aa446639(VS.85).aspx) (you want the DACL, not the SACL). You can then get the actual permissions (rights) from that with [`GetEffectiveRightsFromAcl`](http://msdn.microsoft.com/en-us/library/aa446637(VS.85).aspx). This has a race condition, so it's rarely a good idea though. In particular, between the time you retrieve the DACL and the time you try to do something with the file, the DACL may have changed, so what you retrieved is no longer correct.
MSDN doesn't have nearly as many hyperlinks as it should, you need to search a little to find [`_stat` Structure `st_mode` Field Constants](http://msdn.microsoft.com/en-us/library/3kyc8381.aspx). On both Unix and Windows, you only get the basic permissions of a file, not its access control lists. Since Windows uses ACLs a lot, `_stat` won't give you much useful information. You need to use native Windows API functions to get the ACL.
3,449,465
I work in Linux. In Linux with stat function, we can extract the permissions of a file. Similarly how can we extract the permissions of a file in windows. \_stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. <http://msdn.microsoft.com/en-us/library/14h5k7ff%28VS.71%29.aspx>
2010/08/10
['https://Stackoverflow.com/questions/3449465', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/266836/']
The struct stat structure does *not* contain any file permission info on Windows. Windows security is far more convoluted, you'd need GetFileSecurity() to retrieve the DACL for the file. That's rarely done in a Windows program, you'd typically let Windows evaluate the effective permissions and deal with the "you can't do it" error return. ERROR\_ACCESS\_DENIED from GetLastError().
MSDN doesn't have nearly as many hyperlinks as it should, you need to search a little to find [`_stat` Structure `st_mode` Field Constants](http://msdn.microsoft.com/en-us/library/3kyc8381.aspx). On both Unix and Windows, you only get the basic permissions of a file, not its access control lists. Since Windows uses ACLs a lot, `_stat` won't give you much useful information. You need to use native Windows API functions to get the ACL.
2,527,451
> > Let $x,y,z$ are non zero integers satisfying the system of equations $x+y+z=3$ and $x^3+y^3+z^3=3$ then find solution triplets (all) of $(x,y,z)$. > > > I tried using: $$x^3+y^3+z^3-3xyz=(x+y+z)(x^2+y^2+z^2-xy-yz-zx)$$ but didn't concluded something good, please help to begin with this, in write direction.
2017/11/19
['https://math.stackexchange.com/questions/2527451', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/281534/']
The hint: $$27=(x+y+z)^3=x^3+y^3+z^3+3(x+y)(x+z)(y+z)=3+3(x+y)(x+z)(y+z),$$ which gives $$(x+y)(x+z)(y+z)=8$$ and number of cases: $$x+y\in\{\pm1,\pm2\pm4\pm8\}$$
$x+y+z=x^3+y^3+z^3=3$ The solution set for $(x+y)$ in above equation given by Michael Rozenberg is shown below $(x+y)\in\{\pm1,\pm2\pm4\pm8\}$ The above solution implies that $(x,y,z)$ can only have the below mentioned integer solutions; $(x,y,z)= (4,4,-5),(-5,4,4),(4,-5,4),(1,1,1)$
20,821,730
``` #coding=utf-8 import wx class App(wx.App): def OnInit(self): frame=wx.Frame(parent=None,title='Bare') frame.Show() return Ture app=App() app.MainLoop() ``` runs OK! but the GUI interface is fleeting, just leaving the CMD console in the screen. a newer for python ,why the outcome of the GUI interface fleeting? environment:Gvim+WIN7+PYTHON2.7
2013/12/29
['https://Stackoverflow.com/questions/20821730', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3143152/']
First, according to `help :!` command of `vim`: > > `:!{cmd}` Execute {cmd} with **the shell**. > > > `vim` cause the cmd shell to be executed. Second, according to [Using Python on Windows - Executing scripts](http://docs.python.org/2/using/windows.html#executing-scripts): > > Python scripts (files with the extension .py) will be executed by > `python.exe by` default. **This executable opens a terminal, which stays > open even if the program uses a GUI.** If you do not want this to > happen, use the extension `.pyw` which will cause the script to be > executed by `pythonw.exe` by default (both executables are located in > the top-level of your Python installation directory). This suppresses > the terminal window on startup. > > > So, if you want run the GUI program without cmd console, run the program outside the vim using `pythonw.exe`. For instance, save the file with `.pyw` extension, and double click the file.
It is fleeting because you have a NameError in your code. You should be returning True, not Ture, which is undefined. I am surprised you still see the console window though. If that stays up though, it should be showing the traceback.
90,738
I am trying to compile oclvanitygen because I have an Nvidia GTX 1080 that would most likely be helpful for this. I'm using the Windows Subsystem for Linux with Ubuntu 18.04. I tried this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libopencl.so.1` It basically says that `libopencl.so.1` does not exist. However, I have `libnvidia-opencl.so.1`, so I try this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` Then it says `/usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` So I do a list of `x86_64-linux-gnu`, and there it is, clear as day. [list of x86-64-linux-gnu](https://imgur.com/7Mkz6k3) How can I compile this correctly? Here is a picture of what happens when I run the command: [GCC Command](https://imgur.com/XflXMc1) I have installed the `ocl-icd-opencl-dev` package, but it does not include `libopencl.so.1`. Please tell me if I am doing something wrong. Thanks!
2019/09/30
['https://bitcoin.stackexchange.com/questions/90738', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/68755/']
You can reduce storage requirements by running Bitcoin-core in pruning mode * [How can I run bitcoind in pruning mode?](https://bitcoin.stackexchange.com/q/37496/13866)
The cheapest configuration consists from RPi3 or its copy Opange Pi equipped with SATA shield for external HDD. I've used my old HDD which left after laptop upgrade with SSD. I bought extension shield with metal case so everything is assembled together and the case has a fan. This hardware is working for almost two years. During first year it had Core + LND, now it serves Core + Elects and fairly stable (for this cheapest configuration).
90,738
I am trying to compile oclvanitygen because I have an Nvidia GTX 1080 that would most likely be helpful for this. I'm using the Windows Subsystem for Linux with Ubuntu 18.04. I tried this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libopencl.so.1` It basically says that `libopencl.so.1` does not exist. However, I have `libnvidia-opencl.so.1`, so I try this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` Then it says `/usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` So I do a list of `x86_64-linux-gnu`, and there it is, clear as day. [list of x86-64-linux-gnu](https://imgur.com/7Mkz6k3) How can I compile this correctly? Here is a picture of what happens when I run the command: [GCC Command](https://imgur.com/XflXMc1) I have installed the `ocl-icd-opencl-dev` package, but it does not include `libopencl.so.1`. Please tell me if I am doing something wrong. Thanks!
2019/09/30
['https://bitcoin.stackexchange.com/questions/90738', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/68755/']
Please do NOT run bitcoind on a remote server (I'm assuming cloud). This defeats the whole purpose of a decentralized network, not to mention privacy of being able to check your balances or broadcasting your transactions. Your cloud provider can always keep your ssh logs and any activity you perform on that server. A better cheaper solution (other than pruned nodes, which I would generally refrain from recommending as it prevents you from validating the whole chain) would be something along the lines of Raspberry Pi as also suggested by others. You can follow the instructions here: <https://github.com/rootzoll/raspiblitz> If you are not too tech savvy, you could buy a preconfigured Raspberry Pi with raspiblitz <https://thecryptocloak.com/product/build-a-node/>
You can reduce storage requirements by running Bitcoin-core in pruning mode * [How can I run bitcoind in pruning mode?](https://bitcoin.stackexchange.com/q/37496/13866)
90,738
I am trying to compile oclvanitygen because I have an Nvidia GTX 1080 that would most likely be helpful for this. I'm using the Windows Subsystem for Linux with Ubuntu 18.04. I tried this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libopencl.so.1` It basically says that `libopencl.so.1` does not exist. However, I have `libnvidia-opencl.so.1`, so I try this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` Then it says `/usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` So I do a list of `x86_64-linux-gnu`, and there it is, clear as day. [list of x86-64-linux-gnu](https://imgur.com/7Mkz6k3) How can I compile this correctly? Here is a picture of what happens when I run the command: [GCC Command](https://imgur.com/XflXMc1) I have installed the `ocl-icd-opencl-dev` package, but it does not include `libopencl.so.1`. Please tell me if I am doing something wrong. Thanks!
2019/09/30
['https://bitcoin.stackexchange.com/questions/90738', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/68755/']
You can run it locally in prune mode like @redgrittybrick suggested, or you can look into renting a cloud server. For example yesterday I created an AWS EC2 instance with extra storage and I played around with geth to deploy some smart contracts to testnet. You can do the same with bitcoind etc. You will connect to these remote servers with ssh and execute terminal commands without wasting any hard drive of your local pc.
The cheapest configuration consists from RPi3 or its copy Opange Pi equipped with SATA shield for external HDD. I've used my old HDD which left after laptop upgrade with SSD. I bought extension shield with metal case so everything is assembled together and the case has a fan. This hardware is working for almost two years. During first year it had Core + LND, now it serves Core + Elects and fairly stable (for this cheapest configuration).
90,738
I am trying to compile oclvanitygen because I have an Nvidia GTX 1080 that would most likely be helpful for this. I'm using the Windows Subsystem for Linux with Ubuntu 18.04. I tried this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libopencl.so.1` It basically says that `libopencl.so.1` does not exist. However, I have `libnvidia-opencl.so.1`, so I try this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` Then it says `/usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` So I do a list of `x86_64-linux-gnu`, and there it is, clear as day. [list of x86-64-linux-gnu](https://imgur.com/7Mkz6k3) How can I compile this correctly? Here is a picture of what happens when I run the command: [GCC Command](https://imgur.com/XflXMc1) I have installed the `ocl-icd-opencl-dev` package, but it does not include `libopencl.so.1`. Please tell me if I am doing something wrong. Thanks!
2019/09/30
['https://bitcoin.stackexchange.com/questions/90738', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/68755/']
Please do NOT run bitcoind on a remote server (I'm assuming cloud). This defeats the whole purpose of a decentralized network, not to mention privacy of being able to check your balances or broadcasting your transactions. Your cloud provider can always keep your ssh logs and any activity you perform on that server. A better cheaper solution (other than pruned nodes, which I would generally refrain from recommending as it prevents you from validating the whole chain) would be something along the lines of Raspberry Pi as also suggested by others. You can follow the instructions here: <https://github.com/rootzoll/raspiblitz> If you are not too tech savvy, you could buy a preconfigured Raspberry Pi with raspiblitz <https://thecryptocloak.com/product/build-a-node/>
You can run it locally in prune mode like @redgrittybrick suggested, or you can look into renting a cloud server. For example yesterday I created an AWS EC2 instance with extra storage and I played around with geth to deploy some smart contracts to testnet. You can do the same with bitcoind etc. You will connect to these remote servers with ssh and execute terminal commands without wasting any hard drive of your local pc.
90,738
I am trying to compile oclvanitygen because I have an Nvidia GTX 1080 that would most likely be helpful for this. I'm using the Windows Subsystem for Linux with Ubuntu 18.04. I tried this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libopencl.so.1` It basically says that `libopencl.so.1` does not exist. However, I have `libnvidia-opencl.so.1`, so I try this command: `gcc oclvanitygen.o oclengine.o pattern.o util.o -o oclvanitygen -ggdb -O3 -Wall -L/usr/lib/x86_64-linux-gnu/ -lpcre -lcrypto -lm -lpthread -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` Then it says `/usr/bin/ld: cannot find -l:/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1` So I do a list of `x86_64-linux-gnu`, and there it is, clear as day. [list of x86-64-linux-gnu](https://imgur.com/7Mkz6k3) How can I compile this correctly? Here is a picture of what happens when I run the command: [GCC Command](https://imgur.com/XflXMc1) I have installed the `ocl-icd-opencl-dev` package, but it does not include `libopencl.so.1`. Please tell me if I am doing something wrong. Thanks!
2019/09/30
['https://bitcoin.stackexchange.com/questions/90738', 'https://bitcoin.stackexchange.com', 'https://bitcoin.stackexchange.com/users/68755/']
Please do NOT run bitcoind on a remote server (I'm assuming cloud). This defeats the whole purpose of a decentralized network, not to mention privacy of being able to check your balances or broadcasting your transactions. Your cloud provider can always keep your ssh logs and any activity you perform on that server. A better cheaper solution (other than pruned nodes, which I would generally refrain from recommending as it prevents you from validating the whole chain) would be something along the lines of Raspberry Pi as also suggested by others. You can follow the instructions here: <https://github.com/rootzoll/raspiblitz> If you are not too tech savvy, you could buy a preconfigured Raspberry Pi with raspiblitz <https://thecryptocloak.com/product/build-a-node/>
The cheapest configuration consists from RPi3 or its copy Opange Pi equipped with SATA shield for external HDD. I've used my old HDD which left after laptop upgrade with SSD. I bought extension shield with metal case so everything is assembled together and the case has a fan. This hardware is working for almost two years. During first year it had Core + LND, now it serves Core + Elects and fairly stable (for this cheapest configuration).
219,984
Let $C$ be a (very) general genus 1 curve embedded in $\mathbb{CP}^1\times \mathbb{CP}^1$ as a (2,2)-divisor. Each projection defines $C$ as a double cover of $\mathbb{CP}^1$ and induces an involution $\tau\_i:C\to C$. Let $G\simeq \mathbb Z/2 \* \mathbb Z/2$ be the subgroup of $Aut(C)$ generated by these. Note that $G$ is infinite. Are there points on $C$ with finite orbit under $G$?
2015/10/04
['https://mathoverflow.net/questions/219984', 'https://mathoverflow.net', 'https://mathoverflow.net/users/68722/']
No. Letting $\sigma$ and $\tau$ denote the two involutions, $\sigma \circ \tau$ is a translation by an element of $\mathrm{Pic}^0(C)$. In general, this translation will not be torsion, so its orbit through any point is infinite. (In fact, if the translation IS torsion, then $G$ is a finite dihedral group, not $\mathbb{Z}/2 \ast \mathbb{Z}/2$.)
Regarding K3 surfaces in $\mathbb P^1\times\mathbb P^1\times\mathbb P^1$, you might find the following two articles relevant. (Also forward trace them as references for further articles.) 1. Baragar, A. Rational points on K3 surfaces in $\mathbb P^1\times\mathbb P^1\times\mathbb P^1$. *Math. Ann.* **305** (1996), no. 3, 541-558. (MR1397435) 2. Wang, Lan Rational points and canonical heights on K3-surfaces in $\mathbb P^1\times\mathbb P^1\times\mathbb P^1$. *Recent developments in the inverse Galois problem* (Seattle, WA, 1993), 273-289, *Contemp. Math.*, **186**, Amer. Math. Soc., Providence, RI, 1995 (MR1352278) **Addendum** Since you mention that you're interested in higher dimensional analogous, I'll mention the following. The involutions on a $(2,2,2)$-surface in $\mathbb P^1\times\mathbb P^1\times\mathbb P^1$ are morphisms. But if $n\ge4$, then the involutions on a $(2,2,\ldots,2)$ hypersurface in $\underbrace{\mathbb P^1\times\mathbb P^1\times\cdots\times\mathbb P^1}\_{\text{$n$ factors}}$ have non-trivial indeterminacy locus, so some points have orbits that terminate.
4,343,329
While studying Stirling numbers of the second kind the following formula for $n!$ suddenly popped up! $$n! = (-1)^n \sum\_{i=1}^n (-1)^i\binom{n}{i} i^n $$ I was curious if I could find a "direct" proof, i.e. not involving Stirling numbers, but after trying different approaches, f.i. induction, I was stuck. So a hint would be welcome!
2021/12/27
['https://math.stackexchange.com/questions/4343329', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/392000/']
Here is some insight for you. Consider a partially ordered set $S$ which has all meets. We will prove that $S$ has all joins. Let us consider some indexed collection $\{s\_i \in S\}\_{i \in I}$. Let $J = \{x \in S \mid \forall i \in I (s\_i \leq x)\}$. I claim that $\bigwedge J$ is the join of $s$. Indeed, we first note that for all $i$, for all $x \in J$, $s\_i \leq x$ (by the very definition of $J$). Therefore, $s\_i \leq \bigwedge J$. Now suppose that for all $i \in I$, $s\_i \leq x$. Then $x \in J$, so $\bigwedge J \leq x$. This completes the proof. $\square$ Your definition also works. Let's work through it. First, we must show that $Q := \{ \bigvee X \mid X \subseteq \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha$ and $\bigvee X$ exists$\}$ is in fact a $c$-ideal. As you have shown, (1) is trivial. For (2), suppose that $X \subseteq \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha$ and $\bigvee X$ exists, and that $a \leq \bigvee X$. Then $a = a \land \bigvee X = \bigvee \{a \land x \mid x \in X\}$ (using the fact that $a \land$ is the left adjoint to $a \implies$ and therefore preserves any colimits that do exist). Since each $I\_\alpha$ is downward closed, if $x \in I\_\alpha$ then $a \land x \in I\_\alpha$. And thus, we see that $\{a \land x \mid x \in X\} \subseteq \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha$. Thus, $a \in Q$. For (3), we need to get a big cleverer if we wish to avoid choice. Given $a \in Q$, let $f(a) = \{w \in \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha \mid w \leq a\}$; then clearly, $a = \bigvee f(a)$. Now suppose we have some family $\{x\_k \in Q\}\_{k \in K}$, and that $\bigvee\limits\_{k \in K} x\_k$ exists. Then in particular, we have $\bigvee\limits\_{k \in K} x\_k = \bigvee\limits\_{k \in K} \bigvee f(x\_k) = \bigvee \bigcup \limits\_{k \in K} f(x\_k)$. Note that $f(x\_k) \subseteq \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha$ by definition, so $\bigcup \limits\_{k \in K} f(x\_k) \subseteq \bigcup\limits\_{\alpha \in \mathcal{J}} I\_\alpha$. Therefore, $\bigvee\limits\_{k \in K} x\_k = \bigvee \bigcup \limits\_{k \in K} f(x\_k) \in Q$. Now, let's go about proving that $Q$ is in fact the join of the $I\_\alpha$. Clearly, we see that if $x \in I\_\alpha$, then $x = \bigvee \{x\} \in Q$. So $I\_\alpha \subseteq Q$ for all $\alpha$. Now suppose that we had some $y$ such that for all $\alpha$, $I\_\alpha \subseteq y$. Then condition 3 ensures that $Q \subseteq y$.
I found an alternative way to define the join. I would still like insight on the original question and/or a relationship to what follows. Let $A = \{ K \in H' \ | \ \underset{\alpha \in \mathcal{J}}{\bigcup} I\_{\alpha} \subseteq K \}$ that is $A$ is the set of complete ideals containing the union. Now clearly, $A$ is inhabited since $\underset{\alpha \in \mathcal{J}}{\bigcup} I\_{\alpha} \subseteq H \in H'$. Trivially we have the $\bigcap A$ is a complete ideal as it is an intersection of complete ideals. We wish to show that $\underset{\alpha \in \mathcal{J}}{\bigvee} I\_{\alpha} = \bigcap A$. First note that for every $\beta \in \mathcal{J}$ we have $I\_{\beta} \subseteq \underset{\alpha \in \mathcal{J}}{\bigcup} I\_{\alpha} \subseteq \bigcap A$ (where the last inclusion comes from the fact that $\underset{\alpha \in \mathcal{J}}{\bigcup} I\_{\alpha} \subseteq K$ for all $K \in A$.) So clearly, $\bigcap A$ is an upperbound. Suppose you have another upperbound $M$ in $H'$. That is for all $\beta \in \mathcal{J}$ we have $I\_{\beta} \subseteq M$. Then $\underset{\alpha \in \mathcal{J}}{\bigcup} I\_{\alpha} \subseteq M$ and thus $M \in A$. So we can conclude that $\bigcap A \subseteq M$.
73,481,572
I have converted the timestamp `4/1/2021 00:00` into the format `Thu Apr 01 2021 00:00:00 GMT-0500 (Central Daylight Time)` as shown in the code below. However, adding 30 days is not giving me appropriate result. ```js //Handling Date String: 4/1/2021 00:00 function setStart(input) { if (!(input instanceof Date)) console.log('Handling Date String:' +input) input = new Date(Date.parse(input)); input.setHours(0); input.setMinutes(0); input.setSeconds(0); input.setMilliseconds(0); start = input; return start; } var initialDate = setStart('4/1/2021 00:00'); console.log("Printing converted date below:"); console.log(setStart('4/1/2021 00:00')); var date = new Date(); // Now //date.setDate(date.getDate() + 30); // Set now + 30 days as the new date date.setDate(initialDate + 30); console.log("Printing date after adding 30 days below") console.log(date); /* var getDaysArray = function(start, end) { for(var arr=[],dt=new Date(start); dt<=new Date(end); dt.setDate(dt.getDate()+1)){ arr.push(new Date(dt)); } return arr; }; var daylist = getDaysArray(new Date("2018-05-01"),new Date("2018-06-01")); console.log(daylist); */ ``` The browser's console is printing it like the following: ``` Handling Date String:4/1/2021 00:00 Printing converted date below: Handling Date String:4/1/2021 00:00 Thu Apr 01 2021 00:00:00 GMT-0500 (Central Daylight Time) Printing date after adding 30 days below Invalid Date ``` What is causing it to print `Invalid Date` ?
2022/08/25
['https://Stackoverflow.com/questions/73481572', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2271895/']
You want to get the date after 30 days from the initialDate, don't you? refer this ```js var date = new Date(initialDate); // Now //date.setDate(date.getDate() + 30); // Set now + 30 days as the new date date.setDate(date.getDate() + 30); console.log("Printing date after adding 30 days below") console.log(date); ```
You should something like ```js var date = new Date().getTime(); // Now const offset = 30*23*3600*1000; const newDate = new Date(date+offset).toLocaleString('en-US', {timeZone: 'CST'}); // Change added console.log("Printing date after adding 30 days below") console.log(newDate); ```
12,467,901
I am using soapUI for testing a REST web service. Is there a way to attach a file with the other parameters in a multipart request? I see the attachment tab in the panel but I cannot give that attachment a parameter name so that server can identify. It's not helping.
2012/09/17
['https://Stackoverflow.com/questions/12467901', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/957081/']
I found it but forgot to post it here. It was not so intuitive. 1. In your REST Request if you can see an attachment tab, open it and add and attachment with + button. The Name of that file would show full path. e.g. `C:\temp\my-file.csv` 2. In you parameters tab, add a parameter and give it a name. The value of that parameter will be `file:C:\temp\my-file.csv` 3. In SoapUI 5.x and greater, you must select the "Post QueryString" checkbox. Without this, the file will not be send along with the request. That should be it. When attaching a file if you select Yes when it asks to Cache the file, you won't have to specify full path in step 2 above. The value of file parameter should be `file:my-file.csv`
select mediatype as application/json and then add the json string to that. It will go to server as payload. Usually this request is of POST or PUT type
15,126,798
I have a form where I want people to put in their year of birth. You can only apply if you are over 18 so in the year of birth field I want the min age to be 18. I have done this as shown below however I want to sort the numbers from latest year at the top and oldest year at the bottom. currently I show 1913 first, but I want to show 1994 first. Here is my code ``` <div id="my-container"></div> <script> var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = (y-100); x < (y - 18); x++) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); </script> ```
2013/02/28
['https://Stackoverflow.com/questions/15126798', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/737114/']
As [Nile mentioned](https://stackoverflow.com/questions/15126798/js-for-loop-sort-numbers/15126843#comment21290540_15126798), ``` var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = y-18; x >= y-100; x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); ``` <http://jsfiddle.net/samliew/WzwKw/>
try this ``` <script> var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = y-18; x > y - 100; x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); </script> ```
15,126,798
I have a form where I want people to put in their year of birth. You can only apply if you are over 18 so in the year of birth field I want the min age to be 18. I have done this as shown below however I want to sort the numbers from latest year at the top and oldest year at the bottom. currently I show 1913 first, but I want to show 1994 first. Here is my code ``` <div id="my-container"></div> <script> var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = (y-100); x < (y - 18); x++) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); </script> ```
2013/02/28
['https://Stackoverflow.com/questions/15126798', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/737114/']
try this ``` <script> var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = y-18; x > y - 100; x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); </script> ```
``` <script> $( document ).ready( function() { var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = (y-18); x >= (y - 100); x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); }); </script> ``` Please try with this.
15,126,798
I have a form where I want people to put in their year of birth. You can only apply if you are over 18 so in the year of birth field I want the min age to be 18. I have done this as shown below however I want to sort the numbers from latest year at the top and oldest year at the bottom. currently I show 1913 first, but I want to show 1994 first. Here is my code ``` <div id="my-container"></div> <script> var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = (y-100); x < (y - 18); x++) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); </script> ```
2013/02/28
['https://Stackoverflow.com/questions/15126798', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/737114/']
As [Nile mentioned](https://stackoverflow.com/questions/15126798/js-for-loop-sort-numbers/15126843#comment21290540_15126798), ``` var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = y-18; x >= y-100; x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); ``` <http://jsfiddle.net/samliew/WzwKw/>
``` <script> $( document ).ready( function() { var d = new Date(); var y = d.getFullYear(); var selectList = "<select>"; for (var x = (y-18); x >= (y - 100); x--) { selectList += "<option>" + x + "</option>"; } selectList += "</select>"; $('#my-container').html(selectList); }); </script> ``` Please try with this.
70,289,554
It's just a theoretical question. Is there a way to run the docker but only run one specific script without changing the Dockerfile? Maybe with the `docker run [container]` command? **Dockerfile:** ``` FROM python:3.8 ADD main1.py ADD main2.py ADD main3.py ADD main4.py ADD main5.py ``` **Theoretical Command:** `docker run docker-test main2.py`
2021/12/09
['https://Stackoverflow.com/questions/70289554', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17496765/']
There is nothing "theoretical" about this. Docker copies into place the files, and if they are working executables, you can execute them with `docker run image executable` ... but * it requires the files to be properly executable (or you will need to explicitly say `docker run image python executable` to run a Python script which is not executable) * it requires the files to be in your `PATH` for you to be able to specify their names without a path; or you will need to specify the full path within the container, or perhaps a relative path (`./executable` if they are in the container's default working directory) ``` docker run image /path/to/executable ``` * you obviously need the container to contain `python` in its `PATH` in order for it to find `python`; or you will similarly need to specify the full path to the interpreter ``` docker run image /usr/bin/python3 /path/to/executable ``` In summary, probably make sure you have `chmod +x` the script files and that they contain (the moral equivalent of) `#!/usr/bin/env python3` (or `python` if that's what the binary is called) on their first line. (And obviously, don't use DOS line feeds in files you want to be able to execute in a Linux container. Python can cope but the Linux kernel will look for `/usr/bin/env python3^M` if that's exactly what it says on the [shebang line](https://en.wikipedia.org/wiki/Shebang_(Unix)).)
In the specific case of a Python application, the standard Python [setuptools](https://setuptools.pypa.io/en/latest/) package has some functionality that can simplify this. In your application's `setup.cfg` file you can declare [entry points](https://setuptools.pypa.io/en/latest/userguide/entry_point.html) (different from the similarly-named Docker concept) which provide simple scripts to launch a specific part of your application. ``` [options.entry_points] console_scripts = main1 = app.main1:main main2 = app.main2:main ``` where the scripts `app/main1.py` look like normal top-level Python scripts ```py #!/usr/bin/env python3 # the console_scripts call this directly def main(): ... # for interactive use if __name__ == '__main__': main() ``` Now in your Dockerfile, you can use a generic Python application recipe and install this; all of the `console_scripts` will be automatically visible in the standard `$PATH`. ```sh FROM python:3.8 WORKDIR /app COPY . . RUN pip install . CMD ["main1"] ``` ```sh docker run --rm my-image main2 ``` It's worth noting that, up until the last part, we've been using generic Python utilities, and you can do the same thing without Docker ```sh # directly on the host, without Docker python3 -m venv ./virtual_environment . ./virtual_environment/bin/activate pip install . # then run any of the scripts directly main3 # technically activating the virtual environment is optional deactivate ./virtual_environment/bin/main4 ``` The fundamental point here is that the same rules apply for running a command on the host, in a Dockerfile `CMD`, or in a `docker run` command override (must be on `$PATH`, executable, have the correct interpreter, *etc.*). See [@tripleee's answer](https://stackoverflow.com/a/70289864) for a more generic, non-Python-specific approach.
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
In your case, it's the best to use rotate option from transform property as mentioned before. There is also `writing-mode` property and it works like rotate(90deg) so in your case, it should be rotated after it's applied. Even it's not the right solution in this case but you should be aware of this property. Example: ``` writing-mode:vertical-rl; ``` More about transform: <https://kolosek.com/css-transform/> More about writing-mode: <https://css-tricks.com/almanac/properties/w/writing-mode/>
I guess [this](http://snook.ca/archives/html_and_css/css-text-rotation) is what you are looking for? Added an example: The html: ``` <div class="example-date"> <span class="day">31</span> <span class="month">July</span> <span class="year">2009</span> </div> ``` The css: ``` .year { display:block; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); //For IE support } ``` Alle examples are from the mentioned site.
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
I guess [this](http://snook.ca/archives/html_and_css/css-text-rotation) is what you are looking for? Added an example: The html: ``` <div class="example-date"> <span class="day">31</span> <span class="month">July</span> <span class="year">2009</span> </div> ``` The css: ``` .year { display:block; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); //For IE support } ``` Alle examples are from the mentioned site.
Using `writing-mode` and `transform`. ``` .rotate { writing-mode: vertical-lr; -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); } <span class="rotate">Hello</span> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
I guess [this](http://snook.ca/archives/html_and_css/css-text-rotation) is what you are looking for? Added an example: The html: ``` <div class="example-date"> <span class="day">31</span> <span class="month">July</span> <span class="year">2009</span> </div> ``` The css: ``` .year { display:block; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); //For IE support } ``` Alle examples are from the mentioned site.
You can use like this... ``` <div id="rot">hello</div> #rot { -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); width:100px; } ``` Have a look at this fiddle:<http://jsfiddle.net/anish/MAN4g/>
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
In your case, it's the best to use rotate option from transform property as mentioned before. There is also `writing-mode` property and it works like rotate(90deg) so in your case, it should be rotated after it's applied. Even it's not the right solution in this case but you should be aware of this property. Example: ``` writing-mode:vertical-rl; ``` More about transform: <https://kolosek.com/css-transform/> More about writing-mode: <https://css-tricks.com/almanac/properties/w/writing-mode/>
Using `writing-mode` and `transform`. ``` .rotate { writing-mode: vertical-lr; -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); } <span class="rotate">Hello</span> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
You need to use the CSS3 [transform property](http://www.w3.org/TR/css3-2d-transforms/#transform-property) `rotate` - [see here](http://caniuse.com/#search=rotate) for which browsers support it and the prefix you need to use. One example for webkit browsers is `-webkit-transform: rotate(-90deg);` **Edit:** The question was changed substantially so I have added a [**demo**](http://jsfiddle.net/6wSAJ/) that works in Chrome/Safari (as I only included the `-webkit-` CSS prefixed rules). The problem you have is that you do not want to rotate the *title div*, but simply the text inside it. If you remove your rotation, the `<div>`s are in the correct position and all you need to do is wrap the text in an element and rotate that instead. There already exists a more customisable widget as part of the jQuery UI - see the [accordion](http://jqueryui.com/demos/accordion/) demo page. I am sure with some CSS cleverness you should be able to make the accordion vertical and also rotate the title text :-) **Edit 2:** I had anticipated the text center problem and have already [updated my demo](http://jsfiddle.net/6wSAJ/2/). There is a height/width constraint though, so longer text could still break the layout. **Edit 3:** It looks like the horizontal version was part of the [original plan](http://wiki.jqueryui.com/w/page/12137702/Accordion) but I cannot see any way of configuring it on the demo page. I was incorrect… the new accordion is part of the **upcoming** jQuery UI 1.9! So you could try the development builds if you want the new functionality. Hope this helps!
Using `writing-mode` and `transform`. ``` .rotate { writing-mode: vertical-lr; -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); } <span class="rotate">Hello</span> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
I guess [this](http://snook.ca/archives/html_and_css/css-text-rotation) is what you are looking for? Added an example: The html: ``` <div class="example-date"> <span class="day">31</span> <span class="month">July</span> <span class="year">2009</span> </div> ``` The css: ``` .year { display:block; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); //For IE support } ``` Alle examples are from the mentioned site.
[![enter image description here](https://i.stack.imgur.com/upf5W.png)](https://i.stack.imgur.com/upf5W.png) also you can ``` <div style="position:relative;display:block; height:125px;width:300px;"> <div class="status"> <div class="inner-point"> <div class="inner nowrap"> Some text </div> </div> </div> </div> <style> .status { position: absolute; background: #009FE3; right: 0; bottom: 0; top: 0; width: 37px; } .status .inner-point { position: absolute; bottom: 0; left: 0; background: red; width: 37px; height: 37px; } .status .inner { font-style: normal; font-weight: bold; font-size: 20px; line-height: 27px; letter-spacing: 0.2px; color: white; transform: rotate(-90deg); } </style> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
You need to use the CSS3 [transform property](http://www.w3.org/TR/css3-2d-transforms/#transform-property) `rotate` - [see here](http://caniuse.com/#search=rotate) for which browsers support it and the prefix you need to use. One example for webkit browsers is `-webkit-transform: rotate(-90deg);` **Edit:** The question was changed substantially so I have added a [**demo**](http://jsfiddle.net/6wSAJ/) that works in Chrome/Safari (as I only included the `-webkit-` CSS prefixed rules). The problem you have is that you do not want to rotate the *title div*, but simply the text inside it. If you remove your rotation, the `<div>`s are in the correct position and all you need to do is wrap the text in an element and rotate that instead. There already exists a more customisable widget as part of the jQuery UI - see the [accordion](http://jqueryui.com/demos/accordion/) demo page. I am sure with some CSS cleverness you should be able to make the accordion vertical and also rotate the title text :-) **Edit 2:** I had anticipated the text center problem and have already [updated my demo](http://jsfiddle.net/6wSAJ/2/). There is a height/width constraint though, so longer text could still break the layout. **Edit 3:** It looks like the horizontal version was part of the [original plan](http://wiki.jqueryui.com/w/page/12137702/Accordion) but I cannot see any way of configuring it on the demo page. I was incorrect… the new accordion is part of the **upcoming** jQuery UI 1.9! So you could try the development builds if you want the new functionality. Hope this helps!
[![enter image description here](https://i.stack.imgur.com/upf5W.png)](https://i.stack.imgur.com/upf5W.png) also you can ``` <div style="position:relative;display:block; height:125px;width:300px;"> <div class="status"> <div class="inner-point"> <div class="inner nowrap"> Some text </div> </div> </div> </div> <style> .status { position: absolute; background: #009FE3; right: 0; bottom: 0; top: 0; width: 37px; } .status .inner-point { position: absolute; bottom: 0; left: 0; background: red; width: 37px; height: 37px; } .status .inner { font-style: normal; font-weight: bold; font-size: 20px; line-height: 27px; letter-spacing: 0.2px; color: white; transform: rotate(-90deg); } </style> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
Using `writing-mode` and `transform`. ``` .rotate { writing-mode: vertical-lr; -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); } <span class="rotate">Hello</span> ```
[![enter image description here](https://i.stack.imgur.com/upf5W.png)](https://i.stack.imgur.com/upf5W.png) also you can ``` <div style="position:relative;display:block; height:125px;width:300px;"> <div class="status"> <div class="inner-point"> <div class="inner nowrap"> Some text </div> </div> </div> </div> <style> .status { position: absolute; background: #009FE3; right: 0; bottom: 0; top: 0; width: 37px; } .status .inner-point { position: absolute; bottom: 0; left: 0; background: red; width: 37px; height: 37px; } .status .inner { font-style: normal; font-weight: bold; font-size: 20px; line-height: 27px; letter-spacing: 0.2px; color: white; transform: rotate(-90deg); } </style> ```
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
In your case, it's the best to use rotate option from transform property as mentioned before. There is also `writing-mode` property and it works like rotate(90deg) so in your case, it should be rotated after it's applied. Even it's not the right solution in this case but you should be aware of this property. Example: ``` writing-mode:vertical-rl; ``` More about transform: <https://kolosek.com/css-transform/> More about writing-mode: <https://css-tricks.com/almanac/properties/w/writing-mode/>
You can use like this... ``` <div id="rot">hello</div> #rot { -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); width:100px; } ``` Have a look at this fiddle:<http://jsfiddle.net/anish/MAN4g/>
6,028,128
How do I rotate text in css to get following output: ![enter image description here](https://i.stack.imgur.com/Kcbot.jpg)hi, Edit: Thanks for quick suggestion. I have added my sample code in jsfidle: <http://jsfiddle.net/koolkabin/yawYM/> HTML: ``` <div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div> ``` CSS: ``` .mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;} ``` The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
2011/05/17
['https://Stackoverflow.com/questions/6028128', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178301/']
You can use like this... ``` <div id="rot">hello</div> #rot { -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); width:100px; } ``` Have a look at this fiddle:<http://jsfiddle.net/anish/MAN4g/>
[![enter image description here](https://i.stack.imgur.com/upf5W.png)](https://i.stack.imgur.com/upf5W.png) also you can ``` <div style="position:relative;display:block; height:125px;width:300px;"> <div class="status"> <div class="inner-point"> <div class="inner nowrap"> Some text </div> </div> </div> </div> <style> .status { position: absolute; background: #009FE3; right: 0; bottom: 0; top: 0; width: 37px; } .status .inner-point { position: absolute; bottom: 0; left: 0; background: red; width: 37px; height: 37px; } .status .inner { font-style: normal; font-weight: bold; font-size: 20px; line-height: 27px; letter-spacing: 0.2px; color: white; transform: rotate(-90deg); } </style> ```
562,193
I want to make a Sallen & Key 2nd-Order Butterworth highpass filter with a defined gain. Let's say gain is +6 db. [![enter image description here](https://i.stack.imgur.com/EuwOs.png)](https://i.stack.imgur.com/EuwOs.png) Then, R3 = R4 = 1 kOhm F = 1000 Hz C = 100 nF R2 = 2 \* Q / ( 2 \* 3.14 \* F \* C ) Now, I would assume that Q = 1 / ( 3 - A), where A = 1 + R3 / R4. But this table here doesn't agree. [![enter image description here](https://i.stack.imgur.com/nrxGm.png)](https://i.stack.imgur.com/nrxGm.png) What am i missing?
2021/04/26
['https://electronics.stackexchange.com/questions/562193', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/262542/']
Here's your diagram with some annotations: [![enter image description here](https://i.stack.imgur.com/t7JQnl.png)](https://i.stack.imgur.com/t7JQnl.png) (I'm not promising anything about stability here. This is a high pass filter with gain significantly greater than 1. So this is only an idealized analysis, by the numbers. That's all. Not a practical recipe.) Using [sympy](https://www.sympy.org/en/index.html): ``` eq1 = Eq( va/(1/s/c) + va/r1 + va/(1/s/c), vo/r1 + vb/(1/s/c) + vi/(1/s/c) ) eq2 = Eq( vb/r2 + vb/(1/s/c), va/(1/s/c) ) eq3 = Eq( vc/r4 + vc/r3, vo/r3 ) eq4 = Eq( vo/r3 + vo/r1, va/r1 + vc/r3 + io ) ans = solve( [eq1, eq2, eq3, eq4, Eq( vb, vc )], [io, va, vb, vc, vo] ) simplify( ans[vo]/vi ) c**2*r1*r2*s**2*(r3 + r4)/(c**2*r1*r2*r4*s**2 + 2*c*r1*r4*s - c*r2*r3*s + r4) ``` Moving that towards the standard high-pass form leads to the following: $$\begin{align\*} \omega\_{\_0}&=\frac1{C\sqrt{R\_1\,R\_2}}\\\\ \zeta&=\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}\\\\ K&=1+\frac{R\_3}{R\_4}\\\\ \mathcal{H}\left(s\right)&=K\frac{s^2}{s^2+2\zeta\,\omega\_{\_0}s+\omega\_{\_0}^{\:\!2}} \end{align\*}$$ I'll leave the algebraic details for you to find on your own. Now, you want to make a Butterworth filter. The 2nd order *normalized* (also known as *analytic*) Butterworth constants are: \$s^2 + \sqrt{2} s + 1\$. (This is where \$\omega\_{\_0}=1\$.) So it follows that \$2\zeta=\sqrt{2}\$ or \$\zeta=\frac12\sqrt{2}\$. So you have this new requirement: $$\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}=\frac12\sqrt{2}$$ From here, it is advisable to set \$R\_1=\eta\, R\$ and \$R\_2=\frac{R}{\eta}\$ so that \$\omega\_{\_0}=\frac1{R\,C}\$. This gives you some freedom to adjust these two resistor values. Also, given your desired gain of \$A\_v=K=2\$, it follows that \$\frac{R\_3}{R\_4}=1\$ and that: $$\begin{align\*} \eta-\frac12\frac1{\eta}&=\frac12\sqrt{2}\\\\ 2\eta-\frac1{\eta}&=\sqrt{2}\\\\ \therefore \eta&=\frac14\left(\sqrt{2}+\sqrt{10}\right)\approx 1.14412281 \end{align\*}$$ From here you can compute \$R\_1\$ and \$R\_2\$, given a desired \$R\$ used in setting \$\omega\_{\_0}\$. Let's say \$\omega\_{\_0}=6283.18531\$ (\$f\_{\_0}=1\:\text{kHz}\$) and that \$C=100\:\text{nF}\$, per your starting condition. Then it follows that \$R\approx 1.592\:\text{k}\Omega\$ and therefore that \$R\_1\approx 1.821\:\text{k}\Omega\$ and \$R\_2\approx 1.391\:\text{k}\Omega\$. My apologies for all that precision, here. But I'm retaining it so you can compare with the results from this [recommended site to compute filter component values](http://sim.okawa-denshi.jp/en/OPseikiHikeisan.htm). Using the E96 series of resistors, the above site says: ``` R1 = 1.82kΩ R2 = 1.4kΩ R3 = 10kΩ R4 = 10kΩ C1 = 0.1uF C2 = 0.1uF ``` Which is obviously quite close to what I just computed. Also, feel free to go there and look at the plot, as well. Again. This is a high pass filter with a voltage gain you've specified as \$A\_v=2\$! Isolated and by itself, I'm not at all suggesting that you try it with a high performance opamp. But computationally, at least, you can see where the numbers come from. (Or, at least, after you do some algebra.) P.S. You can also choose to set \$R\_1\$ and \$R\_2\$ to the same value. But if so, and if keeping with the Butterworth response, then you will find that the gain is no longer 2. It will have to be less. Something closer to \$3-\sqrt{2}\approx 1.586\$.
> > First, I will present a method that uses [Mathematica](https://www.wolfram.com/mathematica) to solve this problem. When I was studying this stuff I used the method all the time (without using Mathematica of course). > > > Well, we are trying to analyze the following [opamp-circuit](https://en.wikipedia.org/wiki/Operational_amplifier): ![schematic](https://i.stack.imgur.com/UCuCm.png) [simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fUCuCm.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) When we use and apply [KCL](https://en.wikipedia.org/wiki/Kirchhoff%27s_circuit_laws#Kirchhoff%27s_current_law), we can write the following set of equations: $$ \begin{cases} \text{I}\_1=\text{I}\_2+\text{I}\_3\\ \\ \text{I}\_1+\text{I}\_3+\text{I}\_4=\text{I}\_2+\text{I}\_5 \end{cases}\tag1 $$ When we use and apply [Ohm's law](https://en.wikipedia.org/wiki/Ohm%27s_law), we can write the following set of equations: $$ \begin{cases} \text{I}\_1=\frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}\\ \\ \text{I}\_2=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}\\ \\ \text{I}\_3=\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \text{I}\_2=\frac{\text{V}\_2}{\text{R}\_4}\\ \\ \text{I}\_5=\frac{\text{V}\_3-\text{V}\_4}{\text{R}\_5}\\ \\ \text{I}\_5=\frac{\text{V}\_4}{\text{R}\_6} \end{cases}\tag2 $$ Substitute \$(2)\$ into \$(1)\$, in order to get: $$ \begin{cases} \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_2}{\text{R}\_4}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_2}{\text{R}\_4}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\frac{\text{V}\_3-\text{V}\_4}{\text{R}\_5}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_2}{\text{R}\_4}+\frac{\text{V}\_4}{\text{R}\_6} \end{cases}\tag3 $$ Now, using an [ideal opamp](https://en.wikipedia.org/wiki/Operational_amplifier#Ideal_op_amps), we know that: $$\text{V}\_x:=\text{V}\_+=\text{V}\_-=\text{V}\_2=\text{V}\_4\tag4$$ So we can rewrite equation \$(3)\$ as follows: $$ \begin{cases} \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_x}{\text{R}\_4}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_x}{\text{R}\_4}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\frac{\text{V}\_3-\text{V}\_x}{\text{R}\_5}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_x}{\text{R}\_4}+\frac{\text{V}\_x}{\text{R}\_6} \end{cases}\tag5 $$ Now, we can solve for the transfer function: $$\mathcal{H}:=\frac{\text{V}\_3}{\text{V}\_\text{i}}=\frac{\text{R}\_3\text{R}\_4\left(\text{R}\_5+\text{R}\_6\right)}{\text{R}\_6\left(\text{R}\_1\left(\text{R}\_2+\text{R}\_3\right)+\text{R}\_3\left(\text{R}\_2+\text{R}\_4\right)\right)-\text{R}\_1\text{R}\_4\text{R}\_5}\tag6$$ Where I used the following Mathematica-code: ``` In[1]:=Clear["Global`*"]; V2 = Vx; V4 = Vx; FullSimplify[ Solve[{I1 == I2 + I3, I1 + I3 + I4 == I2 + I5, I1 == (Vi - V1)/R1, I2 == (V1 - V2)/R2, I3 == (V1 - V3)/R3, I2 == V2/R4, I5 == (V3 - V4)/R5, I5 == V4/R6}, {I1, I2, I3, I4, I5, V1, V3, Vx}]] Out[1]={{I1 -> ((R4 R5 - (R2 + R3) R6) Vi)/( R1 R4 R5 - (R1 (R2 + R3) + R3 (R2 + R4)) R6), I2 -> (R3 R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), I3 -> ((R4 R5 - R2 R6) Vi)/( R1 R4 R5 - (R1 (R2 + R3) + R3 (R2 + R4)) R6), I4 -> ((R3 R4 + 2 R4 R5 - 2 R2 R6) Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), I5 -> (R3 R4 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), V1 -> (R3 (R2 + R4) R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), V3 -> (R3 R4 (R5 + R6) Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), Vx -> (R3 R4 R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)}} ``` My equation was also confirmed using [LTspice](https://en.wikipedia.org/wiki/LTspice). --- When we want to apply the derivation from above to your circuit we need to use [Laplace transform](https://en.wikipedia.org/wiki/Laplace_transform) (I will use lower case function names for the functions that are in the (complex) s-domain, so \$\text{y}\left(\text{s}\right)\$ is the Laplace transform of the function \$\text{Y}\left(t\right)\$): * $$\text{R}\_1=\frac{1}{\text{sC}\_1}\tag7$$ * $$\text{R}\_2=\frac{1}{\text{sC}\_2}\tag8$$ So, we can rewrite the transfer function as: $$\mathscr{H}\left(\text{s}\right)=\frac{\text{R}\_3\text{R}\_4\left(\text{R}\_5+\text{R}\_6\right)}{\text{R}\_6\left(\frac{1}{\text{sC}\_1}\left(\frac{1}{\text{sC}\_2}+\text{R}\_3\right)+\text{R}\_3\left(\frac{1}{\text{sC}\_2}+\text{R}\_4\right)\right)-\frac{1}{\text{sC}\_1}\text{R}\_4\text{R}\_5}\tag9$$ Now, when working with sinusoidal signals we can use \$\text{s}:=\text{j}\omega\$ (where \$\text{j}^2=-1\$ and \$\omega=2\pi\text{f}\$ with \$\text{f}\$ is the frequency of the input signal in Hertz). Now, we know the values for \$\text{C}\_1=\text{C}\_2=100\cdot10^{-9}\space\text{F}\$ and \$\text{R}\_5=\text{R}\_6=1000\space\Omega\$ and we know that at \$\omega=2\pi\cdot1000\space\text{rad/sec}\$ we have \$20\log\_{10}\left(\left|\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|\right)=6\$. So by setting \$\text{R}\_3=\text{R}\_4:=\text{R}\$ we can solve for it and get: $$\text{R}\approx1587.8\space\Omega\tag{10}$$ Where I used the following code: ``` In[2]:=Clear["Global`*"]; R1 = 1/(s*C1); R2 = 1/(s*C2); s = I*\[Omega]; \[Omega] = 2*Pi*1000; C1 = c; C2 = c; c = 100*10^(-9); R5 = 1000; R6 = 1000; R3 = R; R4 = R; x = FullSimplify[ Sqrt[ComplexExpand[ Re[(R3 R4 (R5 + R6))/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)]]^2 + ComplexExpand[ Im[(R3 R4 (R5 + R6))/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)]]^2], Assumptions -> R > 0]; FullSimplify[Solve[{20 Log10[x] == 6, R > 0}, R]] Out[2]={{R -> (1/\[Pi]) 2500 \[Sqrt](2/ 3 (-125 - 80 10^(1/5) - 50 10^(2/5) - 32 10^(3/5) - 20 10^(4/5) + Sqrt[ 81125 + 51200 10^(1/5) + 32300 10^(2/5) + 20384 10^(3/5) + 12860 10^(4/5)]))}} In[3]:=N[%2] Out[3]={{R -> 1587.8}} ```
562,193
I want to make a Sallen & Key 2nd-Order Butterworth highpass filter with a defined gain. Let's say gain is +6 db. [![enter image description here](https://i.stack.imgur.com/EuwOs.png)](https://i.stack.imgur.com/EuwOs.png) Then, R3 = R4 = 1 kOhm F = 1000 Hz C = 100 nF R2 = 2 \* Q / ( 2 \* 3.14 \* F \* C ) Now, I would assume that Q = 1 / ( 3 - A), where A = 1 + R3 / R4. But this table here doesn't agree. [![enter image description here](https://i.stack.imgur.com/nrxGm.png)](https://i.stack.imgur.com/nrxGm.png) What am i missing?
2021/04/26
['https://electronics.stackexchange.com/questions/562193', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/262542/']
> > First, I will present a method that uses [Mathematica](https://www.wolfram.com/mathematica) to solve this problem. When I was studying this stuff I used the method all the time (without using Mathematica of course). > > > Well, we are trying to analyze the following [opamp-circuit](https://en.wikipedia.org/wiki/Operational_amplifier): ![schematic](https://i.stack.imgur.com/UCuCm.png) [simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fUCuCm.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) When we use and apply [KCL](https://en.wikipedia.org/wiki/Kirchhoff%27s_circuit_laws#Kirchhoff%27s_current_law), we can write the following set of equations: $$ \begin{cases} \text{I}\_1=\text{I}\_2+\text{I}\_3\\ \\ \text{I}\_1+\text{I}\_3+\text{I}\_4=\text{I}\_2+\text{I}\_5 \end{cases}\tag1 $$ When we use and apply [Ohm's law](https://en.wikipedia.org/wiki/Ohm%27s_law), we can write the following set of equations: $$ \begin{cases} \text{I}\_1=\frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}\\ \\ \text{I}\_2=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}\\ \\ \text{I}\_3=\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \text{I}\_2=\frac{\text{V}\_2}{\text{R}\_4}\\ \\ \text{I}\_5=\frac{\text{V}\_3-\text{V}\_4}{\text{R}\_5}\\ \\ \text{I}\_5=\frac{\text{V}\_4}{\text{R}\_6} \end{cases}\tag2 $$ Substitute \$(2)\$ into \$(1)\$, in order to get: $$ \begin{cases} \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_2}{\text{R}\_4}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_2}{\text{R}\_4}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_2}{\text{R}\_2}+\frac{\text{V}\_3-\text{V}\_4}{\text{R}\_5}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_2}{\text{R}\_4}+\frac{\text{V}\_4}{\text{R}\_6} \end{cases}\tag3 $$ Now, using an [ideal opamp](https://en.wikipedia.org/wiki/Operational_amplifier#Ideal_op_amps), we know that: $$\text{V}\_x:=\text{V}\_+=\text{V}\_-=\text{V}\_2=\text{V}\_4\tag4$$ So we can rewrite equation \$(3)\$ as follows: $$ \begin{cases} \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}=\frac{\text{V}\_x}{\text{R}\_4}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_x}{\text{R}\_4}+\text{I}\_5\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_1-\text{V}\_x}{\text{R}\_2}+\frac{\text{V}\_3-\text{V}\_x}{\text{R}\_5}\\ \\ \frac{\text{V}\_\text{i}-\text{V}\_1}{\text{R}\_1}+\frac{\text{V}\_1-\text{V}\_3}{\text{R}\_3}+\text{I}\_4=\frac{\text{V}\_x}{\text{R}\_4}+\frac{\text{V}\_x}{\text{R}\_6} \end{cases}\tag5 $$ Now, we can solve for the transfer function: $$\mathcal{H}:=\frac{\text{V}\_3}{\text{V}\_\text{i}}=\frac{\text{R}\_3\text{R}\_4\left(\text{R}\_5+\text{R}\_6\right)}{\text{R}\_6\left(\text{R}\_1\left(\text{R}\_2+\text{R}\_3\right)+\text{R}\_3\left(\text{R}\_2+\text{R}\_4\right)\right)-\text{R}\_1\text{R}\_4\text{R}\_5}\tag6$$ Where I used the following Mathematica-code: ``` In[1]:=Clear["Global`*"]; V2 = Vx; V4 = Vx; FullSimplify[ Solve[{I1 == I2 + I3, I1 + I3 + I4 == I2 + I5, I1 == (Vi - V1)/R1, I2 == (V1 - V2)/R2, I3 == (V1 - V3)/R3, I2 == V2/R4, I5 == (V3 - V4)/R5, I5 == V4/R6}, {I1, I2, I3, I4, I5, V1, V3, Vx}]] Out[1]={{I1 -> ((R4 R5 - (R2 + R3) R6) Vi)/( R1 R4 R5 - (R1 (R2 + R3) + R3 (R2 + R4)) R6), I2 -> (R3 R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), I3 -> ((R4 R5 - R2 R6) Vi)/( R1 R4 R5 - (R1 (R2 + R3) + R3 (R2 + R4)) R6), I4 -> ((R3 R4 + 2 R4 R5 - 2 R2 R6) Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), I5 -> (R3 R4 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), V1 -> (R3 (R2 + R4) R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), V3 -> (R3 R4 (R5 + R6) Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6), Vx -> (R3 R4 R6 Vi)/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)}} ``` My equation was also confirmed using [LTspice](https://en.wikipedia.org/wiki/LTspice). --- When we want to apply the derivation from above to your circuit we need to use [Laplace transform](https://en.wikipedia.org/wiki/Laplace_transform) (I will use lower case function names for the functions that are in the (complex) s-domain, so \$\text{y}\left(\text{s}\right)\$ is the Laplace transform of the function \$\text{Y}\left(t\right)\$): * $$\text{R}\_1=\frac{1}{\text{sC}\_1}\tag7$$ * $$\text{R}\_2=\frac{1}{\text{sC}\_2}\tag8$$ So, we can rewrite the transfer function as: $$\mathscr{H}\left(\text{s}\right)=\frac{\text{R}\_3\text{R}\_4\left(\text{R}\_5+\text{R}\_6\right)}{\text{R}\_6\left(\frac{1}{\text{sC}\_1}\left(\frac{1}{\text{sC}\_2}+\text{R}\_3\right)+\text{R}\_3\left(\frac{1}{\text{sC}\_2}+\text{R}\_4\right)\right)-\frac{1}{\text{sC}\_1}\text{R}\_4\text{R}\_5}\tag9$$ Now, when working with sinusoidal signals we can use \$\text{s}:=\text{j}\omega\$ (where \$\text{j}^2=-1\$ and \$\omega=2\pi\text{f}\$ with \$\text{f}\$ is the frequency of the input signal in Hertz). Now, we know the values for \$\text{C}\_1=\text{C}\_2=100\cdot10^{-9}\space\text{F}\$ and \$\text{R}\_5=\text{R}\_6=1000\space\Omega\$ and we know that at \$\omega=2\pi\cdot1000\space\text{rad/sec}\$ we have \$20\log\_{10}\left(\left|\underline{\mathscr{H}}\left(\text{j}\omega\right)\right|\right)=6\$. So by setting \$\text{R}\_3=\text{R}\_4:=\text{R}\$ we can solve for it and get: $$\text{R}\approx1587.8\space\Omega\tag{10}$$ Where I used the following code: ``` In[2]:=Clear["Global`*"]; R1 = 1/(s*C1); R2 = 1/(s*C2); s = I*\[Omega]; \[Omega] = 2*Pi*1000; C1 = c; C2 = c; c = 100*10^(-9); R5 = 1000; R6 = 1000; R3 = R; R4 = R; x = FullSimplify[ Sqrt[ComplexExpand[ Re[(R3 R4 (R5 + R6))/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)]]^2 + ComplexExpand[ Im[(R3 R4 (R5 + R6))/(-R1 R4 R5 + R1 (R2 + R3) R6 + R3 (R2 + R4) R6)]]^2], Assumptions -> R > 0]; FullSimplify[Solve[{20 Log10[x] == 6, R > 0}, R]] Out[2]={{R -> (1/\[Pi]) 2500 \[Sqrt](2/ 3 (-125 - 80 10^(1/5) - 50 10^(2/5) - 32 10^(3/5) - 20 10^(4/5) + Sqrt[ 81125 + 51200 10^(1/5) + 32300 10^(2/5) + 20384 10^(3/5) + 12860 10^(4/5)]))}} In[3]:=N[%2] Out[3]={{R -> 1587.8}} ```
From "A handbook of Active Filters", by D.E. Johnson, et al., reference VCVS high-pass filter. This uses tables of coefficients for the various types of filters (butterworth, cheby, elliptic, ...). Warning, C is a coefficient, C1 are the capacitor values. For 2nd order butterworth coefficients: ``` B = sqrt(2) C = 1.0 ``` Equations: ``` R2 = 4 * C / {[B + sqrt(B^2 + 8 * C * (K + 1)] * w * C1} R1 = C / {w^2 * C1^2 * R2} R4 = K * R2 / {K - 1} R3 = K * R2 ``` where: ``` K = gain w = 2*π*f C1 = capacitors (arbitrary value, same value for both) ``` R4 & R3 equations are given to optimize DC offset. You can make them any reasonable value if you don't care about DC offset. Choosing C1 = 100nF: ``` R2 = 1391.77 -> nearest 1% value = 1.40k R1 = 1821.85 -> nearest 1% value = 1.82k R3 = R4 = 2783.54 -> nearest 1% value = 2.87k ``` Spice simulation shows this to be very close to what you want. Watch out for your choice of dielectric for C1. Either use plastic or COG dielectrics. If using COG (NPO) dielectric, you may want to make C1 = 10nF. X7R, and other class 2 ceramic dielectrics, will introduce distortion, have a strong temperature dependence, and change value over time.
562,193
I want to make a Sallen & Key 2nd-Order Butterworth highpass filter with a defined gain. Let's say gain is +6 db. [![enter image description here](https://i.stack.imgur.com/EuwOs.png)](https://i.stack.imgur.com/EuwOs.png) Then, R3 = R4 = 1 kOhm F = 1000 Hz C = 100 nF R2 = 2 \* Q / ( 2 \* 3.14 \* F \* C ) Now, I would assume that Q = 1 / ( 3 - A), where A = 1 + R3 / R4. But this table here doesn't agree. [![enter image description here](https://i.stack.imgur.com/nrxGm.png)](https://i.stack.imgur.com/nrxGm.png) What am i missing?
2021/04/26
['https://electronics.stackexchange.com/questions/562193', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/262542/']
Here's your diagram with some annotations: [![enter image description here](https://i.stack.imgur.com/t7JQnl.png)](https://i.stack.imgur.com/t7JQnl.png) (I'm not promising anything about stability here. This is a high pass filter with gain significantly greater than 1. So this is only an idealized analysis, by the numbers. That's all. Not a practical recipe.) Using [sympy](https://www.sympy.org/en/index.html): ``` eq1 = Eq( va/(1/s/c) + va/r1 + va/(1/s/c), vo/r1 + vb/(1/s/c) + vi/(1/s/c) ) eq2 = Eq( vb/r2 + vb/(1/s/c), va/(1/s/c) ) eq3 = Eq( vc/r4 + vc/r3, vo/r3 ) eq4 = Eq( vo/r3 + vo/r1, va/r1 + vc/r3 + io ) ans = solve( [eq1, eq2, eq3, eq4, Eq( vb, vc )], [io, va, vb, vc, vo] ) simplify( ans[vo]/vi ) c**2*r1*r2*s**2*(r3 + r4)/(c**2*r1*r2*r4*s**2 + 2*c*r1*r4*s - c*r2*r3*s + r4) ``` Moving that towards the standard high-pass form leads to the following: $$\begin{align\*} \omega\_{\_0}&=\frac1{C\sqrt{R\_1\,R\_2}}\\\\ \zeta&=\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}\\\\ K&=1+\frac{R\_3}{R\_4}\\\\ \mathcal{H}\left(s\right)&=K\frac{s^2}{s^2+2\zeta\,\omega\_{\_0}s+\omega\_{\_0}^{\:\!2}} \end{align\*}$$ I'll leave the algebraic details for you to find on your own. Now, you want to make a Butterworth filter. The 2nd order *normalized* (also known as *analytic*) Butterworth constants are: \$s^2 + \sqrt{2} s + 1\$. (This is where \$\omega\_{\_0}=1\$.) So it follows that \$2\zeta=\sqrt{2}\$ or \$\zeta=\frac12\sqrt{2}\$. So you have this new requirement: $$\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}=\frac12\sqrt{2}$$ From here, it is advisable to set \$R\_1=\eta\, R\$ and \$R\_2=\frac{R}{\eta}\$ so that \$\omega\_{\_0}=\frac1{R\,C}\$. This gives you some freedom to adjust these two resistor values. Also, given your desired gain of \$A\_v=K=2\$, it follows that \$\frac{R\_3}{R\_4}=1\$ and that: $$\begin{align\*} \eta-\frac12\frac1{\eta}&=\frac12\sqrt{2}\\\\ 2\eta-\frac1{\eta}&=\sqrt{2}\\\\ \therefore \eta&=\frac14\left(\sqrt{2}+\sqrt{10}\right)\approx 1.14412281 \end{align\*}$$ From here you can compute \$R\_1\$ and \$R\_2\$, given a desired \$R\$ used in setting \$\omega\_{\_0}\$. Let's say \$\omega\_{\_0}=6283.18531\$ (\$f\_{\_0}=1\:\text{kHz}\$) and that \$C=100\:\text{nF}\$, per your starting condition. Then it follows that \$R\approx 1.592\:\text{k}\Omega\$ and therefore that \$R\_1\approx 1.821\:\text{k}\Omega\$ and \$R\_2\approx 1.391\:\text{k}\Omega\$. My apologies for all that precision, here. But I'm retaining it so you can compare with the results from this [recommended site to compute filter component values](http://sim.okawa-denshi.jp/en/OPseikiHikeisan.htm). Using the E96 series of resistors, the above site says: ``` R1 = 1.82kΩ R2 = 1.4kΩ R3 = 10kΩ R4 = 10kΩ C1 = 0.1uF C2 = 0.1uF ``` Which is obviously quite close to what I just computed. Also, feel free to go there and look at the plot, as well. Again. This is a high pass filter with a voltage gain you've specified as \$A\_v=2\$! Isolated and by itself, I'm not at all suggesting that you try it with a high performance opamp. But computationally, at least, you can see where the numbers come from. (Or, at least, after you do some algebra.) P.S. You can also choose to set \$R\_1\$ and \$R\_2\$ to the same value. But if so, and if keeping with the Butterworth response, then you will find that the gain is no longer 2. It will have to be less. Something closer to \$3-\sqrt{2}\approx 1.586\$.
From "A handbook of Active Filters", by D.E. Johnson, et al., reference VCVS high-pass filter. This uses tables of coefficients for the various types of filters (butterworth, cheby, elliptic, ...). Warning, C is a coefficient, C1 are the capacitor values. For 2nd order butterworth coefficients: ``` B = sqrt(2) C = 1.0 ``` Equations: ``` R2 = 4 * C / {[B + sqrt(B^2 + 8 * C * (K + 1)] * w * C1} R1 = C / {w^2 * C1^2 * R2} R4 = K * R2 / {K - 1} R3 = K * R2 ``` where: ``` K = gain w = 2*π*f C1 = capacitors (arbitrary value, same value for both) ``` R4 & R3 equations are given to optimize DC offset. You can make them any reasonable value if you don't care about DC offset. Choosing C1 = 100nF: ``` R2 = 1391.77 -> nearest 1% value = 1.40k R1 = 1821.85 -> nearest 1% value = 1.82k R3 = R4 = 2783.54 -> nearest 1% value = 2.87k ``` Spice simulation shows this to be very close to what you want. Watch out for your choice of dielectric for C1. Either use plastic or COG dielectrics. If using COG (NPO) dielectric, you may want to make C1 = 10nF. X7R, and other class 2 ceramic dielectrics, will introduce distortion, have a strong temperature dependence, and change value over time.
562,193
I want to make a Sallen & Key 2nd-Order Butterworth highpass filter with a defined gain. Let's say gain is +6 db. [![enter image description here](https://i.stack.imgur.com/EuwOs.png)](https://i.stack.imgur.com/EuwOs.png) Then, R3 = R4 = 1 kOhm F = 1000 Hz C = 100 nF R2 = 2 \* Q / ( 2 \* 3.14 \* F \* C ) Now, I would assume that Q = 1 / ( 3 - A), where A = 1 + R3 / R4. But this table here doesn't agree. [![enter image description here](https://i.stack.imgur.com/nrxGm.png)](https://i.stack.imgur.com/nrxGm.png) What am i missing?
2021/04/26
['https://electronics.stackexchange.com/questions/562193', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/262542/']
Here's your diagram with some annotations: [![enter image description here](https://i.stack.imgur.com/t7JQnl.png)](https://i.stack.imgur.com/t7JQnl.png) (I'm not promising anything about stability here. This is a high pass filter with gain significantly greater than 1. So this is only an idealized analysis, by the numbers. That's all. Not a practical recipe.) Using [sympy](https://www.sympy.org/en/index.html): ``` eq1 = Eq( va/(1/s/c) + va/r1 + va/(1/s/c), vo/r1 + vb/(1/s/c) + vi/(1/s/c) ) eq2 = Eq( vb/r2 + vb/(1/s/c), va/(1/s/c) ) eq3 = Eq( vc/r4 + vc/r3, vo/r3 ) eq4 = Eq( vo/r3 + vo/r1, va/r1 + vc/r3 + io ) ans = solve( [eq1, eq2, eq3, eq4, Eq( vb, vc )], [io, va, vb, vc, vo] ) simplify( ans[vo]/vi ) c**2*r1*r2*s**2*(r3 + r4)/(c**2*r1*r2*r4*s**2 + 2*c*r1*r4*s - c*r2*r3*s + r4) ``` Moving that towards the standard high-pass form leads to the following: $$\begin{align\*} \omega\_{\_0}&=\frac1{C\sqrt{R\_1\,R\_2}}\\\\ \zeta&=\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}\\\\ K&=1+\frac{R\_3}{R\_4}\\\\ \mathcal{H}\left(s\right)&=K\frac{s^2}{s^2+2\zeta\,\omega\_{\_0}s+\omega\_{\_0}^{\:\!2}} \end{align\*}$$ I'll leave the algebraic details for you to find on your own. Now, you want to make a Butterworth filter. The 2nd order *normalized* (also known as *analytic*) Butterworth constants are: \$s^2 + \sqrt{2} s + 1\$. (This is where \$\omega\_{\_0}=1\$.) So it follows that \$2\zeta=\sqrt{2}\$ or \$\zeta=\frac12\sqrt{2}\$. So you have this new requirement: $$\sqrt{\frac{R\_1}{R\_2}}-\frac12\frac{R\_3}{R\_4}\sqrt{\frac{R\_2}{R\_1}}=\frac12\sqrt{2}$$ From here, it is advisable to set \$R\_1=\eta\, R\$ and \$R\_2=\frac{R}{\eta}\$ so that \$\omega\_{\_0}=\frac1{R\,C}\$. This gives you some freedom to adjust these two resistor values. Also, given your desired gain of \$A\_v=K=2\$, it follows that \$\frac{R\_3}{R\_4}=1\$ and that: $$\begin{align\*} \eta-\frac12\frac1{\eta}&=\frac12\sqrt{2}\\\\ 2\eta-\frac1{\eta}&=\sqrt{2}\\\\ \therefore \eta&=\frac14\left(\sqrt{2}+\sqrt{10}\right)\approx 1.14412281 \end{align\*}$$ From here you can compute \$R\_1\$ and \$R\_2\$, given a desired \$R\$ used in setting \$\omega\_{\_0}\$. Let's say \$\omega\_{\_0}=6283.18531\$ (\$f\_{\_0}=1\:\text{kHz}\$) and that \$C=100\:\text{nF}\$, per your starting condition. Then it follows that \$R\approx 1.592\:\text{k}\Omega\$ and therefore that \$R\_1\approx 1.821\:\text{k}\Omega\$ and \$R\_2\approx 1.391\:\text{k}\Omega\$. My apologies for all that precision, here. But I'm retaining it so you can compare with the results from this [recommended site to compute filter component values](http://sim.okawa-denshi.jp/en/OPseikiHikeisan.htm). Using the E96 series of resistors, the above site says: ``` R1 = 1.82kΩ R2 = 1.4kΩ R3 = 10kΩ R4 = 10kΩ C1 = 0.1uF C2 = 0.1uF ``` Which is obviously quite close to what I just computed. Also, feel free to go there and look at the plot, as well. Again. This is a high pass filter with a voltage gain you've specified as \$A\_v=2\$! Isolated and by itself, I'm not at all suggesting that you try it with a high performance opamp. But computationally, at least, you can see where the numbers come from. (Or, at least, after you do some algebra.) P.S. You can also choose to set \$R\_1\$ and \$R\_2\$ to the same value. But if so, and if keeping with the Butterworth response, then you will find that the gain is no longer 2. It will have to be less. Something closer to \$3-\sqrt{2}\approx 1.586\$.
**Transfer function** for two **equal capacitors C** and gain **A=2**: H(s)=N(s)/D(s) with **N(s)=(s² \* 2 \* R1 \* R2 C²)** and **D(s)=[1+s(R1 \* 2C - R2 \* C) + s² \* R1 \* R2 \* C²]** From this (comparison with the general transfer function) with **k=R2/R1** Pole frequency **wp=1/[R1 \* C \* SQRT(k)]** and Pole-Q **Qp=SQRT(k)/(2-k)**=0.7071 with k1,2=2 + [1 (-+)SQRT(1+4)] **k1**=2 + 1 - 2.236 =**0.764** (for k2 Qp is negative). **R2=0.764 \* R1** --- **EDIT** (completion): Here is the general transfer function for a Sallen-Key filter (lowpass, highpass) with gain **A=1+(R3/R4)** and the horizontal elements Y0 and Y5: H(s)=N(s)/D(s) with **N(s)=A \* Y0 \* Y5** and **D(s)=Y2(Y0+Y1+Y5) + Y5[Y0 \* Y1 \* (1-A)]** Fot a **highpass** we select: **Y0=sC0, Y5=sC5, Y1=1/R1 and Y2=1/R2** For **C0=C5** and **A=2** the highpass function results as given above (after some mathematical manipulatons.)
562,193
I want to make a Sallen & Key 2nd-Order Butterworth highpass filter with a defined gain. Let's say gain is +6 db. [![enter image description here](https://i.stack.imgur.com/EuwOs.png)](https://i.stack.imgur.com/EuwOs.png) Then, R3 = R4 = 1 kOhm F = 1000 Hz C = 100 nF R2 = 2 \* Q / ( 2 \* 3.14 \* F \* C ) Now, I would assume that Q = 1 / ( 3 - A), where A = 1 + R3 / R4. But this table here doesn't agree. [![enter image description here](https://i.stack.imgur.com/nrxGm.png)](https://i.stack.imgur.com/nrxGm.png) What am i missing?
2021/04/26
['https://electronics.stackexchange.com/questions/562193', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/262542/']
**Transfer function** for two **equal capacitors C** and gain **A=2**: H(s)=N(s)/D(s) with **N(s)=(s² \* 2 \* R1 \* R2 C²)** and **D(s)=[1+s(R1 \* 2C - R2 \* C) + s² \* R1 \* R2 \* C²]** From this (comparison with the general transfer function) with **k=R2/R1** Pole frequency **wp=1/[R1 \* C \* SQRT(k)]** and Pole-Q **Qp=SQRT(k)/(2-k)**=0.7071 with k1,2=2 + [1 (-+)SQRT(1+4)] **k1**=2 + 1 - 2.236 =**0.764** (for k2 Qp is negative). **R2=0.764 \* R1** --- **EDIT** (completion): Here is the general transfer function for a Sallen-Key filter (lowpass, highpass) with gain **A=1+(R3/R4)** and the horizontal elements Y0 and Y5: H(s)=N(s)/D(s) with **N(s)=A \* Y0 \* Y5** and **D(s)=Y2(Y0+Y1+Y5) + Y5[Y0 \* Y1 \* (1-A)]** Fot a **highpass** we select: **Y0=sC0, Y5=sC5, Y1=1/R1 and Y2=1/R2** For **C0=C5** and **A=2** the highpass function results as given above (after some mathematical manipulatons.)
From "A handbook of Active Filters", by D.E. Johnson, et al., reference VCVS high-pass filter. This uses tables of coefficients for the various types of filters (butterworth, cheby, elliptic, ...). Warning, C is a coefficient, C1 are the capacitor values. For 2nd order butterworth coefficients: ``` B = sqrt(2) C = 1.0 ``` Equations: ``` R2 = 4 * C / {[B + sqrt(B^2 + 8 * C * (K + 1)] * w * C1} R1 = C / {w^2 * C1^2 * R2} R4 = K * R2 / {K - 1} R3 = K * R2 ``` where: ``` K = gain w = 2*π*f C1 = capacitors (arbitrary value, same value for both) ``` R4 & R3 equations are given to optimize DC offset. You can make them any reasonable value if you don't care about DC offset. Choosing C1 = 100nF: ``` R2 = 1391.77 -> nearest 1% value = 1.40k R1 = 1821.85 -> nearest 1% value = 1.82k R3 = R4 = 2783.54 -> nearest 1% value = 2.87k ``` Spice simulation shows this to be very close to what you want. Watch out for your choice of dielectric for C1. Either use plastic or COG dielectrics. If using COG (NPO) dielectric, you may want to make C1 = 10nF. X7R, and other class 2 ceramic dielectrics, will introduce distortion, have a strong temperature dependence, and change value over time.
76,845
Once the attacker finds an exploitable vulnerability in a user program, e.g., buffer overflow. Assume his goal is to gain root privilege and typical countermeasures are not present in the system (ASLR, NX, etc.). What are the general ways that an attacker can gain root privilege (in linux and windows)? EDIT 1: A simple and real examples would be really helpful.
2014/12/25
['https://security.stackexchange.com/questions/76845', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/62118/']
There are many ways to get to root. You need to consider exploits which get you root, as well as those which get you access at a lower privilege in conjunction with a privilege escalation exploit. Generally what you need is an exploit in a service run as root, or another privileged account. As cremefraiche noted, you should have a good read of [cve.mitre.org](http://cve.mitre.org) to get some idea of the variety.
I think in real world case, the attacker would package a new vulnerability into a tool like Metasploit. That tool provides a full framework for gaining a presence on the target host and then escalating privileges.
76,845
Once the attacker finds an exploitable vulnerability in a user program, e.g., buffer overflow. Assume his goal is to gain root privilege and typical countermeasures are not present in the system (ASLR, NX, etc.). What are the general ways that an attacker can gain root privilege (in linux and windows)? EDIT 1: A simple and real examples would be really helpful.
2014/12/25
['https://security.stackexchange.com/questions/76845', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/62118/']
There are many ways to get to root. You need to consider exploits which get you root, as well as those which get you access at a lower privilege in conjunction with a privilege escalation exploit. Generally what you need is an exploit in a service run as root, or another privileged account. As cremefraiche noted, you should have a good read of [cve.mitre.org](http://cve.mitre.org) to get some idea of the variety.
One way to gain the root privilege in Linux is to exploit a vulnerability in a set-root-uid program. Basically, a set-root-uid program allows an unprivileged user to do some tasks with the root privilege. An example of a set-root-uid program is the passwd program for password management. You can find a simple example with step-by step guidance of exploiting set-root-uid program to gain root privilege at here: <http://www.cis.syr.edu/~wedu/seed/Labs_12.04/Vulnerability/Buffer_Overflow/>
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Is this actually a problem? =========================== I fairly recently had this exact experience. My manager was considerably more interested in doing day to day work than managerial duties, such as: * [Caring about resource management](https://workplace.stackexchange.com/q/9128/2322) * Effectively working with other managers * Making our team's project work [visible](https://workplace.stackexchange.com/a/11818/2322) to others I had many conversations about this very subject, to the point where I (and others on my team) were told to effectively "just worry about your own position and not what others were doing." Well, our main problem was that my manager was *not* effectively leading the team and the key obstacle to our project being successful was in fact our manager not doing the leadership/managerial duties. Your concerns are absolutely valid. Some things to keep in mind: * Some people are managers because of circumstance, rather than desire/ability. Many a manager gets there because they happen to be the most senior individual contributor even though they may be considerably more effective as an individual contributor than manager. Or other reasons unrelated to their ability to manage. * Some managers never accept the idea that they are managers and not worker bees. * Management offers considerably more ambiguous "what did I do at work today?" answers. For many people who like checklists and feeling accomplished, this can make work very hollow/meaningless * Management is a huge step outside a comfort zone for many people. The longer someone has been an individual contributor, the more difficult it can be. * They might be totally aware of this issue but having a really hard time doing anything about it. * This becomes more important the larger a team is. If your boss has 3 direct reports, it's less important. But if you have a team of 10, your manager doing day-to-day work is considerably more problematic. What can you do about it? ========================= Don't focus on the things you can't change (ie your manager's tendency to do work he shouldn't do). Focus on what your manager is *not* doing for you and your team. Are you not getting the resources you need from him? Is your team not working together effectively? Do you need a team meeting/etc? If you don't have regular 1/1s because of your manager is too busy doing day-to-day work, don't say "you should stop doing day to day work so we can have 1/1s" but just approach it from the "can we have 1/1s? this would be helpful for x/y/z reasons." If your team needs more visibility, approach it from the perspective of, "hey, what do you think we can do to get our team more visibility?" In addition to this, be sure to thank your manager for the effective managerial work that he does. People respond surprisingly well to positive feedback. Continually reinforcing your manager for managing is a easy, non-threatening way you can encourage them to manage rather than do day-to-day work. --- This [answer](https://workplace.stackexchange.com/a/11606/2322) to a related question is quite informative.
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating: * He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet) * The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate * He really does like getting his hands dirty. * Doing those tasks reminds him of what he's passionate about. * He wants a break from his other duties. * Etc. He certainly isn't the first person to move up and miss doing the grunt work. If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc). By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours. **Personal anecdote(I've made my point by now, the rest is fluff):** I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code. It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time. Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating: * He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet) * The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate * He really does like getting his hands dirty. * Doing those tasks reminds him of what he's passionate about. * He wants a break from his other duties. * Etc. He certainly isn't the first person to move up and miss doing the grunt work. If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc). By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours. **Personal anecdote(I've made my point by now, the rest is fluff):** I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code. It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time. Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
It isn't your place to do anything about this. Your manager will manage his time according to his boss and himself. If it's not affecting you then you shouldn't say anything. If it is affecting you, for example he hasn't made a decision on which way a project should go, politely ask him for a decision and state that your work is being held up by the lack of a decision. If his queries are impacting on your work then you should point out to him how it is impacting and the right tools / libraries to use to avoid impacting on you in the future, focus on the way for him to stop impacting your work and you might just find he realises he's a bit out of touch and stops on his own. However if he wants to run those queries rather than delegate then that's his right as the Manager. If it's such a big problem then find another job (and mention why you're leaving in your exit interview), or find a way to become a manager on the same level as him (if that's possible) and then you can talk to him as a colleague rather than your boss.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Is this actually a problem? =========================== I fairly recently had this exact experience. My manager was considerably more interested in doing day to day work than managerial duties, such as: * [Caring about resource management](https://workplace.stackexchange.com/q/9128/2322) * Effectively working with other managers * Making our team's project work [visible](https://workplace.stackexchange.com/a/11818/2322) to others I had many conversations about this very subject, to the point where I (and others on my team) were told to effectively "just worry about your own position and not what others were doing." Well, our main problem was that my manager was *not* effectively leading the team and the key obstacle to our project being successful was in fact our manager not doing the leadership/managerial duties. Your concerns are absolutely valid. Some things to keep in mind: * Some people are managers because of circumstance, rather than desire/ability. Many a manager gets there because they happen to be the most senior individual contributor even though they may be considerably more effective as an individual contributor than manager. Or other reasons unrelated to their ability to manage. * Some managers never accept the idea that they are managers and not worker bees. * Management offers considerably more ambiguous "what did I do at work today?" answers. For many people who like checklists and feeling accomplished, this can make work very hollow/meaningless * Management is a huge step outside a comfort zone for many people. The longer someone has been an individual contributor, the more difficult it can be. * They might be totally aware of this issue but having a really hard time doing anything about it. * This becomes more important the larger a team is. If your boss has 3 direct reports, it's less important. But if you have a team of 10, your manager doing day-to-day work is considerably more problematic. What can you do about it? ========================= Don't focus on the things you can't change (ie your manager's tendency to do work he shouldn't do). Focus on what your manager is *not* doing for you and your team. Are you not getting the resources you need from him? Is your team not working together effectively? Do you need a team meeting/etc? If you don't have regular 1/1s because of your manager is too busy doing day-to-day work, don't say "you should stop doing day to day work so we can have 1/1s" but just approach it from the "can we have 1/1s? this would be helpful for x/y/z reasons." If your team needs more visibility, approach it from the perspective of, "hey, what do you think we can do to get our team more visibility?" In addition to this, be sure to thank your manager for the effective managerial work that he does. People respond surprisingly well to positive feedback. Continually reinforcing your manager for managing is a easy, non-threatening way you can encourage them to manage rather than do day-to-day work. --- This [answer](https://workplace.stackexchange.com/a/11606/2322) to a related question is quite informative.
It isn't your place to do anything about this. Your manager will manage his time according to his boss and himself. If it's not affecting you then you shouldn't say anything. If it is affecting you, for example he hasn't made a decision on which way a project should go, politely ask him for a decision and state that your work is being held up by the lack of a decision. If his queries are impacting on your work then you should point out to him how it is impacting and the right tools / libraries to use to avoid impacting on you in the future, focus on the way for him to stop impacting your work and you might just find he realises he's a bit out of touch and stops on his own. However if he wants to run those queries rather than delegate then that's his right as the Manager. If it's such a big problem then find another job (and mention why you're leaving in your exit interview), or find a way to become a manager on the same level as him (if that's possible) and then you can talk to him as a colleague rather than your boss.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Build trust. Gently explain that other are dedicated to the type of problems that they are trying to solve and offer to be a proxy (i.e. tell them that you want to help them save time and point them in the right direction whenever they have a problem like the ones above). Also gently explain that their time is super valuable and if they spend it doing things that low level drones can and are already doing you (i.e. the company) are losing money. At the end of the day remember who is signing your paycheck.
It isn't your place to do anything about this. Your manager will manage his time according to his boss and himself. If it's not affecting you then you shouldn't say anything. If it is affecting you, for example he hasn't made a decision on which way a project should go, politely ask him for a decision and state that your work is being held up by the lack of a decision. If his queries are impacting on your work then you should point out to him how it is impacting and the right tools / libraries to use to avoid impacting on you in the future, focus on the way for him to stop impacting your work and you might just find he realises he's a bit out of touch and stops on his own. However if he wants to run those queries rather than delegate then that's his right as the Manager. If it's such a big problem then find another job (and mention why you're leaving in your exit interview), or find a way to become a manager on the same level as him (if that's possible) and then you can talk to him as a colleague rather than your boss.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Build trust. Gently explain that other are dedicated to the type of problems that they are trying to solve and offer to be a proxy (i.e. tell them that you want to help them save time and point them in the right direction whenever they have a problem like the ones above). Also gently explain that their time is super valuable and if they spend it doing things that low level drones can and are already doing you (i.e. the company) are losing money. At the end of the day remember who is signing your paycheck.
EDIT: this answer as written when OP's original version implied they were an individual contributor, before the crucial detail that they are a manager managing a team of 10, which completely changes the question. Moreover this makes the boss a level-2 manager, which is a different situation. --- I'd bloody rejoice. A manager who wants to keep their hand in the game? Consider yourself lucky. This is a blessing in disguise. I don't see that this a problem, certainly no more than a manager who spends too much time in meetings, presentations, reviews, conferences, executive lunches, politicking, MBA classes, playing golf, drinking, betting on the horses or other sanctioned modes of slacking. Even if we conclude it's a problem, it's at most a small problem and it's certainly not ***your*** problem. One good side-effect is that they will still be competent at hiring good technical people, which is something that PowerPoint warriors lose (or delegate to the HR dept, or stop caring, and the organizational rot sets in). (**What's their motivation?** Need to present credible data to higher-ups? Want to stay technical and deny the cloak of management being thrust upon them? Technically insecure? Impostor syndrome? Afraid of being laid off, or that their role has become obsolete? Want to understand what you or their subordinates are doing better? Want to know how to hire or manage you better? or hire your replacement if you leave? They may have several of these motivations, and don't expect them to tell you.) Most of those are fine, and even the ones that aren't can work to your advantage. ***You can (privately) show them you that you can do their work faster*** (or some automated script, or query tool, or GUI). Implement it yourself. If they're a chart person, give them charts. If they're a KPI person, give them numbers. If they like doing it interactively, install a query tool and write a wiki of frequently-used queries. If they want to tie things to the build/SCM process, implement that. Consider this a hidden opportunity to both do something productive and "get recognition" at multiple levels of the hierarchy. This is how useful internal tools generally happen. Show them a functional prototype then see if they approve spending further time on it. a > > I know that for some people giving up the "getting my hands dirty" is difficult > > > Honestly that's a badge of being a good engineer, if somewhat unrealistic about their productivity. (Read about *"Engineer-not-Manager"*) > > How can I convince them to stop "doing", without being rude, annoying, or worse? > > > **It's not your %#@& job to.** If you must, be very oblique. Just offer them a higher-productivity alternative, and privately walk them through it, only if they show interest. Then if they still insist on doing it themselves, then let it be. They may have some unresolved identity or competence crisis; if so, don't force it. > > but I really feel this is becoming a problem and I want to try to improve the situation. > > > But it's not, based on anything you've said! Anyway it's not your perception that matters as to whether it's a problem. Don't let your ego be threatened, don't feel insecure. ***tl;dr: Rejoice, let it go, use it to your career advantage, keep them happy while nudging them towards a mutually useful point, boost their managerial self-esteem***
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating: * He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet) * The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate * He really does like getting his hands dirty. * Doing those tasks reminds him of what he's passionate about. * He wants a break from his other duties. * Etc. He certainly isn't the first person to move up and miss doing the grunt work. If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc). By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours. **Personal anecdote(I've made my point by now, the rest is fluff):** I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code. It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time. Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
EDIT: this answer as written when OP's original version implied they were an individual contributor, before the crucial detail that they are a manager managing a team of 10, which completely changes the question. Moreover this makes the boss a level-2 manager, which is a different situation. --- I'd bloody rejoice. A manager who wants to keep their hand in the game? Consider yourself lucky. This is a blessing in disguise. I don't see that this a problem, certainly no more than a manager who spends too much time in meetings, presentations, reviews, conferences, executive lunches, politicking, MBA classes, playing golf, drinking, betting on the horses or other sanctioned modes of slacking. Even if we conclude it's a problem, it's at most a small problem and it's certainly not ***your*** problem. One good side-effect is that they will still be competent at hiring good technical people, which is something that PowerPoint warriors lose (or delegate to the HR dept, or stop caring, and the organizational rot sets in). (**What's their motivation?** Need to present credible data to higher-ups? Want to stay technical and deny the cloak of management being thrust upon them? Technically insecure? Impostor syndrome? Afraid of being laid off, or that their role has become obsolete? Want to understand what you or their subordinates are doing better? Want to know how to hire or manage you better? or hire your replacement if you leave? They may have several of these motivations, and don't expect them to tell you.) Most of those are fine, and even the ones that aren't can work to your advantage. ***You can (privately) show them you that you can do their work faster*** (or some automated script, or query tool, or GUI). Implement it yourself. If they're a chart person, give them charts. If they're a KPI person, give them numbers. If they like doing it interactively, install a query tool and write a wiki of frequently-used queries. If they want to tie things to the build/SCM process, implement that. Consider this a hidden opportunity to both do something productive and "get recognition" at multiple levels of the hierarchy. This is how useful internal tools generally happen. Show them a functional prototype then see if they approve spending further time on it. a > > I know that for some people giving up the "getting my hands dirty" is difficult > > > Honestly that's a badge of being a good engineer, if somewhat unrealistic about their productivity. (Read about *"Engineer-not-Manager"*) > > How can I convince them to stop "doing", without being rude, annoying, or worse? > > > **It's not your %#@& job to.** If you must, be very oblique. Just offer them a higher-productivity alternative, and privately walk them through it, only if they show interest. Then if they still insist on doing it themselves, then let it be. They may have some unresolved identity or competence crisis; if so, don't force it. > > but I really feel this is becoming a problem and I want to try to improve the situation. > > > But it's not, based on anything you've said! Anyway it's not your perception that matters as to whether it's a problem. Don't let your ego be threatened, don't feel insecure. ***tl;dr: Rejoice, let it go, use it to your career advantage, keep them happy while nudging them towards a mutually useful point, boost their managerial self-esteem***
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Build trust. Gently explain that other are dedicated to the type of problems that they are trying to solve and offer to be a proxy (i.e. tell them that you want to help them save time and point them in the right direction whenever they have a problem like the ones above). Also gently explain that their time is super valuable and if they spend it doing things that low level drones can and are already doing you (i.e. the company) are losing money. At the end of the day remember who is signing your paycheck.
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating: * He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet) * The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate * He really does like getting his hands dirty. * Doing those tasks reminds him of what he's passionate about. * He wants a break from his other duties. * Etc. He certainly isn't the first person to move up and miss doing the grunt work. If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc). By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours. **Personal anecdote(I've made my point by now, the rest is fluff):** I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code. It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time. Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
I'm kind of latching on to one idea that may not actually be relevant, but one thing you mentioned was the difficulty of giving up "getting my hands dirty". This could be true, or it could be that he just fails at delegating tasks once in a while. Various reasons could be at play for not delegating: * He's uncomfortable with delegating tasks(or otherwise hasn't gotten used to it yet) * The tasks he ends up doing are close to his experience, so he sees himself as the obvious candidate * He really does like getting his hands dirty. * Doing those tasks reminds him of what he's passionate about. * He wants a break from his other duties. * Etc. He certainly isn't the first person to move up and miss doing the grunt work. If you end up in meetings where your boss says things like "Today I'm going to try doing `<drone work tasks>` to help you guys along", then whoever has the most experience with those drone tasks could speak up and ask to do them instead. 'Ask' is the key word in the last sentence. Don't *tell* your boss you're going to do the task - *ask* him. It's important that he sees he has the power to make the decision. Eg. (You say) "Oh! I've been working on the SQL queries lately and have a few scripts that help me. I could do `<the thing>` and have the report in your e-mail by close-of-business today. Would that be ok with you?" The key is to make it really easy for him to say 'yes' to you - stack the odds in your favor however you can(you're not busy, it'll take you no time at all, you have the tools ready to go, you won't miss your deadline(s) for anything, his time is better spent elsewhere, etc). By taking initiative to do these tasks, you(as a team) show him you're willing to step up for him to get the job done, and it's a way of easing him into delegating tasks to people. He may be good at delegating big-picture stuff. He's not stupid enough to think he can do all the work himself. But these one-off situations are trickier, especially when you remember being able to do these kinds of things in a few hours. **Personal anecdote(I've made my point by now, the rest is fluff):** I'm a very non-confrontational person and I'm also a junior software developer. I was given the reins of one of our R&D labs, which may sound more grandiose than it really was - I 'managed' 2 people's time in the lab(both working part time usually, sometimes full time) for roughly 4 months. At the start most of my time, roughly 80% weekly, was on my main project, so I had ~8 hours per week (2 hours per day Mon-Thurs) to deal with the R&D lab. I wasn't comfortable with telling people what to do, but I really had no other choice. If I hadn't been thrown in the deep end and had to 'figure it out' so abruptly with the time constraints that I had, I think the transition would've been tougher and I'd be more prone to helping with tasks. To say the least, it was *very* difficult to not stick my hands in the code. It also helped that the people I 'managed' were two coworkers I had worked with extensively who were both smart and trustworthy. When I gave them tasks, I was certain they'd ask questions if they got stuck, but otherwise they would finish them and not waste time. Your post doesn't give too much detail, but the delegation thing just got stuck in my head since I went through that last year. If your boss is a newly-made/recently-promoted boss, perhaps that's what he's going through.
This depends a lot on the managers/directors in questions. Are you positive that they actually take longer to perform XX task? I have had directors & managers from both sides of the competence scale in regards to being able to perform the work of the people under them. You will find that in some cases while they may appear 'slower' than you or your peers they are checking up on the quality of other work, if they are on the lower end of the competence scale they may be simply doing it as exercises to familiarize themselves with day to day operations or trying to figure out where bottlenecks are. ( remember at Mcdonalds a manager is someone who knows every single job in the store inside and out. ) Now if its a director that is doing this you have to be aware that "its their company", you just happen to be there because it suits them to have you around. They were there long before you started and will be there long after you leave. and more likely than not when the company first started it was them that did the lions share of the work, and as time progressed more and more staff got added because their workload increased.
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
Is this actually a problem? =========================== I fairly recently had this exact experience. My manager was considerably more interested in doing day to day work than managerial duties, such as: * [Caring about resource management](https://workplace.stackexchange.com/q/9128/2322) * Effectively working with other managers * Making our team's project work [visible](https://workplace.stackexchange.com/a/11818/2322) to others I had many conversations about this very subject, to the point where I (and others on my team) were told to effectively "just worry about your own position and not what others were doing." Well, our main problem was that my manager was *not* effectively leading the team and the key obstacle to our project being successful was in fact our manager not doing the leadership/managerial duties. Your concerns are absolutely valid. Some things to keep in mind: * Some people are managers because of circumstance, rather than desire/ability. Many a manager gets there because they happen to be the most senior individual contributor even though they may be considerably more effective as an individual contributor than manager. Or other reasons unrelated to their ability to manage. * Some managers never accept the idea that they are managers and not worker bees. * Management offers considerably more ambiguous "what did I do at work today?" answers. For many people who like checklists and feeling accomplished, this can make work very hollow/meaningless * Management is a huge step outside a comfort zone for many people. The longer someone has been an individual contributor, the more difficult it can be. * They might be totally aware of this issue but having a really hard time doing anything about it. * This becomes more important the larger a team is. If your boss has 3 direct reports, it's less important. But if you have a team of 10, your manager doing day-to-day work is considerably more problematic. What can you do about it? ========================= Don't focus on the things you can't change (ie your manager's tendency to do work he shouldn't do). Focus on what your manager is *not* doing for you and your team. Are you not getting the resources you need from him? Is your team not working together effectively? Do you need a team meeting/etc? If you don't have regular 1/1s because of your manager is too busy doing day-to-day work, don't say "you should stop doing day to day work so we can have 1/1s" but just approach it from the "can we have 1/1s? this would be helpful for x/y/z reasons." If your team needs more visibility, approach it from the perspective of, "hey, what do you think we can do to get our team more visibility?" In addition to this, be sure to thank your manager for the effective managerial work that he does. People respond surprisingly well to positive feedback. Continually reinforcing your manager for managing is a easy, non-threatening way you can encourage them to manage rather than do day-to-day work. --- This [answer](https://workplace.stackexchange.com/a/11606/2322) to a related question is quite informative.
EDIT: this answer as written when OP's original version implied they were an individual contributor, before the crucial detail that they are a manager managing a team of 10, which completely changes the question. Moreover this makes the boss a level-2 manager, which is a different situation. --- I'd bloody rejoice. A manager who wants to keep their hand in the game? Consider yourself lucky. This is a blessing in disguise. I don't see that this a problem, certainly no more than a manager who spends too much time in meetings, presentations, reviews, conferences, executive lunches, politicking, MBA classes, playing golf, drinking, betting on the horses or other sanctioned modes of slacking. Even if we conclude it's a problem, it's at most a small problem and it's certainly not ***your*** problem. One good side-effect is that they will still be competent at hiring good technical people, which is something that PowerPoint warriors lose (or delegate to the HR dept, or stop caring, and the organizational rot sets in). (**What's their motivation?** Need to present credible data to higher-ups? Want to stay technical and deny the cloak of management being thrust upon them? Technically insecure? Impostor syndrome? Afraid of being laid off, or that their role has become obsolete? Want to understand what you or their subordinates are doing better? Want to know how to hire or manage you better? or hire your replacement if you leave? They may have several of these motivations, and don't expect them to tell you.) Most of those are fine, and even the ones that aren't can work to your advantage. ***You can (privately) show them you that you can do their work faster*** (or some automated script, or query tool, or GUI). Implement it yourself. If they're a chart person, give them charts. If they're a KPI person, give them numbers. If they like doing it interactively, install a query tool and write a wiki of frequently-used queries. If they want to tie things to the build/SCM process, implement that. Consider this a hidden opportunity to both do something productive and "get recognition" at multiple levels of the hierarchy. This is how useful internal tools generally happen. Show them a functional prototype then see if they approve spending further time on it. a > > I know that for some people giving up the "getting my hands dirty" is difficult > > > Honestly that's a badge of being a good engineer, if somewhat unrealistic about their productivity. (Read about *"Engineer-not-Manager"*) > > How can I convince them to stop "doing", without being rude, annoying, or worse? > > > **It's not your %#@& job to.** If you must, be very oblique. Just offer them a higher-productivity alternative, and privately walk them through it, only if they show interest. Then if they still insist on doing it themselves, then let it be. They may have some unresolved identity or competence crisis; if so, don't force it. > > but I really feel this is becoming a problem and I want to try to improve the situation. > > > But it's not, based on anything you've said! Anyway it's not your perception that matters as to whether it's a problem. Don't let your ego be threatened, don't feel insecure. ***tl;dr: Rejoice, let it go, use it to your career advantage, keep them happy while nudging them towards a mutually useful point, boost their managerial self-esteem***
42,335
My boss (and, actually, his boss too, which is the company general director) are generally quite good. But it happens (seldom, but frequently enough) that they start to fiddle with the details: day to day chores that they should not do. Examples are: DB queries to extract data, scripts to parse excel files, even re-installing software on their workstation, and the like. The problem is that there are people in the company that could do it much better, much faster. Often, we already have programs or libraries to do what they are trying to do in a more efficient way, or we can create them. This is not a very urgent problem, per-se (even if they make mistakes - not being their primary job, they may miss or forget important points), but that eats up their time, and that's the real issue: he does have very little time to "manage" (listen to his subordinates, make decisions, planning...) How can I convince them to stop "doing", without being rude, annoying, or worse? (he is still my boss, after all :) ) I know that for some people giving up the "getting my hands dirty" is difficult, but I really feel this is becoming a problem and I want to try to improve the situation. --- EDIT: Just to clarify: him doing things is both a problem by itself (but that is specific to my case, so I won't bother you with this part), and above all, a problem because it hinders his ability to manage others. Getting an answer by email is very difficult, meet him 1-1 to discuss projects, software to buy, planning, requires days or weeks, etc. I am a team leader myself, and I strongly believe in leading by example, which means also working with your colleagues, but my first obligation with my people is to lead them, otherwise I may end up blocking 10 developers because they are waiting for an answer from me.
2015/03/05
['https://workplace.stackexchange.com/questions/42335', 'https://workplace.stackexchange.com', 'https://workplace.stackexchange.com/users/7408/']
This depends a lot on the managers/directors in questions. Are you positive that they actually take longer to perform XX task? I have had directors & managers from both sides of the competence scale in regards to being able to perform the work of the people under them. You will find that in some cases while they may appear 'slower' than you or your peers they are checking up on the quality of other work, if they are on the lower end of the competence scale they may be simply doing it as exercises to familiarize themselves with day to day operations or trying to figure out where bottlenecks are. ( remember at Mcdonalds a manager is someone who knows every single job in the store inside and out. ) Now if its a director that is doing this you have to be aware that "its their company", you just happen to be there because it suits them to have you around. They were there long before you started and will be there long after you leave. and more likely than not when the company first started it was them that did the lions share of the work, and as time progressed more and more staff got added because their workload increased.
EDIT: this answer as written when OP's original version implied they were an individual contributor, before the crucial detail that they are a manager managing a team of 10, which completely changes the question. Moreover this makes the boss a level-2 manager, which is a different situation. --- I'd bloody rejoice. A manager who wants to keep their hand in the game? Consider yourself lucky. This is a blessing in disguise. I don't see that this a problem, certainly no more than a manager who spends too much time in meetings, presentations, reviews, conferences, executive lunches, politicking, MBA classes, playing golf, drinking, betting on the horses or other sanctioned modes of slacking. Even if we conclude it's a problem, it's at most a small problem and it's certainly not ***your*** problem. One good side-effect is that they will still be competent at hiring good technical people, which is something that PowerPoint warriors lose (or delegate to the HR dept, or stop caring, and the organizational rot sets in). (**What's their motivation?** Need to present credible data to higher-ups? Want to stay technical and deny the cloak of management being thrust upon them? Technically insecure? Impostor syndrome? Afraid of being laid off, or that their role has become obsolete? Want to understand what you or their subordinates are doing better? Want to know how to hire or manage you better? or hire your replacement if you leave? They may have several of these motivations, and don't expect them to tell you.) Most of those are fine, and even the ones that aren't can work to your advantage. ***You can (privately) show them you that you can do their work faster*** (or some automated script, or query tool, or GUI). Implement it yourself. If they're a chart person, give them charts. If they're a KPI person, give them numbers. If they like doing it interactively, install a query tool and write a wiki of frequently-used queries. If they want to tie things to the build/SCM process, implement that. Consider this a hidden opportunity to both do something productive and "get recognition" at multiple levels of the hierarchy. This is how useful internal tools generally happen. Show them a functional prototype then see if they approve spending further time on it. a > > I know that for some people giving up the "getting my hands dirty" is difficult > > > Honestly that's a badge of being a good engineer, if somewhat unrealistic about their productivity. (Read about *"Engineer-not-Manager"*) > > How can I convince them to stop "doing", without being rude, annoying, or worse? > > > **It's not your %#@& job to.** If you must, be very oblique. Just offer them a higher-productivity alternative, and privately walk them through it, only if they show interest. Then if they still insist on doing it themselves, then let it be. They may have some unresolved identity or competence crisis; if so, don't force it. > > but I really feel this is becoming a problem and I want to try to improve the situation. > > > But it's not, based on anything you've said! Anyway it's not your perception that matters as to whether it's a problem. Don't let your ego be threatened, don't feel insecure. ***tl;dr: Rejoice, let it go, use it to your career advantage, keep them happy while nudging them towards a mutually useful point, boost their managerial self-esteem***
72,274,175
I am trying to reverse the contents of an array and store them in another array, but it just outputs last element of the original array. Here's my code: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> float* copy(const float *source, int s){ float* target; int x=s-1; target=(float*)malloc(s*sizeof(float)); for (int i= 0; i<s; i++){ target[x - i]=source[i]; } return target; } int main(){ int nelements; float *source= NULL; float *target=NULL; printf("Enter no of elements:"); scanf("%d", &nelements); source=(float*)malloc(nelements*sizeof(float)); for (int i=0; i<nelements; i++){ scanf("%f", &source[i]); } target=copy(source, nelements); printf("%f\n", *target); free(source); free(target); return 0; } ```
2022/05/17
['https://Stackoverflow.com/questions/72274175', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/19136146/']
> > but it just outputs last element of the original array > > > Yes, that would be what the line `printf("%f\n", *target);` achieves. You need to print each item in `target` from inside a `for` loop.
You have to print your "target" like you scan your "source" to print all element of array one by one.
72,274,175
I am trying to reverse the contents of an array and store them in another array, but it just outputs last element of the original array. Here's my code: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> float* copy(const float *source, int s){ float* target; int x=s-1; target=(float*)malloc(s*sizeof(float)); for (int i= 0; i<s; i++){ target[x - i]=source[i]; } return target; } int main(){ int nelements; float *source= NULL; float *target=NULL; printf("Enter no of elements:"); scanf("%d", &nelements); source=(float*)malloc(nelements*sizeof(float)); for (int i=0; i<nelements; i++){ scanf("%f", &source[i]); } target=copy(source, nelements); printf("%f\n", *target); free(source); free(target); return 0; } ```
2022/05/17
['https://Stackoverflow.com/questions/72274175', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/19136146/']
> > but it just outputs last element of the original array > > > Yes, that would be what the line `printf("%f\n", *target);` achieves. You need to print each item in `target` from inside a `for` loop.
Maybe you could try to print your "target" like you scan your "source" to print all element of array one by one.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
I find the easiest way to get to the bottom of a mineshaft is to set your ladder 2 blocks onto the wall. That way you can carefully fall almost the entire way to the bottom and simply hold the backwards key to reattatch yourself to the ladder just before you hit the ground.
A good way to mine fast is by using a Haste II beacon combined with an Efficiency V Diamond or Netherite Pickaxe or some of the above answers are useful too. Edit: The above solution is good for pre-1.18 but only works while you're in the Beacon's range. Now, **Moss** is a faster solution, and once you get a Mob Grinder, you can get a lot of Bone Meal to replace all Stone types (and ***only*** Stone types, so the ores are safe) with more Moss, allowing for faster mining and less durability lost of your Pickaxe, with the fastest speeds being achieved with a Diamond or Netherite ***hoe***.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
If you're not married to building a completely man-made mine, the answer is to find a deep tunnel. Getting down to the bottom is correct, as that is where the highest concentration of useful minerals is located, but digging a tunnel doesn't expose you to nearly the same amount of blocks as using a generated cave system. In my primary game, I dug a mine down to the bottom, clearing out a large amount of stone, which only resulted in some coal, and very few iron, where as at the bottom I discovered a cave network (filled with lava, but some water solved that), which resulted in a large amount of coal and iron, as well as diamond and gold.
I've dug straight down to bedrock as well and at the bottom carved out a 40 long by 20 wide room 4 high. This netted me a full stack of redstone, lots of lava. 2 diamond, lots of coal, almost no iron. The straight down to bedrock approach I find is really good for redstone but not much else. I find that in the generated caves there is a lot more ore along the walls. So you really need both I think. I've made a waterfall going down my vertical bedrock mine shaft and shoot up to the top with a boat for fast surface access.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
This a well covered question already but the technique I personally use isn't listed so I figure I'll add it to the mix. It isn't the technique for strip mining a chunk and extracting absolutely **everything** but it **does** expose lots of extra unseen blocks. It is much faster for quickly gaining things you want, it's incredibly easy to do, and is also less wearing on your pickaxes. ***Getting down to and up from the mine:*** Use water held up by a sign at the bottom of a 1x1 shaft that is straight down starting up at the surface for dropping to diamond ore levels. To make it, dig a 1x3 section (so you don't mine beneath your feet) leave one side open for the drop shaft, fill the middle with cobble, and place ladders in the other shaft. The drop can be as great a distance as you want as long as the bottom of it looks like this: > > o = Stone > > **X** = Dug out > > **W** = Water > > **S** = A Wood Sign > > **L** = Ladder > > > o **X** o **L** o > > o **X** o **L** o > > o **X** o **L** o > > o **W** o **L** o > > o **S** o **L** o > > **X X X L X** ( This is the mine ) > > **X X X L X** > > > The drop is quick and completely safe. I use ladders for the return trip up but, if you prefer, (I think they take too long to make and are unreliable) you can make boat-waterfall ladder for coming back up. ***Mining:*** 1: Dig the standard 2x1 tunnels away from your entry point. I personally do this standing at Y: 9 so I occasionally run into unexplored caves but, if you are scared of cave mining, do it at Y:8 or Y:7. I don't suggest going to a lower depth than this because bedrock can get in the way, and ore veins that are beneath your feet will be smaller. 2: Every 4th block into your tunnel dig the upper blocks in a 1x1 shaft as far as you can reach on both sides of your tunnel. If you see an ore you like, dig the bottom out and go get it! The view of walls of your 2x1 tunnel would look like this > > **x** = dug out > > o = stone > > o o o **x** o o o **x** o o o **x** o o o **x** o o o **x** o o o **x** o o > > o o o o o o o o o o o o o o o o o o o o o o o o o o > > > Extra optional step: 3: If you want to squeeze more out of this type of mine, return once you have finished a good section and bring pieces of TnT. Place them in the back of the 1x1 shafts in the sides of your mine and set them off with Flint n Steel. I don't always do this because making TnT is a pain... but it does work. **General Mining Tips:** 1: When mining always place torches on the right wall. When you want to come back just turn around and follow the torches that are now on your left. This is a very helpful technique for not getting lost in any mine exploring or digging. 2: If you have a well enchanted diamond shovel, dig out the sections of dirt you come across. High level shovels obliterate dirt at an insane speed and this typically reveals interesting stuff. Hope this helps!
i would like to add some (CREATIVITY) to the branch mining. conventional branch mining is explained above. also in *seven sided die*'s answer there is mention that veins occur in **2x2 blocks**. we generally think mining in term of 2d lets consider the third dimension. [![made an illustration showing the method](https://i.stack.imgur.com/BYtoX.jpg)](https://i.stack.imgur.com/BYtoX.jpg) (this is just an illustration) so the wool is to show that 4 spaces are left between corridors. reason for leaving 4 spaces :- * (Assuming that veins occur in **2x2 blocks**) the vein has possibility of appearing in center 2 block (out of 4 wool block i.e pink and blue wool in this figure) so it can be spotted while mining corridors on alternate floor (1st , 3rd , 5th, .....) * same rule of possibility of spotting veins apply to corridor on (2nd , 4th , 6th, .....) * the above shows the possible center block vein. block adjacent to cyan and maroon (in shown figure) can be easily seen so no doubt about that. so this method reduces number of blocks mined and increases efficiency with respect to time. **Key assumptions : veins appear in 2x2xX**(there is very very less probability of generating 1x1x1 vein ).
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
I've dug straight down to bedrock as well and at the bottom carved out a 40 long by 20 wide room 4 high. This netted me a full stack of redstone, lots of lava. 2 diamond, lots of coal, almost no iron. The straight down to bedrock approach I find is really good for redstone but not much else. I find that in the generated caves there is a lot more ore along the walls. So you really need both I think. I've made a waterfall going down my vertical bedrock mine shaft and shoot up to the top with a boat for fast surface access.
This is an update regarding all the new version released since this question as been asked as to date it is the 1.8.X). Mojang made some change in the generation of resources and cave. As the branch mining was used by almost all player, Mojang decide that this was not supposed to be the best case to Find resources, as the cave where supposed to be what they wanted be the ground generation was bad at that time. So to counter optimised mining (using tech as describe above on the layer 11 so you don't have lava lake). So they change to generation code to make more resources spawn inside cave, and create better cave around the Map. Exploring is now almost always more efficient then optimise mining. You can still use optimise mining so you can find part of the cave at the good range of level for diamonds for example (like this you can have diamonds, redstone, lapis, iron and gold).
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
Dig down to bedrock with a staircase. Then make a room about 10 by 10. Finally branch out on each side of the wall. Pick one side and go with it untill it is to long. Then get another side. Once all four are branched, branch off them. I now have about 15-20 BLOCKS of diamond 20-23 BLOCKS of gold like 30-50 stacks of coal no red (I don't mine it just go around) and 40-45 BLOCKS of iron all totaling about 7 hrs of work
The easiest way to mine is to mine a 2x2 tunnel horizontally. You can cover 8 blocks that way, with the same amount of blocks mined as a branch mine, which only reveals 6 blocks. As for getting up and down, use a water fall cushion (to jump into, must be 2 deep) and a water LADDER (check the youtube videos to see what it is).
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
In regards to getting to and from your mine: My solution is to never leave the mine. Bring down some saplings, some wheat seeds, and whatever else, and build your base underground near your mine. It's a lot safer and more predictable than living on the surface, since you can completely light your cave system. The only downside is that eventually your character turns pale and starts muttering about "My precious..."
Have you ever thought of getting the minions mod? Once you get it you have to get up to 8 levels of experiance (8 levels is recomended) then you press the "m" key then commit to evil in which you then pick one of three things, repeat untill you get the master staff, with it you right click the ground four times, one minion will appear wherever you right click in those four times. Once you have your four minions, you press the "m" key again and select the "dig mineshaft", once you have selected(right clicked) where the mineshaft is going to be, your minions will automaticly dig the mineshaft down into bedrock and place a cobblestone staircase. Once they finish that then you can press the "m" botton (once again!) and select "strip mine", once you have selected an area then one minion will work on it, going a certain number of blocks forward.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
Referring to your edited question about the distances to and from your mine: For the way down to my mines I usually use a minecart. For the way up, this would be a nice construction: [Piston Elevator](http://www.youtube.com/watch?v=WNGVwyARMyE)
i would like to add some (CREATIVITY) to the branch mining. conventional branch mining is explained above. also in *seven sided die*'s answer there is mention that veins occur in **2x2 blocks**. we generally think mining in term of 2d lets consider the third dimension. [![made an illustration showing the method](https://i.stack.imgur.com/BYtoX.jpg)](https://i.stack.imgur.com/BYtoX.jpg) (this is just an illustration) so the wool is to show that 4 spaces are left between corridors. reason for leaving 4 spaces :- * (Assuming that veins occur in **2x2 blocks**) the vein has possibility of appearing in center 2 block (out of 4 wool block i.e pink and blue wool in this figure) so it can be spotted while mining corridors on alternate floor (1st , 3rd , 5th, .....) * same rule of possibility of spotting veins apply to corridor on (2nd , 4th , 6th, .....) * the above shows the possible center block vein. block adjacent to cyan and maroon (in shown figure) can be easily seen so no doubt about that. so this method reduces number of blocks mined and increases efficiency with respect to time. **Key assumptions : veins appear in 2x2xX**(there is very very less probability of generating 1x1x1 vein ).
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
personally for getting up and down I use 2 vertical shafts, one completely filled with water, and the other with a 1 block deep layer of water at the bottom and use a boat
A nice method if you don't like staircasing down is to mine a 1x2 tunnel down to bedrock and then using water to get up and down. To get down, drop a water bucket in and then remove it to float down with the water. To get up, simply place blocks of water above you and then remove and replace them to work your way up. Also, mining around y 3-6 is a good strategy.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
Dig down to bedrock with a staircase. Then make a room about 10 by 10. Finally branch out on each side of the wall. Pick one side and go with it untill it is to long. Then get another side. Once all four are branched, branch off them. I now have about 15-20 BLOCKS of diamond 20-23 BLOCKS of gold like 30-50 stacks of coal no red (I don't mine it just go around) and 40-45 BLOCKS of iron all totaling about 7 hrs of work
A good way to mine fast is by using a Haste II beacon combined with an Efficiency V Diamond or Netherite Pickaxe or some of the above answers are useful too. Edit: The above solution is good for pre-1.18 but only works while you're in the Beacon's range. Now, **Moss** is a faster solution, and once you get a Mob Grinder, you can get a lot of Bone Meal to replace all Stone types (and ***only*** Stone types, so the ores are safe) with more Moss, allowing for faster mining and less durability lost of your Pickaxe, with the fastest speeds being achieved with a Diamond or Netherite ***hoe***.
8,310
When I'm not exploring fresh caves or lands in minecraft, I'm busy trying to find deposits of diamond, gold and iron deep in the earth. So far I've just been digging around just above bedrock on a whim to look for these rare minerals but I've started thinking that I should be taking a more controlled, efficient approach to mining. **What is the optimal mining strategy that yields the most rare minerals while minimizing blocks removed and time spent digging and traveling?** **Edit:** The existing answers are great for mining, but no one has addressed travel time to and from the mine which is usually ~60 blocks downward and incredibly tedious. Solutions?
2010/10/01
['https://gaming.stackexchange.com/questions/8310', 'https://gaming.stackexchange.com', 'https://gaming.stackexchange.com/users/1070/']
There is a [great wiki](https://web.archive.org/web/20131208061328/http://www.voxelwiki.com/minecraft/Elites_of_Minecraft:_The_Miner) with some number crunching. I use this in single player: ``` ▒▒██▒▒__▒▒__ ██ blocks you should mine ▒▒██▒▒__▒▒__ ▒▒ blocks you can see __▒▒__▒▒██▒▒ __ blocks you can't see if you don't mine ▒▒ blocks __▒▒__▒▒██▒▒ Repeat this pattern as many times as needed ``` Normally, I have a 2x1 trunk, and branches like a standard branch mine, but instead of just going outwards from the trunk, I go up one level and out, skip two blocks, then down one level and out. I leave two blocks between branches. And I leave two blocks between floors, and line up the branches the same between floors. There are some areas left unexplored by this pattern, but they are thin, and it is unlikely that a diamond vein with spawn entirely within that narrow region. (About 3% will). The larger number of blocks uncovered are far more likely to contain diamonds. > > If your high density branch mine gets you 100% diamonds, the low density branch mine would give you **212.6%** ores in the same time, minus 3% from the earlier probability worked out before. > > > Also, you ought to build it so that the floor of the lowest tunnel is on level 11, to avoid falling in lava. If you find that there are few cave systems near your mine, feel free to dig lower, but caves tend to cluster, and caves level 10 and below are filled with lava. I dig my main tunnel on both sides of the area I want to cover, then dig back and forth in a zigzag patten, which means I'm always digging, never walking. I'm not sure if this is true anymore, but it used to be that larger deposits were formed by the word generator in multiplayer, so you were less likely to miss diamond deposits when using a wider mining pattern. Thus, this pattern ``` ▒▒██▒▒____▒▒____ ██ blocks you should mine ▒▒██▒▒____▒▒____ ▒▒ blocks you can see __▒▒____▒▒██▒▒__ __ blocks you can't see if you don't mine ▒▒ blocks __▒▒____▒▒██▒▒__ Repeat this pattern as many times as needed ``` is more efficient. As for transit? I use a long two wide straight staircase that goes all the way to bedrock. Minecarts work well for getting me deep into the mine.
The easiest way to mine is to mine a 2x2 tunnel horizontally. You can cover 8 blocks that way, with the same amount of blocks mined as a branch mine, which only reveals 6 blocks. As for getting up and down, use a water fall cushion (to jump into, must be 2 deep) and a water LADDER (check the youtube videos to see what it is).
56,167,977
I have a Parent Div with class (".filterTags"), there is two child Div with class(".tagParent") inside it. There is a close button (x) inside the child div, on clicking the close button (x) the corresponding child becomes display none. when the two of the child div becomes display none, then the parent div should also need to become none. How to Achieve this? ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
2019/05/16
['https://Stackoverflow.com/questions/56167977', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9536402/']
You can just add: ``` if($('.filterTags .tagParent:visible').length == 0) $('.filterTags').hide(); ``` This will check if there are any visible elements with the class `tagParent` and if there is none, then it will hide `<div class="filterTags">` **Demo** ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); if($('.filterTags .tagParent:visible').length == 0) $('.filterTags').hide(); }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
You need to check if the number of hidden childs is equal to total childs or not, like in th efollowing snippet ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); let tags = $(this).parents(".filterTags").find(".tagParent"); let hidden = $(this).parents(".filterTags").find(".tagParent:not(:visible)"); if (tags.length === hidden.length) { $(this).parents(".filterTags").hide(); } }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
56,167,977
I have a Parent Div with class (".filterTags"), there is two child Div with class(".tagParent") inside it. There is a close button (x) inside the child div, on clicking the close button (x) the corresponding child becomes display none. when the two of the child div becomes display none, then the parent div should also need to become none. How to Achieve this? ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
2019/05/16
['https://Stackoverflow.com/questions/56167977', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9536402/']
You can just add: ``` if($('.filterTags .tagParent:visible').length == 0) $('.filterTags').hide(); ``` This will check if there are any visible elements with the class `tagParent` and if there is none, then it will hide `<div class="filterTags">` **Demo** ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); if($('.filterTags .tagParent:visible').length == 0) $('.filterTags').hide(); }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
You have 2 possibilities to achieve this: 1. **Handle the parent class, when all the childs are hidden** 2. **Give parent no layout, the layout is driven by the childrens** **Handle the parent class, when all the childs are hidden** You can create a jquery method wich handles the childrens show/hide behaviour, adding a class to parent (e.g. 'hidden') when all the childrens disappears: ``` <div id="parent"> <div class="children"> CHILDREN A </div> <div class="children"> CHILDREN B </div> </div> .hidden { display: none; } #parent { background: red; width: 10rem; height: 2rem; padding: 10px; display: flex; } #parent.hidden { display: none; } .children { background: blue; height: 100%; } $('.children').on('click', function(_){ // store objects in constants for performances const $this = $(this); const $parent = $this.parent(); // get the length of parent childrens with hidden class // you can also check using :visible selector // const {length} = $parent.find(':visible'); const {length} = $parent.find('.hidden'); // hide the child $this.addClass('hidden'); // logical example // if children count with class hidden is equals to the children count // (-1 because we need to consider the current children) // then hide the parent if(length === $parent.children.length - 1) { $parent.addClass('hidden'); } }) ``` <https://jsfiddle.net/NicolaLC/Ldnz0p9y/> This solution is cool but not the best one in my opinon, because you can achieve the same result using only css (this case is limited by the work you need to do and the result you want to achieve) **Give parent no layout, the layout is driven by the childrens** This is the best solution, the logic behind this is than the parent is only a wrapper, it has no layout and it adapt to childrens, so when no children is visible the parent disappears automatically: ``` <div class="parent"> <div class="children"> CHILDREN A </div> <div class="children"> CHILDREN B </div> </div> .hidden { display: none; } .parent { background: red; display: flex; } .children { background: blue; height: 2rem; width: 50%; margin: 1rem; display: inline-flex; } .children.hidden { display: none; } $('.children').on('click', function(_) { $(this).addClass('hidden'); settimeout(() => { $(this).removeClass('hidden'); }, 5000) }) ``` <https://jsfiddle.net/NicolaLC/kprdht1a/12/>
56,167,977
I have a Parent Div with class (".filterTags"), there is two child Div with class(".tagParent") inside it. There is a close button (x) inside the child div, on clicking the close button (x) the corresponding child becomes display none. when the two of the child div becomes display none, then the parent div should also need to become none. How to Achieve this? ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
2019/05/16
['https://Stackoverflow.com/questions/56167977', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9536402/']
You need to check if the number of hidden childs is equal to total childs or not, like in th efollowing snippet ```js $(".tagCloser").click(function() { $(this).parent(".tagParent").hide(); let tags = $(this).parents(".filterTags").find(".tagParent"); let hidden = $(this).parents(".filterTags").find(".tagParent:not(:visible)"); if (tags.length === hidden.length) { $(this).parents(".filterTags").hide(); } }); ``` ```css .filterTags { display: flex; flex-wrap: wrap; padding: 20px 25px 10px; background: yellow; } .tagParent { padding: 0px 0px 0px 15px; background: #e40046; color: #fff; font-family: Bold; border-radius: 5px; margin: 0px 10px 10px 0px; display: flex; } .tagContent { align-self: center; } .tagCloser { padding: 7px 10px; cursor: pointer; align-self: center; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="filterTags"> <div class="tagParent"> <span class="tagContent">Urgent</span> <span class="tagCloser">x</span> </div> <div class="tagParent"> <span class="tagContent">Popular</span> <span class="tagCloser">x</span> </div> </div> ```
You have 2 possibilities to achieve this: 1. **Handle the parent class, when all the childs are hidden** 2. **Give parent no layout, the layout is driven by the childrens** **Handle the parent class, when all the childs are hidden** You can create a jquery method wich handles the childrens show/hide behaviour, adding a class to parent (e.g. 'hidden') when all the childrens disappears: ``` <div id="parent"> <div class="children"> CHILDREN A </div> <div class="children"> CHILDREN B </div> </div> .hidden { display: none; } #parent { background: red; width: 10rem; height: 2rem; padding: 10px; display: flex; } #parent.hidden { display: none; } .children { background: blue; height: 100%; } $('.children').on('click', function(_){ // store objects in constants for performances const $this = $(this); const $parent = $this.parent(); // get the length of parent childrens with hidden class // you can also check using :visible selector // const {length} = $parent.find(':visible'); const {length} = $parent.find('.hidden'); // hide the child $this.addClass('hidden'); // logical example // if children count with class hidden is equals to the children count // (-1 because we need to consider the current children) // then hide the parent if(length === $parent.children.length - 1) { $parent.addClass('hidden'); } }) ``` <https://jsfiddle.net/NicolaLC/Ldnz0p9y/> This solution is cool but not the best one in my opinon, because you can achieve the same result using only css (this case is limited by the work you need to do and the result you want to achieve) **Give parent no layout, the layout is driven by the childrens** This is the best solution, the logic behind this is than the parent is only a wrapper, it has no layout and it adapt to childrens, so when no children is visible the parent disappears automatically: ``` <div class="parent"> <div class="children"> CHILDREN A </div> <div class="children"> CHILDREN B </div> </div> .hidden { display: none; } .parent { background: red; display: flex; } .children { background: blue; height: 2rem; width: 50%; margin: 1rem; display: inline-flex; } .children.hidden { display: none; } $('.children').on('click', function(_) { $(this).addClass('hidden'); settimeout(() => { $(this).removeClass('hidden'); }, 5000) }) ``` <https://jsfiddle.net/NicolaLC/kprdht1a/12/>
1,414,662
We are currently using an HDD for our NetApp storage for our VMs. We're considering replacing them with SSDs, but many disk manufacturers have different performance. What range of latencies can we expect from SSDs versus HDDs? How much better are SSDs on average?
2019/03/16
['https://superuser.com/questions/1414662', 'https://superuser.com', 'https://superuser.com/users/639471/']
The latencies of an SSD vary hugely, but in terms of IOPs (which us probably the term you want to google)you are looking at an increase in the order of 2-5 magnitudes. (Ie 100 iops for HDD, starting at more then 10000 + for an SSD). Have a look at <https://en.m.wikipedia.org/wiki/IOPS> SSDs are like a night and day difference. I would only use hdds for backups and unimportant archival data - like videos, music collections. A heavily swapping HDD can render a system unuseable - while it will just be a bit sluggish on SSD. Speedwise SSDs are at least 5 times as fast in sequential reads and writes - which represents the closest benchmark You did not ask, but SSD is also over 5 times as reliable as hdd (but unlike hdd more likely to fail completely and without warning - so RAID is still important)
NVMe SSD latencies can be as low as [250 µs](https://phoenixnap.com/kb/nvme-vs-sata-vs-m-2-comparison) (microseconds). Much faster than the typical [2-4 ms](https://en.wikipedia.org/wiki/Hard_disk_drive_performance_characteristics#Rotational_latency) (millisecond) latencies of HDDs that spin at 7,500 - 15,000 RPM. 0.25 ms vs. 2 ms means that an NVMe SSD will have about 1/8th the latency of a fast 15,000 RPM HDD. However a lot of factors can affect both of these numbers. It is possible for overly-taxed SSDs to provide >1 millisecond performance, and a cache on an HDD could at times provide zippier data access to commonly-used blocks. YMMV and you should consider running your own tests for the disks you are considering deploying.
367,882
Some tags work inside their braces: `{\scriptsize lorem}`. Others, outside: `\flushright{lorem}` (and they stay in force for a while). *Edit*: Others outside, lasting only within the braces: `{\textbf lorem}`. Others, either inside or outside: `\em{lorem}`, ditto `\tt`. The difference may depend on declarative form vs. action form, although that triggers bad memories of high school Latin. [Why are text format commands used inside braces?](https://tex.stackexchange.com/questions/64480/why-are-text-format-commands-used-inside-braces) How can one remember which tag has which scope?
2017/05/03
['https://tex.stackexchange.com/questions/367882', 'https://tex.stackexchange.com', 'https://tex.stackexchange.com/users/83172/']
``` % !TEX TS-program = pdflatex % !TEX encoding = UTF-8 Unicode % arara: pdflatex \pdfminorversion=7 % ateb: https://tex.stackexchange.com/a/367883/ \documentclass{article} \usepackage[a4paper,scale=.9]{geometry} \usepackage{booktabs} \usepackage{cfr-lm} \begin{document} \verb|\flushright| is really starting an environment and would be better marked as such in \LaTeX. \verb|\begin{flushright}lorem\end{flushright}| \begin{flushright}lorem\end{flushright} \verb|{\textbf lorem}| is not the same as \verb|\textbf{lorem}|. The former will make only the \verb|l| bold, while the latter will make \verb|lorem| bold. \verb|\bfseries| is a \emph{switch} and does not take an argument. Everything following will be bold until the switch is changed or the local \TeX{} group ends. Hence, limiting its scope requires a local group, \verb|{\bfseries lorem}|. \begin{tabular}{ccc} \verb|\textbf{lorem}| & \verb|{\textbf lorem}| & \verb|{\bfseries lorem}| \\ \textbf{lorem} & {\textbf lorem} & {\bfseries lorem} \\ \end{tabular} \verb|\scriptsize| is another switch: everything following will be in this size, until another size is activated or the local \TeX{} group ends. {\scriptsize Hence, brackets are needed to limit the scope, \verb|{\scriptsize lorem}|. However, to be fully effective, the scope of size-changing macros must include a paragraph break at the end.} In some contexts, this doesn't matter (and can even be exploited), but generally, ending a size mid-paragraph is not what you want. \scriptsize \verb|\scriptsize| is another switch: everything following will be in this size, until another size is activated or the local \TeX{} group ends. {\normalsize Hence, brackets are needed to limit the scope, \verb|{\scriptsize lorem}|. However, to be fully effective, the scope of size-changing macros must include a paragraph break at the end.} In some contexts, this doesn't matter (and can even be exploited), but generally, ending a size mid-paragraph is not what you want. \normalsize \verb|\tt| is obsolete and ought not be used in \LaTeXe{} at all. Use \verb|\ttfamily| as a switch, \verb|{\ttfamily lorem}|, or \verb|\texttt| with an argument, \verb|\texttt{lorem}|. If you stick to \LaTeX{} font selection commands, then all those which take arguments have names beginning with \verb|\text| (with the exception of \verb|\emph|, as explained below), while switches do not. Switches instead have standard endings which indicate the kind of thing they switch: \verb|size| for size, \verb|family| for family, \verb|shape| for shape and \verb|series| for width and weight. \newcommand*\cs[1]{\texttt{\textbackslash#1}} \begin{center} \begin{tabular}{*{7}{l}} \toprule Switch & Switch & Text & Switch & Text & Switch & Text \\ \midrule \cs{tiny} & \cs{upshape} & \cs{textup} & \cs{rmfamily} & \cs{textrm} & \cs{mdseries} & \cs{textmd} \\ \cs{scriptsize} & \cs{itshape} & \cs{textit} & \cs{sffamily} & \cs{textsf} & \cs{bfseries} & \cs{textbf} \\ \cs{footnotesize} & \cs{slshape} & \cs{textsl} & \cs{ttfamily} & \cs{texttt} \\ \cs{small} & \cs{scshape} & \cs{textsc} \\ \cs{large} \\ \cs{Large} \\ \cs{LARGE} \\ \cs{Huge} \\ \cs{normalsize} & \cs{normalfont} & \cs{textnormal} & \cs{normalfont} & \cs{textnormal} & \cs{normalfont} & \cs{textnormal} \\ \bottomrule \end{tabular} \end{center} This system is the New Font Selection Scheme, introduced with \LaTeXe more than twenty years ago (so no longer so `new'). \verb|\emph{lorem}| is not part of this scheme because, strictly speaking, it does not specify a particular font change but is, rather, \emph{semantic} mark-up. \verb|\emph| and the \TeX{} switch \verb|\em| specify that text should be \emph{emphasised} using whatever format is currently active for marking such text. By default, this means that text is italicised, if currently non-italic, or made upright, if currently italic. However, it would be perfectly legitimate to design a class in which important text was made bold rather than rendered italic/non-italic. With the default settings, the difference between the semantic \verb|\emph| and the non-semantic \verb|\textit| can be observed by seeing what happens when such changes are nested. \begin{verbatim} This is not especially important. \emph{This is very important, especially \emph{this phrase}, which deserves particular attention.} This is not especially important. \textit{This is very important, especially \textit{this phrase}, which deserves particular attention.} This is not especially important. \emph{This is very important, especially \textit{this phrase}, which deserves particular attention.} This is not especially important. \textit{This is very important, especially \emph{this phrase}, which deserves particular attention.} \end{verbatim} This is not especially important. \emph{This is very important, especially \emph{this phrase}, which deserves particular attention.} This is not especially important. \textit{This is very important, especially \textit{this phrase}, which deserves particular attention.} This is not especially important. \emph{This is very important, especially \textit{this phrase}, which deserves particular attention.} This is not especially important. \textit{This is very important, especially \emph{this phrase}, which deserves particular attention.} \end{document} ``` [![font stuff and things](https://i.stack.imgur.com/cblZY.png)](https://i.stack.imgur.com/cblZY.png)
In addition to cfr's answer I think it's important to stress that declarations do not have braces, they are not "inside their braces", they just change the state (typically the font) at the current point So taking your examples ``` {\scriptsize lorem} ``` the outer braces are not part of the command syntax, you could just as well go ``` \scriptsize lorem \normalsize ``` or ``` \begin{center}\scriptsize lorem\end{center} ``` --- ``` \flushright{lorem} ``` The braces here are unconnected with the command and just form a group that would scope any declaration such as `\scriptsize` inside "lorem". `\flushright` is only intended to be used as an environment ``` \begin{flushright} lorem\end{flushright} ``` The declaration form is `\raggedright`. ``` \raggedright lipsum ``` --- ``` {\textbf lorem} ``` the braces here are again unconnected to the `\textbf` command and form a group, `\textbf` is a macro with one argument so here, as its argument isn't braced, the argument is the next token, which is `l` so it is the same as ``` {\textbf{l}orem} ``` with the `l` being the argument to `\textbf` and the outer braces playing no role in this command. --- `\em` and `\tt` are declarations like `\raggedright` (`\tt` is not defined by default in latex and is just defined in some classes with compatibility with early versions of LaTeX)
7,043,502
I am having trouble formating the dates that are being returned from my mySQL database. Here is the code that I am trying to use: ``` <?php function get_gold_time() { $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); while($result = mysql_fetch_array( $goldquery )) { echo "'" . date_format($result['time'], 'jS ,g A') . "'" . ", " ; } } ?> ``` This is the error I receive: Warning: date\_format() expects parameter 1 to be DateTime, string given in /home/bellsnet/public\_html/chart.php on line 128 '', Without the date format my code looks like this: ``` <?php function get_gold_time() { $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); while($result = mysql_fetch_array( $goldquery )) { echo "'" .$result['time'] . "'" . ", " ; } } ?> ``` And is returning my values as follows: ``` '2011-08-10 01:15:02', '2011-08-10 01:00:02', '2011-08-10 00:45:02', '2011-08-10 00:30:02', '2011-08-10 00:15:02', '2011-08-10 00:00:02', '2011-08-09 23:45:03', '2011-08-09 23:30:02', '2011-08-09 23:15:02', '2011-08-09 23:00:03', '2011-08-09 22:45:02', '2011-08-09 22:40:22', '2011-08-09 22:30:02', '2011-08-09 22:15:02', '2011-08-09 22:13:41', '2011-08-10 02:00:02', '2011-08-10 01:45:02', '2011-08-10 01:30:02', '2011-08-10 02:15:02', '2011-08-10 02:30:02', '2011-08-10 02:45:02', '2011-08-10 03:00:02', '2011-08-10 03:15:03', '2011-08-10 03:30:03', '2011-08-10 03:45:03', '2011-08-10 04:00:03', '2011-08-10 04:15:01', ``` Any Help WOuld be greatly appreciated! Ive been tinking around with this for hours.
2011/08/12
['https://Stackoverflow.com/questions/7043502', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/766840/']
try date() ``` <?php function get_gold_time() { $goldquery = mysql_query("SELECT * FROM metal_price WHERE metal= 'GOLD' LIMIT 0, 96"); while($result = mysql_fetch_array( $goldquery )) { echo "'" . date('jS ,g A', strToTime($result['time'])) . "'" . ", " ; } } ?> ``` or use DATE\_FORMAT() directly in MYSQL query: <http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>
It would be far better to just format the date in MySQL through DATE\_FORMAT() as it would be quite a bit faster and give you what you want. See this: <http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>
19,719,635
I am building a website contact form. I have form submissions being added to Firebase via Angular js. When a new submission is submitted to Firebase I am using child\_added in Node to trigger nodemailer. This is working fine, except that the entire submissions collection is being re-emailed whenever I restart the dev server, and multiple times daily in production on Heroku. How can I ensure that emails won't be sent more than once? ``` var myRoot = new Firebase('https://firebase.firebaseio.com/website/submissions'); myRoot.on('child_added', function(snapshot) { var userData = snapshot.val(); var smtpTransport = nodemailer.createTransport("SMTP",{ auth: { user: "email@gmail.com", pass: "password" } }); var mailOptions = { from: "Website <email@gmail.com>", // sender address to: "email@email.com.au", // list of receivers subject: "New Website Lead", // Subject line html: "<p><strong>Name: </strong>" + userData.name + "</p>" + "<p><strong>Email: </strong>" + userData.email + "</p>" + "<p><strong>Phone: </strong>" + userData.phone + "</p>" + "<p><strong>Enquiry: </strong>" + userData.enquiry + "</p>" + "<p><strong>Submitted: </strong>" + userData.date + "</p>" // html body }; smtpTransport.sendMail(mailOptions, function(error, response) { if(error) { console.log(error); } else { console.log("Message sent: " + response.message); } smtpTransport.close(); }); }); ```
2013/11/01
['https://Stackoverflow.com/questions/19719635', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2934691/']
You could use ``` var duty = [ "Operate Equipment", "Check for Water Damage", "Check for Mold", "Follow Insurance Procedure", "Restore" ], x = parseInt( document.getElementById('counter').value, 10 ); document.getElementById('task').innerHTML = duty.slice(0, x).join('<br />'); ``` --- **Notes** * Always use the second argument (radix) when using `parseInt` or `parseFloat`. * If `document.getElementById('counter').value` is a numerical string (like `'3'`), don't use `parseInt`. Instead, if necessary, use `+'3'` to get the number `3`. Only use `parseInt` if you want to parse something like `'3px'` into `3`. * Don't use `getElementById` to get the same element at each iteration of a loop. Then, instead of ``` for(var i = 0; i < n; ++i) { doSomething(document.getElementById('foo'), i); } ``` use ``` var el = document.getElementById('foo'); for(var i = 0; i < n; ++i) { doSomething(el, i); } ``` * Never change `innerHTML` at each iteration of a loop, because modifying the DOM has bad performance. Then, instead of ``` for(var i = 0; i < n; ++i) { element.innerHTML += someHTML(i); // n DOM modifications } ``` use ``` var html = ''; for(var i = 0; i < n; ++i) { html += someHTML(i); } element.innerHTML = html; // only 1 DOM modification ```
``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test2</title> </head> <body> <input type="button" onclick="dutyarray()" value="Click">To see my top <input type="number" id="counter"> job duties here</input> <br /> <p id="task">Duties</p> <script> function dutyarray() { var x = document.getElementById('counter').value; x = parseInt(x); var duty = [ "Operate Equipment", "Check for Water Damage", "Check for Mold", "Follow Insurance Procedure", "Restore" ]; if (x > duty.length-1) x = duty.length-1; // Performs some checking document.getElementById('task').innerHTML = ""; for ( ; x >= 0; x--) { document.getElementById('task').innerHTML += duty[x] + "<br>"; } } </script> </body> </html> ```
43,606,911
I've a function that gets a `.csv` file from parameter and a `myrownumber` (a number indicating a row of the .csv) of this array. This returns the content of the line number `myrownumber` of the csv file. ``` private function readASpecificRow($filePath, $myrownumber) { $rowImLookingFor = array(); $f = fopen($filePath, "r"); $i = 0; while (($line = fgetcsv($f)) !== false) { $i ++; foreach ($line as $cell) { if ($i == $myrownumber) { array_push($rowImLookingFor, $cell); } } } fclose($f); return($rowImLookingFor); } ``` This is very innefficent as I've to iterate all the file until I find the row I'm looking for. **Is there any other way to read directly the row number `myrownumber` of the `csv` file?** PS: I know there are a lot of solutions with will like to keep using `fgetcsv` because on the cells are some line breaks and with `fgetscsv` I keep the control of it. If i use `file` or whatever, the number of lines are different from the real number of lines of the csv due to the line breaks inside of some cells. Thanks in advance.
2017/04/25
['https://Stackoverflow.com/questions/43606911', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/742269/']
I know that this doesn't provide you with a different solution but it could help with the assumed inefficiency. I'd personally refactor the function to look more like this: ``` private function readASpecificRow($filePath, $myrownumber) { $f = fopen($filePath, "r"); $i = 0; $myrownumber = (int) $myrownumber; // ensure it's actually a number. while (($line = fgetcsv($f)) !== false) { if (++$i < $myrownumber) continue; fclose($f); return $line; } return false; // if the specified line wasn't there return false } ``` It should be a bit faster.
You can use `file()` to get file by lines, than use `str_getcsv` to parse specific line to CSV.
43,606,911
I've a function that gets a `.csv` file from parameter and a `myrownumber` (a number indicating a row of the .csv) of this array. This returns the content of the line number `myrownumber` of the csv file. ``` private function readASpecificRow($filePath, $myrownumber) { $rowImLookingFor = array(); $f = fopen($filePath, "r"); $i = 0; while (($line = fgetcsv($f)) !== false) { $i ++; foreach ($line as $cell) { if ($i == $myrownumber) { array_push($rowImLookingFor, $cell); } } } fclose($f); return($rowImLookingFor); } ``` This is very innefficent as I've to iterate all the file until I find the row I'm looking for. **Is there any other way to read directly the row number `myrownumber` of the `csv` file?** PS: I know there are a lot of solutions with will like to keep using `fgetcsv` because on the cells are some line breaks and with `fgetscsv` I keep the control of it. If i use `file` or whatever, the number of lines are different from the real number of lines of the csv due to the line breaks inside of some cells. Thanks in advance.
2017/04/25
['https://Stackoverflow.com/questions/43606911', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/742269/']
I know that this doesn't provide you with a different solution but it could help with the assumed inefficiency. I'd personally refactor the function to look more like this: ``` private function readASpecificRow($filePath, $myrownumber) { $f = fopen($filePath, "r"); $i = 0; $myrownumber = (int) $myrownumber; // ensure it's actually a number. while (($line = fgetcsv($f)) !== false) { if (++$i < $myrownumber) continue; fclose($f); return $line; } return false; // if the specified line wasn't there return false } ``` It should be a bit faster.
There's no simple way to start reading directly row, but what you can try this way: ``` $pre_pos = <previous position>; fseek($file, $pre_pos); while(...) { fgetcsv(...); ... } $pre_pos = ftell($file); ```
43,606,911
I've a function that gets a `.csv` file from parameter and a `myrownumber` (a number indicating a row of the .csv) of this array. This returns the content of the line number `myrownumber` of the csv file. ``` private function readASpecificRow($filePath, $myrownumber) { $rowImLookingFor = array(); $f = fopen($filePath, "r"); $i = 0; while (($line = fgetcsv($f)) !== false) { $i ++; foreach ($line as $cell) { if ($i == $myrownumber) { array_push($rowImLookingFor, $cell); } } } fclose($f); return($rowImLookingFor); } ``` This is very innefficent as I've to iterate all the file until I find the row I'm looking for. **Is there any other way to read directly the row number `myrownumber` of the `csv` file?** PS: I know there are a lot of solutions with will like to keep using `fgetcsv` because on the cells are some line breaks and with `fgetscsv` I keep the control of it. If i use `file` or whatever, the number of lines are different from the real number of lines of the csv due to the line breaks inside of some cells. Thanks in advance.
2017/04/25
['https://Stackoverflow.com/questions/43606911', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/742269/']
I know that this doesn't provide you with a different solution but it could help with the assumed inefficiency. I'd personally refactor the function to look more like this: ``` private function readASpecificRow($filePath, $myrownumber) { $f = fopen($filePath, "r"); $i = 0; $myrownumber = (int) $myrownumber; // ensure it's actually a number. while (($line = fgetcsv($f)) !== false) { if (++$i < $myrownumber) continue; fclose($f); return $line; } return false; // if the specified line wasn't there return false } ``` It should be a bit faster.
You need to iterate over the entire file, but you can return early once your row is found to make it a bit more efficient. I can't see any need for the inner `foreach` loop on each line so that could be removed: ``` private function readASpecificRow($filePath, $myrownumber) { $f = fopen($filePath, "r"); for($i = 1; $line = fgetcsv($f); $i++) { if($i === $myrownumber) { fclose($f); return $line; } } return false; } ``` Note that this is not zero-based, so if `$myrownumber` is 1 it'll return the first line. Change the `$i = 1;` to `$i = 0` in the for loop to make it zero-based.
26,667,162
How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class `mids` from R's package `mice`? I would like the result to still be a `mids` object. **Edit: Example** ``` library(mice) data(nhanes) # create imputed datasets imput = mice(nhanes) ``` The imputed datasets are stored as a list of lists ``` imput$imp ``` where there are rows only for the observations with imputation for the given variable. The original (incomplete) dataset is stored here: ``` imput$data ``` For example, how would I create a new variable calculated as `chl/2` in each of the imputed datasets, yielding a new `mids` object?
2014/10/31
['https://Stackoverflow.com/questions/26667162', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212811/']
Another option is to calculate the variables before the imputation and place restrictions on them. ```r library(mice) # Create the additional variable - this will have missing nhanes$extra <- nhanes$chl / 2 # Change the method of imputation for extra, so that it always equals chl/2 # Change the predictor matrix so only chl predicts extra ini <- mice(nhanes, max = 0, print = FALSE) meth <- ini$meth meth["extra"] <- "~I(chl / 2)" pred <- ini$pred # extra isn't used to predict pred["extra", "chl"] <- 1 # Imputations imput <- mice(nhanes, seed = 1, pred = pred, meth = meth, print = FALSE) ``` There are examples in [mice: Multivariate Imputation by Chained Equations in R](https://www.jstatsoft.org/article/view/v045i03).
There is an overload of `with` that can help you here ``` with(imput, chl/2) ``` the documentation is given at `?with.mids`
26,667,162
How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class `mids` from R's package `mice`? I would like the result to still be a `mids` object. **Edit: Example** ``` library(mice) data(nhanes) # create imputed datasets imput = mice(nhanes) ``` The imputed datasets are stored as a list of lists ``` imput$imp ``` where there are rows only for the observations with imputation for the given variable. The original (incomplete) dataset is stored here: ``` imput$data ``` For example, how would I create a new variable calculated as `chl/2` in each of the imputed datasets, yielding a new `mids` object?
2014/10/31
['https://Stackoverflow.com/questions/26667162', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212811/']
This can be done easily as follows - Use `complete()` to convert a mids object to a long-format data.frame: ``` long1 <- complete(midsobj1, action='long', include=TRUE) ``` Perform whatever manipulations needed: ``` long1$new.var <- long1$chl/2 long2 <- subset(long1, age >= 5) ``` use `as.mids()` to convert back manipulated data to mids object: ``` midsobj2 <- as.mids(long2) ``` Now you can use `midsobj2` as required. Note that the `include=TRUE` (used to include the original data with missing values) is needed for `as.mids()` to compress the long-formatted data properly. Note that prior to mice v2.25 there was a bug in the as.mids() function (see this post <https://stats.stackexchange.com/a/158327/69413>) EDIT: According to this answer <https://stackoverflow.com/a/34859264/4269699> (from what is essentially a duplicate question) you can also edit the mids object directly by accessing $data and $imp. So for example ``` midsobj2<-midsobj1 midsobj2$data$new.var <- midsobj2$data$chl/2 midsobj2$imp$new.var <- midsobj2$imp$chl/2 ``` You will run into trouble though if you want to subset $imp or if you want to use $call, so I wouldn't recommend this solution in general.
There is an overload of `with` that can help you here ``` with(imput, chl/2) ``` the documentation is given at `?with.mids`
26,667,162
How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class `mids` from R's package `mice`? I would like the result to still be a `mids` object. **Edit: Example** ``` library(mice) data(nhanes) # create imputed datasets imput = mice(nhanes) ``` The imputed datasets are stored as a list of lists ``` imput$imp ``` where there are rows only for the observations with imputation for the given variable. The original (incomplete) dataset is stored here: ``` imput$data ``` For example, how would I create a new variable calculated as `chl/2` in each of the imputed datasets, yielding a new `mids` object?
2014/10/31
['https://Stackoverflow.com/questions/26667162', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212811/']
This can be done easily as follows - Use `complete()` to convert a mids object to a long-format data.frame: ``` long1 <- complete(midsobj1, action='long', include=TRUE) ``` Perform whatever manipulations needed: ``` long1$new.var <- long1$chl/2 long2 <- subset(long1, age >= 5) ``` use `as.mids()` to convert back manipulated data to mids object: ``` midsobj2 <- as.mids(long2) ``` Now you can use `midsobj2` as required. Note that the `include=TRUE` (used to include the original data with missing values) is needed for `as.mids()` to compress the long-formatted data properly. Note that prior to mice v2.25 there was a bug in the as.mids() function (see this post <https://stats.stackexchange.com/a/158327/69413>) EDIT: According to this answer <https://stackoverflow.com/a/34859264/4269699> (from what is essentially a duplicate question) you can also edit the mids object directly by accessing $data and $imp. So for example ``` midsobj2<-midsobj1 midsobj2$data$new.var <- midsobj2$data$chl/2 midsobj2$imp$new.var <- midsobj2$imp$chl/2 ``` You will run into trouble though if you want to subset $imp or if you want to use $call, so I wouldn't recommend this solution in general.
Another option is to calculate the variables before the imputation and place restrictions on them. ```r library(mice) # Create the additional variable - this will have missing nhanes$extra <- nhanes$chl / 2 # Change the method of imputation for extra, so that it always equals chl/2 # Change the predictor matrix so only chl predicts extra ini <- mice(nhanes, max = 0, print = FALSE) meth <- ini$meth meth["extra"] <- "~I(chl / 2)" pred <- ini$pred # extra isn't used to predict pred["extra", "chl"] <- 1 # Imputations imput <- mice(nhanes, seed = 1, pred = pred, meth = meth, print = FALSE) ``` There are examples in [mice: Multivariate Imputation by Chained Equations in R](https://www.jstatsoft.org/article/view/v045i03).
26,667,162
How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class `mids` from R's package `mice`? I would like the result to still be a `mids` object. **Edit: Example** ``` library(mice) data(nhanes) # create imputed datasets imput = mice(nhanes) ``` The imputed datasets are stored as a list of lists ``` imput$imp ``` where there are rows only for the observations with imputation for the given variable. The original (incomplete) dataset is stored here: ``` imput$data ``` For example, how would I create a new variable calculated as `chl/2` in each of the imputed datasets, yielding a new `mids` object?
2014/10/31
['https://Stackoverflow.com/questions/26667162', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212811/']
Another option is to calculate the variables before the imputation and place restrictions on them. ```r library(mice) # Create the additional variable - this will have missing nhanes$extra <- nhanes$chl / 2 # Change the method of imputation for extra, so that it always equals chl/2 # Change the predictor matrix so only chl predicts extra ini <- mice(nhanes, max = 0, print = FALSE) meth <- ini$meth meth["extra"] <- "~I(chl / 2)" pred <- ini$pred # extra isn't used to predict pred["extra", "chl"] <- 1 # Imputations imput <- mice(nhanes, seed = 1, pred = pred, meth = meth, print = FALSE) ``` There are examples in [mice: Multivariate Imputation by Chained Equations in R](https://www.jstatsoft.org/article/view/v045i03).
There's a function for this in the `basecamb` package: ``` library(basecamb) apply_function_to_imputed_data(mids_object, function) ```
26,667,162
How can I perform an operation (like subsetting or adding a calculated column) on each imputed dataset in an object of class `mids` from R's package `mice`? I would like the result to still be a `mids` object. **Edit: Example** ``` library(mice) data(nhanes) # create imputed datasets imput = mice(nhanes) ``` The imputed datasets are stored as a list of lists ``` imput$imp ``` where there are rows only for the observations with imputation for the given variable. The original (incomplete) dataset is stored here: ``` imput$data ``` For example, how would I create a new variable calculated as `chl/2` in each of the imputed datasets, yielding a new `mids` object?
2014/10/31
['https://Stackoverflow.com/questions/26667162', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212811/']
This can be done easily as follows - Use `complete()` to convert a mids object to a long-format data.frame: ``` long1 <- complete(midsobj1, action='long', include=TRUE) ``` Perform whatever manipulations needed: ``` long1$new.var <- long1$chl/2 long2 <- subset(long1, age >= 5) ``` use `as.mids()` to convert back manipulated data to mids object: ``` midsobj2 <- as.mids(long2) ``` Now you can use `midsobj2` as required. Note that the `include=TRUE` (used to include the original data with missing values) is needed for `as.mids()` to compress the long-formatted data properly. Note that prior to mice v2.25 there was a bug in the as.mids() function (see this post <https://stats.stackexchange.com/a/158327/69413>) EDIT: According to this answer <https://stackoverflow.com/a/34859264/4269699> (from what is essentially a duplicate question) you can also edit the mids object directly by accessing $data and $imp. So for example ``` midsobj2<-midsobj1 midsobj2$data$new.var <- midsobj2$data$chl/2 midsobj2$imp$new.var <- midsobj2$imp$chl/2 ``` You will run into trouble though if you want to subset $imp or if you want to use $call, so I wouldn't recommend this solution in general.
There's a function for this in the `basecamb` package: ``` library(basecamb) apply_function_to_imputed_data(mids_object, function) ```
28,806,955
I have a problem with retrieve basic user information. This is my code: ``` require_once 'facebook-php-sdk/autoload.php'; FacebookSession::setDefaultApplication('appid', 'appsecret'); try { $token = 'mytoken'; $session = new FacebookSession($token); $request = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className()); $username = $request->getName(); echo $username . '<br>'; } catch (FacebookRequestException $e) { echo'Error'; echo $e; } ``` but no exception is throws, and nothing is printed. What's wrong?
2015/03/02
['https://Stackoverflow.com/questions/28806955', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1246746/']
The notation `x.(T)` is called a [Type Assertion](http://golang.org/ref/spec#Type_assertions). > > For an expression `x` of interface type and a type `T`, the primary expression `x.(T)` asserts that `x` is not `nil` and that the value stored in `x` is of type `T`. > > > Your example: ``` result["args"].(map[string]interface{})["foo"] ``` It means that the value of your `results` map associated with key `"args"` is of type `map[string]interface{}` (another map with `string` keys and any values). And you want to access the element of that map associated with the key `"foo"`. If you know noting about the input JSON format, then yes, you have to use a generic `map[string]interface{}` type to process it. If you know the exact structure of the input JSON, you can create a `struct` to match the expected fields, and doing so you can unmarshal a JSON text into a value of your custom `struct` type, for example: ``` type Point struct { Name string X, Y int } func main() { in := `{"Name":"center","X":2,"Y":3}` pt := Point{} json.Unmarshal([]byte(in), &pt) fmt.Printf("Result: %+v", pt) } ``` Output: ``` Result: {Name:center X:2 Y:3} ``` Try it on the [Go Playground](http://play.golang.org/p/9P3kdq6Cg0). Modeling your input ------------------- Your current JSON input could be modelled with this type: ``` type Data struct { Args struct { Foo string } } ``` And accessing `Foo` (try it on the [Go Playground)](http://play.golang.org/p/80dWvpwUsH): ``` d := Data{} json.Unmarshal([]byte(in), &d) fmt.Println("Foo:", d.Args.Foo) ```
`struct` is the best option, but if you insist, you can add a type declaration for a map, then you can add methods to help with the type assertions: ``` package main import "encoding/json" type dict map[string]interface{} func (d dict) d(k string) dict { return d[k].(map[string]interface{}) } func (d dict) s(k string) string { return d[k].(string) } func main() { apiResponse := []byte(`{"args": {"foo": "bar"}}`) var result dict json.Unmarshal(apiResponse, &result) foo := result.d("args").s("foo") println(foo == "bar") } ``` <https://golang.org/ref/spec#Type_declarations>
60,028,662
When I have an xml layout like: ``` <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/my_image" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/my_image" /> ``` Then there are 2 instances of the bitmap associated with drawable in memory or just one?
2020/02/02
['https://Stackoverflow.com/questions/60028662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2401535/']
When loading drawables from `Resources`, these will be cached with a `DrawableCache` which is a `ThemedResourceCache`. The `ResourcesImpl` [states in a comment](https://android.googlesource.com/platform/frameworks/base/+/a09e9e4fe112a9db923cfee520ed7acfd708ecdc/core/java/android/content/res/ResourcesImpl.java#622): > > > ``` > // First, check whether we have a cached version of this drawable > // that was inflated against the specified theme. Skip the cache if > // we're currently preloading or we're not using the cache. > > ``` > >
Good question!!! I have viewed source code and it looks like it will create new bitmap instances for each ImageView. There is a cumbersome process goes under all of that... ImageView uses Drawable Drawable uses ImageDecoder ImageDecoder uses BitmapFactory BitmapFactory uses [native C++ code](https://android.googlesource.com/platform/frameworks/base/+/7b2f8b8/core/jni/android/graphics/BitmapFactory.cpp) for image decoding. (Look at line 157 and below) Brief look at the code tells me that it will create new instances of ~~bitmap~~ Drawable for each ImageView even if used same image. I didn't find any logic related to such optimization. **UPDATE** Yes there is a optimization took place in case of bitmap loading. Abhisek Mallick absolutely right. Even without looking into the code it is easy to check. Create a RecyclerView with ImageView's. Load into those ImageView's same bitmap. And try to change the number of items. While changing look at the Profiler->Memory. Memory allocation won't be changed.
60,028,662
When I have an xml layout like: ``` <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/my_image" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/my_image" /> ``` Then there are 2 instances of the bitmap associated with drawable in memory or just one?
2020/02/02
['https://Stackoverflow.com/questions/60028662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2401535/']
When loading drawables from `Resources`, these will be cached with a `DrawableCache` which is a `ThemedResourceCache`. The `ResourcesImpl` [states in a comment](https://android.googlesource.com/platform/frameworks/base/+/a09e9e4fe112a9db923cfee520ed7acfd708ecdc/core/java/android/content/res/ResourcesImpl.java#622): > > > ``` > // First, check whether we have a cached version of this drawable > // that was inflated against the specified theme. Skip the cache if > // we're currently preloading or we're not using the cache. > > ``` > >
You can find the answer here : For instance, every time you create a Button, a new drawable is loaded from the framework resources (android.R.drawable.btn\_default). This means all buttons across all the apps use a different drawable instance as their background. However, all these drawables share a common state, called the "constant state." source: <https://android-developers.googleblog.com/2009/05/drawable-mutations.html?m=1>
55,284,103
I have made a little pop up when I hover over a square but I want to go to this popup even with an existing margin. Here is a snippet with my HTML and CSS code: ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: solid lightgrey; position: relative; } .frame { height: 100%; } .st { height: 250px; } .info { visibility: hidden; position: absolute; top: 0; left: 120%; margin-left: -5px; border-radius: 5px; border: solid black 1px; color: white; } .vertical:hover .info { visibility: visible; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent rgba(2, 0, 0, 0.75) transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="frame"></div> <div class="info"> <div class="header"> <div class="name">Hover</div> </div> <div class="st"></div> <div class="arrow"></div> </div> </div> ``` Here is an example (if you don't follow the arrow the popup will close): <https://jsfiddle.net/bpez64fr/> I want to ignore the margin and allow the user to go to the popup and make it work as if there was no margin
2019/03/21
['https://Stackoverflow.com/questions/55284103', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9419485/']
My strategy would be to put the element to be shown on hover at `left:100%` so that there's no gap for the cursor to "fall in". You can then use `padding` on this element to create the visual whitespace between the main element and the hover element, and put the element's content in an inner element `.info-inner` in my example. Note that `.info-inner` must be `position:relative` for the positioning of the `.arrow` to work. Let me know if this works for you. ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: solid lightgrey; position: relative; } .frame { height: 100%; } .st { height: 250px; } .info { visibility: hidden; position: absolute; top: 0; left: 100%; padding-left: 10px; } .info-inner { border-radius: 5px; border: solid black 1px; color: white; position: relative; } .vertical:hover .info { visibility: visible; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent rgba(2, 0, 0, 0.75) transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="frame"></div> <div class="info"> <div class="info-inner"> <div class="header"> <div class="name">Hover</div> </div> <div class="st"></div> <div class="arrow"></div> </div> </div> </div> ```
You can use the css transitions property to delay the invisibility of the element. Example: ``` .info{ transition: visibility 2s ease-out;} ``` [`Updated jsFiddle`](https://jsfiddle.net/4n10kwra/) In this latter example, I increased the distance to the pop-up to improve the demo: [`UPDATED Updated jsFiddle`](https://jsfiddle.net/4n10kwra/1/) CSS transitions allow you to delay the advent/removal of a css modification to the DOM, giving the user time to slide the mouse from the box to the pop-up. References: <https://css-tricks.com/almanac/properties/t/transition-delay/> <https://www.w3schools.com/cssref/css3_pr_transition-delay.asp>
55,284,103
I have made a little pop up when I hover over a square but I want to go to this popup even with an existing margin. Here is a snippet with my HTML and CSS code: ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: solid lightgrey; position: relative; } .frame { height: 100%; } .st { height: 250px; } .info { visibility: hidden; position: absolute; top: 0; left: 120%; margin-left: -5px; border-radius: 5px; border: solid black 1px; color: white; } .vertical:hover .info { visibility: visible; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent rgba(2, 0, 0, 0.75) transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="frame"></div> <div class="info"> <div class="header"> <div class="name">Hover</div> </div> <div class="st"></div> <div class="arrow"></div> </div> </div> ``` Here is an example (if you don't follow the arrow the popup will close): <https://jsfiddle.net/bpez64fr/> I want to ignore the margin and allow the user to go to the popup and make it work as if there was no margin
2019/03/21
['https://Stackoverflow.com/questions/55284103', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9419485/']
My strategy would be to put the element to be shown on hover at `left:100%` so that there's no gap for the cursor to "fall in". You can then use `padding` on this element to create the visual whitespace between the main element and the hover element, and put the element's content in an inner element `.info-inner` in my example. Note that `.info-inner` must be `position:relative` for the positioning of the `.arrow` to work. Let me know if this works for you. ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: solid lightgrey; position: relative; } .frame { height: 100%; } .st { height: 250px; } .info { visibility: hidden; position: absolute; top: 0; left: 100%; padding-left: 10px; } .info-inner { border-radius: 5px; border: solid black 1px; color: white; position: relative; } .vertical:hover .info { visibility: visible; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent rgba(2, 0, 0, 0.75) transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="frame"></div> <div class="info"> <div class="info-inner"> <div class="header"> <div class="name">Hover</div> </div> <div class="st"></div> <div class="arrow"></div> </div> </div> </div> ```
There are several ways to do this but here is one example. It simple positions the element next to the previous one without a gap. ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: 3px solid lightgrey; position: relative; } .infoWrap { opacity: 0; position: absolute; top: -3px; left: 100%; padding: 0 10px; transition: all ease-in-out 0.2s; } .info { position: relative; background: #eee; border: solid #aaa 1px; border-radius: 5px; color: #666; width: 100%; min-height: 53px; padding: 10px; } .vertical:hover .infoWrap { opacity: 1; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent #aaa transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="infoWrap"> <div class="info"> <div class="header"> <div class="name">Hover</div> </div> <div class="arrow"></div> </div> </div> </div> ```
55,284,103
I have made a little pop up when I hover over a square but I want to go to this popup even with an existing margin. Here is a snippet with my HTML and CSS code: ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: solid lightgrey; position: relative; } .frame { height: 100%; } .st { height: 250px; } .info { visibility: hidden; position: absolute; top: 0; left: 120%; margin-left: -5px; border-radius: 5px; border: solid black 1px; color: white; } .vertical:hover .info { visibility: visible; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent rgba(2, 0, 0, 0.75) transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="frame"></div> <div class="info"> <div class="header"> <div class="name">Hover</div> </div> <div class="st"></div> <div class="arrow"></div> </div> </div> ``` Here is an example (if you don't follow the arrow the popup will close): <https://jsfiddle.net/bpez64fr/> I want to ignore the margin and allow the user to go to the popup and make it work as if there was no margin
2019/03/21
['https://Stackoverflow.com/questions/55284103', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9419485/']
There are several ways to do this but here is one example. It simple positions the element next to the previous one without a gap. ```css .vertical { height: 70px; width: 70px; border-radius: 5px; margin-bottom: 10px; margin-right: 10px; border: 3px solid lightgrey; position: relative; } .infoWrap { opacity: 0; position: absolute; top: -3px; left: 100%; padding: 0 10px; transition: all ease-in-out 0.2s; } .info { position: relative; background: #eee; border: solid #aaa 1px; border-radius: 5px; color: #666; width: 100%; min-height: 53px; padding: 10px; } .vertical:hover .infoWrap { opacity: 1; } .arrow { position: absolute; right: 100%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent #aaa transparent transparent; top: 25px; } ``` ```html <div class="vertical"> <div class="infoWrap"> <div class="info"> <div class="header"> <div class="name">Hover</div> </div> <div class="arrow"></div> </div> </div> </div> ```
You can use the css transitions property to delay the invisibility of the element. Example: ``` .info{ transition: visibility 2s ease-out;} ``` [`Updated jsFiddle`](https://jsfiddle.net/4n10kwra/) In this latter example, I increased the distance to the pop-up to improve the demo: [`UPDATED Updated jsFiddle`](https://jsfiddle.net/4n10kwra/1/) CSS transitions allow you to delay the advent/removal of a css modification to the DOM, giving the user time to slide the mouse from the box to the pop-up. References: <https://css-tricks.com/almanac/properties/t/transition-delay/> <https://www.w3schools.com/cssref/css3_pr_transition-delay.asp>
3,002,562
I read that the modulo operation finds remainder after division. My misconseption here is about the remainder. Is the remainder the last digit of the result? I thought it was the first. Example: $5/7 = 0.7142857142857142857...$ $5 \mod 8 = 7$. $7/3 = 2.33333..$ but $7 \mod 3 = 1$. Remainder of the first result is point 3333... $9/4 = 2.25$ $9 \mod 4 = 1$. Ok same as first but different remainder. $9/7 = 1.2857142857142...$ $9 \mod 7 = 2$. What? Remainder is two, the first digit. This is probably "random" for reals? But not for integers? $111111111$ : If there are nine ones we should divide by $7$, it gives $2$ remnants. Since $9-2=7$ ones. So using modulo operation on the reals is not something one should do?
2018/11/17
['https://math.stackexchange.com/questions/3002562', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
When you want to compute $a \bmod b$ with $a,b$ positive integers, you do division like you learned in school and write $a=qb+r$ where $q$ is the quotient and $r$ is the remainder. We typically choose $r$ to be in the range $0$ to $b-1$. Then we write $r=a \bmod b$, so is you want $1234 \bmod 7$, you write $1234=176\cdot 7 + 2$, so $1234 \bmod 7=2$. You don't need to do anything with the decimal expansion. The main time I have seen the modulo operation used with the modulus $b$ other than an integer is reducing angles of a circle when the angles are measured in radians. You compute an angle, then take it $\mod 2\pi$ to put the angle in the range $[0,2\pi)$. You can use other moduli, but this is the common one.
Let's examine a couple of your examples. First $\dfrac{7}3 = \color{#0a0}2.333\ldots = \color{#0a0}2 + \dfrac{\color{#c00}1}3\ $ has quotient $\color{#0a0}2$ and remainder $\color{#c00}1$ without fractions: $\ 7 = \color{#0a0}2\cdot 3 + \color{#c00}1$ and $\,\ \dfrac{9}7 = \color{#0a0}1.286\ldots = \color{#0a0}1 + \dfrac{\color{#c00}2}7\ $ has quotient $\color{#0a0}1$ and remainder $\color{#c00}2$ without fractions: $\ 9 = \color{#0a0}1\cdot 7 + \color{#c00}2$ Generally we have $\, a = \color{#0a0}q\cdot b + \color{#c00}r\ $ with remainder $\ \color{#c00}r = a\bmod b\,$ obeying $\, 0\le r < b$ which is obtained by (long) dividing $a$ by $b\,$ (Euclidean division with remainder) This remainder $r$ is the *least* natural of the form $\, a-q\,b\,$ for some integer $q$. Said procedurally: continually add/subtract $b$ from $a$ till you land in the interval $[0,b)$ Note that if $a, b\neq 0$ are reals then the prior procedure still works fine.
3,002,562
I read that the modulo operation finds remainder after division. My misconseption here is about the remainder. Is the remainder the last digit of the result? I thought it was the first. Example: $5/7 = 0.7142857142857142857...$ $5 \mod 8 = 7$. $7/3 = 2.33333..$ but $7 \mod 3 = 1$. Remainder of the first result is point 3333... $9/4 = 2.25$ $9 \mod 4 = 1$. Ok same as first but different remainder. $9/7 = 1.2857142857142...$ $9 \mod 7 = 2$. What? Remainder is two, the first digit. This is probably "random" for reals? But not for integers? $111111111$ : If there are nine ones we should divide by $7$, it gives $2$ remnants. Since $9-2=7$ ones. So using modulo operation on the reals is not something one should do?
2018/11/17
['https://math.stackexchange.com/questions/3002562', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']
When you want to compute $a \bmod b$ with $a,b$ positive integers, you do division like you learned in school and write $a=qb+r$ where $q$ is the quotient and $r$ is the remainder. We typically choose $r$ to be in the range $0$ to $b-1$. Then we write $r=a \bmod b$, so is you want $1234 \bmod 7$, you write $1234=176\cdot 7 + 2$, so $1234 \bmod 7=2$. You don't need to do anything with the decimal expansion. The main time I have seen the modulo operation used with the modulus $b$ other than an integer is reducing angles of a circle when the angles are measured in radians. You compute an angle, then take it $\mod 2\pi$ to put the angle in the range $[0,2\pi)$. You can use other moduli, but this is the common one.
$\frac 73 = 2\frac 13 = 2.333333....$ but neither $\frac 13$ nor $0.33333....$ are the "remainder". $\frac 13$ and $0.3333....$ are the *values* of the result of dividing a value by a divisor that is larger than it. The "remainder" is what *remains* after you have divided everything that will fit in in evenly. $2\*3 = 6 < 7$ and $3\*3 = 9 > 7$. So the most we can evenly fit $3$ into $7$ is $2$ times. That leaves $7- 2\*3 = 1$ that we haven't dealt with and can't deal with unless we get a hammer. So that is the *remainder*. We can then take the remainder and a a big hammer and *pound* it into a fractional bit of $\frac 13$ or $0.33333....$ and take care of it that way. But then ... we have dealt with it. And *nothing* remains. Because we took care of it. So by definition, the remainder is the *integer* that is left after we divide things evenly *before* we take the hammer and meat grinder to get the fractional parts. Anyway... the actual digits of the decimal representations have nothing to do with anything. ... To your examples: > > 5/7=0.7142857142857142857... > > > Um... you never do anything with it: $5 = 0\times 7 + 5; 0\*7 < 5 < 1\*7$ so $5\div 7 = 0$ with $5$ remainder. $\frac 57 = 0\frac 57$. The remainder is $5$. $5\equiv 5 \pmod 7$. > > 5mod8=7 > > > That is incorrect. $5 = 0\times 8 + 5; 0\*8 < 5 < 1\*8$ so $5\div 8 = 0$ with $5$ remainder. $\frac 58 = 0\frac 58$. The remainder is $5$. $5\equiv 5 \pmod 8$. > > 7/3=2.33333.. but 7mod3=1. Remainder of the first result is point 3333... > > > $7 = 2\times 3 + 1; 2\*3 < 7 < 3\*3$ so $7\div 3 = 2$ with $1$ remainder. $\frac 73 = 2\frac 13$. The remainder is $1$. $7\equiv 1 \pmod 3$. > > 9/4=2.25 9mod4=1. Ok same as first but different remainder. > > > $9 = 2\times 4 + 1; 2\*4 < 9 < 3\*4$ so $9\div 4 = 2$ with $1$ remainder. $\frac 94 = 2\frac 14$. The remainder is $1$. $9\equiv 1 \pmod 4$. > > 9/7=1.2857142857142... 9mod7=2. What? Remainder is two, the first digit. This is probably "random" for reals? But not for integers? > > > $9 = 1\times 7 + 2; 1\*7 < 9 < 2\*7$ so $9\div 7 = 1$ with $2$ remainder. $\frac 97 = 1\frac 27$. The remainder is $2$. $9\equiv 2 \pmod 7$. The fact that the first digit of $\frac 27$ is $2$ is an irrelevent coincidence. Decimals are not important. There are days where I fantasize that it should be illegal to teach decimals outside of engineering and accounting classes. Any way decimal expansion has *NOTHING* to do with this question. > > 111111111 : If there are nine ones we should divide by 7, it gives 2 remnants. Since 9−2=7 ones. So using modulo operation on the reals is not something one should do? > > > That is .... incomprehensible. $1111111111 = 15873015\times 7 + 6;15873015\*7 < 111111111 < 15873016\*7$ so $111111111\div 7 = 15873015$ with $6$ remainder. $\frac {111111111}7 = 15873015 \frac 67$. The remainder is $6$. $111111111\equiv 6 \pmod 7$.
583,558
I need to download 10,000 zip files from a client's FTP that has about 40,000 items on it. I have contemplated doing: ``` $ cat > files.txt file1 file2 file3 file4 ``` with ``` $ wget -i files.txt ``` Is there a better solution for such a large amount in case I get timed out?
2013/04/16
['https://superuser.com/questions/583558', 'https://superuser.com', 'https://superuser.com/users/187031/']
The solution is good and quite solid: with the proper options, `wget` will retry and download any file whose transfer got interrupted. You can also script most command-line FTP clients, however (e.g. BSD ftp client). But `wget` is better in that you can configure it to not download files you already have, which makes it very convenient for syncs. `wget` supports (on Linux at least) also rate limiting, and it is quite easy to distribute the file list between several files in order to download in parallel, or you can use [GNU parallel](http://savannah.gnu.org/projects/parallel).
`wget` is good and competent and will probably work fine in this case as mentioned by Iserni's answer, if you dig into the manual for available options. I'll just state some alternatives. I use [LFTP](http://lftp.yar.ru/) for transfers and syncing over both FTP and SFTP. It has an internal queuing system that works well for my use case, supports mirroring, reverse mirroring, FXP, all regular FTP functions and more (even Bittorrent nowadays). In this case it seems simple enough to just use a script and `wget`, but I wanted to mention a program that simplified FTP transfers for me greatly. I've also used [NcFTP](http://www.ncftp.com/ncftp/) that has a very nice batch system, but the deal breaker in LFTP's favor for me was that it supported both FTP and SFTP. Another alternative is [`rsync`](http://rsync.samba.org/) which also supports FTP, and perhaps you are already used to this. It also has quite advanced options ready as per filtering and resuming broken downloads. An advantage with a "real" FTP client as compared to batch `wget` use is that a single connection to the server can be reused, which might boost performance. I'm not sure there is such an alternative for `wget`, but maybe there is. If this is a true one-off operation, you could probably use more or less anything.
583,558
I need to download 10,000 zip files from a client's FTP that has about 40,000 items on it. I have contemplated doing: ``` $ cat > files.txt file1 file2 file3 file4 ``` with ``` $ wget -i files.txt ``` Is there a better solution for such a large amount in case I get timed out?
2013/04/16
['https://superuser.com/questions/583558', 'https://superuser.com', 'https://superuser.com/users/187031/']
The solution is good and quite solid: with the proper options, `wget` will retry and download any file whose transfer got interrupted. You can also script most command-line FTP clients, however (e.g. BSD ftp client). But `wget` is better in that you can configure it to not download files you already have, which makes it very convenient for syncs. `wget` supports (on Linux at least) also rate limiting, and it is quite easy to distribute the file list between several files in order to download in parallel, or you can use [GNU parallel](http://savannah.gnu.org/projects/parallel).
lftp is pretty good at this. Note the *continue* and *expandnd wildcards* OPTS. ``` lftp :~> help mirror Usage: mirror [OPTS] [remote [local]] Mirror specified remote directory to local directory ``` -c, --continue continue a mirror job if possible -e, --delete delete files not present at remote site --delete-first delete old files before transferring new ones -s, --allow-suid set suid/sgid bits according to remote site --allow-chown try to set owner and group on files --ignore-time ignore time when deciding whether to download -n, --only-newer download only newer files (-c won't work) -r, --no-recursion don't go to subdirectories -p, --no-perms don't set file permissions --no-umask don't apply umask to file modes -R, --reverse reverse mirror (put files) -L, --dereference download symbolic links as files -N, --newer-than=SPEC download only files newer than specified time -P, --parallel[=N] download N files in parallel -i RX, --include RX include matching files -x RX, --exclude RX exclude matching files RX is extended regular expression -v, --verbose[=N] verbose operation --log=FILE write lftp commands being executed to FILE --script=FILE write lftp commands to FILE, but don't execute them --just-print, --dry-run same as --script=- When using -R, the first directory is local and the second is remote. If the second directory is omitted, basename of first directory is used. If both directories are omitted, current local and remote directories are used. ``` lftp :~> help mget Usage: mget [OPTS] Gets selected files with expanded wildcards -c continue, reget -d create directories the same as in file names and get the files into them instead of current directory -E delete remote files after successful transfer -a use ascii mode (binary is the default) -O specifies base directory or URL where files should be placed ```
583,558
I need to download 10,000 zip files from a client's FTP that has about 40,000 items on it. I have contemplated doing: ``` $ cat > files.txt file1 file2 file3 file4 ``` with ``` $ wget -i files.txt ``` Is there a better solution for such a large amount in case I get timed out?
2013/04/16
['https://superuser.com/questions/583558', 'https://superuser.com', 'https://superuser.com/users/187031/']
`wget` is good and competent and will probably work fine in this case as mentioned by Iserni's answer, if you dig into the manual for available options. I'll just state some alternatives. I use [LFTP](http://lftp.yar.ru/) for transfers and syncing over both FTP and SFTP. It has an internal queuing system that works well for my use case, supports mirroring, reverse mirroring, FXP, all regular FTP functions and more (even Bittorrent nowadays). In this case it seems simple enough to just use a script and `wget`, but I wanted to mention a program that simplified FTP transfers for me greatly. I've also used [NcFTP](http://www.ncftp.com/ncftp/) that has a very nice batch system, but the deal breaker in LFTP's favor for me was that it supported both FTP and SFTP. Another alternative is [`rsync`](http://rsync.samba.org/) which also supports FTP, and perhaps you are already used to this. It also has quite advanced options ready as per filtering and resuming broken downloads. An advantage with a "real" FTP client as compared to batch `wget` use is that a single connection to the server can be reused, which might boost performance. I'm not sure there is such an alternative for `wget`, but maybe there is. If this is a true one-off operation, you could probably use more or less anything.
lftp is pretty good at this. Note the *continue* and *expandnd wildcards* OPTS. ``` lftp :~> help mirror Usage: mirror [OPTS] [remote [local]] Mirror specified remote directory to local directory ``` -c, --continue continue a mirror job if possible -e, --delete delete files not present at remote site --delete-first delete old files before transferring new ones -s, --allow-suid set suid/sgid bits according to remote site --allow-chown try to set owner and group on files --ignore-time ignore time when deciding whether to download -n, --only-newer download only newer files (-c won't work) -r, --no-recursion don't go to subdirectories -p, --no-perms don't set file permissions --no-umask don't apply umask to file modes -R, --reverse reverse mirror (put files) -L, --dereference download symbolic links as files -N, --newer-than=SPEC download only files newer than specified time -P, --parallel[=N] download N files in parallel -i RX, --include RX include matching files -x RX, --exclude RX exclude matching files RX is extended regular expression -v, --verbose[=N] verbose operation --log=FILE write lftp commands being executed to FILE --script=FILE write lftp commands to FILE, but don't execute them --just-print, --dry-run same as --script=- When using -R, the first directory is local and the second is remote. If the second directory is omitted, basename of first directory is used. If both directories are omitted, current local and remote directories are used. ``` lftp :~> help mget Usage: mget [OPTS] Gets selected files with expanded wildcards -c continue, reget -d create directories the same as in file names and get the files into them instead of current directory -E delete remote files after successful transfer -a use ascii mode (binary is the default) -O specifies base directory or URL where files should be placed ```