qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
73,628,868
###### Updated Let's suppose that you got octal escape sequences in a stream: ``` backslash \134 is escaped as \134134 single quote ' and double quote \042 linefeed `\012` and carriage return `\015` %s & etc... ``` **note:** The escaped characters are limited to `0x01-0x1F 0x22 0x5C 0x7F` How can you revert those escape sequences back to their corresponding character with `awk`? While `awk` is able to understand them out-of-box when used in a literal string or as a parameter argument, I can't find the way to leverage this capability when the escape sequence is part of the data. For now I'm using one `gsub` per escape sequence but it doesn't feel efficient. Here's the expected output for the given sample: ``` backslash \ is escaped as \134 single quote ' and double quote " linefeed ` ` and carriage return ` %s & etc... ``` **PS:** While I have the additional constraint of unescaping each line into an awk variable before printing the result, it doesn't really matter.
2022/09/07
[ "https://Stackoverflow.com/questions/73628868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3387716/" ]
UPDATE :: about `gawk`'s `strtonum()` in unicode mode : ``` echo '\666' | LC_ALL='en_US.UTF-8' gawk -e ' $++NF = "<( "(sprintf("%c", strtonum((_=_<_) substr($++_, ++_))))" )>"' 0000000 909522524 539507744 690009798 2622 \ 6 6 6 < ( ƶ ** ) > \n 134 066 066 066 040 074 050 040 306 266 040 051 076 012 \ 6 6 6 sp < ( sp ? ? sp ) > nl 92 54 54 54 32 60 40 32 198 182 32 41 62 10 5c 36 36 36 20 3c 28 20 c6 b6 20 29 3e 0a 0000016 ``` By default, `gawk` in unicode mode would decode out a multi-byte character instead of byte `\266 | 0xB6`. If you wanna ensure consistency of always decoding out a single-byte out, even in `gawk` unicode mode, this should do the trick : ``` echo '\666' | LC_ALL='en_US.UTF-8' gawk -e '$++NF = sprintf("<( %c )>", strtonum((_=_<_) substr($++_, ++_)) + _*++_^_++*_^++_)' 0000000 909522524 539507744 1042882742 10 \ 6 6 6 < ( 266 ) > \n 134 066 066 066 040 074 050 040 266 040 051 076 012 \ 6 6 6 sp < ( sp ? sp ) > nl 92 54 54 54 32 60 40 32 182 32 41 62 10 5c 36 36 36 20 3c 28 20 b6 20 29 3e 0a 0000015 ``` ***long story short*** : add `4^5 * 54` to output of `strtonum()`, which happens to be `0xD800`, the starting point of `UTF-16 surrogates` =================== =================== =================== one quick note about `@Gene`'s proposed `perl`-based solution : ``` echo 'abc \555 456' | perl -p -e 's/\\([0-7]{3})/chr(oct($1))/ge' Wide character in print at -e line 1, <> line 1. abc ŭ 456 ``` octal codes wrap around, meaning `\4xx = \0xx ; \6xx = \2xx` etc : ``` printf '\n %s\n' $'\555' m ``` so `perl` is incorrectly decoding these as multi-byte characters, when in fact `\555`, as confirmed by `printf`, is merely lowercase `"m" (0x6D)` ps : my `perl` is version `5.34`
this separate post is made specifically to showcase how to extend the octal lookup reference tables in `gawk` `unicode`-mode to ***`all 256 bytes`*** without external dependencies or warning messages: * `ASCII` bytes reside in table `o2bL` * 8-bit bytes reside in table `o2bH` . ``` # gawk profile, created Fri Sep 16 09:53:26 2022 'BEGIN { 1 makeOctalRefTables(PROCINFO["sorted_in"] = "@val_str_asc" \ (ORS = "")) 128 for (_ in o2bL) { 128 print o2bL[_] } 128 for (_ in o2bH) { 128 print o2bH[_] } } function makeOctalRefTables(_,__,___,____) { 1 _=__=___=____="" for (_ in o2bL) { break } 1 if (!(_ in o2bL)) { 1 ____=_+=((_+=_^=_<_)-+-++_)^_-- 128 do { o2bL[sprintf("\\%o",_)] = \ sprintf("""%c",_) } while (_--) 1 o2bL["\\" ((_+=(_+=_^=_<_)+_)*_--+_+_)] = "\\&" 1 ___=--_*_^_--*--_*++_^_*(_^=++_)^(! —_) 128 do { o2bH[sprintf("\\%o", +_)] = \ sprintf("%c",___+_) } while (____<--_) } 1 return length(o2bL) ":" length(o2bH) }' ``` | ``` \0 \1 \2 \3 \4 \5 \6 \7 \10\11 \12 \13 \14 \16 \17 \20 \21 \22 \23 \24 \25 \26 \27 \30 \31 \32 \33 34 \35 \36 \37 \40 \41 !\42 "\43 #\44 $\45 %\47 '\50 (\51 )\52 *\53 +\54 ,\55 -\56 .\57 / \60 0\61 1\62 2\63 3\64 4\65 5\66 6\67 7\70 8\71 9\72 :\73 ;\74 <\75 =\76 >\77 ? \100 @\101 A\102 B\103 C\104 D\105 E\106 F\107 G\110 H\111 I\112 J\113 K\114 L\115 M\116 N\117 O \120 P\121 Q\122 R\123 S\124 T\125 U\126 V\127 W\130 X\131 Y\132 Z\133 [\134 \\46 \&\135 ]\136 ^\137 _ \140 `\141 a\142 b\143 c\144 d\145 e\146 f\147 g\150 h\151 i\152 j\153 k\154 l\155 m\156 n\157 o \160 p\161 q\162 r\163 s\164 t\165 u\166 v\167 w\170 x\171 y\172 z\173 {\174 |\175 }\176 ~\177 \200 ?\201 ?\202 ?\203 ?\204 ?\205 ?\206 ?\207 ?\210 ?\211 ?\212 ?\213 ?\214 ?\215 ?\216 ?\217 ? \220 ?\221 ?\222 ?\223 ?\224 ?\225 ?\226 ?\227 ?\230 ?\231 ?\232 ?\233 ?\234 ?\235 ?\236 ?\237 ? \240 ?\241 ?\242 ?\243 ?\244 ?\245 ?\246 ?\247 ?\250 ?\251 ?\252 ?\253 ?\254 ?\255 ?\256 ?\257 ? \260 ?\261 ?\262 ?\263 ?\264 ?\265 ?\266 ?\267 ?\270 ?\271 ?\272 ?\273 ?\274 ?\275 ?\276 ?\277 ? \300 ?\301 ?\302 ?\303 ?\304 ?\305 ?\306 ?\307 ?\310 ?\311 ?\312 ?\313 ?\314 ?\315 ?\316 ?\317 ? \320 ?\321 ?\322 ?\323 ?\324 ?\325 ?\326 ?\327 ?\330 ?\331 ?\332 ?\333 ?\334 ?\335 ?\336 ?\337 ? \340 ?\341 ?\342 ?\343 ?\344 ?\345 ?\346 ?\347 ?\350 ?\351 ?\352 ?\353 ?\354 ?\355 ?\356 ?\357 ? \360 ?\361 ?\362 ?\363 ?\364 ?\365 ?\366 ?\367 ?\370 ?\371 ?\372 ?\373 ?\374 ?\375 ?\376 ?\377 ? ```
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the `/etc/init.d/jexec` script which is already installed and required for JDK 6. I would advise sticking to the tarball or self extracting `*.bin` and using JAVA\_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need [jexec](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6211008) anyway.
In general I would suggest that you install the Oracle JDK not the OpenJDK. Otherwise you might risk running into some issues. I always found problems of all sorts and sizes with OpenJDK that I don't even bother trying it any more. Download the JDK RPM from [here](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and follow the usual instructions. Its usually very straightforward and without problems. Full detailed instructions including how to install it [here](http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html). Make sure you choose the right version you need (JDK 1.7 or JDK 1.6, dont mix) because from your question you seem to have a confusion of library versions from 1.5 to 1.7. And another thing, uninstall whatever you have installed already before installing a fresh one to avoid conflicts.
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
In general I would suggest that you install the Oracle JDK not the OpenJDK. Otherwise you might risk running into some issues. I always found problems of all sorts and sizes with OpenJDK that I don't even bother trying it any more. Download the JDK RPM from [here](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and follow the usual instructions. Its usually very straightforward and without problems. Full detailed instructions including how to install it [here](http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html). Make sure you choose the right version you need (JDK 1.7 or JDK 1.6, dont mix) because from your question you seem to have a confusion of library versions from 1.5 to 1.7. And another thing, uninstall whatever you have installed already before installing a fresh one to avoid conflicts.
sudo rpm -i jdk-11.0.9\_linux-x64\_bin.rpm or whatever package you are trying to install
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the `/etc/init.d/jexec` script which is already installed and required for JDK 6. I would advise sticking to the tarball or self extracting `*.bin` and using JAVA\_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need [jexec](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6211008) anyway.
Check my answer here [Transaction check error when installing Sun JDK 7](https://stackoverflow.com/questions/10270380/transaction-check-error-when-installing-sun-jdk-7/18621115) Basically you may use rpm --force to install one JDK on top of the other. This scenario is completely valid specially when you have to develop for different JAVA versions.
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the `/etc/init.d/jexec` script which is already installed and required for JDK 6. I would advise sticking to the tarball or self extracting `*.bin` and using JAVA\_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need [jexec](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6211008) anyway.
Just faced the same issue. I was not comfortable using --force command; did not want to risk messing-up the existing Java that came installed at system setup. I ended up doing the following and running the app server with a different version of Java under a different user ID. downloaded the Java tar.gz version and uncompressed: ``` tar -zxvf jdk-7u45-linux-x64.gz ``` Created the directory: ``` mkdir /usr/java/jdk1.7.0_45 ``` Copied the contents to the new directory manually: ``` cp -r /.../jdk1.7.0_45/* /usr/java/jdk1.7.0_45 ``` Set the java\_home under the user ID home directory in .bashrc and .bash\_profile files: ``` export JAVA_HOME=/usr/java/jdk1.7.0_45 export PATH=$JAVA_HOME/bin:$PATH export PATH=$PATH:/usr/sfw/lib/gcc:/usr/sfw/bin ```
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
The problem here is that you cannot use the Oracle rpm to install JDK 7 when you already have the Oracle JDK 6 as it tries to install the `/etc/init.d/jexec` script which is already installed and required for JDK 6. I would advise sticking to the tarball or self extracting `*.bin` and using JAVA\_HOME if you are going to use the Oracle distribution as it does not have this problem and you will probably not need [jexec](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6211008) anyway.
sudo rpm -i jdk-11.0.9\_linux-x64\_bin.rpm or whatever package you are trying to install
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
Check my answer here [Transaction check error when installing Sun JDK 7](https://stackoverflow.com/questions/10270380/transaction-check-error-when-installing-sun-jdk-7/18621115) Basically you may use rpm --force to install one JDK on top of the other. This scenario is completely valid specially when you have to develop for different JAVA versions.
sudo rpm -i jdk-11.0.9\_linux-x64\_bin.rpm or whatever package you are trying to install
16,246,615
Help! I can't figure out how to install a jdk! ``` [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.7.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.7.0-openjdk available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk-devel" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk-devel available. Error: Nothing to do [/usr/lib/jvm]$ su -c "yum install java-1.6.0-openjdk" Loaded plugins: langpacks, presto, refresh-packagekit No package java-1.6.0-openjdk available. Error: Nothing to do ``` Here I've manually downloaded some rpm's, the last one from oracle's website: ``` [~]$ rpm -ivh java-1.7.0-openjdk-devel-1.7.0.19-2.3.9.3.fc20.x86_64.rpm error: Failed dependencies: java-1.7.0-openjdk = 1:1.7.0.19-2.3.9.3.fc20 is needed by java-1.7.0-openjdk-devel-1:1.7.0.19-2.3.9.3.fc20.x86_64 [~]$ sudo rpm -ivh java-1.7.0-openjdk-1.7.0.19-2.3.9.3.fc20.x86_64.rpm Preparing... ################################# [100%] file /usr/lib/jvm-exports/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 file /usr/lib/jvm/jre-1.7.0-openjdk.x86_64 from install of java-1.7.0-openjdk-1:1.7.0.19-2.3.9.3.fc20.x86_64 conflicts with file from package java-1.7.0-openjdk-1:1.7.0.9-2.3.7.0.fc18.x86_64 [~]$ sudo rpm -ivh jdk-7u21-linux-x64.rpm Preparing... ################################# [100%] file /etc/init.d/jexec from install of jdk-2000:1.7.0_21-fcs.x86_64 conflicts with file from package jdk-2000:1.6.0_38-fcs.x86_64 ``` Debug ----- Here's some debug information: ``` [/usr/lib/jvm]$ yum search jdk Loaded plugins: langpacks, presto, refresh-packagekit =========================================================== N/S Matched: jdk ============================================================ java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation jdk.x86_64 : Java(TM) Platform Standard Edition Development Kit ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. ``` . ``` [/usr/lib/jvm]$ yum list java* Loaded plugins: langpacks, presto, refresh-packagekit Installed Packages java-1.5.0-gcj.x86_64 ``` . ``` [/usr/lib/jvm]$ cat /etc/fedora-release Fedora release 18 (Spherical Cow) ``` Requirements ------------ I *must* have "**jni.h**", "**libjava.so**", "**libhpi.so**", "**lipverify.so**" and "**libjvm.so**" included. So far I've found out that these DO NOT have what I need: * Undesired Versions (for sure): + jdk1.7.0\_06 <-- *I'm surprised about this one, but it doesn't have libjvm nor libhpi* + java-1.7.0 + java-openjdk + java-1.7.0-openjdk-1.7.0.9.x86\_64 + java-1.5.0-gcj-4.4 + java-1.6.0-openjdk + java-1.7.0-openjdk.x86\_64 + jre-1.5.0-gcj + jre-1.7.0-openjdk.x86\_64 + jre-openjdk + jre-1.7.0 + jre-7u11-linux-x64.rpm java-1.5.0-gcj-1.5.0.0 + jre-1.5.0 + jre1.7.0\_11 + jre-gcj And these do: * Desired Versions (that I know of, there could be more): + **jdk1.6.0\_34-x86** + jdk1.5.0\_22-x86 + java-6-openjdk Can someone help me install jdk1.6 or java-6-openjdk please?
2013/04/26
[ "https://Stackoverflow.com/questions/16246615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1696153/" ]
Just faced the same issue. I was not comfortable using --force command; did not want to risk messing-up the existing Java that came installed at system setup. I ended up doing the following and running the app server with a different version of Java under a different user ID. downloaded the Java tar.gz version and uncompressed: ``` tar -zxvf jdk-7u45-linux-x64.gz ``` Created the directory: ``` mkdir /usr/java/jdk1.7.0_45 ``` Copied the contents to the new directory manually: ``` cp -r /.../jdk1.7.0_45/* /usr/java/jdk1.7.0_45 ``` Set the java\_home under the user ID home directory in .bashrc and .bash\_profile files: ``` export JAVA_HOME=/usr/java/jdk1.7.0_45 export PATH=$JAVA_HOME/bin:$PATH export PATH=$PATH:/usr/sfw/lib/gcc:/usr/sfw/bin ```
sudo rpm -i jdk-11.0.9\_linux-x64\_bin.rpm or whatever package you are trying to install
5,164
I've built a new Page-Template in Magento. On this template I will show the Category-Image and after that, the product grid (as standard). How can I get the Category-Image for my Template? From my Template: ``` <div class="col-main grid4-3 grid-col2-main in-col2"> <?php echo $this->getChildHtml('global_messages') ?> <div class="worlds-image"">Category Image</div> <?php echo $this->getChildHtml('content') ?> </div> ```
2013/06/26
[ "https://magento.stackexchange.com/questions/5164", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/2503/" ]
If you want to get the thumbnail image of the current category that you are browsing, then use the following code: ``` <?php $categoryImage = Mage::getModel('catalog/layer')->getCurrentCategory()->getThumbnail(); //Get the file name of the Image stored for the category ?> <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$categoryImage ?>" /> ```
Great, and ``` <?php $categoryImage = Mage::getModel('catalog/layer')->getCurrentCategory()->getImage(); //Get the file name of the Image stored for the category ?> <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$categoryImage ?>" /> ``` ..is for the category Image. Thanks for your help, It's not easy for a newbie to make "easy things" in magento .
5,164
I've built a new Page-Template in Magento. On this template I will show the Category-Image and after that, the product grid (as standard). How can I get the Category-Image for my Template? From my Template: ``` <div class="col-main grid4-3 grid-col2-main in-col2"> <?php echo $this->getChildHtml('global_messages') ?> <div class="worlds-image"">Category Image</div> <?php echo $this->getChildHtml('content') ?> </div> ```
2013/06/26
[ "https://magento.stackexchange.com/questions/5164", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/2503/" ]
If you want to get the thumbnail image of the current category that you are browsing, then use the following code: ``` <?php $categoryImage = Mage::getModel('catalog/layer')->getCurrentCategory()->getThumbnail(); //Get the file name of the Image stored for the category ?> <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$categoryImage ?>" /> ```
An easier way to grab the full url of the category image (on Magento 1.7, anyway) is to use the function "getImageUrl()". Thus, we can grab more or less the same code from the category view.phtml to create our category image... ``` <?php $_category = Mage::getModel('catalog/layer')->getCurrentCategory(); $_catImgHtml = ''; if ($_catImgUrl = $_category->getImageUrl()) { $_catImgHtml = '<p class="category-image"><img src="'.$_catImgUrl.'" alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>'; $_catImgHtml = $_helper->categoryAttribute($_category, $_catImgHtml, 'image'); } ?> ``` You can even simplify this if all you want is a bare link: ``` $_catImgHtml = '<img src="'.$_catImgUrl.'">'; ``` followed by... ``` <?php if($_catImgUrl): ?> <?php echo $_catImgHtml ?> <?php endif; ?> ```
5,511,737
I have the following code in R: ``` z <- scale(x) / sqrt(n-1) # standardized matrix x such that z'z=correlation matrix R <- t(z) %*% z # correlation matrix I <- diag(py - 1) # identity matrix(py defined before) df <- rep(0, length(k)) # k=seq(0,5,0.001) for (i in seq(0,5,0.001)) { H <- z %*% solve(R+(i*I)) %*% t(z) tr <- sum(diag(H)) df <- c(df,tr) ## problem here } ``` The last line in the code is not good, as what I want is a vector (`df`) that reads each number from `tr` for each i, so that df returns a vector containing all `tr`. Any help is appreciated. Thanks
2011/04/01
[ "https://Stackoverflow.com/questions/5511737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/687362/" ]
Is the application pool running in integrated mode the IIS site running under that application pool? It's my understanding that if this isn't the case, the MVC site will not run. Alternatively, have you tried [this?](https://stackoverflow.com/questions/1741439/asp-mvc-in-iis-7-results-in-http-error-403-14-forbidden/5459217#5459217)
+1 Unicorn power HooooooO!!!!! Also I've always when hosting a site published the project to a different folder then setup the site via IIS from that folder hope this helps.
7,276,440
I want to loop through a DataGridView that is created on the main form in a BackgroundWorker to export the data to a CSV file. The BackgroundWorker is created on a separate form where the progress of the export will be displayed via a progress bar. Here is the code on the export form that calls the BackgroundWorker: ``` private DataGridView exportGrid; public void ExportCSV(DataGridView mainGrid) { this.exportGrid = mainGrid; //Set progress bar maximum progressBar1.Maximum = mainGrid.Rows.Count; if (backgroundWorker1.IsBusy != true) { //Start the asynchronous operation backgroundWorker1.RunWorkerAsync(); } //Show the form this.ShowDialog(); } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; //Write data rows foreach (DataGridViewRow row in exportGrid.Rows) { //Check if the background worker has been cancelled if (worker.CancellationPending == true) { e.Cancel = true; break; } else { foreach (DataGridViewCell cell in row.Cells) { if (cell.Visible) { //Do CSV writing here... } } //Report current progress to update UI worker.ReportProgress(row.Index + 1); } } } private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { //Update progress bar this.progressBar1.Value = e.ProgressPercentage; } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //Close the form once the background worker is complete this.Close(); } ``` This code has been causing the following errors: * BindingSource cannot be its own data source. Do not set the DataSource and DataMember properties to values that refer back to BindingSource. * Cross-thread operation not valid: Control 'mainGrid' accessed from a thread other than the thread it was created on. I assume that these are because I am accessing the DataGridView in a thread that did not create it. What is the best way to go about doing this? Is it even possible? **Update:** The reason I am looping through the DataGridView instead of the datasource is that the users will be changing the column order, sort order and showing/hiding columns of the grid and they want these changes reflected in the exported data. Is there a different way to handle this?
2011/09/01
[ "https://Stackoverflow.com/questions/7276440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/199919/" ]
Jeff in my opinion you are doing at minimum two mistakes in here: * Exporting data from a UI control instead of doing it from the data source; * Trying to access a UI control from a background thread; I just would not try to access a UI control (Grid in your case) in a form which is not even the form where the background thread is declared, code will be so unclear and unreadable... then consider that UI controls are used to render data in the UI; whenever you need to access the data for anything else than rendering in the screen you'd better access directly the datasource used to populate the UI.
I have ran into this before. Here's how I did this. This is taken straight out of the project I did this in. You should be able to get the idea of how to set up the threading to make this work. I didn't include the methods that actually write the CSV file, I'm assuming your main problem is with the threading. And as Davide Piras said, it's probably not a good idea to write the data directly from a control. The BackGroundWorker's EventHandlers: ``` #region TableWorker Events void TableWorker_DoWork(object sender, DoWorkEventArgs e) { bool done = false; GetSwitch(); ProgressLabel.Visible = true; while (!done) { for (int i = 1; i <= 100; i++) { Thread.Sleep(100); TableWorker.ReportProgress(i); } done = Export.ExportDataTable(SaveFile, DataTable); } } void TableWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { Progress.Style = ProgressBarStyle.Blocks; Progress.Value = e.ProgressPercentage; ProgressLabel.Text = "Writing File: " + e.ProgressPercentage.ToString() + "% Complete"; } void TableWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Progress.Value = 100; ProgressLabel.Visible = false; Progress.Visible = false; //MessageBox.Show("Export Completed!"); TableWorker.Dispose(); ExportButton.Enabled = true; this.Close(); } #endregion ``` Event that starts the BackgroundWorker. ``` private void EntireTableButton_Click(object sender, EventArgs e) { dialogResult = Export.SetSaveDialog(SaveFile, ".csv", "csv file (*.csv)|*.csv"); if (dialogResult == DialogResult.OK) { TableWorker.RunWorkerAsync(); this.Hide(); ProgressLabel.Visible = true; ProgressLabel.Text = "Retrieving Data..."; Progress.Style = ProgressBarStyle.Marquee; Progress.Visible = true; ExportButton.Enabled = false; while (TableWorker.IsBusy) { Application.DoEvents(); } Progress.Visible = false; } } ``` The Background worker's ReportProgress method will allow you to pass the progress to the ProgressChanged event. By doing this you can update the progress bar on another form.
72,696
I have been involved in two volunteering groups for the past two years and I'm not sure If I should ever mention it in the SOP/CV. Should I mention it in one or both my SOP and CV? Also, how detailed should I write on the type of activity/nature of the work/vision/reasoning/accomplishments, etc. Note: I'm applying for Electrical and Computer Engineering for a master's degree. The volunteering work is totally unrelated to the degree. The activities are focused on aiding homeless and abused animals
2016/07/12
[ "https://academia.stackexchange.com/questions/72696", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/57672/" ]
I would recommend against mentioning unrelated volunteer work in one's statement of purpose---after all, you have said that it is unrelated to the career that you are intending to pursue. If it *were* directly linked, then of course it would be useful to mention it. Likewise, there is no space for this type of work in any of the main sections of an academic CV: this isn't like applying to college, where you are encouraged to list a bunch of extracurricular activities to show your breadth and interesting personality. Graduate admissions is instead more typically about showing that you have the mix of skills, drive, and focus necessary to succeed in you intended program. It is often the case, however, that people will have some sort of "other significant experiences" section at the very end of their CV in which they put miscellaneous things that they think are important. If you feel that your volunteer work is an important ingredient in understanding you as a potential professional, then this is the appropriate place to include a brief note. It may help you if it catches the eye of somebody who finds it significant, and it is unlikely to hurt you.
I see nothing wrong in mentioning that on your resume even if it is unrelated. If you have enough place on your 1-2 page resume, you can put it. In my eyes, It shows that you are a passionate, social and informed person and not just a (sitting in front of the computer) geek.
72,696
I have been involved in two volunteering groups for the past two years and I'm not sure If I should ever mention it in the SOP/CV. Should I mention it in one or both my SOP and CV? Also, how detailed should I write on the type of activity/nature of the work/vision/reasoning/accomplishments, etc. Note: I'm applying for Electrical and Computer Engineering for a master's degree. The volunteering work is totally unrelated to the degree. The activities are focused on aiding homeless and abused animals
2016/07/12
[ "https://academia.stackexchange.com/questions/72696", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/57672/" ]
> > Should I mention it in one or both my SOP and CV? > > > Yes, in the CV (shows you're well rounded and well enough organized to keep up with a commitment outside of school), but not in the SOP (because it's unrelated) -- unless this particular experience was fundamental in motivating you to want to go to grad school. > > Also, how detailed should I write on the type of activity/nature of the work/vision/reasoning/accomplishments, etc. > > > The whole thing should fit on two (maximum three) lines. If you have ever done any other volunteer work, you can make a whole section for Volunteer Work. Alternatively you could include it under Work Experience, and then in the description make it clear that it was a volunteer position.
I see nothing wrong in mentioning that on your resume even if it is unrelated. If you have enough place on your 1-2 page resume, you can put it. In my eyes, It shows that you are a passionate, social and informed person and not just a (sitting in front of the computer) geek.
72,696
I have been involved in two volunteering groups for the past two years and I'm not sure If I should ever mention it in the SOP/CV. Should I mention it in one or both my SOP and CV? Also, how detailed should I write on the type of activity/nature of the work/vision/reasoning/accomplishments, etc. Note: I'm applying for Electrical and Computer Engineering for a master's degree. The volunteering work is totally unrelated to the degree. The activities are focused on aiding homeless and abused animals
2016/07/12
[ "https://academia.stackexchange.com/questions/72696", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/57672/" ]
I would recommend against mentioning unrelated volunteer work in one's statement of purpose---after all, you have said that it is unrelated to the career that you are intending to pursue. If it *were* directly linked, then of course it would be useful to mention it. Likewise, there is no space for this type of work in any of the main sections of an academic CV: this isn't like applying to college, where you are encouraged to list a bunch of extracurricular activities to show your breadth and interesting personality. Graduate admissions is instead more typically about showing that you have the mix of skills, drive, and focus necessary to succeed in you intended program. It is often the case, however, that people will have some sort of "other significant experiences" section at the very end of their CV in which they put miscellaneous things that they think are important. If you feel that your volunteer work is an important ingredient in understanding you as a potential professional, then this is the appropriate place to include a brief note. It may help you if it catches the eye of somebody who finds it significant, and it is unlikely to hurt you.
> > Should I mention it in one or both my SOP and CV? > > > Yes, in the CV (shows you're well rounded and well enough organized to keep up with a commitment outside of school), but not in the SOP (because it's unrelated) -- unless this particular experience was fundamental in motivating you to want to go to grad school. > > Also, how detailed should I write on the type of activity/nature of the work/vision/reasoning/accomplishments, etc. > > > The whole thing should fit on two (maximum three) lines. If you have ever done any other volunteer work, you can make a whole section for Volunteer Work. Alternatively you could include it under Work Experience, and then in the description make it clear that it was a volunteer position.
39,384,482
I have a query which takes around 2 seconds to load: ``` SELECT OUTPUT_VAL.NEXTVAL VAR1_R_ID,A.R_ID,A.VAR1,A.SEQU,A.OUTPUT,B.VAR1 DATATYPE_VAR1 FROM ( SELECT A.R_ID,A.VAR1,A.SEQU,A.OUTPUT,B.D_TYPE FROM ( select A.R_ID, 2484 VAR1,1 SEQU, A.USER OUTPUT from R_TB_1 A WHERE A.R_ID BETWEEN 2457854437 AND 2458854437 union all select A.R_ID, A.MEM_VAR1 VAR1,1 SEQU, MEM_OUTPUT OUTPUT from R_TB_1 A WHERE A.R_ID BETWEEN 2457854437 AND 2458854437 ) A LEFT JOIN VAR1_TABLE B ON A.VAR1=B.VAR1 ) A LEFT JOIN VAR1_TABLE B ON A.D_TYPE=B.VAR1_NAME; ``` How can I rewrite it to improve performance?
2016/09/08
[ "https://Stackoverflow.com/questions/39384482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893394/" ]
So, you have a table `VAR1_TABLE` with at least three columns, `VAR1`, `D_TYPE` and `VAR1_NAME`... you select rows that have a `VAR1` column from another table, then you join with `VAR1_TABLE` on `MEM_VAR1 = VAR1`, and then you join again on `D_TYPE = VAR1_NAME`? Can you explain this part, since it makes no sense to me... why are you comparing `D_TYPE` to `VAR1_NAME`? Just because you can do it and the query runs without errors doesn't mean it makes sense. Assuming the table R\_TB\_1 has many rows (you seem to be selecting 100,000 rows which is a small portion of the whole table), the `UNION ALL` means the table is scanned twice. You may be better off selecting just once, in a CTE, and then doing the union based on the CTE... if your version is at least Oracle 11.1. (By the way, state your Oracle version whenever you ask a question!) If you are on Oracle 10 or below, you will need subqueries like you have now. Something like this: ``` with Z ( R_ID, MEM_VAR1, USER, MEM_OUTPUT ) as ( select R_ID, MEM_VAR1, USER, MEM_OUTPUT from R_TB_1 where R_ID between 2457854437 and 2458854437 ), A ( R_ID, VAR1, SEQU, OUTPUT ) as ( select R_ID, 2484 , 1, USER from Z union all select R_ID, MEM_VAR1, 1, MEM_OUTPUT from Z ) select -- your joins from A to the other table here; A is defined in the WITH clause ```
``` WITH temp AS ( SELECT OUTPUT_VAL.NEXTVAL VAR1_R_ID,A.R_ID,A.VAR1,A.SEQU,A.OUTPUT,B.VAR1 DATATYPE_VAR1 FROM ( SELECT A.R_ID,A.VAR1,A.SEQU,A.OUTPUT,B.D_TYPE FROM ( SELECT A.R_ID, 2484 VAR1,1 SEQU, A.USER OUTPUT from R_TB_1 A WHERE A.R_ID BETWEEN 2457854437 AND 2458854437 union ALL select A.R_ID, A.MEM_VAR1 VAR1,1 SEQU, MEM_OUTPUT OUTPUT from R_TB_1 A WHERE A.R_ID BETWEEN 2457854437 AND 2458854437 ) A LEFT JOIN VAR1_TABLE B ON A.VAR1=B.VAR1 ) A LEFT JOIN VAR1_TABLE B ON A.D_TYPE=B.VAR1_NAME ) SELECT * FROM temp ```
43,938,023
Imitating an "increasing" C-styled for loop in Python is very simple: ``` for (int i = A ; i < B ; i += C) ``` can be easily implemented in Python, **Without consuming memory for an array from A to B**, using: ``` for i in range(A, B, C) # (xrange if Python 2.x) ``` But what about decreasing loops? How can one imitate C-styled loops such as: ``` for (int i = A ; i >= B ; i -= C) ``` Even using `reversed(range(A, B, C))` constructs an array in the memory, as `reversed` first has to evaluate the whole `range` generator in order to yield its values reversed... Is there any trick for implementing such a for loop in Python, without constructing an array in the memory? Is there an equivalent for `range` generator, that yields decreasing numbers?
2017/05/12
[ "https://Stackoverflow.com/questions/43938023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8002900/" ]
range takes 3 args `range(start,stop,step)`. The step arg can be negative to iterate backwards. ``` arr = range(10) # range generator in python 3 for i in range(len(arr)-1,0,-1): print(arr[i]) 9 8 7 6 5 4 3 2 1 ``` Note that the start is `len(arr)-1` because lists are 0-indexed so the max idx is 9 for a list of length 10. Negative steps don't have to be 1 either: ``` for i in range(len(arr)-1,0,-3): print(arr[i]) 9 6 3 ``` In answer to your second question, you can set arr to be a countdown from the beginning ``` arr = range(10,0,-1) for a in arr: print(a) 10 9 8 7 6 5 4 3 2 1 ```
Just go ahead and call `reversed()` on the result of `range()`. It won't build the whole list because the `range` object has a [`__reversed__`](https://docs.python.org/3/reference/datamodel.html#object.__reversed__) method, which the `reversed()` function detects and uses. Here's how you can see that it has that method: ``` >>> dir(range(3)) ['__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index', 'start', 'step', 'stop'] ``` This is assuming you're using Python 3. In Python 2, `range` builds a list in memory regardless of whether you reverse it, although most of the time it makes no performance difference. You can use `xrange`, which is like Python 3's `range`, and also has a `__reversed__` method.
73,641,007
In R, I am trying to calculate the geometric mean (exp(mean(log(x, na.rm=T))) across all columns in a data frame by participant ID. The data frame is in long format. Below is a comparable code that I have so far... it isn't working. I have also tried data.table, but still unsuccessful. Any help appreciated ``` mtcars_sub <- mtcars[,1:2] mtcars_sub_gm <- mtcars_sub %>% group_by(cyl) %>% summarise_all(function (x) exp(mean(log(x, na.rm=TRUE)))) gm_vars <- names(mtcars_sub )[1] #this is very simplistic, but in my actual program there are +80 columns mtcars_sub_gm <- mtcars_sub [,lapply(.SD, function(x) {exp(mean(log(x, na.rm=T)))}), by = cyl, .SDcols = gm_vars] ```
2022/09/07
[ "https://Stackoverflow.com/questions/73641007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17966658/" ]
I think the issue was related to the placement of the `na.rm = TRUE`, which should be a parameter of `mean()` but was placed within the `log()` parentheses. ``` library(dplyr) mtcars[,1:5] %>% group_by(cyl) %>% summarize(across(everything(), ~exp(mean(log(.x), na.rm=TRUE)))) # A tibble: 3 × 5 cyl mpg disp hp drat <dbl> <dbl> <dbl> <dbl> <dbl> 1 4 26.3 102. 80.1 4.06 2 6 19.7 180. 121. 3.56 3 8 14.9 347. 204. 3.21 ```
You could also use a nested combination of `sapply()` to apply a function to multiple columns and `ave()` to apply that function to groups according to a reference column ``` mtcars_sub <- mtcars[,c(2,3,1)] sapply(mtcars_sub[,c(2:3)], FUN = function(x) ave(x, mtcars_sub[,c("cyl")], FUN = function(x) exp(mean(log(x),na.rm = TRUE)) ) ) ```
19,265,202
I'm trying to make following tutorial: <https://medium.com/on-coding/e8d93c9ce0e2> When it comes to run: ``` php artisan migrate ``` I get following error: ``` [Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.user' doesn't exist (SQL: alter table `user` add `id` int unsigned not null auto_increment prim ary key, add `username` varchar(255) null, add `password` varchar(255) null, add `email` varchar(255) null, add `created_at` datetime null, add `updated_at` datet ime null) (Bindings: array ( )) ``` Database connection is working, the migrations table was created successfully. Database name was changed as you can see in the error message. Whats quite strange to me, is that it tries to alter the table - which doesn't exists - and not to create it. Here are my other files, like UserModel, Seeder, Migtation and DB Config. CreateUserTable: ``` <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('user', function(Blueprint $table) { $table->increments("id"); $table ->string("username") ->nullable() ->default(null); $table ->string("password") ->nullable() ->default(null); $table ->string("email") ->nullable() ->default(null); $table ->dateTime("created_at") ->nullable() ->default(null); $table ->dateTime("updated_at") ->nullable() ->default(null); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('user', function(Blueprint $table) { Schema::dropIfExists("user"); }); } } ``` UserModel: ``` use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'user'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password'); /** * Get the unique identifier for the user. * * @return mixed */ public function getAuthIdentifier() { return $this->getKey(); } /** * Get the password for the user. * * @return string */ public function getAuthPassword() { return $this->password; } /** * Get the e-mail address where password reminders are sent. * * @return string */ public function getReminderEmail() { return $this->email; } } ``` UserSeeder: ``` class UserSeeder extends DatabaseSeeder { public function run() { $users = [ [ "username" => "ihkawiss", "password" => Hash::make("123456"), "email" => "[email protected]" ] ]; foreach ($users as $user) { User::create($user); } } } ``` DatabaseSeeder: ``` class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); $this->call('UserSeeder'); } } ``` Database Config: ``` return array( /* |-------------------------------------------------------------------------- | PDO Fetch Style |-------------------------------------------------------------------------- | | By default, database results will be returned as instances of the PHP | stdClass object; however, you may desire to retrieve records in an | array format for simplicity. Here you can tweak the fetch style. | */ 'fetch' => PDO::FETCH_CLASS, /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => 'mysql', /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => array( 'sqlite' => array( 'driver' => 'sqlite', 'database' => __DIR__.'/../database/production.sqlite', 'prefix' => '', ), 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), 'pgsql' => array( 'driver' => 'pgsql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'prefix' => '', ), ), /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk have not actually be run in the databases. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => array( 'cluster' => true, 'default' => array( 'host' => '127.0.0.1', 'port' => 6379, 'database' => 0, ), ), ); ``` Hope somebody can give me a hint here. Best regards ihkawiss
2013/10/09
[ "https://Stackoverflow.com/questions/19265202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1636426/" ]
In your `CreateUserTable` migration file, instead of `Schema::table` you have to use `Schema::create`. The `Schema::table` is used to alter an existing table and the `Schema::create` is used to create new table. Check the documentation: * <http://laravel.com/docs/schema#creating-and-dropping-tables> * <http://laravel.com/docs/schema#adding-columns> So your user migration will be: ``` <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('user', function(Blueprint $table) { { $table->increments("id",true); $table->string("username")->nullable()->default(null); $table->string("password")->nullable()->default(null); $table->string("email")->nullable()->default(null); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists("user"); } } ```
The underlying cause of this may be if the syntax used for creating the migration `php artisan migrate ...` is not quite correct. In this case the `--create` will not get picked up properly and you will see the `Schema::table` instead of the expected `Schema::create`. When a migration file is generated like this you might also be missing some of the other markers for a create migration such as the `$table->increments('id');` and `$table->timestamps();` For example, these two commands will not create a create table migration file as you might expect: ``` php artisan migrate:make create_tasks_table --table="tasks" --create php artisan migrate:make create_tasks2_table --table=tasks2 --create ``` However, the command will not fail with an error. Instead laravel will create a migration file using `Schema::table` I always just use the full syntax when creating a new migration file like this: ``` php artisan migrate:make create_tasks_table --table=tasks --create=tasks ``` to avoid any issues like this.
19,265,202
I'm trying to make following tutorial: <https://medium.com/on-coding/e8d93c9ce0e2> When it comes to run: ``` php artisan migrate ``` I get following error: ``` [Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.user' doesn't exist (SQL: alter table `user` add `id` int unsigned not null auto_increment prim ary key, add `username` varchar(255) null, add `password` varchar(255) null, add `email` varchar(255) null, add `created_at` datetime null, add `updated_at` datet ime null) (Bindings: array ( )) ``` Database connection is working, the migrations table was created successfully. Database name was changed as you can see in the error message. Whats quite strange to me, is that it tries to alter the table - which doesn't exists - and not to create it. Here are my other files, like UserModel, Seeder, Migtation and DB Config. CreateUserTable: ``` <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('user', function(Blueprint $table) { $table->increments("id"); $table ->string("username") ->nullable() ->default(null); $table ->string("password") ->nullable() ->default(null); $table ->string("email") ->nullable() ->default(null); $table ->dateTime("created_at") ->nullable() ->default(null); $table ->dateTime("updated_at") ->nullable() ->default(null); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('user', function(Blueprint $table) { Schema::dropIfExists("user"); }); } } ``` UserModel: ``` use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'user'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password'); /** * Get the unique identifier for the user. * * @return mixed */ public function getAuthIdentifier() { return $this->getKey(); } /** * Get the password for the user. * * @return string */ public function getAuthPassword() { return $this->password; } /** * Get the e-mail address where password reminders are sent. * * @return string */ public function getReminderEmail() { return $this->email; } } ``` UserSeeder: ``` class UserSeeder extends DatabaseSeeder { public function run() { $users = [ [ "username" => "ihkawiss", "password" => Hash::make("123456"), "email" => "[email protected]" ] ]; foreach ($users as $user) { User::create($user); } } } ``` DatabaseSeeder: ``` class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); $this->call('UserSeeder'); } } ``` Database Config: ``` return array( /* |-------------------------------------------------------------------------- | PDO Fetch Style |-------------------------------------------------------------------------- | | By default, database results will be returned as instances of the PHP | stdClass object; however, you may desire to retrieve records in an | array format for simplicity. Here you can tweak the fetch style. | */ 'fetch' => PDO::FETCH_CLASS, /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => 'mysql', /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => array( 'sqlite' => array( 'driver' => 'sqlite', 'database' => __DIR__.'/../database/production.sqlite', 'prefix' => '', ), 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), 'pgsql' => array( 'driver' => 'pgsql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'prefix' => '', ), ), /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk have not actually be run in the databases. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => array( 'cluster' => true, 'default' => array( 'host' => '127.0.0.1', 'port' => 6379, 'database' => 0, ), ), ); ``` Hope somebody can give me a hint here. Best regards ihkawiss
2013/10/09
[ "https://Stackoverflow.com/questions/19265202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1636426/" ]
In your `CreateUserTable` migration file, instead of `Schema::table` you have to use `Schema::create`. The `Schema::table` is used to alter an existing table and the `Schema::create` is used to create new table. Check the documentation: * <http://laravel.com/docs/schema#creating-and-dropping-tables> * <http://laravel.com/docs/schema#adding-columns> So your user migration will be: ``` <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('user', function(Blueprint $table) { { $table->increments("id",true); $table->string("username")->nullable()->default(null); $table->string("password")->nullable()->default(null); $table->string("email")->nullable()->default(null); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists("user"); } } ```
Sometimes it is caused by custom artisan commands. Some of these commands might initiate few classes. And because we did a rollback, the table cannot be found. Check you custom artisan commands. You can comment out the lines which are causing the trigger. Run the php artisan migrate command and then uncomment. This is what I had to do.
19,265,202
I'm trying to make following tutorial: <https://medium.com/on-coding/e8d93c9ce0e2> When it comes to run: ``` php artisan migrate ``` I get following error: ``` [Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.user' doesn't exist (SQL: alter table `user` add `id` int unsigned not null auto_increment prim ary key, add `username` varchar(255) null, add `password` varchar(255) null, add `email` varchar(255) null, add `created_at` datetime null, add `updated_at` datet ime null) (Bindings: array ( )) ``` Database connection is working, the migrations table was created successfully. Database name was changed as you can see in the error message. Whats quite strange to me, is that it tries to alter the table - which doesn't exists - and not to create it. Here are my other files, like UserModel, Seeder, Migtation and DB Config. CreateUserTable: ``` <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('user', function(Blueprint $table) { $table->increments("id"); $table ->string("username") ->nullable() ->default(null); $table ->string("password") ->nullable() ->default(null); $table ->string("email") ->nullable() ->default(null); $table ->dateTime("created_at") ->nullable() ->default(null); $table ->dateTime("updated_at") ->nullable() ->default(null); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('user', function(Blueprint $table) { Schema::dropIfExists("user"); }); } } ``` UserModel: ``` use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'user'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password'); /** * Get the unique identifier for the user. * * @return mixed */ public function getAuthIdentifier() { return $this->getKey(); } /** * Get the password for the user. * * @return string */ public function getAuthPassword() { return $this->password; } /** * Get the e-mail address where password reminders are sent. * * @return string */ public function getReminderEmail() { return $this->email; } } ``` UserSeeder: ``` class UserSeeder extends DatabaseSeeder { public function run() { $users = [ [ "username" => "ihkawiss", "password" => Hash::make("123456"), "email" => "[email protected]" ] ]; foreach ($users as $user) { User::create($user); } } } ``` DatabaseSeeder: ``` class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); $this->call('UserSeeder'); } } ``` Database Config: ``` return array( /* |-------------------------------------------------------------------------- | PDO Fetch Style |-------------------------------------------------------------------------- | | By default, database results will be returned as instances of the PHP | stdClass object; however, you may desire to retrieve records in an | array format for simplicity. Here you can tweak the fetch style. | */ 'fetch' => PDO::FETCH_CLASS, /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => 'mysql', /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => array( 'sqlite' => array( 'driver' => 'sqlite', 'database' => __DIR__.'/../database/production.sqlite', 'prefix' => '', ), 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), 'pgsql' => array( 'driver' => 'pgsql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ), 'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'prefix' => '', ), ), /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk have not actually be run in the databases. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => array( 'cluster' => true, 'default' => array( 'host' => '127.0.0.1', 'port' => 6379, 'database' => 0, ), ), ); ``` Hope somebody can give me a hint here. Best regards ihkawiss
2013/10/09
[ "https://Stackoverflow.com/questions/19265202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1636426/" ]
The underlying cause of this may be if the syntax used for creating the migration `php artisan migrate ...` is not quite correct. In this case the `--create` will not get picked up properly and you will see the `Schema::table` instead of the expected `Schema::create`. When a migration file is generated like this you might also be missing some of the other markers for a create migration such as the `$table->increments('id');` and `$table->timestamps();` For example, these two commands will not create a create table migration file as you might expect: ``` php artisan migrate:make create_tasks_table --table="tasks" --create php artisan migrate:make create_tasks2_table --table=tasks2 --create ``` However, the command will not fail with an error. Instead laravel will create a migration file using `Schema::table` I always just use the full syntax when creating a new migration file like this: ``` php artisan migrate:make create_tasks_table --table=tasks --create=tasks ``` to avoid any issues like this.
Sometimes it is caused by custom artisan commands. Some of these commands might initiate few classes. And because we did a rollback, the table cannot be found. Check you custom artisan commands. You can comment out the lines which are causing the trigger. Run the php artisan migrate command and then uncomment. This is what I had to do.
11,600,708
I'm working on a project that will use a comparison voting logic to sort the highest rated to the top and lowest to the bottom(Similar to a "hot or not" or "Hotstagram"). Basically what I need to do is take 2 random pictures that are directly next to each other in the database and have users vote, adding one point to the winner and subtracting on point from the loser essentially filtering the highest to the top. My question is two fold, How can I get a random item in a MySql database then get a random item directly next to it. and secondly (if anyone has prior experience with this) how would you structure your DB? I'm thinking One table for images and a second that will hold the votes(then compile the results on page load). I guess what my concern is here, for the ranking, ever new entered photo will start at zero, so you could have X amount of photos with the same rank? I'm just throwing some thoughts out there and I need another mind to toss this around.
2012/07/22
[ "https://Stackoverflow.com/questions/11600708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1283726/" ]
You can use the [Order by Rand()](http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand) function to get a random record from the database. `SELECT * FROM tbl_name ORDER BY RAND();` You can also limit this to two rows easily enough as such: `SELECT * FROM tbl_name ORDER BY RAND() limit 2;` This will however get two random rows from the db, not two consecutive rows. If you wanted to get two random AND consecutive rows, you could run a query to get the ID and a subquery to get the next ID after it. As for keep data in one/two tables, definately keep it in two tables. Link your second table that keeps the votes with a link to the ID of the image. Obviously add indexes as required on the linked (and or other fields) as needed. Edit: Here is the code to get you the two subsequent rows of data in one row then: ``` select a.id, ( select min(c.id) from table1 c where c.id>a.id limit 1 ) as id2 from table1 a order by rand() limit 1; ``` Edit 2: If you wanted them as separate rows to pull in all sorts of other bits, I have provided the query below. I used an extra subquery as if the initial query happened to pull out the max value (possible when using order by rand() then it solves the issue of only returning one row of data. ``` select b.id from table1 b, ( select a.id as id from table1 a where a.id<(select max(id) from table1 limit 1) order by rand() limit 1 ) a where b.id>=a.id order by b.id limit 2 ; ```
Here is another way to get two random rows in order: ``` with first as (select id from table t where id < (select max(id) from table) order by rand() limit 1 ) select id from table t order by abs(id - first.id) limit 2 ``` As for structuring the data. You will probably want one for the photos, one for users, one for the "offers" (pairs of photos with a user id), and one for the votes. It usually becomes quite important to know what users are not voting for as well as what they are voting for. If you want to break ties on photos with the same ranking, you can use the date the photo first entered the system, the number of offers, or some combination of the two.
67,824
Exodus 18:20: > > **וְהִזְהַרְתָּ֣ה** אֶתְהֶ֔ם אֶת־הַחֻקִּ֖ים וְאֶת־הַתּוֹרֹ֑ת **וְהוֹדַעְתָּ֣** > לָהֶ֗ם אֶת־הַדֶּ֙רֶךְ֙ יֵ֣לְכוּ בָ֔הּ וְאֶת־הַֽמַּעֲשֶׂ֖ה אֲשֶׁ֥ר > יַעֲשֽׂוּן׃ > > > My translation - somewhat "exaggerated" to point the nuances, here: > > > You shall **warn** them about the statutes and laws and **make them know** about the path that they should walk in, and the work that they should do. > > > Why is a different verb (see the bolded words) used regarding each different area? It seems that there is some nuance in the meaning of the objects following each verb that necessitates a different verb.
2016/01/29
[ "https://judaism.stackexchange.com/questions/67824", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/5275/" ]
The **second** verb-object is the simple amplification and expansion of nuance of the **first** verb-object. That is, both verb-objects are the main idea of their respective clauses. Thus the second verb-object (and what follows) modifies the first verb-object (and what follows). According to the 19th Century mathematician and Hebraist [Dr. William Wickes](http://menachemmendel.net/blog/who-was-william-wickes/), the Hebrew Scriptures were written in verse dichotomy, which means that every verse appears in dyad form. In other words, the *second* half of every verse modifies the *first* half of every verse (with minor exceptions for example among verses containing genealogies). Wickes calls these verse divisions the logical and syntactical function of dichotomy by cantillation. For example, please click on the image below to enlarge, or **[view the source online](https://archive.org/stream/treatiseonaccent00wickuoft#page/n49/mode/2up)**. [![enter image description here](https://i.stack.imgur.com/7qjWdm.png)](https://i.stack.imgur.com/hN5eB.png) The following diagram provides my own schematic depiction of the logical and syntactical relationship of these Hebrew words and phrases according to their dichotomy. In other words, the cantillation marks provide the audible and visual cues regarding the logical and functional relationship between each of the words and phrases. Please click to enlarge. [![enter image description here](https://i.stack.imgur.com/SsN00m.png)](https://i.stack.imgur.com/8O8sL.png) In summary, the **first** verb-object is the main thought of the verse. The **second** verb-object comprises the main thought of the second half of the verse. In other words, each of the two verb-objects is amplified by what follows in each respective half of each verse. But since the second major dichotomy modifies the first major dichotomy of the verse, the **second** verb-object is the logical and syntactical amplification of the **first** verb-object.
The usage of diffrent verbs in this posuk seems to be a reflection of [Synonymous Parallelism](https://en.wikipedia.org/wiki/Biblical_poetry#Parallelism) found in the Hebrew Bible in which each element of the second part of the verse or strophe are synonyms/explanations of the idea of its first part. You shall warn them (A) about the statutes (B) and laws (C) make them know (A) about the path that they should walk in (B) and the work that they should do (C)
67,824
Exodus 18:20: > > **וְהִזְהַרְתָּ֣ה** אֶתְהֶ֔ם אֶת־הַחֻקִּ֖ים וְאֶת־הַתּוֹרֹ֑ת **וְהוֹדַעְתָּ֣** > לָהֶ֗ם אֶת־הַדֶּ֙רֶךְ֙ יֵ֣לְכוּ בָ֔הּ וְאֶת־הַֽמַּעֲשֶׂ֖ה אֲשֶׁ֥ר > יַעֲשֽׂוּן׃ > > > My translation - somewhat "exaggerated" to point the nuances, here: > > > You shall **warn** them about the statutes and laws and **make them know** about the path that they should walk in, and the work that they should do. > > > Why is a different verb (see the bolded words) used regarding each different area? It seems that there is some nuance in the meaning of the objects following each verb that necessitates a different verb.
2016/01/29
[ "https://judaism.stackexchange.com/questions/67824", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/5275/" ]
The [Malbim](http://www.hebrewbooks.org/pdfpager.aspx?req=40081&st=&pgnum=275) says that this is the usual split of "עשה" and "לא תעשה". The form of "אזהרה" always comes regarding "לא תעשה" (since you **warn** someone of something that he shouldn't do). These too he splits into "חקים" which are "לא תעשה" for **physical actions**, and "תורות" which are "לא תעשה" of **thoughts and teachings** (pride, forgetting *Hashem*, etc.). And for the "עשה", equivalently, "תודיע להם את הדרך" is parallel to the **thoughts and teachings** ("דרכי הנפש"), while "המעשה אשר יעשון" is the **physical actions** of "עשה". By the way, the Malbim strongly opposes the view alluded to in Joseph's answer (that many verses in the Torah are formed in such a way that the second part is the equivalent, or slightly amplified version, of the first). His principle is: > > * מפרש דברי אלהים באופן **שלא ימצא בשום מקום כפל ענין במלות שונות**.‏ > * **שכל מלה הבאה במאמר, מוכרחת לבא במאמר ההוא,** על פי כללי הלשון והבדלי הנרדפים.‏ > * שלא נמצא מאמר ריק מרעיון נשגב.‏ > > >
The usage of diffrent verbs in this posuk seems to be a reflection of [Synonymous Parallelism](https://en.wikipedia.org/wiki/Biblical_poetry#Parallelism) found in the Hebrew Bible in which each element of the second part of the verse or strophe are synonyms/explanations of the idea of its first part. You shall warn them (A) about the statutes (B) and laws (C) make them know (A) about the path that they should walk in (B) and the work that they should do (C)
131,339
I just got a new Macbook Pro. I know it's an Intel processor, but is it 32 bits or 64 bits processor?
2010/04/15
[ "https://superuser.com/questions/131339", "https://superuser.com", "https://superuser.com/users/34224/" ]
64bit processor
Enter this into Terminal: ``` uname -a ``` If you see `x86_64` at the end of the string returned , your OS X kernel suports 64 bit. Also bear in mind you need to hold down the `6` and `4` keys while booting to startup with the 64 bit kernel ( there are other ways to accomplish this as well ) At least this was the case on recent Macs - I assume the new MacBook Pros released in April 2010 still boot by default into 32 bit mode as well.
42,150,118
i am trying to generate a new variable as follows: if value for testA is 1 and value for testB is 1 ==> code testAB as 1 if value for testA is 1 and value for testB is missing or 0 ==> code testAB as 1 if value for testA is missing or 0 and value for testB is 1 ==> code testAB as 1 if value for testA is 0 and value for testB is 0 ==> code testAB as 0 if value for testA is missing and value for testB is missing ==> code testAB as NA the code i came up with shown below does not work. it seems only to generate a 1 if testA and testB are 1, and NA otherwise. what do you recommend? thank you! ``` df2$testAB<-ifelse((df1$testA == 1) | (df1$testB == 1),1,0),1, 0,NA)) ```
2017/02/10
[ "https://Stackoverflow.com/questions/42150118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7418739/" ]
This should get you what you're looking for ``` df1 <- data.frame(testA = c(1, 1, 1, 0, 0, 0, NA, NA, NA), testB = c(0, 1, NA, 0, 1, NA, 0, 1, NA)) ind <- is.na(df1$testA) + is.na(df1$testB) < 2 df1$testAB[!ind] <- NA df1$testAB[ind] <- as.numeric(as.logical(rowSums(df1[ind,], na.rm = TRUE))) > df1 testA testB testAB 1 1 0 1 2 1 1 1 3 1 NA 1 4 0 0 0 5 0 1 1 6 0 NA 0 7 NA 0 0 8 NA 1 1 9 NA NA NA ```
You need, minimally, n-1 ifelse() statements for n unique outcomes. To simplify the problem, group your criteria for each outcome with *or* (`|`). In your case.. `1`: ``` (df$testA == 1 & df$testB == 1) | (df$testA == 1 & (is.na(df$testB) | df$testB == 0)) | ((is.na(df$testA) | df$testA == 0) & df$testB == 1) ``` `0`: `testA == 0 & testB == 0` `NA`: `is.na(testA) & is.na(testB)` With n-1 statements you don't have to write the most costly statement, so the logic for the following is: define all NA, then all 0, the rest is 1. ``` df <- expand.grid(testA =c(NA,0,1),testB = c(NA,0,1)) df$testAB = ifelse(is.na(df$testA) & is.na(df$testB),NA, ifelse(df$testA == 0 & df$testB == 0, 0,1)) ``` Outcome: ``` testA testB testAB 1 NA NA NA 2 0 NA NA 3 1 NA 1 4 NA 0 NA 5 0 0 0 6 1 0 1 7 NA 1 1 8 0 1 1 9 1 1 1 ``` Tidyverse version: ``` library(tidyverse) df <- expand.grid(testA =c(NA,0,1),testB = c(NA,0,1)) df <- df %>% mutate(testAB = ifelse(is.na(testA) & is.na(testB),NA, ifelse(testA == 0 & testB == 0, 0,1)) ) ``` To test your own logic, you can make all arguments explicit: ``` df$testAB = ifelse(is.na(df$testA) & is.na(df$testB),NA, ifelse(df$testA == 0 & df$testB == 0, 0, ifelse((df$testA == 1 & df$testB == 1) | (df$testA == 1 & (is.na(df$testB) | df$testB == 0)) | ((is.na(df$testA) | df$testA == 0) & df$testB == 1),1, "error"))) ```
370,135
Following is my code which I am using to display comments of posts in a loop (Custom Post Types). I would like to display only latest 3 comments. Kindly help me to limit comments. ``` <?php foreach (get_comments() as $comment): ?> <div><span class="author-name"><?php echo $comment->comment_author; ?> said:</span> <span class="author-cmnt">"<?php echo $comment->comment_content; ?>".</span></div> <?php endforeach; ?> ```
2020/07/01
[ "https://wordpress.stackexchange.com/questions/370135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/190895/" ]
I don't usually work with comment so my suggestion is untested, but I see that get\_comments() receives an array of args. Try this: `$comments = get_comments(array("number" => 3))` and instead of your foreach loop: `foreach ($comments as $comment):`
My answer to this is to use something like this: ``` $args = ['number' => 3]; $comments = get_comments( $args ); ```
20,707,448
Given a sequence of unordered n integers, S = a1,a2,a3... Give a formal and recursive definition of the length of the longest non-decreasing subsequence in term of n. So, my thoughts are that if we're defining it recursively then each integer in the sequence is a sequence of length of 1 and contains a non decreasing sub-sequence of length 1. Would this be the correct way to say this or am I completely off?
2013/12/20
[ "https://Stackoverflow.com/questions/20707448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2565869/" ]
The final keyword prevents you from modifying a class if applied to the class, or a method if applied to a method. From <http://en.wikipedia.org/wiki/Final_%28Java%29> : > > A final method cannot be overridden or hidden by subclasses. This is used to prevent unexpected behavior from a subclass altering a method that may be crucial to the function or consistency of the class. > > > If you subclass a class with a final method you need to leave that method alone. If the class is final you can't subclass it at all.
Refresh dependencies solved my issue.
53,397,939
I have code that looks like this. ``` public static Dictionary<int, Action> functionsMap; void Function() { if (!isDictionaryInitialized) { functionsMap = new Dictionary<int, Action>(); functionsMap.Add(1, () => StartCoroutine(Function1())); functionsMap.Add(1, () => StartCoroutine(Function2())); } } void CheckForFunction() { var r = currentFunctionNumber; if (functionsMap.TryGetValue(r, out currentAction)) { currentAction(); } } ``` The code works fine when I start my program. However if I go to another scene and then return to it, I get this error. > > "MissingReferenceException: The object of type 'ScriptName' has been > destroyed but you are still trying to access it. Your script should > either check if it is null or you should not destroy the object." > > > The problem is I have never destroyed the object. Initially I didn't have bool `isDictionaryInitialized` and I defined the new `Dictionary` outside of the Function because I thought the error was related to my program trying to access a `Dictionary` that was deleted after the scene was closed. I get the same problem with or without the bool, and regardless of where I define the `Dictionary.` What is causing this, and what is the reason so I can avoid making the same mistake? Edit: This question was marked as duplicate, but the link I don't believe applies to my situation, or if it does I don't understand how. It says static objects are not reloaded on a scene change, and the Dictionary is defined as a static object. I also tried changing it to non-static and the result is the same. I have dozens of gameobjects in my code and don't have this issue with any other object, so I assume the problem is related to how the dictionary object is defined. Is there a way to keep the Dictionary object from being destroyed on scene change? I don't have it as a game object in the scene, it's just defined in the code itself as a public static Dictionary. Could someone tell me what I need to do differently please and thank you?
2018/11/20
[ "https://Stackoverflow.com/questions/53397939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10576580/" ]
The problem might be caused by changing scenes because simply loading another scene would destroy all gameobject in the current scene. According to [Object.DontDestroyOnLoad](https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html). > > The load of a new Scene destroys all current Scene objects. > > > To solve this, you can either use `DontDestroyOnLoad` function to mark the object you want to be kept before loading another scene, or using different way to load like [LoadSceneMode.Additive](https://docs.unity3d.com/ScriptReference/SceneManagement.LoadSceneMode.Additive.html) without destroying the current scene.
First you are adding two `Action`s to your Dictionary but both with the same `key`. ``` functionsMap.Add(1, () => StartCoroutine(Function1())); functionsMap.Add(1, () => StartCoroutine(Function2())); ``` wouldn't this overwrite the first entry? --- Than your general problem is: While `functionsMap` is `static` the two actions / one action you added are non-static (`StartCoroutine` always requires an instance of `MonoBehaviour` to run on) and therefore only available for the according component! (You talked about an Update method so this has to be a `MonoBehaviour` attached to a GameObject in your first scene.) Now if you change the Scene, the GameObject holding that component is probably destroyed if you are not using [`DontDestroyOnLoad`](https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html) The result is that your `static` Dictionary stays intact and filled meaning the entry with `key = 1` still exists **but** the `Value` namely the added non-static `Action` is no longer available. To avoid that you should add ``` DontDestroyOnLoad(this.gameObject); ``` either in `Awake` or `Start` to prevent the `GameObject` holding the component and thereby holding the `Action` that belongs to the reference(s) in the entry in your Dictionary.
1,060,718
$$\ln(\tan(x) + \sec(x))=\frac{\ln (1+\sin x )-\ln(1-\sin x )}{2}$$ Is this true or false? I thought the right side looked like a sum of an even and an odd function but I ended up with $$\ln(\tan(x) + \sec(x))=\ln(\tan(x) + \sec(x))$$ which is true, but it's not what I was trying to prove.
2014/12/10
[ "https://math.stackexchange.com/questions/1060718", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183782/" ]
We'll start from RHS $$\begin{align} \frac12\Big[\ln(1+\sin x )-\ln(1-\sin x)\Big] &=\frac12\left[\ln\left(\frac{1+\sin x}{1-\sin x} \right)\right]\\ &=\frac12\left[\ln\left(\frac{(1+\sin x)^2}{1-\sin^2 x} \right)\right]\\ &=\frac12\left[\ln\left(\frac{(1+\sin x)^2}{\cos^2 x} \right)\right]\\ &=\ln\left(\frac{ 1+\sin x }{\cos x} \right)\\ &=\ln\left(\frac1{\cos x}+\frac{\sin x}{\cos x} \right)\\ \frac12\Big[\ln(1+\sin x )-\ln(1-\sin x)\Big] &=\ln\left(\sec x+\tan x \right)\\ \end{align}$$ So, It's true!
Let $s = \sin x, c = \cos x$. The LHS is $\displaystyle \ln (\frac{s}{c} + \frac{1}{c}) = \ln (\frac{s+1}{c}) = \ln(\frac{1+s}{\sqrt{1-s^2}}) = \ln (\frac{1+s}{\sqrt{(1+s)(1-s)}}) \\ =\ln(\frac{\sqrt{1+s}}{\sqrt{1-s}}) = \ln(\sqrt{1+s}) - \ln(\sqrt{1-s}) = \frac{1}{2} [\ln(1+s) - \ln(1-s)]$
1,060,718
$$\ln(\tan(x) + \sec(x))=\frac{\ln (1+\sin x )-\ln(1-\sin x )}{2}$$ Is this true or false? I thought the right side looked like a sum of an even and an odd function but I ended up with $$\ln(\tan(x) + \sec(x))=\ln(\tan(x) + \sec(x))$$ which is true, but it's not what I was trying to prove.
2014/12/10
[ "https://math.stackexchange.com/questions/1060718", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183782/" ]
We'll start from RHS $$\begin{align} \frac12\Big[\ln(1+\sin x )-\ln(1-\sin x)\Big] &=\frac12\left[\ln\left(\frac{1+\sin x}{1-\sin x} \right)\right]\\ &=\frac12\left[\ln\left(\frac{(1+\sin x)^2}{1-\sin^2 x} \right)\right]\\ &=\frac12\left[\ln\left(\frac{(1+\sin x)^2}{\cos^2 x} \right)\right]\\ &=\ln\left(\frac{ 1+\sin x }{\cos x} \right)\\ &=\ln\left(\frac1{\cos x}+\frac{\sin x}{\cos x} \right)\\ \frac12\Big[\ln(1+\sin x )-\ln(1-\sin x)\Big] &=\ln\left(\sec x+\tan x \right)\\ \end{align}$$ So, It's true!
$2\ln (\tan x+\sec x)=\ln \left(\dfrac{(1+\sin x)^2}{\cos^2 x}\right)=\ln \left(\dfrac{(1+\sin x)^2}{1-\sin^2 x}\right)=\ln \left(\dfrac{1+\sin x}{1-\sin x}\right)$
1,060,718
$$\ln(\tan(x) + \sec(x))=\frac{\ln (1+\sin x )-\ln(1-\sin x )}{2}$$ Is this true or false? I thought the right side looked like a sum of an even and an odd function but I ended up with $$\ln(\tan(x) + \sec(x))=\ln(\tan(x) + \sec(x))$$ which is true, but it's not what I was trying to prove.
2014/12/10
[ "https://math.stackexchange.com/questions/1060718", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183782/" ]
$2\ln (\tan x+\sec x)=\ln \left(\dfrac{(1+\sin x)^2}{\cos^2 x}\right)=\ln \left(\dfrac{(1+\sin x)^2}{1-\sin^2 x}\right)=\ln \left(\dfrac{1+\sin x}{1-\sin x}\right)$
Let $s = \sin x, c = \cos x$. The LHS is $\displaystyle \ln (\frac{s}{c} + \frac{1}{c}) = \ln (\frac{s+1}{c}) = \ln(\frac{1+s}{\sqrt{1-s^2}}) = \ln (\frac{1+s}{\sqrt{(1+s)(1-s)}}) \\ =\ln(\frac{\sqrt{1+s}}{\sqrt{1-s}}) = \ln(\sqrt{1+s}) - \ln(\sqrt{1-s}) = \frac{1}{2} [\ln(1+s) - \ln(1-s)]$
903
Lets say a batsman hits a shot and in midway it hits a bird in the air and then as soon as it hits the bird, the ball starts falling down and is caught by a fielder, will the batsman be given out? I searched a lot all over but could find nothing about a rule which clarifies this, any help will be appreciated.
2012/06/04
[ "https://sports.stackexchange.com/questions/903", "https://sports.stackexchange.com", "https://sports.stackexchange.com/users/521/" ]
This is one of the reason why what we commonly think of as 'rules' of a sport are usually actually called 'laws'. See the [Laws of Cricket](http://www.lords.org/laws-and-spirit/laws-of-cricket/) They are called Laws because you cannot possibly define to the very last possible detail every single possibility that might happen - such as the example here. In cricket the laws are applied by the Umpires and their ruling is final (except in some cases where technological challenges are allowed in certain circumstances). So in the case here, the Umpire would apply [Law 32 (Caught)](http://www.lords.org/laws-and-spirit/laws-of-cricket/laws/law-32-caught,58,AR.html) - which states that one condition for a fair catch is that: > > (ii) the ball is at no time in contact with any object grounded beyond the boundary. > > > A bird in the air, is not grounded beyond the boundary In addition it later states: > > a catch shall be considered fair if .... (f) the ball is caught off an obstruction within the boundary that has not been designated a boundary by the umpires before the toss. > > > The umpires are not going to designate a temporary phenomenan such as a bird to be a boundary so this would clearly be a fair catch, and the batsman would be out.
The rule for all indoor stadiums having roofs are that if the roof is closed and the ball hits the roof, then it is considered a dead ball. Hussey [hits the roof](http://www.youtube.com/watch?v=OkcP5M2n-F0) with a monstrous shot.
903
Lets say a batsman hits a shot and in midway it hits a bird in the air and then as soon as it hits the bird, the ball starts falling down and is caught by a fielder, will the batsman be given out? I searched a lot all over but could find nothing about a rule which clarifies this, any help will be appreciated.
2012/06/04
[ "https://sports.stackexchange.com/questions/903", "https://sports.stackexchange.com", "https://sports.stackexchange.com/users/521/" ]
This is one of the reason why what we commonly think of as 'rules' of a sport are usually actually called 'laws'. See the [Laws of Cricket](http://www.lords.org/laws-and-spirit/laws-of-cricket/) They are called Laws because you cannot possibly define to the very last possible detail every single possibility that might happen - such as the example here. In cricket the laws are applied by the Umpires and their ruling is final (except in some cases where technological challenges are allowed in certain circumstances). So in the case here, the Umpire would apply [Law 32 (Caught)](http://www.lords.org/laws-and-spirit/laws-of-cricket/laws/law-32-caught,58,AR.html) - which states that one condition for a fair catch is that: > > (ii) the ball is at no time in contact with any object grounded beyond the boundary. > > > A bird in the air, is not grounded beyond the boundary In addition it later states: > > a catch shall be considered fair if .... (f) the ball is caught off an obstruction within the boundary that has not been designated a boundary by the umpires before the toss. > > > The umpires are not going to designate a temporary phenomenan such as a bird to be a boundary so this would clearly be a fair catch, and the batsman would be out.
I believe the first answer is incorrect. If the ball hit a flying bird it would probably be called a *dead ball*, as I believe it has to go directly to a human fielder without touching *anything else* to be considered out caught. In the same way that if the ball hit a helmet on the ground, bounced up and someone caught it, it would be a *dead ball* and 5 penalty points awarded to the batting side.
903
Lets say a batsman hits a shot and in midway it hits a bird in the air and then as soon as it hits the bird, the ball starts falling down and is caught by a fielder, will the batsman be given out? I searched a lot all over but could find nothing about a rule which clarifies this, any help will be appreciated.
2012/06/04
[ "https://sports.stackexchange.com/questions/903", "https://sports.stackexchange.com", "https://sports.stackexchange.com/users/521/" ]
The rule for all indoor stadiums having roofs are that if the roof is closed and the ball hits the roof, then it is considered a dead ball. Hussey [hits the roof](http://www.youtube.com/watch?v=OkcP5M2n-F0) with a monstrous shot.
I believe the first answer is incorrect. If the ball hit a flying bird it would probably be called a *dead ball*, as I believe it has to go directly to a human fielder without touching *anything else* to be considered out caught. In the same way that if the ball hit a helmet on the ground, bounced up and someone caught it, it would be a *dead ball* and 5 penalty points awarded to the batting side.
60,416,583
I have an array(lets call it X) and X contains arrays. I want to push an element(a string) into an array that is inside of X. I've tried searching for quite a while and all i find are people trying to push arrays inside of other arrays. I've tried the following code: ``` push(@X[0],$element); ``` Which gives me the error: > > Experimental push on scalar is now forbidden at perlscript.pl line 30, > near "$element)" > > > I'm on perl 5 version 26.
2020/02/26
[ "https://Stackoverflow.com/questions/60416583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10954322/" ]
In Perl, arrays cannot contain other arrays. To make a multi-dimensional data structure, you need references. Consider this example. ``` use strict; use warnings; use Data::Dumper; my @inner = qw(a b c); my @outer = ( \@inner, # reference to existing array [100, 200, 300], # new anonymous array reference ); print Dumper \@outer; ``` This prints ``` $VAR1 = [ [ 'a', 'b', 'c' ], [ 100, 200, 300 ] ]; ``` Your outer array is just that, an array. But the elements inside it are references to arrays. You can either reference an existing array, or create a new, anonymous one. When dumping out the structure for debugging, note how `Dumper` from [Data::Dumper](https://metacpan.org/pod/Data::Dumper) requires a reference too, so we use the same notation with the `\`. Now to add an element to `@inner` via its position inside `@outer`, you need to take the first element out `@outer`. To do that, the sigil changes, so you get `$outer[0]`. To pass that to `push`, we need to turn it into an array. That's called *dereferencing* as an array. ``` push @{ $outer[0] }, 'd'; ``` When we `Dumper` it again, we get ``` $VAR1 = [ [ 'a', 'b', 'c', 'd' ], [ 100, 200, 300 ] ]; ``` Because the first element is a reference to a named array variable, we can also operate on it directly. ``` push @inner, 'e'; ``` This will change the value of the first element in `@outer`, because both refer (see why it's called a *reference*?) to the same thing in memory. ``` $VAR1 = [ [ 'a', 'b', 'c', 'd', 'e' ], [ 100, 200, 300 ] ]; ``` We can't do that with the second element, because it started out as an anonymous reference. --- Let's have a look at your warning. > > Experimental push on scalar is now forbidden at perlscript.pl line 30, near "$element)" > > > In Perl 5.20.0 `push` on references [was deprecated](https://perldoc.perl.org/perl5200delta.html#push-on-reference-is-experimental) because it didn't work as intended, and started warning. In Perl 5.30.0 [this was changed](https://perldoc.perl.org/perldelta.html#Changes-to-Existing-Diagnostics) and it [is now a fatal error](https://perldoc.perl.org/perldiag.html#Type-of-arg-%25d-to-%25s-must-be-%25s-(not-%25s)), making your program die. Also see [perlref](https://perldoc.perl.org/perlref.html) and [perlreftut](https://perldoc.perl.org/perlreftut.html).
I think that this does what you want: ``` push @{ $X[0] }, $element; ```
60,416,583
I have an array(lets call it X) and X contains arrays. I want to push an element(a string) into an array that is inside of X. I've tried searching for quite a while and all i find are people trying to push arrays inside of other arrays. I've tried the following code: ``` push(@X[0],$element); ``` Which gives me the error: > > Experimental push on scalar is now forbidden at perlscript.pl line 30, > near "$element)" > > > I'm on perl 5 version 26.
2020/02/26
[ "https://Stackoverflow.com/questions/60416583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10954322/" ]
I think that this does what you want: ``` push @{ $X[0] }, $element; ```
Like everybody mentioned already, `push @{ $X[0] }, $element;`. Since you say you are using v5.26, you can also use postfix dereferencing: `push $X[0]->@*, $element;`
60,416,583
I have an array(lets call it X) and X contains arrays. I want to push an element(a string) into an array that is inside of X. I've tried searching for quite a while and all i find are people trying to push arrays inside of other arrays. I've tried the following code: ``` push(@X[0],$element); ``` Which gives me the error: > > Experimental push on scalar is now forbidden at perlscript.pl line 30, > near "$element)" > > > I'm on perl 5 version 26.
2020/02/26
[ "https://Stackoverflow.com/questions/60416583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10954322/" ]
In Perl, arrays cannot contain other arrays. To make a multi-dimensional data structure, you need references. Consider this example. ``` use strict; use warnings; use Data::Dumper; my @inner = qw(a b c); my @outer = ( \@inner, # reference to existing array [100, 200, 300], # new anonymous array reference ); print Dumper \@outer; ``` This prints ``` $VAR1 = [ [ 'a', 'b', 'c' ], [ 100, 200, 300 ] ]; ``` Your outer array is just that, an array. But the elements inside it are references to arrays. You can either reference an existing array, or create a new, anonymous one. When dumping out the structure for debugging, note how `Dumper` from [Data::Dumper](https://metacpan.org/pod/Data::Dumper) requires a reference too, so we use the same notation with the `\`. Now to add an element to `@inner` via its position inside `@outer`, you need to take the first element out `@outer`. To do that, the sigil changes, so you get `$outer[0]`. To pass that to `push`, we need to turn it into an array. That's called *dereferencing* as an array. ``` push @{ $outer[0] }, 'd'; ``` When we `Dumper` it again, we get ``` $VAR1 = [ [ 'a', 'b', 'c', 'd' ], [ 100, 200, 300 ] ]; ``` Because the first element is a reference to a named array variable, we can also operate on it directly. ``` push @inner, 'e'; ``` This will change the value of the first element in `@outer`, because both refer (see why it's called a *reference*?) to the same thing in memory. ``` $VAR1 = [ [ 'a', 'b', 'c', 'd', 'e' ], [ 100, 200, 300 ] ]; ``` We can't do that with the second element, because it started out as an anonymous reference. --- Let's have a look at your warning. > > Experimental push on scalar is now forbidden at perlscript.pl line 30, near "$element)" > > > In Perl 5.20.0 `push` on references [was deprecated](https://perldoc.perl.org/perl5200delta.html#push-on-reference-is-experimental) because it didn't work as intended, and started warning. In Perl 5.30.0 [this was changed](https://perldoc.perl.org/perldelta.html#Changes-to-Existing-Diagnostics) and it [is now a fatal error](https://perldoc.perl.org/perldiag.html#Type-of-arg-%25d-to-%25s-must-be-%25s-(not-%25s)), making your program die. Also see [perlref](https://perldoc.perl.org/perlref.html) and [perlreftut](https://perldoc.perl.org/perlreftut.html).
The syntax for `push` is ``` push ARRAY, LIST ``` For example, ``` push @a, $element; ``` Whereever a variable name appear, you may replace the name with a block that evaluate to an reference. ``` push @{ $X[0] }, $element; ``` And that's what you need.
60,416,583
I have an array(lets call it X) and X contains arrays. I want to push an element(a string) into an array that is inside of X. I've tried searching for quite a while and all i find are people trying to push arrays inside of other arrays. I've tried the following code: ``` push(@X[0],$element); ``` Which gives me the error: > > Experimental push on scalar is now forbidden at perlscript.pl line 30, > near "$element)" > > > I'm on perl 5 version 26.
2020/02/26
[ "https://Stackoverflow.com/questions/60416583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10954322/" ]
In Perl, arrays cannot contain other arrays. To make a multi-dimensional data structure, you need references. Consider this example. ``` use strict; use warnings; use Data::Dumper; my @inner = qw(a b c); my @outer = ( \@inner, # reference to existing array [100, 200, 300], # new anonymous array reference ); print Dumper \@outer; ``` This prints ``` $VAR1 = [ [ 'a', 'b', 'c' ], [ 100, 200, 300 ] ]; ``` Your outer array is just that, an array. But the elements inside it are references to arrays. You can either reference an existing array, or create a new, anonymous one. When dumping out the structure for debugging, note how `Dumper` from [Data::Dumper](https://metacpan.org/pod/Data::Dumper) requires a reference too, so we use the same notation with the `\`. Now to add an element to `@inner` via its position inside `@outer`, you need to take the first element out `@outer`. To do that, the sigil changes, so you get `$outer[0]`. To pass that to `push`, we need to turn it into an array. That's called *dereferencing* as an array. ``` push @{ $outer[0] }, 'd'; ``` When we `Dumper` it again, we get ``` $VAR1 = [ [ 'a', 'b', 'c', 'd' ], [ 100, 200, 300 ] ]; ``` Because the first element is a reference to a named array variable, we can also operate on it directly. ``` push @inner, 'e'; ``` This will change the value of the first element in `@outer`, because both refer (see why it's called a *reference*?) to the same thing in memory. ``` $VAR1 = [ [ 'a', 'b', 'c', 'd', 'e' ], [ 100, 200, 300 ] ]; ``` We can't do that with the second element, because it started out as an anonymous reference. --- Let's have a look at your warning. > > Experimental push on scalar is now forbidden at perlscript.pl line 30, near "$element)" > > > In Perl 5.20.0 `push` on references [was deprecated](https://perldoc.perl.org/perl5200delta.html#push-on-reference-is-experimental) because it didn't work as intended, and started warning. In Perl 5.30.0 [this was changed](https://perldoc.perl.org/perldelta.html#Changes-to-Existing-Diagnostics) and it [is now a fatal error](https://perldoc.perl.org/perldiag.html#Type-of-arg-%25d-to-%25s-must-be-%25s-(not-%25s)), making your program die. Also see [perlref](https://perldoc.perl.org/perlref.html) and [perlreftut](https://perldoc.perl.org/perlreftut.html).
Like everybody mentioned already, `push @{ $X[0] }, $element;`. Since you say you are using v5.26, you can also use postfix dereferencing: `push $X[0]->@*, $element;`
60,416,583
I have an array(lets call it X) and X contains arrays. I want to push an element(a string) into an array that is inside of X. I've tried searching for quite a while and all i find are people trying to push arrays inside of other arrays. I've tried the following code: ``` push(@X[0],$element); ``` Which gives me the error: > > Experimental push on scalar is now forbidden at perlscript.pl line 30, > near "$element)" > > > I'm on perl 5 version 26.
2020/02/26
[ "https://Stackoverflow.com/questions/60416583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10954322/" ]
The syntax for `push` is ``` push ARRAY, LIST ``` For example, ``` push @a, $element; ``` Whereever a variable name appear, you may replace the name with a block that evaluate to an reference. ``` push @{ $X[0] }, $element; ``` And that's what you need.
Like everybody mentioned already, `push @{ $X[0] }, $element;`. Since you say you are using v5.26, you can also use postfix dereferencing: `push $X[0]->@*, $element;`
42,489,497
I have a procedure where users enter "student id" to search and see the details of that individual. I know this inst correct and I have far more syntax to write but so far this is what I have:- Please note I have declared all variables and my table columns name and types are correct. I haven't ran the code yet because I'm sure I'm missing something more. So please help. I'm coding on toad for oracle in plsql. Below codes are for fetching the data and putting them onto their specific field online. ``` BEGIN -- fetching data from table 'unsus' IF EXISTS SELECT UNSUS_STUDENT_NO student_no, UNSUS_STUDENT_NAME name, UNSUS_SUSPEND_ACCOUNT suspend_acc, UNSUS_UNSUSPEND_DATE unsus_date, UNSUS_USER_ID user_id FROM SATURN.UNSUS WHERE UNSUS_SUSPEND_NO = ('000123456'); -- opening table rows (form based) twbkfrmt.P_TableRowOpen; twbkfrmt.P_TableData ('Student ID'); twbkfrmt.P_TableData ('Full Name'); twbkfrmt.P_TableData ('Suspended ?'); twbkfrmt.P_TableData ('Unsuspension Date'); twbkfrmt.P_TableData ('Added On ?'); twbkfrmt.P_TableData ('Altered By'); twbkfrmt.P_TableRowOpen; -- table data adding onto form fields twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 25, cmaxlength => 9, cvalue => student_no, cattributes => 'style="font-size:12px" readonly ' || disabled)); twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 60, cmaxlength => 60, cvalue => name, cattributes => 'style="font-size:12px" readonly ' || disabled)); twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 15, cmaxlength => 5, cvalue => suspend_acc, cattributes => 'style="font-size:12px" readonly ' || disabled)); twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 20, cmaxlength => 15, cvalue => unsus_date, cattributes => 'style="font-size:12px" readonly ' || disabled)); twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 20, cmaxlength => 15, --cvalue => , cattributes => 'style="font-size:12px" readonly ' || disabled)); twbkfrmt.p_TableDataWhite (HTF.formtext ( cname => '', csize => 30, cmaxlength => 30, cvalue => user_id, cattributes => 'style="font-size:12px" readonly ' || disabled)); ```
2017/02/27
[ "https://Stackoverflow.com/questions/42489497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7426389/" ]
There are several ways to go about this. The standard method, and it is lightening fast, is to just select the data and have a no\_data\_found exception. I hope you haven't prefaced all of your column names with the table name, that is not good practice IMHO. ``` DECLARE l_student_no saturn.unsus.student_no%TYPE; l_student_name saturn.unsus.student_name%TYPE; l_suspend_account saturn.unsus.suspend_account%TYPE; BEGIN SELECT student_no, student_name, suspend_account INTO l_student_no, l_student_name, l_suspend_account FROM saturn.unsus WHERE suspend_no = ('000123456'); -- you have your data, do your HTML formatting. twbkfrmt.p_tabledatawhite ( HTF.formtext ( cname => '' , csize => 25 , cmaxlength => 9 , cvalue => l_student_no , cattributes => 'style="font-size:12px" readonly ' || disabled ) ); -- ... EXCEPTION WHEN NO_DATA_FOUND THEN -- code jumps to here when the suspend_no is not found -- the null means just ignore no_data_found NULL; END; ```
Just need a check whether the set exists. ``` SELECT COUNT(UNSUS_STUDENT_NO) INTO studentCount FROM SATURN.UNSUS WHERE UNSUS_SUSPEND_NO = ('000123456'); IF studentCount > 0 THEN -- Insert all logic here. END IF; ```
20,270,871
I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error: `builtins.ValueError: need more than 1 value to unpack` ``` questions_list = [] answers_list = [] questions_file=open('qanda.txt','r') for line in questions_file: line=line.strip() questions,answers =line.split(':') questions_list.append(questions) answers_list.append(answers) ```
2013/11/28
[ "https://Stackoverflow.com/questions/20270871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046660/" ]
This is probably because when you're doing the splitting, there is no `:`, so the function just returns one argument, and not 2. This is probably caused by the last line, meaning that you're last line has nothing but empty spaces. Like so: ``` >>> a = ' ' >>> a = a.strip() >>> a '' >>> a.split(':') [''] ``` As you can see, the list returned from `.split` is just a single empty string. So, just to show you a demo, this is a sample file: > > > ``` > a: b > c: d > e: f > > g: h > > ``` > > We try to use the following script (`val.txt` is the name of the above file): ``` with open('val.txt', 'r') as v: for line in v: a, b = line.split(':') print a, b ``` And this gives us: ``` Traceback (most recent call last): a b c d File "C:/Nafiul Stuff/Python/testingZone/28_11_13/val.py", line 3, in <module> a, b = line.split(':') e f ValueError: need more than 1 value to unpack ``` When trying to look at this through a debugger, the variable `line` becomes `\n`, and you can't split that. However, a simple logical ammendment, would correct this problem: ``` with open('val.txt', 'r') as v: for line in v: if ':' in line: a, b = line.strip().split(':') print a, b ```
`line.split(':')` apparently returns a list with one element, not two. Hence that's why it can't unpack the result into `questions` and `answers`. Example: ``` >>> line = 'this-line-does-not-contain-a-colon' >>> question, answers = line.split(':') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: need more than 1 value to unpack ```
20,270,871
I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error: `builtins.ValueError: need more than 1 value to unpack` ``` questions_list = [] answers_list = [] questions_file=open('qanda.txt','r') for line in questions_file: line=line.strip() questions,answers =line.split(':') questions_list.append(questions) answers_list.append(answers) ```
2013/11/28
[ "https://Stackoverflow.com/questions/20270871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046660/" ]
`line.split(':')` apparently returns a list with one element, not two. Hence that's why it can't unpack the result into `questions` and `answers`. Example: ``` >>> line = 'this-line-does-not-contain-a-colon' >>> question, answers = line.split(':') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: need more than 1 value to unpack ```
The reason why this happens could be a few, as already covered in the other answers. Empty line, or maybe a line only have a question and no colon. If you want to parse the lines even if they don't have the colon (for example if some lines only have the question), you can change your split to the following: ``` questions, answers, garbage = (line+'::').split(':', maxsplit=2) ``` This way, the values for `questions` and `answers` will be filled if they are there, and will be empty it the original file doesn't have them. For all intents and purposes, ignore the variable `garbage`.
20,270,871
I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error: `builtins.ValueError: need more than 1 value to unpack` ``` questions_list = [] answers_list = [] questions_file=open('qanda.txt','r') for line in questions_file: line=line.strip() questions,answers =line.split(':') questions_list.append(questions) answers_list.append(answers) ```
2013/11/28
[ "https://Stackoverflow.com/questions/20270871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046660/" ]
This is probably because when you're doing the splitting, there is no `:`, so the function just returns one argument, and not 2. This is probably caused by the last line, meaning that you're last line has nothing but empty spaces. Like so: ``` >>> a = ' ' >>> a = a.strip() >>> a '' >>> a.split(':') [''] ``` As you can see, the list returned from `.split` is just a single empty string. So, just to show you a demo, this is a sample file: > > > ``` > a: b > c: d > e: f > > g: h > > ``` > > We try to use the following script (`val.txt` is the name of the above file): ``` with open('val.txt', 'r') as v: for line in v: a, b = line.split(':') print a, b ``` And this gives us: ``` Traceback (most recent call last): a b c d File "C:/Nafiul Stuff/Python/testingZone/28_11_13/val.py", line 3, in <module> a, b = line.split(':') e f ValueError: need more than 1 value to unpack ``` When trying to look at this through a debugger, the variable `line` becomes `\n`, and you can't split that. However, a simple logical ammendment, would correct this problem: ``` with open('val.txt', 'r') as v: for line in v: if ':' in line: a, b = line.strip().split(':') print a, b ```
Try: ``` question, answers = line.split(':', maxsplit=1) question, __, answers = line.partition(':') ``` Also in Python 3 you can do something else: ``` question, *many_answers = line.split(':') ``` which looks like: ``` temp = line.split(':') question = temp[0] many_answers = tuple(temp[1:]) ```
20,270,871
I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error: `builtins.ValueError: need more than 1 value to unpack` ``` questions_list = [] answers_list = [] questions_file=open('qanda.txt','r') for line in questions_file: line=line.strip() questions,answers =line.split(':') questions_list.append(questions) answers_list.append(answers) ```
2013/11/28
[ "https://Stackoverflow.com/questions/20270871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046660/" ]
This is probably because when you're doing the splitting, there is no `:`, so the function just returns one argument, and not 2. This is probably caused by the last line, meaning that you're last line has nothing but empty spaces. Like so: ``` >>> a = ' ' >>> a = a.strip() >>> a '' >>> a.split(':') [''] ``` As you can see, the list returned from `.split` is just a single empty string. So, just to show you a demo, this is a sample file: > > > ``` > a: b > c: d > e: f > > g: h > > ``` > > We try to use the following script (`val.txt` is the name of the above file): ``` with open('val.txt', 'r') as v: for line in v: a, b = line.split(':') print a, b ``` And this gives us: ``` Traceback (most recent call last): a b c d File "C:/Nafiul Stuff/Python/testingZone/28_11_13/val.py", line 3, in <module> a, b = line.split(':') e f ValueError: need more than 1 value to unpack ``` When trying to look at this through a debugger, the variable `line` becomes `\n`, and you can't split that. However, a simple logical ammendment, would correct this problem: ``` with open('val.txt', 'r') as v: for line in v: if ':' in line: a, b = line.strip().split(':') print a, b ```
The reason why this happens could be a few, as already covered in the other answers. Empty line, or maybe a line only have a question and no colon. If you want to parse the lines even if they don't have the colon (for example if some lines only have the question), you can change your split to the following: ``` questions, answers, garbage = (line+'::').split(':', maxsplit=2) ``` This way, the values for `questions` and `answers` will be filled if they are there, and will be empty it the original file doesn't have them. For all intents and purposes, ignore the variable `garbage`.
20,270,871
I have a file with questions and answers on the same line, I want to seperate them and append them to their own empty list but keep getting this error: `builtins.ValueError: need more than 1 value to unpack` ``` questions_list = [] answers_list = [] questions_file=open('qanda.txt','r') for line in questions_file: line=line.strip() questions,answers =line.split(':') questions_list.append(questions) answers_list.append(answers) ```
2013/11/28
[ "https://Stackoverflow.com/questions/20270871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046660/" ]
Try: ``` question, answers = line.split(':', maxsplit=1) question, __, answers = line.partition(':') ``` Also in Python 3 you can do something else: ``` question, *many_answers = line.split(':') ``` which looks like: ``` temp = line.split(':') question = temp[0] many_answers = tuple(temp[1:]) ```
The reason why this happens could be a few, as already covered in the other answers. Empty line, or maybe a line only have a question and no colon. If you want to parse the lines even if they don't have the colon (for example if some lines only have the question), you can change your split to the following: ``` questions, answers, garbage = (line+'::').split(':', maxsplit=2) ``` This way, the values for `questions` and `answers` will be filled if they are there, and will be empty it the original file doesn't have them. For all intents and purposes, ignore the variable `garbage`.
9,641,631
I tried to simplify my question to a basic example I wrote down below, the actual problem is much more complex so the below queries might not make much sense but the basic concepts are the same (data from one query as argument to another). **Query 1:** ``` SELECT Ping.ID as PingID, Base.ID as BaseID FROM (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "ping" ORDER BY l.ID DESC ) Ping INNER JOIN (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "Base" ORDER BY l.ID DESC ) Base ON Base.DateTime < Ping.DateTime GROUP BY Ping.ID ORDER BY Ping.ID DESC; +--------+--------+ | PingID | BaseID | +--------+--------+ | 11 | 10 | | 9 | 8 | | 7 | 6 | | 5 | 3 | | 4 | 3 | +--------+--------+ ``` // from below I need to replace 11 by PingID above and 10 by BaseID above then the results to show up on as third column above (0 if no results, 1 if results) **Query 2:** ``` SELECT * FROM (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "ping" AND l.ID = 11) Ping INNER JOIN (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "base" AND l.ID = 10) Base ON Base.Data < Ping.Data; ``` How can I do this? Again I'm not sure what kind of advice I will receive but please understand that the Query 2 is in reality over 200 lines and I basically can't touch it so I don't have so much flexibility as I'd like and ideally I'd like to get this working all in SQL without having to script this. ``` CREATE DATABASE lookback; use lookback; CREATE TABLE mygroup ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, DateTime DateTime ) ENGINE=InnoDB; CREATE TABLE list ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, Type VARCHAR(255), MyGroup BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; CREATE TABLE sublist ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, ParentID BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; INSERT INTO mygroup (DateTime) VALUES ("2012-03-09 22:33:19"), ("2012-03-09 22:34:19"), ("2012-03-09 22:35:19"), ("2012-03-09 22:36:19"), ("2012-03-09 22:37:19"), ("2012-03-09 22:38:19"), ("2012-03-09 22:39:19"), ("2012-03-09 22:40:19"), ("2012-03-09 22:41:19"), ("2012-03-09 22:42:19"), ("2012-03-09 22:43:19"); INSERT INTO list (Type, MyGroup, Data) VALUES ("ping", 1, 4), ("base", 2, 2), ("base", 3, 4), ("ping", 4, 7), ("ping", 5, 8), ("base", 6, 7), ("ping", 7, 8), ("base", 8, 3), ("ping", 9, 10), ("base", 10, 2), ("ping", 11, 3); INSERT INTO sublist (ParentID, Data) VALUES (1, 2), (2, 3), (3, 6), (4, 8), (5, 4), (6, 5), (7, 1), (8, 9), (9, 11), (10, 4), (11, 6); ```
2012/03/09
[ "https://Stackoverflow.com/questions/9641631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391986/" ]
The simplest way of dealing with this is temporary tables, described [here](http://dev.mysql.com/doc/refman/5.0/en/create-table.html) and [here](http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-select-into-table.html). If you create an empty table to store your results (let's call it `tbl_temp1`) you can to this: ``` INSERT INTO tbl_temp1 (PingID, BaseID) SELECT Ping.ID as PingID, Base.ID as BaseID FROM ... ``` Then you can query it however you like: ``` SELECT PingID, BaseID from tbl_temp1 ... ``` **Edited to add:** From the docs for [CREATE TEMPORARY TABLE](http://dev.mysql.com/doc/refman/5.6/en/create-table.html): > > You can use the TEMPORARY keyword when creating a table. A TEMPORARY > table is visible only to the current connection, and is dropped > automatically when the connection is closed. This means that two > different connections can use the same temporary table name without > conflicting with each other or with an existing non-TEMPORARY table of > the same name. (The existing table is hidden until the temporary table > is dropped.) > > >
If this were a more flattened query, then there would a straightforward answer. It is certainly possible to use a derived table as the input to outer queries. A simple example would be: ``` select data1, (select data3 from howdy1 where howdy1.data1 = greetings.data1) data3_derived from (select data1 from hello1 where hello1.data2 < 4) as greetings; ``` where the derived table `greetings` is used in the inline query. (SQL Fiddle for this simplistic example: <http://sqlfiddle.com/#!3/49425/2> ) Following this logic would lead us to assume that you could cast your first query as a derived table of `query1` and then recast `query2` into the select statement. For that I constructed the following: ``` select query1.pingId, query1.baseId, (SELECT ping.Data pingData FROM (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "ping" AND l.ID = query1.pingId ) Ping INNER JOIN (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "base" AND l.ID = query1.baseId ) Base ON Base.Data < Ping.Data) from (SELECT Ping.ID as PingID, Base.ID as BaseID FROM (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "ping" ORDER BY l.ID DESC ) Ping INNER JOIN (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "Base" ORDER BY l.ID DESC ) Base ON Base.DateTime < Ping.DateTime GROUP BY Ping.ID ) query1 order by pingId desc; ``` where I have inserted `query2` into a select clause from `query1` and inserted `query1.pingId` and `query1.baseId` in place of `11` and `10`, respectively. If 11 and 10 are left in place, this query works (but obviously only generates the same data for each row). But when this is executed, I'm given an error: `Unknown column 'query1.pingId'`. Obviously, query1 cannot be seen inside the nested derived tables. Since, in general, this type of query is possible, when the nesting is only 1 level deep (as per my greeting example at the top), there must be logical restrictions as to why this level of nesting isn't possible. (Time to pull out the database theory book...) If I were faced with this, I'd rewrite and flatten the queries to get the real data that I wanted. And eliminate a couple things including that really nasty `group by` that is used in query1 to get the max baseId for a given pingId. You say that's not possible, due to external constraints. So, this is, ultimately, a non-answer answer. Not very useful, but maybe it'll be worth something. (SQL Fiddle for all this: <http://sqlfiddle.com/#!2/bac74/35> )
9,641,631
I tried to simplify my question to a basic example I wrote down below, the actual problem is much more complex so the below queries might not make much sense but the basic concepts are the same (data from one query as argument to another). **Query 1:** ``` SELECT Ping.ID as PingID, Base.ID as BaseID FROM (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "ping" ORDER BY l.ID DESC ) Ping INNER JOIN (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "Base" ORDER BY l.ID DESC ) Base ON Base.DateTime < Ping.DateTime GROUP BY Ping.ID ORDER BY Ping.ID DESC; +--------+--------+ | PingID | BaseID | +--------+--------+ | 11 | 10 | | 9 | 8 | | 7 | 6 | | 5 | 3 | | 4 | 3 | +--------+--------+ ``` // from below I need to replace 11 by PingID above and 10 by BaseID above then the results to show up on as third column above (0 if no results, 1 if results) **Query 2:** ``` SELECT * FROM (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "ping" AND l.ID = 11) Ping INNER JOIN (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "base" AND l.ID = 10) Base ON Base.Data < Ping.Data; ``` How can I do this? Again I'm not sure what kind of advice I will receive but please understand that the Query 2 is in reality over 200 lines and I basically can't touch it so I don't have so much flexibility as I'd like and ideally I'd like to get this working all in SQL without having to script this. ``` CREATE DATABASE lookback; use lookback; CREATE TABLE mygroup ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, DateTime DateTime ) ENGINE=InnoDB; CREATE TABLE list ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, Type VARCHAR(255), MyGroup BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; CREATE TABLE sublist ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, ParentID BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; INSERT INTO mygroup (DateTime) VALUES ("2012-03-09 22:33:19"), ("2012-03-09 22:34:19"), ("2012-03-09 22:35:19"), ("2012-03-09 22:36:19"), ("2012-03-09 22:37:19"), ("2012-03-09 22:38:19"), ("2012-03-09 22:39:19"), ("2012-03-09 22:40:19"), ("2012-03-09 22:41:19"), ("2012-03-09 22:42:19"), ("2012-03-09 22:43:19"); INSERT INTO list (Type, MyGroup, Data) VALUES ("ping", 1, 4), ("base", 2, 2), ("base", 3, 4), ("ping", 4, 7), ("ping", 5, 8), ("base", 6, 7), ("ping", 7, 8), ("base", 8, 3), ("ping", 9, 10), ("base", 10, 2), ("ping", 11, 3); INSERT INTO sublist (ParentID, Data) VALUES (1, 2), (2, 3), (3, 6), (4, 8), (5, 4), (6, 5), (7, 1), (8, 9), (9, 11), (10, 4), (11, 6); ```
2012/03/09
[ "https://Stackoverflow.com/questions/9641631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391986/" ]
The simplest way of dealing with this is temporary tables, described [here](http://dev.mysql.com/doc/refman/5.0/en/create-table.html) and [here](http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-select-into-table.html). If you create an empty table to store your results (let's call it `tbl_temp1`) you can to this: ``` INSERT INTO tbl_temp1 (PingID, BaseID) SELECT Ping.ID as PingID, Base.ID as BaseID FROM ... ``` Then you can query it however you like: ``` SELECT PingID, BaseID from tbl_temp1 ... ``` **Edited to add:** From the docs for [CREATE TEMPORARY TABLE](http://dev.mysql.com/doc/refman/5.6/en/create-table.html): > > You can use the TEMPORARY keyword when creating a table. A TEMPORARY > table is visible only to the current connection, and is dropped > automatically when the connection is closed. This means that two > different connections can use the same temporary table name without > conflicting with each other or with an existing non-TEMPORARY table of > the same name. (The existing table is hidden until the temporary table > is dropped.) > > >
If you cannot modify query 2 then there is nothing we can suggest. Here is a combination of your two queries with a reduced level of nesting. I suspect this would be slow with a large dataset - ``` SELECT tmp1.PingID, tmp1.BaseID, IF(slb.Data, 1, 0) AS third_col FROM ( SELECT lp.ID AS PingID, MAX(lb.ID) AS BaseID FROM MyGroup mgp INNER JOIN MyGroup mgb ON mgb.DateTime < mgp.DateTime INNER JOIN list lp ON mgp.ID = lp.MyGroup AND lp.Type = 'ping' INNER JOIN list lb ON mgb.ID = lb.MyGroup AND lb.Type = 'base' GROUP BY lp.ID DESC ) AS tmp1 LEFT JOIN sublist slp ON tmp1.PingID = slp.ParentID LEFT JOIN sublist slb ON tmp1.BaseID = slb.ParentID AND slb.Data < slp.Data; ```
9,641,631
I tried to simplify my question to a basic example I wrote down below, the actual problem is much more complex so the below queries might not make much sense but the basic concepts are the same (data from one query as argument to another). **Query 1:** ``` SELECT Ping.ID as PingID, Base.ID as BaseID FROM (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "ping" ORDER BY l.ID DESC ) Ping INNER JOIN (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "Base" ORDER BY l.ID DESC ) Base ON Base.DateTime < Ping.DateTime GROUP BY Ping.ID ORDER BY Ping.ID DESC; +--------+--------+ | PingID | BaseID | +--------+--------+ | 11 | 10 | | 9 | 8 | | 7 | 6 | | 5 | 3 | | 4 | 3 | +--------+--------+ ``` // from below I need to replace 11 by PingID above and 10 by BaseID above then the results to show up on as third column above (0 if no results, 1 if results) **Query 2:** ``` SELECT * FROM (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "ping" AND l.ID = 11) Ping INNER JOIN (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "base" AND l.ID = 10) Base ON Base.Data < Ping.Data; ``` How can I do this? Again I'm not sure what kind of advice I will receive but please understand that the Query 2 is in reality over 200 lines and I basically can't touch it so I don't have so much flexibility as I'd like and ideally I'd like to get this working all in SQL without having to script this. ``` CREATE DATABASE lookback; use lookback; CREATE TABLE mygroup ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, DateTime DateTime ) ENGINE=InnoDB; CREATE TABLE list ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, Type VARCHAR(255), MyGroup BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; CREATE TABLE sublist ( ID BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, ParentID BIGINT NOT NULL, Data INT NOT NULL ) ENGINE=InnoDB; INSERT INTO mygroup (DateTime) VALUES ("2012-03-09 22:33:19"), ("2012-03-09 22:34:19"), ("2012-03-09 22:35:19"), ("2012-03-09 22:36:19"), ("2012-03-09 22:37:19"), ("2012-03-09 22:38:19"), ("2012-03-09 22:39:19"), ("2012-03-09 22:40:19"), ("2012-03-09 22:41:19"), ("2012-03-09 22:42:19"), ("2012-03-09 22:43:19"); INSERT INTO list (Type, MyGroup, Data) VALUES ("ping", 1, 4), ("base", 2, 2), ("base", 3, 4), ("ping", 4, 7), ("ping", 5, 8), ("base", 6, 7), ("ping", 7, 8), ("base", 8, 3), ("ping", 9, 10), ("base", 10, 2), ("ping", 11, 3); INSERT INTO sublist (ParentID, Data) VALUES (1, 2), (2, 3), (3, 6), (4, 8), (5, 4), (6, 5), (7, 1), (8, 9), (9, 11), (10, 4), (11, 6); ```
2012/03/09
[ "https://Stackoverflow.com/questions/9641631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391986/" ]
If this were a more flattened query, then there would a straightforward answer. It is certainly possible to use a derived table as the input to outer queries. A simple example would be: ``` select data1, (select data3 from howdy1 where howdy1.data1 = greetings.data1) data3_derived from (select data1 from hello1 where hello1.data2 < 4) as greetings; ``` where the derived table `greetings` is used in the inline query. (SQL Fiddle for this simplistic example: <http://sqlfiddle.com/#!3/49425/2> ) Following this logic would lead us to assume that you could cast your first query as a derived table of `query1` and then recast `query2` into the select statement. For that I constructed the following: ``` select query1.pingId, query1.baseId, (SELECT ping.Data pingData FROM (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "ping" AND l.ID = query1.pingId ) Ping INNER JOIN (SELECT sl.Data FROM list l JOIN sublist sl ON sl.ParentID = l.ID WHERE l.Type = "base" AND l.ID = query1.baseId ) Base ON Base.Data < Ping.Data) from (SELECT Ping.ID as PingID, Base.ID as BaseID FROM (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "ping" ORDER BY l.ID DESC ) Ping INNER JOIN (SELECT l.ID, mg.DateTime from list l JOIN mygroup mg ON mg.ID = l.MyGroup WHERE l.Type = "Base" ORDER BY l.ID DESC ) Base ON Base.DateTime < Ping.DateTime GROUP BY Ping.ID ) query1 order by pingId desc; ``` where I have inserted `query2` into a select clause from `query1` and inserted `query1.pingId` and `query1.baseId` in place of `11` and `10`, respectively. If 11 and 10 are left in place, this query works (but obviously only generates the same data for each row). But when this is executed, I'm given an error: `Unknown column 'query1.pingId'`. Obviously, query1 cannot be seen inside the nested derived tables. Since, in general, this type of query is possible, when the nesting is only 1 level deep (as per my greeting example at the top), there must be logical restrictions as to why this level of nesting isn't possible. (Time to pull out the database theory book...) If I were faced with this, I'd rewrite and flatten the queries to get the real data that I wanted. And eliminate a couple things including that really nasty `group by` that is used in query1 to get the max baseId for a given pingId. You say that's not possible, due to external constraints. So, this is, ultimately, a non-answer answer. Not very useful, but maybe it'll be worth something. (SQL Fiddle for all this: <http://sqlfiddle.com/#!2/bac74/35> )
If you cannot modify query 2 then there is nothing we can suggest. Here is a combination of your two queries with a reduced level of nesting. I suspect this would be slow with a large dataset - ``` SELECT tmp1.PingID, tmp1.BaseID, IF(slb.Data, 1, 0) AS third_col FROM ( SELECT lp.ID AS PingID, MAX(lb.ID) AS BaseID FROM MyGroup mgp INNER JOIN MyGroup mgb ON mgb.DateTime < mgp.DateTime INNER JOIN list lp ON mgp.ID = lp.MyGroup AND lp.Type = 'ping' INNER JOIN list lb ON mgb.ID = lb.MyGroup AND lb.Type = 'base' GROUP BY lp.ID DESC ) AS tmp1 LEFT JOIN sublist slp ON tmp1.PingID = slp.ParentID LEFT JOIN sublist slb ON tmp1.BaseID = slb.ParentID AND slb.Data < slp.Data; ```
46,582,362
``` // RecursiveBinarySearch.cpp : Defines the entry point for the console application. // #include "stdafx.h" #define N 9 int RecursiveBinarySearch(int A, int low, int high, int x); int main() { int A[N]; int index = 0; //Put A[0] = 2; A[1] = 6; A[2] = 13; A[3] = 21; A[4] = 36; A[5] = 47; A[6] = 63; A[7] = 81; A[8] = 97; printf("Elements in Array A\n"); while (index <= 8) { printf("%d ", A[index]); index++; } printf("\nLocation(index) of element 63\n"); printf("%d", RecursiveBinarySearch(A, 0, 8, 63)); return 0; } int RecursiveBinarySearch(int A, int low, int high, int x) { //Base Condition if (low > high) return -1; int mid = low + (high - low) / 2; if (x == A[mid]) return mid; else if (x < A[mid]) return RecursiveBinarySearch(A, low, mid - 1, x); else return RecursiveBinarySearch(A, mid + 1, high, x); } ``` Here's first problem. Visual studio says int A[9] argument of type "int\*" is incompatible with parameter of type "int" Here's second problem. int mid expression must have pointer-to-object type I don't know well about pointer so i want to know why this code can't be compiled and how to use pointer in this code.
2017/10/05
[ "https://Stackoverflow.com/questions/46582362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8724654/" ]
Better remove all assignements `A[0] = ..., A[1] = ...` alltogether and write: ``` int A[] = {2,6,13,21,36,47,63,81,97} ``` And replace ``` while (index <= 8) ``` by: ``` while (index < sizeof(A)/sizeof(A[0])) ``` `sizeof(A) / sizeof(A[0])` is the number of elements if the array `A`. `sizeof(A)` is the size in bytes of the whole array, and `sizeof(A[0])` is the size of one elements of the array in bytes. --- But the real problem is here: Replace: ``` int RecursiveBinarySearch(int A, int low, int high, int x) ``` by ``` int RecursiveBinarySearch(int A[], int low, int high, int x) ``` There may be more errors though.
Start taking compiler warnings seriously: ``` helpPointer.c: In function ‘main’: helpPointer.c:30:40: warning: passing argument 1 of ‘RecursiveBinarySearch’ makes integer from pointer without a cast [-Wint-conversion] printf("%d", RecursiveBinarySearch(A, 0, 8, 63)); ^ helpPointer.c:4:5: note: expected ‘int’ but argument is of type ‘int *’ int RecursiveBinarySearch(int A, int low, int high, int x); ^~~~~~~~~~~~~~~~~~~~~ ``` As pointed by people in comments already, you're passing an array into recursive binary search method, so you should change `RecursiveBinarySearch` like this: ``` int RecursiveBinarySearch(int A[], int low, int high, int x); ``` Or ``` int RecursiveBinarySearch(int *A, int low, int high, int x); ``` Which are one and the same thing, since array name is just a pointer which points to the first element of the array. Read [this](https://stackoverflow.com/questions/1641957/is-an-array-name-a-pointer) if you don't have much idea about relationship between array and pointers.
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
Try adding a `height` property to `body` or parent container.
In addition to setting the height property of the map div to 100% you might need to implement [this](https://stackoverflow.com/questions/10762984/leaflet-map-not-displayed-properly-inside-tabbed-panel) to ensure that the map fills the div on a resize.
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
Try adding a `height` property to `body` or parent container.
``` body { padding: 0; margin: 0; } html, body, #map, .row-fluid{ height: 100%; } #map { width: 100%; } .height-css { height: 100%; } ``` your html will be ``` <div class="container-fluid"> <div class="row-fluid"> <div class="span12 height-css"> <div id="map"></div> </div> </div> </div> ```
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
Try adding a `height` property to `body` or parent container.
With CSS from project [Bootleaf](https://github.com/bmcbride/bootleaf) on Github: ``` html,body, #map{ height:100%; width: 100%; overflow: hidden; } body { padding-top: 50px; ```
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
**CCS** ``` #map { width: 100px; height:100px; min-height: 100%; min-width: 100%; display: block; } html, body { height: 100%; } .fill { min-height: 100%; height: 100%; width: 100%; min-width: 100%; } ``` **html** ``` <div class="container fill"> <div id="map"> </div> </div> ```
In addition to setting the height property of the map div to 100% you might need to implement [this](https://stackoverflow.com/questions/10762984/leaflet-map-not-displayed-properly-inside-tabbed-panel) to ensure that the map fills the div on a resize.
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
With CSS from project [Bootleaf](https://github.com/bmcbride/bootleaf) on Github: ``` html,body, #map{ height:100%; width: 100%; overflow: hidden; } body { padding-top: 50px; ```
In addition to setting the height property of the map div to 100% you might need to implement [this](https://stackoverflow.com/questions/10762984/leaflet-map-not-displayed-properly-inside-tabbed-panel) to ensure that the map fills the div on a resize.
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
**CCS** ``` #map { width: 100px; height:100px; min-height: 100%; min-width: 100%; display: block; } html, body { height: 100%; } .fill { min-height: 100%; height: 100%; width: 100%; min-width: 100%; } ``` **html** ``` <div class="container fill"> <div id="map"> </div> </div> ```
``` body { padding: 0; margin: 0; } html, body, #map, .row-fluid{ height: 100%; } #map { width: 100%; } .height-css { height: 100%; } ``` your html will be ``` <div class="container-fluid"> <div class="row-fluid"> <div class="span12 height-css"> <div id="map"></div> </div> </div> </div> ```
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
**CCS** ``` #map { width: 100px; height:100px; min-height: 100%; min-width: 100%; display: block; } html, body { height: 100%; } .fill { min-height: 100%; height: 100%; width: 100%; min-width: 100%; } ``` **html** ``` <div class="container fill"> <div id="map"> </div> </div> ```
With CSS from project [Bootleaf](https://github.com/bmcbride/bootleaf) on Github: ``` html,body, #map{ height:100%; width: 100%; overflow: hidden; } body { padding-top: 50px; ```
16,885,729
I just wanted to know if there is an option to do a JButton inside here: ``` if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } ``` And then just type: panel.add(dialogOdp); Outside? Here is the whole code: ``` final JButton continueGame = new JButton(); continueGame.setPreferredSize(new Dimension(1000, 30)); continueGame.setLocation(95, 45); continueGame.setText("<html>Continue</html>"); continueGame.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ev) { panel.remove(continueGame); SwingUtilities.updateComponentTreeUI(frameKontrastGame); if(RandomNrJeden <= 50) { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be green."); JButton dialogOdp = new JButton(); } else { JOptionPane.showMessageDialog(frameKontrastGame, "Eggs are not supposed to be red."); } }}); //final JLabel im = new JLabel(new ImageIcon("kontrast_logo_2.png")); //panel.add(im); panel.add(dialogOdp); panel.add(continueGame); frameKontrastGame.getContentPane().add(panel); frameKontrastGame.setLocationByPlatform(true); }}); ```
2013/06/02
[ "https://Stackoverflow.com/questions/16885729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2445239/" ]
With CSS from project [Bootleaf](https://github.com/bmcbride/bootleaf) on Github: ``` html,body, #map{ height:100%; width: 100%; overflow: hidden; } body { padding-top: 50px; ```
``` body { padding: 0; margin: 0; } html, body, #map, .row-fluid{ height: 100%; } #map { width: 100%; } .height-css { height: 100%; } ``` your html will be ``` <div class="container-fluid"> <div class="row-fluid"> <div class="span12 height-css"> <div id="map"></div> </div> </div> </div> ```
21,241,326
I'm trying to create a query to return the file with the max version, independent of the value of the server. How could I do that? actual table data: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 local code1.zip 28 0000-00-00 remote code1.zip 21 0000-00-00 local code1.zip 32 0000-00-00 remote code1.zip 27 0000-00-00 ``` the query: ``` SELECT server, filename, max(v4) as v4, date FROM table WHERE date ='0000-00-00' GROUP BY filename, server, date ``` Actual result: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 ``` Expected result: ``` server filename v4 date local code1.zip 41 0000-00-00 ``` EDIT: It's for **MySQL** Thanks in advance.
2014/01/20
[ "https://Stackoverflow.com/questions/21241326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
If you just want the row with largest v4 you can use this ``` SELECT server, filename, v4, date FROM `table` WHERE date ='0000-00-00' ORDER BY v4 DESC LIMIT 1 ``` to get max V4 for each filename, first you get max(v4) group by filename then INNER JOIN back with `table` like below ``` SELECT T1.server,T1.filename,T1.v4,T1.date FROM `table` T1 INNER JOIN (SELECT filename,max(v4) as maxv4 FROM `table` WHERE date = '0000-00-00' GROUP BY filename)T2 ON T1.filename = T2.filename AND T1.v4 = T2.maxV4 WHERE date = '0000-00-00'; ```
You could use this query: ``` Select Top 1 * From table Where v4 = ( SELECT max(v4) as v4, FROM table WHERE date ='0000-00-00' GROUP BY v4 ) ```
21,241,326
I'm trying to create a query to return the file with the max version, independent of the value of the server. How could I do that? actual table data: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 local code1.zip 28 0000-00-00 remote code1.zip 21 0000-00-00 local code1.zip 32 0000-00-00 remote code1.zip 27 0000-00-00 ``` the query: ``` SELECT server, filename, max(v4) as v4, date FROM table WHERE date ='0000-00-00' GROUP BY filename, server, date ``` Actual result: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 ``` Expected result: ``` server filename v4 date local code1.zip 41 0000-00-00 ``` EDIT: It's for **MySQL** Thanks in advance.
2014/01/20
[ "https://Stackoverflow.com/questions/21241326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
To get the the max version you only have to do: ``` SELECT MAX(version) FROM table ``` If you also want the filename (if you have another column `id`): ``` SELECT t2.filename, t2.maxver FROM table t1 INNER JOIN (SELECT id, MAX(version) maxver FROM table GROUP BY id) t2 ON t1.id=t2.id ORDER BY t2.maxver DESC LIMIT 1 ``` If you also want the filename (if you haven't another column `id`, use `filename`): ``` SELECT t2.filename, t2.maxver FROM table t1 INNER JOIN (SELECT filename, MAX(version) maxver FROM table GROUP BY filename) t2 ON t1.filename=t2.filename WHERE t2.maxver = (SELECT MAX(version) FROM table) ``` There are many ways to do it.
You could use this query: ``` Select Top 1 * From table Where v4 = ( SELECT max(v4) as v4, FROM table WHERE date ='0000-00-00' GROUP BY v4 ) ```
21,241,326
I'm trying to create a query to return the file with the max version, independent of the value of the server. How could I do that? actual table data: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 local code1.zip 28 0000-00-00 remote code1.zip 21 0000-00-00 local code1.zip 32 0000-00-00 remote code1.zip 27 0000-00-00 ``` the query: ``` SELECT server, filename, max(v4) as v4, date FROM table WHERE date ='0000-00-00' GROUP BY filename, server, date ``` Actual result: ``` server filename v4 date local code1.zip 41 0000-00-00 remote code1.zip 39 0000-00-00 ``` Expected result: ``` server filename v4 date local code1.zip 41 0000-00-00 ``` EDIT: It's for **MySQL** Thanks in advance.
2014/01/20
[ "https://Stackoverflow.com/questions/21241326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
If you just want the row with largest v4 you can use this ``` SELECT server, filename, v4, date FROM `table` WHERE date ='0000-00-00' ORDER BY v4 DESC LIMIT 1 ``` to get max V4 for each filename, first you get max(v4) group by filename then INNER JOIN back with `table` like below ``` SELECT T1.server,T1.filename,T1.v4,T1.date FROM `table` T1 INNER JOIN (SELECT filename,max(v4) as maxv4 FROM `table` WHERE date = '0000-00-00' GROUP BY filename)T2 ON T1.filename = T2.filename AND T1.v4 = T2.maxV4 WHERE date = '0000-00-00'; ```
To get the the max version you only have to do: ``` SELECT MAX(version) FROM table ``` If you also want the filename (if you have another column `id`): ``` SELECT t2.filename, t2.maxver FROM table t1 INNER JOIN (SELECT id, MAX(version) maxver FROM table GROUP BY id) t2 ON t1.id=t2.id ORDER BY t2.maxver DESC LIMIT 1 ``` If you also want the filename (if you haven't another column `id`, use `filename`): ``` SELECT t2.filename, t2.maxver FROM table t1 INNER JOIN (SELECT filename, MAX(version) maxver FROM table GROUP BY filename) t2 ON t1.filename=t2.filename WHERE t2.maxver = (SELECT MAX(version) FROM table) ``` There are many ways to do it.
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
You could try to open a remote-session with `Enter-PSSession` and then use the cmdlet `Start-Process` without `Invoke-Command` You could also run the program like this `& "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -cl` (within the remote-session) Finally you should exit the session with `Exit-PSSession` Another possibility is to run the script "locally". Write the script as you would run it on a local machine. Copy it to an accessable share. Then use a remoting method to run the script on the machine.
In the Start-Process call try using the -Wait parameter.
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
The solution suggested by Tom works for me. Here are the commands I used: ``` New-PSSession -computername TestMachine Start-Process yourservice.exe Exit-PSSession ``` Make sure to use `Exit-PSSession` and not `Remove-PSSession` so that the process `yourservice.exe` remains active after exiting the session.
In the Start-Process call try using the -Wait parameter.
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
This WMI solution worked best for me: <https://social.technet.microsoft.com/Forums/scriptcenter/en-US/ead19612-5e7b-4012-8466-0d650232c7a5/invokecommand-and-startprocess?forum=ITCG> – Adam Driscoll (pointed to the same link) Use: ``` ([WMICLASS]"\\localhost\ROOT\CIMV2:win32_process").Create("something.exe argument1Here") ``` Instead of: ``` Start-Process ```
In the Start-Process call try using the -Wait parameter.
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
You could try to open a remote-session with `Enter-PSSession` and then use the cmdlet `Start-Process` without `Invoke-Command` You could also run the program like this `& "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -cl` (within the remote-session) Finally you should exit the session with `Exit-PSSession` Another possibility is to run the script "locally". Write the script as you would run it on a local machine. Copy it to an accessable share. Then use a remoting method to run the script on the machine.
The solution suggested by Tom works for me. Here are the commands I used: ``` New-PSSession -computername TestMachine Start-Process yourservice.exe Exit-PSSession ``` Make sure to use `Exit-PSSession` and not `Remove-PSSession` so that the process `yourservice.exe` remains active after exiting the session.
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
You could try to open a remote-session with `Enter-PSSession` and then use the cmdlet `Start-Process` without `Invoke-Command` You could also run the program like this `& "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -cl` (within the remote-session) Finally you should exit the session with `Exit-PSSession` Another possibility is to run the script "locally". Write the script as you would run it on a local machine. Copy it to an accessable share. Then use a remoting method to run the script on the machine.
I had the exact same issue. Got it to work cleanly, with a combination of `[WMICLASS] 's create()` and `Start-Process`. Check my answer [here](https://stackoverflow.com/a/35052591/1866983)
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
You could try to open a remote-session with `Enter-PSSession` and then use the cmdlet `Start-Process` without `Invoke-Command` You could also run the program like this `& "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -cl` (within the remote-session) Finally you should exit the session with `Exit-PSSession` Another possibility is to run the script "locally". Write the script as you would run it on a local machine. Copy it to an accessable share. Then use a remoting method to run the script on the machine.
This WMI solution worked best for me: <https://social.technet.microsoft.com/Forums/scriptcenter/en-US/ead19612-5e7b-4012-8466-0d650232c7a5/invokecommand-and-startprocess?forum=ITCG> – Adam Driscoll (pointed to the same link) Use: ``` ([WMICLASS]"\\localhost\ROOT\CIMV2:win32_process").Create("something.exe argument1Here") ``` Instead of: ``` Start-Process ```
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
The solution suggested by Tom works for me. Here are the commands I used: ``` New-PSSession -computername TestMachine Start-Process yourservice.exe Exit-PSSession ``` Make sure to use `Exit-PSSession` and not `Remove-PSSession` so that the process `yourservice.exe` remains active after exiting the session.
I had the exact same issue. Got it to work cleanly, with a combination of `[WMICLASS] 's create()` and `Start-Process`. Check my answer [here](https://stackoverflow.com/a/35052591/1866983)
9,236,949
I am working on a script to remotely kill two processes, delete some folders, and launch a service as an application. Eventually this will be deployed to run against multiple servers, but I'm currently testing it against a single server. Everything works great except for the final step which is to launch the remote service (which is being run as an application using the -cl argument due to some compatibility issues with it running as a service). The application launches via the script but immediately shuts back down as the script moves on to the next step. I'm a total noob so I've been digging quite a bit but have had no luck finding a solution. It seems like I may end up having to launch the process in a new runspace, but I'm not having any luck finding a good noob guide for doing that either. Also the script performs just as it should when localized and run on the machine. Here's what I've got ``` $a = Get-ChildItem "\\TestMachine\c$\DataFiles" $pass = cat "C:\cred.txt" | convertto-securestring $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$pass if ($a.Count -gt 10) { Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name TestProcess -force -EA SilentlyContinue} Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {stop-process -name Winword -force -EA SilentlyContinue} Get-ChildItem -Path \\TestMachine\c$\WordDocs -Recurse -EA SilentlyContinue | Where-Object {$_.PsIsContainer} | Remove-Item -Recurse -Force -EA SilentlyContinue Invoke-Command -ComputerName TestMachine -cred $mycred -scriptBlock {Start-Process "C:\Program Files (x86)\Test\TestUploadManager\TestUploadManager.exe" -Verb Runas -ArgumentList -cl} echo "Success: TestMachine Was successfully reset" } else { echo "Failed: Reset was not necessary" } exit ```
2012/02/11
[ "https://Stackoverflow.com/questions/9236949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203211/" ]
This WMI solution worked best for me: <https://social.technet.microsoft.com/Forums/scriptcenter/en-US/ead19612-5e7b-4012-8466-0d650232c7a5/invokecommand-and-startprocess?forum=ITCG> – Adam Driscoll (pointed to the same link) Use: ``` ([WMICLASS]"\\localhost\ROOT\CIMV2:win32_process").Create("something.exe argument1Here") ``` Instead of: ``` Start-Process ```
I had the exact same issue. Got it to work cleanly, with a combination of `[WMICLASS] 's create()` and `Start-Process`. Check my answer [here](https://stackoverflow.com/a/35052591/1866983)
49,017,321
I am running the following powershell command in a build step using TFS 2018. ``` Start-Job -ScriptBlock { Invoke-Command -FilePath \\MyServer\run.ps1 -ComputerName MyServer -ArgumentList arg1, arg2 } ``` Since I don't want the script to affect the build step it should simply fire and forget the script. Hence I am using `Start-Job`. But it seems that once the step is done the process is killed. Is there a way to maintain the process lifetime even though the build step is done or the build process is finished? Additional information... the powershell script should run on the remote server. The script itself triggers an .exe with parameters.
2018/02/27
[ "https://Stackoverflow.com/questions/49017321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621210/" ]
To simply *fire and forget*, invoke the script with `Invoke-Command -AsJob`: ``` Invoke-Command -AsJob -FilePath \\MyServer\run.ps1 -ComputerName MyServer -Args arg1, arg2 Start-Sleep 1 # !! Seemingly, this is necessary, as @doorman has discovered. ``` * This should kick off the script *remotely, asynchronously*, with a job getting created in the *local* session to monitor its execution. + ***Caveat***: The use of `Start-Sleep` - possibly with a *longer* wait time - is seemingly necessary in order for the remote process to be created before the calling script exits, but such a solution **may not be fully robust**, as there is no guaranteed timing. * Since you're not planning to monitor the remote execution, the *local* session terminating - and along with it the monitoring job - should't matter.
When do you want the script to *stop* running? You could use a [do-while](https://blogs.technet.microsoft.com/heyscriptingguy/2014/05/05/powershell-looping-understanding-and-using-do-while/) loop and come up with a `<condition>` that meets your needs. ``` Start-Job -ScriptBlock { do{ Invoke-Command -FilePath \\MyServer\run.ps1 -ComputerName MyServer -ArgumentList arg1, arg2 Start-Sleep 2 }while(<condition>) } ``` Alternatively, you could use the condition `$true` so it executes forever. You will have to stop the job later in the script when you no longer need it. ``` $job = Start-Job -ScriptBlock { do{ Invoke-Command -FilePath \\MyServer\run.ps1 -ComputerName MyServer -ArgumentList arg1, arg2 Start-Sleep 2 }while($true) } Stop-Job $job Remove-Job $job ``` I've added a `Start-Sleep 2` so it doesn't lock up your CPU as no idea what the script is doing - remove if not required.
49,017,321
I am running the following powershell command in a build step using TFS 2018. ``` Start-Job -ScriptBlock { Invoke-Command -FilePath \\MyServer\run.ps1 -ComputerName MyServer -ArgumentList arg1, arg2 } ``` Since I don't want the script to affect the build step it should simply fire and forget the script. Hence I am using `Start-Job`. But it seems that once the step is done the process is killed. Is there a way to maintain the process lifetime even though the build step is done or the build process is finished? Additional information... the powershell script should run on the remote server. The script itself triggers an .exe with parameters.
2018/02/27
[ "https://Stackoverflow.com/questions/49017321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621210/" ]
To simply *fire and forget*, invoke the script with `Invoke-Command -AsJob`: ``` Invoke-Command -AsJob -FilePath \\MyServer\run.ps1 -ComputerName MyServer -Args arg1, arg2 Start-Sleep 1 # !! Seemingly, this is necessary, as @doorman has discovered. ``` * This should kick off the script *remotely, asynchronously*, with a job getting created in the *local* session to monitor its execution. + ***Caveat***: The use of `Start-Sleep` - possibly with a *longer* wait time - is seemingly necessary in order for the remote process to be created before the calling script exits, but such a solution **may not be fully robust**, as there is no guaranteed timing. * Since you're not planning to monitor the remote execution, the *local* session terminating - and along with it the monitoring job - should't matter.
Why not something like this: ``` Invoke-Command -Filepath \\MyServer\Run.ps1 -Computername MyServer -Argumentlist Arg1,Arg2 -AsJob $JobCount = (get-job).Count Do { Start-Sleep -Seconds 1 $totalJobCompleted = (get-job | Where-Object {$_.state -eq "Completed"} | Where-Object {$_.Command -like "NAMEOFCOMMAND*"}).count } Until($totalJobCompleted -ge $JobCount) ```
49,017,321
I am running the following powershell command in a build step using TFS 2018. ``` Start-Job -ScriptBlock { Invoke-Command -FilePath \\MyServer\run.ps1 -ComputerName MyServer -ArgumentList arg1, arg2 } ``` Since I don't want the script to affect the build step it should simply fire and forget the script. Hence I am using `Start-Job`. But it seems that once the step is done the process is killed. Is there a way to maintain the process lifetime even though the build step is done or the build process is finished? Additional information... the powershell script should run on the remote server. The script itself triggers an .exe with parameters.
2018/02/27
[ "https://Stackoverflow.com/questions/49017321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621210/" ]
To simply *fire and forget*, invoke the script with `Invoke-Command -AsJob`: ``` Invoke-Command -AsJob -FilePath \\MyServer\run.ps1 -ComputerName MyServer -Args arg1, arg2 Start-Sleep 1 # !! Seemingly, this is necessary, as @doorman has discovered. ``` * This should kick off the script *remotely, asynchronously*, with a job getting created in the *local* session to monitor its execution. + ***Caveat***: The use of `Start-Sleep` - possibly with a *longer* wait time - is seemingly necessary in order for the remote process to be created before the calling script exits, but such a solution **may not be fully robust**, as there is no guaranteed timing. * Since you're not planning to monitor the remote execution, the *local* session terminating - and along with it the monitoring job - should't matter.
@doorman - PowerShell is natively a single threaded application. In almost all cases, this is a huge benefit. Even forcing multiple threads, you can see the child threads are always dependent on the main thread. If this wasn't the case, it would be very easy to create memory leaks. This is almost always a good thing as when you close the main thread, .Net will clean up all the other threads you may have forgotten about for you. You just happened to run across a case where this behaviour is not beneficial to your situation. There are a few ways to tackle the issue, but the easiest is probably to use the good ol' command prompt to launch an independent new instance not based at all on your original script. To do this, you can use invoke-expression in conjunction with 'cmd /c'. See Below: ``` invoke-expression 'cmd /c start powershell -NoProfile -windowstyle hidden -Command { $i = 0 while ($true) { if($i -gt 30) { break } else { $i | Out-File C:\Temp\IndependentSessionTest.txt -Append Start-Sleep -Seconds 1 $i++ } } } ' ``` This will start a new session, run the script you want, not show a window and not use your powershell profile when the script gets run. You will be able to see that even if you kill the original PowerShell session, this one will keep running. You can verify this by looking at the IndependentSessionTest.txt file after you close the main powershell window and see that the file keeps getting updated numbers. Hopefully this points you in the right direction. Here's some source links: [PowerShell launch script in new instance](https://stackoverflow.com/questions/23237473/powershell-launch-script-in-new-instance) [How to run a PowerShell script without displaying a window?](https://stackoverflow.com/questions/1802127/how-to-run-a-powershell-script-without-displaying-a-window)
18,081,332
Why would I ever run Html controls on the server? As in, why would I want to do this? ``` <p runat = "server">This is a paragraph.</p> ```
2013/08/06
[ "https://Stackoverflow.com/questions/18081332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303685/" ]
One reason you might want to use the HTML controls versus the server controls is to force the rendered HTML to be of a certain element. For example, a `GridView` by default will render as an HTML table, but you may want it to render as DIVs for a table-less layout. HTML controls give your more flexibility in the HTML output; which is one of the reasons people like ASP.NET MVC over ASP.NET WebForms, because you are controlling more of the end result instead of the ASP.NET engine deciding certain things for you. Obviously, with power comes responsibility, you will lose some of the conveniences of server controls.
If you wanted to reference it in the code-behind. Like this: ``` <p id="myParagraph", runat="server"> ... ``` and then in the code-behind: ``` this.myParagraph.Visible = false; ``` I'm not saying you'd set the `Visible` property, I just used it as an example. Now, the way you have the `<p>` marked up now, you wouldn't be able to do anything with it because it's missing the `id`.
18,081,332
Why would I ever run Html controls on the server? As in, why would I want to do this? ``` <p runat = "server">This is a paragraph.</p> ```
2013/08/06
[ "https://Stackoverflow.com/questions/18081332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303685/" ]
If you wanted to reference it in the code-behind. Like this: ``` <p id="myParagraph", runat="server"> ... ``` and then in the code-behind: ``` this.myParagraph.Visible = false; ``` I'm not saying you'd set the `Visible` property, I just used it as an example. Now, the way you have the `<p>` marked up now, you wouldn't be able to do anything with it because it's missing the `id`.
This allows you to set the value and control all attributes server-side ``` <p id="p" runat="server">Value<p> ``` Code Behind: ``` p.Visible = true; p.text = "NewValue"; p.attributes.add("style", "width:90px"); ``` [This link has more info](http://msdn.microsoft.com/en-us/library/7a9d6h4f%28v=vs.100%29.aspx)
18,081,332
Why would I ever run Html controls on the server? As in, why would I want to do this? ``` <p runat = "server">This is a paragraph.</p> ```
2013/08/06
[ "https://Stackoverflow.com/questions/18081332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303685/" ]
One reason you might want to use the HTML controls versus the server controls is to force the rendered HTML to be of a certain element. For example, a `GridView` by default will render as an HTML table, but you may want it to render as DIVs for a table-less layout. HTML controls give your more flexibility in the HTML output; which is one of the reasons people like ASP.NET MVC over ASP.NET WebForms, because you are controlling more of the end result instead of the ASP.NET engine deciding certain things for you. Obviously, with power comes responsibility, you will lose some of the conveniences of server controls.
This allows you to set the value and control all attributes server-side ``` <p id="p" runat="server">Value<p> ``` Code Behind: ``` p.Visible = true; p.text = "NewValue"; p.attributes.add("style", "width:90px"); ``` [This link has more info](http://msdn.microsoft.com/en-us/library/7a9d6h4f%28v=vs.100%29.aspx)
42,948,979
I would like to create routes that support query string. When i say support i mean, passing it to the next route some how. For example: given this route: `domain/home?lang=eng` and when moving to route `domain/about` i want it to keep the Query String and display `domain/about?lang=eng`. I was sure there's a built in functionality for this but after reading the docs and a lot of search on the net, i couldn't find an elegant solution. I'm using `[email protected]` and `[email protected]`
2017/03/22
[ "https://Stackoverflow.com/questions/42948979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3148807/" ]
For react-router 4.x, try `const { history } history.push('/about' + history.location.search)` To access `this.props.history`, make sure you have wrapped the component with `withRouter` HOC `import { withRouter } from 'react-router-dom' ... export default withRouter(component)` refer <https://github.com/ReactTraining/react-router/issues/2185>
You will have to "forward" query param on each page transition - bothering and you can easily forgot to... Instead, I would do this. * read stored/persisted `lang` preference. `localStorage` is good candidate here. Fallback to default language, when no preference is found * share `lang` via context, so that each and every component can read this value. * create some button (or whatever), which would modify this value Since you are using `redux`, I would pull `redux-persist` to persist this preference across page reloads.
55,647,767
I have very big Stream of versioned documents ordered by document id and version. E.g. Av1, Av2, Bv1, Cv1, Cv2 I have to convert this into another Stream whose records are aggregated by document id. A[v1, v2], B[v1], C[v1, V2] Can this be done without using `Collectors.groupBy()`? I don't want to use `groupBy()` because it will load all items in the stream into memory before grouping them. In theory, one need not load the whole stream in memory because it is ordered.
2019/04/12
[ "https://Stackoverflow.com/questions/55647767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322276/" ]
Here's a solution I came up with: ``` Stream<Document> stream = Stream.of( new Document("A", "v1"), new Document("A", "v2"), new Document("B", "v1"), new Document("C", "v1"), new Document("C", "v2") ); Iterator<Document> iterator = stream.iterator(); Stream<GroupedDocument> result = Stream.generate(new Supplier<GroupedDocument>() { Document lastDoc = null; @Override public GroupedDocument get() { try { Document doc = Optional.ofNullable(lastDoc).orElseGet(iterator::next); String id = doc.getId(); GroupedDocument gd = new GroupedDocument(doc.getId()); gd.getVersions().add(doc.getVersion()); if (!iterator.hasNext()) { return null; } while (iterator.hasNext() && (doc = iterator.next()).getId().equals(id)) { gd.getVersions().add(doc.getVersion()); } lastDoc = doc; return gd; } catch (NoSuchElementException ex) { return null; } } }); ``` Here are the `Document` and `GroupedDocument` classes: ``` class Document { private String id; private String version; public Document(String id, String version) { this.id = id; this.version = version; } public String getId() { return id; } public String getVersion() { return version; } } class GroupedDocument { private String id; private List<String> versions; public GroupedDocument(String id) { this.id = id; versions = new ArrayList<>(); } public String getId() { return id; } public List<String> getVersions() { return versions; } @Override public String toString() { return "GroupedDocument{" + "id='" + id + '\'' + ", versions=" + versions + '}'; } } ``` Note that the resulting stream is an infinite stream. After all the groups there will be an infinite number of `null`s. You can take all the elements that are not null by using `takeWhile` in Java 9, or see this [post](https://stackoverflow.com/questions/20746429/limit-a-stream-by-a-predicate).
Would a `Map<String, Stream<String>>` help you with what you need ? > > A - v1, v2 > > B - v1 > > C - v1, v2 > > > > ``` String[] docs = { "Av1", "Av2", "Bv1", "Cv1", "Cv2"}; Map<String, Stream<String>> map = Stream.<String>of(docs). map(s ->s.substring(0, 1)).distinct(). //leave only A B C collect(Collectors.toMap( s1 -> s1, //A B C as keys s1 ->Stream.<String>of(docs). //value is filtered stream of docs filter(s2 -> s1.substring(0, 1). equals(s2.substring(0, 1)) ). map(s3 -> s3.substring(1, s3.length())) //trim A B C )); ```
55,647,767
I have very big Stream of versioned documents ordered by document id and version. E.g. Av1, Av2, Bv1, Cv1, Cv2 I have to convert this into another Stream whose records are aggregated by document id. A[v1, v2], B[v1], C[v1, V2] Can this be done without using `Collectors.groupBy()`? I don't want to use `groupBy()` because it will load all items in the stream into memory before grouping them. In theory, one need not load the whole stream in memory because it is ordered.
2019/04/12
[ "https://Stackoverflow.com/questions/55647767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322276/" ]
You can use [`groupRuns`](http://amaembo.github.io/streamex/javadoc/one/util/streamex/StreamEx.html#groupRuns-java.util.function.BiPredicate-) in the [StreamEx library](https://github.com/amaembo/streamex) for this: ``` class Document { public String id; public int version; public Document(String id, int version) { this.id = id; this.version = version; } public String toString() { return "Document{"+id+version+ "}"; } } public class MyClass { private static List<Document> docs = asList( new Document("A", 1), new Document("A", 2), new Document("B", 1), new Document("C", 1), new Document("C", 2) ); public static void main(String args[]) { StreamEx<List<Document>> groups = StreamEx.of(docs).groupRuns((l, r) -> l.id.equals(r.id)); for (List<Document> grp: groups.collect(toList())) { out.println(grp); } } } ``` which outputs: > > [Document{A1}, Document{A2}] > > [Document{B1}] > > [Document{C1}, Document{C2}] > > > I can't verify this doesn't consume the entire stream, but I cannot imagine why it would need to given what `groupRuns` is meant to do.
Would a `Map<String, Stream<String>>` help you with what you need ? > > A - v1, v2 > > B - v1 > > C - v1, v2 > > > > ``` String[] docs = { "Av1", "Av2", "Bv1", "Cv1", "Cv2"}; Map<String, Stream<String>> map = Stream.<String>of(docs). map(s ->s.substring(0, 1)).distinct(). //leave only A B C collect(Collectors.toMap( s1 -> s1, //A B C as keys s1 ->Stream.<String>of(docs). //value is filtered stream of docs filter(s2 -> s1.substring(0, 1). equals(s2.substring(0, 1)) ). map(s3 -> s3.substring(1, s3.length())) //trim A B C )); ```
26,348,468
I'm trying to set up Minecraft Forge SDK. I need to set up the JAVA\_HOME variable: ``` kiwi@kiwi-gigabyte:~/Desktop/forge-1.7.10-10.13.0.1180-src$ export $JAVA_HOME '/usr/lib/jvm/java-7-openjdk-i386/bin' bash: export: `/usr/lib/jvm/java-7-openjdk-i386': invalid identifier bash: export: `/usr/lib/jvm/java-7-openjdk-i386/bin': invalid identifier ``` What am i doing wrong?
2014/10/13
[ "https://Stackoverflow.com/questions/26348468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3908500/" ]
The syntax is this: ``` export VAR='value' ``` So use ``` export JAVA_HOME='/usr/lib/jvm/java-7-openjdk-i386/bin' ```
If you've got Bash: ``` export JAVA_HOME='/usr/lib/jvm/java-7-openjdk-i386/bin' ``` See how that works. No dollar sign and use equals, only difference.
43,934,799
When I tried to install fresh Wordpress package in the local system(Window 10), I got this error: > > Fatal error: require(): Failed opening required > > 'C:\xampp\htdocs\wordpress/wp-blog-header.php' > (include\_path='.;C:\xampp\php\PEAR') > in C:\xampp\htdocs\wordpress\index.php on line 17 > > > For Localhost am using XAMPP server.
2017/05/12
[ "https://Stackoverflow.com/questions/43934799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8002137/" ]
It may be occurred due to some files are missing.. Download a fresh copy of the WordPress .zip file to your computer, unzip it, and use that to copy up all files and folders EXCEPT the wp-config.php file and the /wp-content/directory. You may need to delete the old wp-admin and wp-include folders. Note- Please backup files and database before doing any actions.
I faced the same error. The solution is to simply extract the WordPress zip folder content into `htdocs` ( if you are using xampp ) or into `www` (if you are using wampp ). Just do not extract it somewhere else and then into htdocs, or else it won't work.
34,846,276
I am trying to make a navbar `scrollToggle` after the window is scrolled `200px`. My code is as follows: ``` $(document).ready(function(){ $(window).scroll(function(){ if($(this).scrollTop() > 200){ $('.upper-header').slideToggle('slow'); } }); }); ``` Ideally the navbar would disappear after `200px` and re-appear whenever the window is scrolled up, so the user can always get the nav by scrolling up (even just a little).
2016/01/18
[ "https://Stackoverflow.com/questions/34846276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5803196/" ]
Basically all what you need to do is to have a flag or a control `toggleIt` to only make the `toggleSlide()` plays once as long as the flag is `true` if the scroll position is more than `200px`. Same thing for toggling the slide animation when the scroll position is less than or equal to `200px`, `slideToggle()` will only plays the animation when the flag `toggleIt` value is `false`, after we play it once we set the value of that flag to `true` so that first `slideToggle` for <= 200 won't plays again, and we can again play the `toggleSlide()` when `scrollTop()` is bigger than `200px`. [**JS Fiddle**](https://jsfiddle.net/Lbh901ud/1/) ```js $(document).ready(function() { // initializing a flag to control playign the slideToggle once var toggleIt = true; $(window).on('scroll', function() { // if the toggleIt flag is true and the scrollTop > 200 // play toggleSlide once, then turn the toggleIT flag to // false, so the animation won't keep playing. if (toggleIt && $(this).scrollTop() > 200) { $('.upper-header').slideToggle('slow'); toggleIt = false; // else if the toggle flag is false and scrollTop() less // or equal to 200, we play the animation and toggle the // toggleIt flag to false in order not to play the animation // more than once } else if (!toggleIt && $(this).scrollTop() <= 200) { $('.upper-header').slideToggle('slow'); toggleIt = true; } }); }); ``` ```css body { margin: 0; padding: 0; height: 1500px; } .upper-header { width: 100%; line-height: 50px; position: fixed; background-color: green; display: inline-element; color: white; text-align: center; } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <div class="upper-header">I'm the navbar</div> ```
This might provide a good start. I made it scroll after 300px, for effect -- watch the orange window. `[**jsFiddle Demo**](https://jsfiddle.net/wmd41Lac/)` **JS:** ``` var st, slid=false; function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; $(window).scroll(debounce(function(){ st = $(window).scrollTop(); $('#rpt').html( st ); if( !slid && st > 300){ slid = true; $('.upper-header').slideToggle('slow'); } if (slid && st < 100){ slid = false; $('.upper-header').slideToggle('slow'); } })); ``` **HTML:** ``` <div class="upper-header">M a i n H e a d e r</div> <div id="wrap"></div> <div id="rpt"></div> ``` **CSS:** ``` html,body{100%;} div{position:relative;} #wrap{height:2000px;} .upper-header{position:fixed;top:0;left:0;width:100%;height:50px;background:#222;color:#888;} #rpt{position:fixed;top:100px;right:0;height:40px;width:100px;background:wheat;} ``` --- Resources: <https://davidwalsh.name/javascript-debounce-function>
60,279,958
How can I show the next div with class `form_section` by clicking `.btn_next`? ```js $(".form_section").hide(); $(document).on("click", ".btn_next", function(e) { $(this).next(".form_section").show(); }); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="row form_section"> <div> <div></div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> <div class="row form_section"> <div> <div></div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> <div class="row form_section"> <div> <div></div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> ```
2020/02/18
[ "https://Stackoverflow.com/questions/60279958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10949054/" ]
first you need to hide current "`.form_section`" section (to the button which was clicked), then get the next `.form_section` to show. ``` <script> //$(".form_section").hide(); $(document).on("click", ".btn_next", function(e){ $(this).parents('.form_section').hide(); $(this).parents('.form_section').next().show(); }); </script> ```
To achieve this you need to traverse the DOM to retrieve the nearest parent `.form_section` to the button which was clicked, hide it, then get the next `.form_section` to show. To do that you can use a combination of `closest()`, `hide()`, `next()` and `show()`. Try this: ```js $(document).on("click", ".btn_next", function(e) { $(this).closest('.form_section').hide().next(".form_section").show(); }); ``` ```css .form_section { display: none; } .form_section:nth-of-type(1) { display: block; } ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="row form_section"> <div> <div>1</div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> <div class="row form_section"> <div> <div>2</div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> <div class="row form_section"> <div> <div>3</div> <div></div> <button class="btn btn-primary btn_next">SHOW NEXT SECTION</button> </div> </div> ``` Note the use of CSS to hide/show the relevant elements when the page loads. This is a better approach than using JS as it avoids the [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content).
9,032
I am trying to implement an adjustment to the default .phtml files that are shipped with magento. I am a little confused as to how the .phtml files are altered without adjusting them directly, consequently I am failing to get this to work. The example I will use is the account dashboard heading (found on `storeName.local/index.php/customer/account/index/`) MY ACCOUNT, I'd like to change it to [USERSNAME]'S ACCOUNT. To do this I have copied the contents of `customer/account/navigation.phtml` into the file path `myNamespace/modulename/account/navigation.phtml` on line 29 there is this code ``` <?php echo $this->__('My Account'); ?> my random text for testing ``` and added this to my modulename/layout.xml ``` <modulename_index_index> <reference name="left"> <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="namespace/modulename/account/navigation.phtml" /> </reference> </modulename_index_index> ``` THEN ``` <modulename_index_index> <reference name="customer_account_navigation"> <action method="insert"><type>simple</type><block>customer/account_navigation</block><template>namespace/modulename/account/navigation.phtml</template></action> </reference> <modulename_index_index> ``` These methods have not worked. To be honest I didn't expect it to but the way I have read the posts is that I need to apply the code from the phtml file which I am overriding into my module, followed by the equivalent file path held in its default module. How do I go about making adjustments Pages viewed to try and resolve issue [try 1](https://magento.stackexchange.com/questions/1411/calling-custom-phtml-file-in-footer) [try 2](https://stackoverflow.com/questions/8909702/magento-including-a-custom-phtml-file-in-view-phtml) [try 3](https://stackoverflow.com/questions/12230672/override-product-price-template-in-magento)
2013/10/07
[ "https://magento.stackexchange.com/questions/9032", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/2732/" ]
As far as I know the heading is located in the file `customer/account/dashboard.phtml`. To overwrite this from your custom extensions layout XML, or the `local.xml` please add the following ``` <customer_account_index> <reference name="customer_account_dashboard"> <action method="setTemplate"><template>[module]/customer/account/dashboard.phtml</template></action> </reference> </customer_account_index> ``` This will change the template file used from the default file to your custom file which, in this case, would be located at `app/design/frontend/[package]/[theme]/template/[module]/customer/account/dashboard.phtml`
I may have confused you earlier with my [overly long post](https://magento.stackexchange.com/a/8957/3408). Start by creating a new theme. Note the base theme is a folder called `app/design/frontend/default/base/`. Let's pretend your theme is "tony" and create a folder called `app/design/frontend/default/tony/`. Now go to the Magento admin, click on the menu System > Configuration, then click on Design. Fill the page in like this before saving. ![enter image description here](https://i.stack.imgur.com/4cArw.jpg) Your new theme is now active but looks exactly like the base theme. Copy the file `app/design/frontend/default/base/customer/account/navigation.phtml` to `app/design/frontend/default/tony/customer/account/navigation.phtml`. Make some edits to the new file and look again at your site, it should have changed! If not go to the admin menu System > Cache Management and turn off all caches until you have finished working on the site.
59,409,376
I would like to check every so often if exists a new version of my app, and if it´s, show a message to user. I use Firebase, connecting and comparing version from remote config with current version of app. This isn´t the problem, my problem is how to show the dialog at any time, in any activity. I have a BaseActivity, where I have methods to connect with firebase and to show the message when it answers. Furthermore, I have a method that executes every hour this update checking: ``` private void checkUpdate() { handlerCheckUpdate.postDelayed(() -> { getConfigFromFirebase(this); checkUpdate(); }, 3600000); } ``` And finally I have Activity1 and Activity2 that extends of BaseActivity. In my Activity1 I start the recursive checkUpdate method. The problem is that, if user is in Activity2 currently, when the message shows, it do it in Activity1 and not in Activity2. What is the best solution to do this?. Thank you very much!
2019/12/19
[ "https://Stackoverflow.com/questions/59409376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9686461/" ]
You can get this result with a `JOIN`, by self-joining on the `color` field, where the name in the second table is `jose`: ``` SELECT a1.name, a1.color FROM tableA a1 JOIN tableA a2 ON a2.color = a1.color AND a2.name = 'jose' ``` Output ``` name color jose red Rap red ``` [SQL Server demo on SQLFIddle](http://sqlfiddle.com/#!18/5f7e3/5) [Oracle demo on SQLFiddle](http://sqlfiddle.com/#!4/5f7e3/1)
If names have only one color, then you would seem to want: ``` select a.* from tableA a where a.color = (select a2.color from tableA a2 where a2.name = 'jose'); ``` You might want to add another condition that `a.name <> 'jose'` if you don't want to return that row.
59,409,376
I would like to check every so often if exists a new version of my app, and if it´s, show a message to user. I use Firebase, connecting and comparing version from remote config with current version of app. This isn´t the problem, my problem is how to show the dialog at any time, in any activity. I have a BaseActivity, where I have methods to connect with firebase and to show the message when it answers. Furthermore, I have a method that executes every hour this update checking: ``` private void checkUpdate() { handlerCheckUpdate.postDelayed(() -> { getConfigFromFirebase(this); checkUpdate(); }, 3600000); } ``` And finally I have Activity1 and Activity2 that extends of BaseActivity. In my Activity1 I start the recursive checkUpdate method. The problem is that, if user is in Activity2 currently, when the message shows, it do it in Activity1 and not in Activity2. What is the best solution to do this?. Thank you very much!
2019/12/19
[ "https://Stackoverflow.com/questions/59409376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9686461/" ]
You can get this result with a `JOIN`, by self-joining on the `color` field, where the name in the second table is `jose`: ``` SELECT a1.name, a1.color FROM tableA a1 JOIN tableA a2 ON a2.color = a1.color AND a2.name = 'jose' ``` Output ``` name color jose red Rap red ``` [SQL Server demo on SQLFIddle](http://sqlfiddle.com/#!18/5f7e3/5) [Oracle demo on SQLFiddle](http://sqlfiddle.com/#!4/5f7e3/1)
I think the best way is "CTE" : ``` with cte1 as ( select 1 as RowToJoin, name, color from tableA ), cte2 as ( select 1 as RowToJoin, color name from tableA where name='jose' ) select c1.name, c1.color from cte1 c1 join cte2 c2 on c2.RowToJoin = c1.RowToJoin where c1.name <> c2.name ``` It looks as something hard, but it's simple. Try to read about it.!
44,688,322
I'm trying to create a UITableViewCell which contains 3 subviews - a button, and two labels. The table view cell should look like this: ``` Button --Label 1----------- --Label 1 continued-- --Label 2----------------- --Label 2 continued ------ ``` Currently, I have button one, with leading, top, width, and height constraints pinning it to the top left. Label 1 has a leading constraint from the Button, top, left and bottom constraints to the content view. Label 1 has number of lines set to 0 and can dynamically expand, and this works so far. I'm having trouble figuring out how to set constraints for Label 2 so that it is always below Label 1 and can also expand. I've tried setting a top constraint on Label 2 to the bottom of Label 1, with all other sides pinned to the content view, but this gave the error that height and vertical position were ambiguous. What constraints do I need to add for Label 2?
2017/06/22
[ "https://Stackoverflow.com/questions/44688322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7587035/" ]
**tl;dr** no particular difference, but if I were to choose, I'd use `bin/rails` There's little to no difference. Let us see. `DISABLE_SPRING=1 bin/rails --version`: `bin/rails`: [`require_relative '../config/boot'`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/generators/rails/app/templates/bin/rails.tt#L2) `config/boot`: [`require 'bundler/setup'`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/generators/rails/app/templates/config/boot.rb.tt#L3) `bundler/setup`: [`Bundler.setup`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/setup.rb#L10) `Bundler.setup`: [`definition.validate_runtime!`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler.rb#L101) `Bundler.definition`: [`Definition.build`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler.rb#L135) `Bundler::Definition.build`: [`Dsl.evaluate`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/definition.rb#L35) `Bundler::Dsl.evaluate`: [`builder.eval_gemfile`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/dsl.rb#L12) `Bundler::Dsl#eval_gemfile`: [`instance_eval`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/dsl.rb#L47) After `require 'bundler/setup'`, trying to `gem 'rails', 'x.y.z'` results in: > > \*\*\* Gem::LoadError Exception: can't activate rails (= x.y.z), already activated rails-5.1.3. Make sure all dependencies are added to Gemfile. > > > With `bundle exec rails --version`, we end up running `bin/rails` anyway: `~/.gem/ruby/x.y.z/bin/rails`: [`load Gem.activate_bin_path('railties', 'rails', version)`](https://github.com/rubygems/rubygems/blob/v2.7.7/lib/rubygems/installer.rb#L747) `exe/rails`: [`require 'rails/cli'`](https://github.com/rails/rails/blob/v5.2.1/railties/exe/rails#L10) `rails/cli`: [`Rails::AppLoader.exec_app`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/cli.rb#L7) `Rails::AppLoader.exec_app`: [`exec RUBY, 'bin/rails', \*ARGV](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/app_loader.rb#L53) Also, do note the message one can found in the [last file](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/app_loader.rb#L13-L14): > > Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that should be used instead of the Bundler-generated `rails` binstub. > > > So, at the end of the day there's no difference. But considering the fact that Rails goes through the trouble of shipping its own binstubs, I'd favor `bin/rails` alternative. Also, it autocompletes better. And, > > App executables now live in the `bin/` directory: `bin/bundle`, `bin/rails`, `bin/rake`. Run `rake rails:update:bin` to add these executables to your own app. `script/rails` is gone from new apps. > > > Running executables within your app ensures they use your app's Ruby version and its bundled gems, and it ensures your production deployment tools only need to execute a single script. No more having to carefully `cd` to the app dir and run `bundle exec ...`. > > > Rather than treating `bin/` as a junk drawer for generated "binstubs", bundler 1.3 adds support for generating stubs for just the executables you actually use: `bundle binstubs unicorn` generates `bin/unicorn`. Add that executable to git and version it just like any other app code. > > > <https://github.com/rails/rails/blob/4-0-stable/railties/CHANGELOG.md>
Bundle exec is a Bundler command. You should use bundle exec in all the cases as it > > bundle-exec - Execute a command in the context of the bundle > > > More info can be found here: <http://bundler.io/v1.15/bundle_exec.html> bin/rails might work but only if all the required gems/executables are present on your system without the scope of the bundle. In short if you have all the gems installed on your system (eg. globally) the bin/rails will work (but might generate conflicts). If you however installed them only within the scope of the bundle they might not work. `bundle exec` ensures that the gems and their versions from your Gemfile are being used.
44,688,322
I'm trying to create a UITableViewCell which contains 3 subviews - a button, and two labels. The table view cell should look like this: ``` Button --Label 1----------- --Label 1 continued-- --Label 2----------------- --Label 2 continued ------ ``` Currently, I have button one, with leading, top, width, and height constraints pinning it to the top left. Label 1 has a leading constraint from the Button, top, left and bottom constraints to the content view. Label 1 has number of lines set to 0 and can dynamically expand, and this works so far. I'm having trouble figuring out how to set constraints for Label 2 so that it is always below Label 1 and can also expand. I've tried setting a top constraint on Label 2 to the bottom of Label 1, with all other sides pinned to the content view, but this gave the error that height and vertical position were ambiguous. What constraints do I need to add for Label 2?
2017/06/22
[ "https://Stackoverflow.com/questions/44688322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7587035/" ]
`bundle exec` just ensures that all gems in Gemfile are installed (globally or on userspace or in `vendor/bundle` directory of the project) when running the command. It's explained in more detail in <https://bundler.io/man/bundle-exec.1.html> (especifically <https://bundler.io/man/bundle-exec.1.html#BUNDLE-INSTALL-BINSTUBS> section): > > ### Bundle Install --binstubs > > > If you use the `--binstubs` flag in `bundle install`, Bundler will automatically create a directory (which defaults to `app_root/bin`) containing all of the executables available from gems in the bundle. > > > After using `--binstubs`, `bin/rspec spec/my_spec.rb` is identical to > `bundle exec rspec spec/my_spec.rb`. > > > Binstubs may also include other customizations like loading `spring` gem, which preloads and speeds up the Rails application.
Bundle exec is a Bundler command. You should use bundle exec in all the cases as it > > bundle-exec - Execute a command in the context of the bundle > > > More info can be found here: <http://bundler.io/v1.15/bundle_exec.html> bin/rails might work but only if all the required gems/executables are present on your system without the scope of the bundle. In short if you have all the gems installed on your system (eg. globally) the bin/rails will work (but might generate conflicts). If you however installed them only within the scope of the bundle they might not work. `bundle exec` ensures that the gems and their versions from your Gemfile are being used.
44,688,322
I'm trying to create a UITableViewCell which contains 3 subviews - a button, and two labels. The table view cell should look like this: ``` Button --Label 1----------- --Label 1 continued-- --Label 2----------------- --Label 2 continued ------ ``` Currently, I have button one, with leading, top, width, and height constraints pinning it to the top left. Label 1 has a leading constraint from the Button, top, left and bottom constraints to the content view. Label 1 has number of lines set to 0 and can dynamically expand, and this works so far. I'm having trouble figuring out how to set constraints for Label 2 so that it is always below Label 1 and can also expand. I've tried setting a top constraint on Label 2 to the bottom of Label 1, with all other sides pinned to the content view, but this gave the error that height and vertical position were ambiguous. What constraints do I need to add for Label 2?
2017/06/22
[ "https://Stackoverflow.com/questions/44688322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7587035/" ]
**tl;dr** no particular difference, but if I were to choose, I'd use `bin/rails` There's little to no difference. Let us see. `DISABLE_SPRING=1 bin/rails --version`: `bin/rails`: [`require_relative '../config/boot'`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/generators/rails/app/templates/bin/rails.tt#L2) `config/boot`: [`require 'bundler/setup'`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/generators/rails/app/templates/config/boot.rb.tt#L3) `bundler/setup`: [`Bundler.setup`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/setup.rb#L10) `Bundler.setup`: [`definition.validate_runtime!`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler.rb#L101) `Bundler.definition`: [`Definition.build`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler.rb#L135) `Bundler::Definition.build`: [`Dsl.evaluate`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/definition.rb#L35) `Bundler::Dsl.evaluate`: [`builder.eval_gemfile`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/dsl.rb#L12) `Bundler::Dsl#eval_gemfile`: [`instance_eval`](https://github.com/bundler/bundler/blob/v1.16.5/lib/bundler/dsl.rb#L47) After `require 'bundler/setup'`, trying to `gem 'rails', 'x.y.z'` results in: > > \*\*\* Gem::LoadError Exception: can't activate rails (= x.y.z), already activated rails-5.1.3. Make sure all dependencies are added to Gemfile. > > > With `bundle exec rails --version`, we end up running `bin/rails` anyway: `~/.gem/ruby/x.y.z/bin/rails`: [`load Gem.activate_bin_path('railties', 'rails', version)`](https://github.com/rubygems/rubygems/blob/v2.7.7/lib/rubygems/installer.rb#L747) `exe/rails`: [`require 'rails/cli'`](https://github.com/rails/rails/blob/v5.2.1/railties/exe/rails#L10) `rails/cli`: [`Rails::AppLoader.exec_app`](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/cli.rb#L7) `Rails::AppLoader.exec_app`: [`exec RUBY, 'bin/rails', \*ARGV](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/app_loader.rb#L53) Also, do note the message one can found in the [last file](https://github.com/rails/rails/blob/v5.2.1/railties/lib/rails/app_loader.rb#L13-L14): > > Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that should be used instead of the Bundler-generated `rails` binstub. > > > So, at the end of the day there's no difference. But considering the fact that Rails goes through the trouble of shipping its own binstubs, I'd favor `bin/rails` alternative. Also, it autocompletes better. And, > > App executables now live in the `bin/` directory: `bin/bundle`, `bin/rails`, `bin/rake`. Run `rake rails:update:bin` to add these executables to your own app. `script/rails` is gone from new apps. > > > Running executables within your app ensures they use your app's Ruby version and its bundled gems, and it ensures your production deployment tools only need to execute a single script. No more having to carefully `cd` to the app dir and run `bundle exec ...`. > > > Rather than treating `bin/` as a junk drawer for generated "binstubs", bundler 1.3 adds support for generating stubs for just the executables you actually use: `bundle binstubs unicorn` generates `bin/unicorn`. Add that executable to git and version it just like any other app code. > > > <https://github.com/rails/rails/blob/4-0-stable/railties/CHANGELOG.md>
`bundle exec` just ensures that all gems in Gemfile are installed (globally or on userspace or in `vendor/bundle` directory of the project) when running the command. It's explained in more detail in <https://bundler.io/man/bundle-exec.1.html> (especifically <https://bundler.io/man/bundle-exec.1.html#BUNDLE-INSTALL-BINSTUBS> section): > > ### Bundle Install --binstubs > > > If you use the `--binstubs` flag in `bundle install`, Bundler will automatically create a directory (which defaults to `app_root/bin`) containing all of the executables available from gems in the bundle. > > > After using `--binstubs`, `bin/rspec spec/my_spec.rb` is identical to > `bundle exec rspec spec/my_spec.rb`. > > > Binstubs may also include other customizations like loading `spring` gem, which preloads and speeds up the Rails application.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
The GIMP - Gnu Image Manipulation Program. Yet another fine example of why you don't let the devs name the product. All three platforms supported, lots of powerful tools, both Free and free. <https://www.gimp.org/downloads/>
Take a look at these programs: * darktable * RAWtherapee * Corel Aftershot Pro * affinity photo * Portrait Pro * Corel Paint Shop Pro * Gimp
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
You might look at darktable: <https://www.darktable.org>.
I use GIMP as well for advanced editing, but for simpler things I sometimes will reach for something more lightweight (both free): * [Paint.NET](https://www.getpaint.net/) - basic layering, color filters, etc * [Inkscape](https://inkscape.org/) - vector/path editing, handles wide variety of formats
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
You might look at darktable: <https://www.darktable.org>.
You probably want [<https://www.photopea.com>](https://www.photopea.com "example") online editor. Very similar to photoshop.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
The GIMP - Gnu Image Manipulation Program. Yet another fine example of why you don't let the devs name the product. All three platforms supported, lots of powerful tools, both Free and free. <https://www.gimp.org/downloads/>
If you have iOS you can buy the [ProCreate App](https://procreate.art/) for ~ 15 Euros (paid once, no subscription). It works best with the Apple Pencil. On Android there is, for instance [AutoDesk SketchBook](https://play.google.com/store/apps/details?id=com.adsk.sketchbook). Many, many other apps are available for both mobile platforms.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
You might look at darktable: <https://www.darktable.org>.
If you have iOS you can buy the [ProCreate App](https://procreate.art/) for ~ 15 Euros (paid once, no subscription). It works best with the Apple Pencil. On Android there is, for instance [AutoDesk SketchBook](https://play.google.com/store/apps/details?id=com.adsk.sketchbook). Many, many other apps are available for both mobile platforms.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
I use GIMP as well for advanced editing, but for simpler things I sometimes will reach for something more lightweight (both free): * [Paint.NET](https://www.getpaint.net/) - basic layering, color filters, etc * [Inkscape](https://inkscape.org/) - vector/path editing, handles wide variety of formats
Take a look at these programs: * darktable * RAWtherapee * Corel Aftershot Pro * affinity photo * Portrait Pro * Corel Paint Shop Pro * Gimp
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
If you have iOS you can buy the [ProCreate App](https://procreate.art/) for ~ 15 Euros (paid once, no subscription). It works best with the Apple Pencil. On Android there is, for instance [AutoDesk SketchBook](https://play.google.com/store/apps/details?id=com.adsk.sketchbook). Many, many other apps are available for both mobile platforms.
You probably want [<https://www.photopea.com>](https://www.photopea.com "example") online editor. Very similar to photoshop.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
I use GIMP as well for advanced editing, but for simpler things I sometimes will reach for something more lightweight (both free): * [Paint.NET](https://www.getpaint.net/) - basic layering, color filters, etc * [Inkscape](https://inkscape.org/) - vector/path editing, handles wide variety of formats
If you have iOS you can buy the [ProCreate App](https://procreate.art/) for ~ 15 Euros (paid once, no subscription). It works best with the Apple Pencil. On Android there is, for instance [AutoDesk SketchBook](https://play.google.com/store/apps/details?id=com.adsk.sketchbook). Many, many other apps are available for both mobile platforms.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
I use GIMP as well for advanced editing, but for simpler things I sometimes will reach for something more lightweight (both free): * [Paint.NET](https://www.getpaint.net/) - basic layering, color filters, etc * [Inkscape](https://inkscape.org/) - vector/path editing, handles wide variety of formats
You probably want [<https://www.photopea.com>](https://www.photopea.com "example") online editor. Very similar to photoshop.
58,667
This is, essentially, a Dock replacer on steroids - dating back to before the Dock even existed. I've been using [DragThing](https://www.dragthing.com/english/about.html) since v1.0 in the mid 1990's so it's fair to say I'm rather used to it & will be sad to see it finally die after macOS 10.15. The author has announced it will receive no further updates & it is no longer available to purchase. I'm hunting for anything vaguely similar - essentially a replacement for the Dock or the even more cumbersome Lauchpad, which I cannot bear [literally 10 screens of apps just apparently scattered in at random, whether I want them there or not]. Screenshots - From the DragThing site, showing various display options - [![enter image description here](https://i.stack.imgur.com/fk6s5.png)](https://i.stack.imgur.com/fk6s5.png) My own, very minimalist way I use it - [![enter image description here](https://i.stack.imgur.com/3QXG5.png)](https://i.stack.imgur.com/3QXG5.png) Each of these tiny labels can be anchored anywhere on screen, follow you to any Space, be hidden in apps you don't want it to interfere with & when clicked, each one pops open to reveal a completely customisable set of tabs which can contain almost anything - folders, apps, docs, pictures etc Right click has options & key commands can be added to any item to launch, hide, get info, reveal original etc. [![enter image description here](https://i.stack.imgur.com/xc9Xc.png)](https://i.stack.imgur.com/xc9Xc.png) *Late edit:* As I now discover I don't have a Mac in the house that will be able to run Catalina, the point has become moot. *Late Late edit* As I now have a new M1 iMac on order I shall be forced to address this very soon :\ If anyone knows Apple Silicon/Big Sur compatible apps, the info would be most welcome.
2019/04/22
[ "https://softwarerecs.stackexchange.com/questions/58667", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/22850/" ]
The GIMP - Gnu Image Manipulation Program. Yet another fine example of why you don't let the devs name the product. All three platforms supported, lots of powerful tools, both Free and free. <https://www.gimp.org/downloads/>
You might look at darktable: <https://www.darktable.org>.
35,296,213
in Windows 10 app I try to read string from .txt file and set the text to RichEditBox: Code variant 1: ``` var read = await FileIO.ReadTextAsync(file, Windows.Storage.Streams.UnicodeEncoding.Utf8); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, read); ``` Code variant 2: ``` var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); ulong size = stream.Size; using (var inputStream = stream.GetInputStreamAt(0)) { using (var dataReader = new Windows.Storage.Streams.DataReader(inputStream)) { dataReader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8; uint numBytesLoaded = await dataReader.LoadAsync((uint)size); string text = dataReader.ReadString(numBytesLoaded); txt.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, text); } } ``` On some files I have this error - "No mapping for the Unicode character exists in the target multi-byte code page" I found one solution: ``` IBuffer buffer = await FileIO.ReadBufferAsync(file); DataReader reader = DataReader.FromBuffer(buffer); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string text = Encoding.UTF8.GetString(fileContent, 0, fileContent.Length); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, text); ``` But with this code the text looks like question marks in rhombus. How I can read and display same text files in normal encoding?
2016/02/09
[ "https://Stackoverflow.com/questions/35296213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5235485/" ]
Challenge here is the encoding and it depends how much accuracy you need for your application. If you need something fast and simple you can adapt this [answer](https://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding) ``` public static Encoding GetEncoding(byte[4] bom) { // Analyze the BOM if (bom[0] == 0x2b && bom[1] == 0x2f && bom[2] == 0x76) return Encoding.UTF7; if (bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf) return Encoding.UTF8; if (bom[0] == 0xff && bom[1] == 0xfe) return Encoding.Unicode; //UTF-16LE if (bom[0] == 0xfe && bom[1] == 0xff) return Encoding.BigEndianUnicode; //UTF-16BE if (bom[0] == 0 && bom[1] == 0 && bom[2] == 0xfe && bom[3] == 0xff) return Encoding.UTF32; return Encoding.ASCII; } async System.Threading.Tasks.Task MyMethod() { FileOpenPicker openPicker = new FileOpenPicker(); StorageFile file = await openPicker.PickSingleFileAsync(); IBuffer buffer = await FileIO.ReadBufferAsync(file); DataReader reader = DataReader.FromBuffer(buffer); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string text = GetEncoding(new byte[4] {fileContent[0], fileContent[1], fileContent[2], fileContent[3] }).GetString(fileContent); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, text); //.. } ``` If you need something more accurate you should think to port to UWP a porting [to .Net](https://github.com/superstrom/chardetsharp) of [Mozilla charset detector](http://www-archive.mozilla.org/projects/intl/chardet.html) as already mentioned in this [answer](https://stackoverflow.com/questions/4520184/how-to-detect-the-character-encoding-of-a-text-file) Please note that the code above is just a sample it is missing all the using statements for types implementing IDisposable and it also should have been wrote in a more consistent way hth -g
Solution: 1) I made a port of Mozilla Universal Charset Detector to UWP (added to [Nuget](https://www.nuget.org/packages/UDE.CSharp.UWP/)) ``` ICharsetDetector cdet = new CharsetDetector(); cdet.Feed(fileContent, 0, fileContent.Length); cdet.DataEnd(); ``` 2) Nuget library [Portable.Text.Encoding](https://www.nuget.org/packages/Portable.Text.Encoding/) ``` if (cdet.Charset != null) string text = Portable.Text.Encoding.GetEncoding(cdet.Charset).GetString(fileContent, 0, fileContent.Length); ``` That's all. Now unicode ecnodings (include cp1251, cp1252) - works good ))
35,296,213
in Windows 10 app I try to read string from .txt file and set the text to RichEditBox: Code variant 1: ``` var read = await FileIO.ReadTextAsync(file, Windows.Storage.Streams.UnicodeEncoding.Utf8); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, read); ``` Code variant 2: ``` var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); ulong size = stream.Size; using (var inputStream = stream.GetInputStreamAt(0)) { using (var dataReader = new Windows.Storage.Streams.DataReader(inputStream)) { dataReader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8; uint numBytesLoaded = await dataReader.LoadAsync((uint)size); string text = dataReader.ReadString(numBytesLoaded); txt.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, text); } } ``` On some files I have this error - "No mapping for the Unicode character exists in the target multi-byte code page" I found one solution: ``` IBuffer buffer = await FileIO.ReadBufferAsync(file); DataReader reader = DataReader.FromBuffer(buffer); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string text = Encoding.UTF8.GetString(fileContent, 0, fileContent.Length); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, text); ``` But with this code the text looks like question marks in rhombus. How I can read and display same text files in normal encoding?
2016/02/09
[ "https://Stackoverflow.com/questions/35296213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5235485/" ]
Challenge here is the encoding and it depends how much accuracy you need for your application. If you need something fast and simple you can adapt this [answer](https://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding) ``` public static Encoding GetEncoding(byte[4] bom) { // Analyze the BOM if (bom[0] == 0x2b && bom[1] == 0x2f && bom[2] == 0x76) return Encoding.UTF7; if (bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf) return Encoding.UTF8; if (bom[0] == 0xff && bom[1] == 0xfe) return Encoding.Unicode; //UTF-16LE if (bom[0] == 0xfe && bom[1] == 0xff) return Encoding.BigEndianUnicode; //UTF-16BE if (bom[0] == 0 && bom[1] == 0 && bom[2] == 0xfe && bom[3] == 0xff) return Encoding.UTF32; return Encoding.ASCII; } async System.Threading.Tasks.Task MyMethod() { FileOpenPicker openPicker = new FileOpenPicker(); StorageFile file = await openPicker.PickSingleFileAsync(); IBuffer buffer = await FileIO.ReadBufferAsync(file); DataReader reader = DataReader.FromBuffer(buffer); byte[] fileContent = new byte[reader.UnconsumedBufferLength]; reader.ReadBytes(fileContent); string text = GetEncoding(new byte[4] {fileContent[0], fileContent[1], fileContent[2], fileContent[3] }).GetString(fileContent); txt.Document.SetText(Windows.UI.Text.TextSetOptions.None, text); //.. } ``` If you need something more accurate you should think to port to UWP a porting [to .Net](https://github.com/superstrom/chardetsharp) of [Mozilla charset detector](http://www-archive.mozilla.org/projects/intl/chardet.html) as already mentioned in this [answer](https://stackoverflow.com/questions/4520184/how-to-detect-the-character-encoding-of-a-text-file) Please note that the code above is just a sample it is missing all the using statements for types implementing IDisposable and it also should have been wrote in a more consistent way hth -g
``` StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/FontFiles/" + fileName)); using (var inputStream = await file.OpenReadAsync()) using (var classicStream = inputStream.AsStreamForRead()) using (var streamReader = new StreamReader(classicStream)) { while (streamReader.Peek() >= 0) { line = streamReader.ReadLine(); } } ```