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
59,702
It's my 17th birthday and you're invited to my party! And as always at parties, there will be cake. One cake... And you need as much of it as possible. As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat...
2015/10/05
[ "https://codegolf.stackexchange.com/questions/59702", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/32686/" ]
Eidetic, Python 2 ================= ``` import random, math, sys, json total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:]) #try: # inp_f = open("./data/Eidetic.json", "r") # out = json.load(inp_f) #except (IOError, ValueError): out = {"last_cake": 0, "runs": 0, ...
ALittleExtra, sh ---------------- ``` #!/bin/sh fair=$(expr $2 / $4) myextra=$(expr $2 / $3) want=$(expr $fair + $myextra) echo $(($want<$2?$want:$2)) ``` I just want a bit more, gets less greedy as cake dwindles
59,702
It's my 17th birthday and you're invited to my party! And as always at parties, there will be cake. One cake... And you need as much of it as possible. As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat...
2015/10/05
[ "https://codegolf.stackexchange.com/questions/59702", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/32686/" ]
Gentleman, Java =============== ``` import static java.lang.Integer.parseInt; import java.io.*; import java.util.*; public class Gentleman{ private final static String FILE_NAME = "data/Gentleman.txt"; static { new File("data").mkdir(); } public static void main(String[] args) throws Excepti...
A Little Off The Top, Python 2 ============================== ``` import math, sys total_degrees, degrees_left, total_people, people_left = map(int, sys.argv[1:]) def get_equal_share(total_degrees, people): return int(math.ceil(total_degrees/float(people))) def noms(total_degrees, degrees_left, people): bid = g...
59,702
It's my 17th birthday and you're invited to my party! And as always at parties, there will be cake. One cake... And you need as much of it as possible. As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat...
2015/10/05
[ "https://codegolf.stackexchange.com/questions/59702", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/32686/" ]
Bob Barker, Java ================ ``` public class BobBarker{ public static void main(String[] args){ System.out.println((int)Math.floor(Integer.parseInt(args[1]) * .84)); } } ``` This is probably going to be replaced with a more thought-out solution later, but I'm curious if this will work. This is ...
**Give me the cake, Bash** ``` #!/bin/bash echo 3594 ```
59,702
It's my 17th birthday and you're invited to my party! And as always at parties, there will be cake. One cake... And you need as much of it as possible. As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat...
2015/10/05
[ "https://codegolf.stackexchange.com/questions/59702", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/32686/" ]
Slim, Python 2 ============== ``` print 0 ``` This bot's on a diet.
Try to Win, C++ =============== ``` #include<iostream> #include<stdlib.h> using namespace std; int main(int argc, char *argv[]) { int td, dl, tp, pl; td = atoi(argv[1]); dl = atoi(argv[2]); tp = atoi(argv[3]); pl = atoi(argv[4]); if (pl == 1) { cout << dl; return 0; } ...
59,702
It's my 17th birthday and you're invited to my party! And as always at parties, there will be cake. One cake... And you need as much of it as possible. As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat...
2015/10/05
[ "https://codegolf.stackexchange.com/questions/59702", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/32686/" ]
SadBot :(, C++ ============== ``` #include<iostream> #include<cstdlib> #include<stdlib.h> int main(int argc, char**argv) { if (argc!=5){std::cout<<"Incorrect number of arguments";return 1;} double list[4]; list[0]= atof(argv[1]); // total Degrees list[1]= atof(argv[2]); // degrees left list[2]= a...
**Give me the cake, Bash** ``` #!/bin/bash echo 3594 ```
57,844,196
hey team i am trying to extract a list of my windows updates (not only hotfix) using powershell. when running Get-HotFix i am getting only the Microsoft HF IDs list and not the list you can view in the Control Panel. any help is much appreciated
2019/09/08
[ "https://Stackoverflow.com/questions/57844196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2998102/" ]
You forgot scoping the `.map` expression ``` <ul> {suggestionList.length ? // v React.Fragment <> <li className="header">Suggestions</li> // v start scope {} {suggestionList.map((item) => <li key={item.id} onClick={this.handleSuggestClick(item)} dangerouslySetInn...
You need to add curly brackets `{}` between two JSX tags to add JS code like so: ``` <ul> {suggestionList.length ? <li className="header">Suggestions</li> // <--- compiler says error from here {suggestionList.map((item) => <li key={item.id} onClick={this.handleSuggestClick(it...
57,844,196
hey team i am trying to extract a list of my windows updates (not only hotfix) using powershell. when running Get-HotFix i am getting only the Microsoft HF IDs list and not the list you can view in the Control Panel. any help is much appreciated
2019/09/08
[ "https://Stackoverflow.com/questions/57844196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2998102/" ]
You forgot scoping the `.map` expression ``` <ul> {suggestionList.length ? // v React.Fragment <> <li className="header">Suggestions</li> // v start scope {} {suggestionList.map((item) => <li key={item.id} onClick={this.handleSuggestClick(item)} dangerouslySetInn...
Wrap in one section like template and add {} -------------------------------------------- Try this, tell me if it work :) ``` <ul> {suggestionList.length ? <template> <li className="header">Suggestions</li> {suggestionList.map((item) => <li key={item.id} onClick={this.han...
31,466,720
I have this project that is just a Web API project. At some point in the past I removed the HelpPages and I made the app use OWIN. Now I have been asked to add API HelpPages back in which I have done. I have set my **Startup** class to look a bit like this: ``` public void Configuration(IAppBuilder app) { // Need...
2015/07/17
[ "https://Stackoverflow.com/questions/31466720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303170/" ]
I have the same problem. If I added > > GlobalConfiguration.Configure(WebApiConfig.Register) > > > in Startup class (I don't use global.asax) everything worked properly. I hope this will help you, too.
If you don't have access to WebApiConfig.Register, which I didn't with my Owin WebApi project, the following code seems to work for me. ``` GlobalConfiguration.Configure((config) => { config.MapHttpAttributeRoutes(); }); ```
2,036,206
${\sin^2(x)\over \tan^2(x)}$ I did this and then got stuck. Could someone give me some hints please?
2016/11/29
[ "https://math.stackexchange.com/questions/2036206", "https://math.stackexchange.com", "https://math.stackexchange.com/users/379666/" ]
Good job at arriving at $${1-\cos^2(x)\over \sec^2(x)-1}= {\sin^2(x)\over \tan^2(x)}$$ We know that $\tan x = \dfrac {\sin x}{\cos x}.$ So.... $${\sin^2(x)\over \tan^2(x)} = \frac{\sin^2 x}{\frac{\sin^2 x}{\cos^2 x}}= \cos^2 x = 1-\sin^2 x$$
we have $$\frac{1}{\sec(x)^2-1}=\frac{\cos(x)^2}{1-\cos(x)^2}$$ and from both we get $$\cos(x)^2=1-\sin(x)^2$$
2,036,206
${\sin^2(x)\over \tan^2(x)}$ I did this and then got stuck. Could someone give me some hints please?
2016/11/29
[ "https://math.stackexchange.com/questions/2036206", "https://math.stackexchange.com", "https://math.stackexchange.com/users/379666/" ]
For the equation: $$\frac{1-\cos^2x}{\sec^2x-1}$$ Multiply the numerator and denominator by $\cos^2x$ We now get: $$\frac{\cos^2x-\cos^4x}{1-\cos^2x}$$ Separate this into two fractions: $$\frac{\cos^2x}{\sin^2x} - \frac{\cos^4x}{\sin^2x}$$ This can then be converted to: $$\cot^2x - \cot^2x\cos^2x$$ We take $\cot^...
we have $$\frac{1}{\sec(x)^2-1}=\frac{\cos(x)^2}{1-\cos(x)^2}$$ and from both we get $$\cos(x)^2=1-\sin(x)^2$$
2,036,206
${\sin^2(x)\over \tan^2(x)}$ I did this and then got stuck. Could someone give me some hints please?
2016/11/29
[ "https://math.stackexchange.com/questions/2036206", "https://math.stackexchange.com", "https://math.stackexchange.com/users/379666/" ]
Good job at arriving at $${1-\cos^2(x)\over \sec^2(x)-1}= {\sin^2(x)\over \tan^2(x)}$$ We know that $\tan x = \dfrac {\sin x}{\cos x}.$ So.... $${\sin^2(x)\over \tan^2(x)} = \frac{\sin^2 x}{\frac{\sin^2 x}{\cos^2 x}}= \cos^2 x = 1-\sin^2 x$$
For the equation: $$\frac{1-\cos^2x}{\sec^2x-1}$$ Multiply the numerator and denominator by $\cos^2x$ We now get: $$\frac{\cos^2x-\cos^4x}{1-\cos^2x}$$ Separate this into two fractions: $$\frac{\cos^2x}{\sin^2x} - \frac{\cos^4x}{\sin^2x}$$ This can then be converted to: $$\cot^2x - \cot^2x\cos^2x$$ We take $\cot^...
2,036,206
${\sin^2(x)\over \tan^2(x)}$ I did this and then got stuck. Could someone give me some hints please?
2016/11/29
[ "https://math.stackexchange.com/questions/2036206", "https://math.stackexchange.com", "https://math.stackexchange.com/users/379666/" ]
Good job at arriving at $${1-\cos^2(x)\over \sec^2(x)-1}= {\sin^2(x)\over \tan^2(x)}$$ We know that $\tan x = \dfrac {\sin x}{\cos x}.$ So.... $${\sin^2(x)\over \tan^2(x)} = \frac{\sin^2 x}{\frac{\sin^2 x}{\cos^2 x}}= \cos^2 x = 1-\sin^2 x$$
Notice that $\sec^2(x)=\frac{1}{\cos^2(x)}$ Putting it in our equation on R.H.S. it becomes: $${1-\cos^2(x)\over \sec^2(x)-1}={1-\cos^2(x)\over\frac{1}{\cos^2(x)}-1}$$ $$=\frac{(1-\cos^2)(\cos^2(x))}{1-\cos^2(x)}$$ $$=\cos^2(x)=1-\sin^2(x)$$
2,036,206
${\sin^2(x)\over \tan^2(x)}$ I did this and then got stuck. Could someone give me some hints please?
2016/11/29
[ "https://math.stackexchange.com/questions/2036206", "https://math.stackexchange.com", "https://math.stackexchange.com/users/379666/" ]
For the equation: $$\frac{1-\cos^2x}{\sec^2x-1}$$ Multiply the numerator and denominator by $\cos^2x$ We now get: $$\frac{\cos^2x-\cos^4x}{1-\cos^2x}$$ Separate this into two fractions: $$\frac{\cos^2x}{\sin^2x} - \frac{\cos^4x}{\sin^2x}$$ This can then be converted to: $$\cot^2x - \cot^2x\cos^2x$$ We take $\cot^...
Notice that $\sec^2(x)=\frac{1}{\cos^2(x)}$ Putting it in our equation on R.H.S. it becomes: $${1-\cos^2(x)\over \sec^2(x)-1}={1-\cos^2(x)\over\frac{1}{\cos^2(x)}-1}$$ $$=\frac{(1-\cos^2)(\cos^2(x))}{1-\cos^2(x)}$$ $$=\cos^2(x)=1-\sin^2(x)$$
18,514,489
I wrote some functions to benchmark a function/piece of code. I do it like this: ``` start = timer for(1 second) call fun iterations++ stop = timer ``` And then I have a MEAN (AVERAGE) time: (stop-start/iterations), right? Single call is too 'short' to measure, so how can I calculate from this type of measure...
2013/08/29
[ "https://Stackoverflow.com/questions/18514489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2619020/" ]
Standard deviation and quartiles both deal with the distribution of values in a group. With only one measurement, these become trivial or meaningless. Since there's only one measurement, that value is the mean, the minimum, the maximum, and the mode. Since none of the measurements deviate from the mean, the variance a...
You'll have to find a way to measure the time precisely enough. You'll need the times for individual calls to `fun` in order to get any meaningful standard deviation etc. [This question](https://stackoverflow.com/questions/1487695/c-cross-platform-high-resolution-timer) may contain useful hints, and I'm sure there are...
18,514,489
I wrote some functions to benchmark a function/piece of code. I do it like this: ``` start = timer for(1 second) call fun iterations++ stop = timer ``` And then I have a MEAN (AVERAGE) time: (stop-start/iterations), right? Single call is too 'short' to measure, so how can I calculate from this type of measure...
2013/08/29
[ "https://Stackoverflow.com/questions/18514489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2619020/" ]
Standard deviation and quartiles both deal with the distribution of values in a group. With only one measurement, these become trivial or meaningless. Since there's only one measurement, that value is the mean, the minimum, the maximum, and the mode. Since none of the measurements deviate from the mean, the variance a...
In general, due to the processing speed and the troubles obtaining micro and millisecond resolutions, most performance measurements are based on a large number of iterations. For example: 1. Read start time 2. for 1,000,000 iterations do 3. perform function 4. end-for 5. read end time. The duration is the end time ...
18,514,489
I wrote some functions to benchmark a function/piece of code. I do it like this: ``` start = timer for(1 second) call fun iterations++ stop = timer ``` And then I have a MEAN (AVERAGE) time: (stop-start/iterations), right? Single call is too 'short' to measure, so how can I calculate from this type of measure...
2013/08/29
[ "https://Stackoverflow.com/questions/18514489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2619020/" ]
Standard deviation and quartiles both deal with the distribution of values in a group. With only one measurement, these become trivial or meaningless. Since there's only one measurement, that value is the mean, the minimum, the maximum, and the mode. Since none of the measurements deviate from the mean, the variance a...
If a single call is too short to measure, then why do you care how long it takes? I'm being a bit facetious, but if you're on Intel Linux, and your process is pinned to one core, you can read the CPU's timestamp counter (TSC), which is the highest resolution tick you can get. In recent Intel CPUs it ticks very solidly...
5,054,430
So after some tries I figured out I needed a driver for this. I've installed the Components from the links below. But I still can't find any SQL references when I try to add them? I'm wondering if anyone would know the reason for this? I just started with asp.net. I've found several other questions regarding code for c...
2011/02/20
[ "https://Stackoverflow.com/questions/5054430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615421/" ]
Right click on References, then select "Add Reference". Browse and select `Mysql.Data.dll`. The dll should be found in the installation directory of the connector you downloaded. ![enter image description here](https://i.stack.imgur.com/CnCBT.png) Finally, in code: ``` using MySql.Data.MySqlClient; ``` And, sampl...
You can browse to the DLL and add a reference.
42,430,205
I was wondering if what can I do with my codes to make it shorter. Here is my code, it is like a simple tabs. Btw, this codes are already working, but I'm thinking that if i have many tabs then I have to repeat many click functions. Is there a way to make my script shorter, Thanks in advance. ``` $(function () { $...
2017/02/24
[ "https://Stackoverflow.com/questions/42430205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6880428/" ]
Give all the links the same class, and a data attribute that says which tab it should open. So something like: ``` <div class="mergers"> <a class="tablink" href="#" data-tab="invMer">Mergers</a> </div> ``` And all the tab DIVs should also have a common class: ``` <div class="tabdiv" id="invMer"> ... </div> ...
Use a data attribute ``` <a data-show=".invPe"> ``` and do ``` $("a[data-show]").on("click", function () { var selector = $(this).data("show"); $(".invMer, .invEq, .invPe").hide(); $(selector).fadeIn(); }); ```
74,272,363
```py a = [1,4,7,5,9,3,5] b = [3,7,6,5,4,9,7] c = [] for i in range(len(a)-1): if a[i] < b[i]: c.append(b[i]) ``` I have the simple code above. Since `len(a) = 7`. The for loop should run 7-1 =6 times. I want to check is `a[i]` is less than `b[i]`. If this is true, then it should print the `b[i]...
2022/11/01
[ "https://Stackoverflow.com/questions/74272363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20369114/" ]
I am not entirely sure what you are trying to achieve but as far as I can tell your code is doing what you are saying. The reason you are not getting any output is because you are not printing the resulting list (try add `print(c)` to the end of your code. If instead you are trying to make a new list that contains the...
I'm not sure about what is your meaning about "there is nothing in the output". If this code snippet is in a function, you can try to add ``` return c ``` or you just print out the variable c, like ``` print(c) ``` Then you'll find the result of your code.
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
Assign the value to the global table (`_G`), like this: ``` _G.value = "Hello WOrld" ``` In another script, you can then do this: ``` value = _G.value ```
When you declare something local you are explicitly telling Lua NOT to share it between scripts. Just create a non-local variable instead: ``` value = "Hello World" ``` In b.lua File Simply Require the a.lua file and use it e.g In b.lua File ``` local a_File = require "a" print(a_File.value) ``` You will get the...
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
Assign the value to the global table (`_G`), like this: ``` _G.value = "Hello WOrld" ``` In another script, you can then do this: ``` value = _G.value ```
better than just cramming stuff into the global table is to use lua's module system the way it was intended to be used. say you had two files, a.lua and b.lua. b.lua needs some value from a.lua. this is how you'd accomplish that: a.lua code: ``` module("a", package.seeall) local myVal = "My value in file a" local S...
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
Assign the value to the global table (`_G`), like this: ``` _G.value = "Hello WOrld" ``` In another script, you can then do this: ``` value = _G.value ```
using director API we transfer a value to another lua file is easy. and it send data in table or array type below code is usefull.. **from a.lua file** ``` data="hellow" director:changeScene({data},"levelroom") ``` **from b.lua file** ``` module(...,package.seeall) new=function(params) localGroup=display.newGr...
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
When you declare something local you are explicitly telling Lua NOT to share it between scripts. Just create a non-local variable instead: ``` value = "Hello World" ``` In b.lua File Simply Require the a.lua file and use it e.g In b.lua File ``` local a_File = require "a" print(a_File.value) ``` You will get the...
better than just cramming stuff into the global table is to use lua's module system the way it was intended to be used. say you had two files, a.lua and b.lua. b.lua needs some value from a.lua. this is how you'd accomplish that: a.lua code: ``` module("a", package.seeall) local myVal = "My value in file a" local S...
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
When you declare something local you are explicitly telling Lua NOT to share it between scripts. Just create a non-local variable instead: ``` value = "Hello World" ``` In b.lua File Simply Require the a.lua file and use it e.g In b.lua File ``` local a_File = require "a" print(a_File.value) ``` You will get the...
using director API we transfer a value to another lua file is easy. and it send data in table or array type below code is usefull.. **from a.lua file** ``` data="hellow" director:changeScene({data},"levelroom") ``` **from b.lua file** ``` module(...,package.seeall) new=function(params) localGroup=display.newGr...
10,593,464
how can I pass a value from `a.lua` to `b.lua`? let us say that in my `a.lua` i have this code of variable. ``` local value = "Hello WOrld!" director:changeScene ("b") ``` my problem is that how can i pass `value` from `a.lua` to `b.lua`? thanks in advance....
2012/05/15
[ "https://Stackoverflow.com/questions/10593464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1038815/" ]
better than just cramming stuff into the global table is to use lua's module system the way it was intended to be used. say you had two files, a.lua and b.lua. b.lua needs some value from a.lua. this is how you'd accomplish that: a.lua code: ``` module("a", package.seeall) local myVal = "My value in file a" local S...
using director API we transfer a value to another lua file is easy. and it send data in table or array type below code is usefull.. **from a.lua file** ``` data="hellow" director:changeScene({data},"levelroom") ``` **from b.lua file** ``` module(...,package.seeall) new=function(params) localGroup=display.newGr...
53,260,841
I am facing a peculiar issue while writing characters to Arduino using python serial communication on macOS 10.14. The Arduino is programmed to read a string, parse it and take PWM action to run a car. Ardiuno's serial communication channel is configured to receive the strings in the format `< A, B, C, D >` where `AB...
2018/11/12
[ "https://Stackoverflow.com/questions/53260841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10127358/" ]
try add `var _this= this;` use `_this.loadContent();` or use `app.loadContent();` ``` getLocation(){ var _this= this; if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { this.position = position; _this.loadContent(); ...
`this` refers to the object that called a function. In the present case, this is `navigator.geolocation`. You can override the calling object by calling `bind` on the function: ``` getLocation(){ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { this.pos...
51,002,860
How can i define dynamically a constant inside dynamically defined subclass of dynamically defined class, like this, but without `NameError: uninitialized constant Foo::Bar` error: ``` Object.const_set('Foo',Class.new) {|klass| klass.const_set('Bar', Class.new){|subklass| subklass.const_set(:YEP,'Yep!')}} ``` to get...
2018/06/23
[ "https://Stackoverflow.com/questions/51002860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868273/" ]
When you wrap method parameters in parenthesis, the curly brace block gets applied to the method call, not the last parameter in the list. So those `{ |klass| ... }` are being passed to `Object.const_set` not to `Class.new`. If you move that close parenthesis after the block it'll work because the blocks get passed to ...
The following is equivalent to @SimpleLime's answer, just expressed differently. ``` def make_class(name, parent=Object) Object.const_set(name, Class.new(parent)) end foo = make_class('Foo') #=> Foo bar = make_class('Bar', foo) #=> Bar bar.superclass #=> Foo bar.const_set('YEP', 'Yep!') Bar::YEP #=> "Yep!" ...
41,516,423
I have a sales table that I want loop and add the total as I go. I have something like this. ``` <h1>Sale</h1> <table> <tr> <th>Name</th> <th>Price</th> <th>Total</th> </tr> <tr ng-repeat="item in items"> <td>{{item.name}}</td> <td>{{item.price}}</td> <td>{{item.price +=item.price}}</td>...
2017/01/07
[ "https://Stackoverflow.com/questions/41516423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3862830/" ]
Have a method that evaluates the subtotal: ``` $scope.getSubTotal = function(index) { var subtotal = 0; for (var i = 0; i < index+1; i++) { var item = $scope.items[i]; subtotal += item.price; } return subtotal; } ``` At your table, pass in the index: ``` <tr ng-repeat="item in items"...
Try ``` <td>{{item.price +=items[$index-1].price}}</td> ```
41,516,423
I have a sales table that I want loop and add the total as I go. I have something like this. ``` <h1>Sale</h1> <table> <tr> <th>Name</th> <th>Price</th> <th>Total</th> </tr> <tr ng-repeat="item in items"> <td>{{item.name}}</td> <td>{{item.price}}</td> <td>{{item.price +=item.price}}</td>...
2017/01/07
[ "https://Stackoverflow.com/questions/41516423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3862830/" ]
Have a method that evaluates the subtotal: ``` $scope.getSubTotal = function(index) { var subtotal = 0; for (var i = 0; i < index+1; i++) { var item = $scope.items[i]; subtotal += item.price; } return subtotal; } ``` At your table, pass in the index: ``` <tr ng-repeat="item in items"...
total needs only once means in that table use like this... ``` <td>Total: {{ getTotal() }}</td> $scope.getTotal = function(){ var total = 0; for(var i = 0; i < $scope.items.length; i++){ var item = $scope.items[i]; total += item.price; } return total; } ```
4,414,720
I want to code a server side software with Delphi+Firebird but i need a documentation (or tutorial) that explains all the steps and components from the beginning. Is there any site/tutorial/document that you can suggest? which explains step by step coding. Even if you suggest a component to make server side connection...
2010/12/11
[ "https://Stackoverflow.com/questions/4414720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218010/" ]
1. The main English information source for Firebird is [IBPhoenix](http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1292063514:200606&page=ibp_document). 2. The main Russian information source for Firebird is [IBase](http://www.ibase.ru/). 3. The [Firebird FAQ](http://www.firebirdfaq.org/faq7/) gives a list of Delphi co...
Actually Firebird is a fork from Interbase, yes Interbase had become an open source some time ago and then become closed source again. So, u can use Interbase as a reference. But as time goes, Firebird become better and better in quality. Also become different from Interbase itself. To get more info on Firebird, u can ...
4,414,720
I want to code a server side software with Delphi+Firebird but i need a documentation (or tutorial) that explains all the steps and components from the beginning. Is there any site/tutorial/document that you can suggest? which explains step by step coding. Even if you suggest a component to make server side connection...
2010/12/11
[ "https://Stackoverflow.com/questions/4414720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218010/" ]
Actually Firebird is a fork from Interbase, yes Interbase had become an open source some time ago and then become closed source again. So, u can use Interbase as a reference. But as time goes, Firebird become better and better in quality. Also become different from Interbase itself. To get more info on Firebird, u can ...
Documentation is a weak side of Firebird server. We usually use a combination of: 1. Interbase documentation 2. Firebird release notes 3. Information from Firebird forums 4. Helen Borrie's Firebird book Delphi uses pretty unified technology to talk to any server be it Firebird or not. So, there is just enough informa...
4,414,720
I want to code a server side software with Delphi+Firebird but i need a documentation (or tutorial) that explains all the steps and components from the beginning. Is there any site/tutorial/document that you can suggest? which explains step by step coding. Even if you suggest a component to make server side connection...
2010/12/11
[ "https://Stackoverflow.com/questions/4414720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218010/" ]
1. The main English information source for Firebird is [IBPhoenix](http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1292063514:200606&page=ibp_document). 2. The main Russian information source for Firebird is [IBase](http://www.ibase.ru/). 3. The [Firebird FAQ](http://www.firebirdfaq.org/faq7/) gives a list of Delphi co...
Documentation is a weak side of Firebird server. We usually use a combination of: 1. Interbase documentation 2. Firebird release notes 3. Information from Firebird forums 4. Helen Borrie's Firebird book Delphi uses pretty unified technology to talk to any server be it Firebird or not. So, there is just enough informa...
79,736
It is clearly said in the *Game of Thrones* series that fire destroys wights. Also it is known that dragonglass and valyrian steel can destroy both wights and white walkers. Can white walkers also be destroyed by fire like the wights?
2017/08/29
[ "https://movies.stackexchange.com/questions/79736", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/40410/" ]
We know that normal fire does not affect them. They are seen walking right through the fire created by the children to shield the cave from the incoming wights, and the fire appears to extinguish before them. We also see the White Walker that Jon kills walk into a burning building, seemingly unfazed. [![White Walker ...
As per [this other question here](https://movies.stackexchange.com/questions/35176/how-useful-are-dragon-glass-arrow-heads-when-fighting-the-white-walkers-in-game?rq=1) it seems likely that dragon fire could also kill White Walkers. It cites: > > “Dragonglass.” The red woman’s laugh was music. “Frozen fire, in the to...
32,644,644
I am trying to input sendKeys to a calendar date element in FireFox browser using Selenium. The element is displayed but I keep getting below exception: ``` Caused by: **org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with** Build info: version: '2.47.1', r...
2015/09/18
[ "https://Stackoverflow.com/questions/32644644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349020/" ]
``` $arr1 = array(0 => 1800, 5 => 1500, 6 => 4545,); $arr2 = array('a', 'b', 'c', 'd', 'e', 'f', 'g',); $arrNeeded = array(); foreach ($arr2 AS $k => $v) { $arrNeeded[$k] = array($v => isset($arr1[$k]) ? $arr1[$k] : 0); } echo '<pre>' . print_r($arrNeeded, true) . '</pre>'; ```
Please try with below code ``` $arr1 = array( 0 => 1800 ,5 => 1500 ,6=> 4545 ); $arr2 = array( 0 => 'a' ,1 => 'b', 2=> 'c',3 => 'd' ,4 => 'e' ,5 => 'f' ,6 => 'g' ); $newarr = ""; if(count($arr2) >0){ foreach($arr2 as $key2 => $val2){ $newVal = isset($arr1[$key2])?$arr1[$key2] : 0; $newarr[$key2...
32,644,644
I am trying to input sendKeys to a calendar date element in FireFox browser using Selenium. The element is displayed but I keep getting below exception: ``` Caused by: **org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with** Build info: version: '2.47.1', r...
2015/09/18
[ "https://Stackoverflow.com/questions/32644644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349020/" ]
``` $arr1 = array(0 => 1800, 5 => 1500, 6 => 4545,); $arr2 = array('a', 'b', 'c', 'd', 'e', 'f', 'g',); $arrNeeded = array(); foreach ($arr2 AS $k => $v) { $arrNeeded[$k] = array($v => isset($arr1[$k]) ? $arr1[$k] : 0); } echo '<pre>' . print_r($arrNeeded, true) . '</pre>'; ```
This might help you ``` <?php $array1 = Array( "0"=>1800,"5" => 1500, "6" => 4545 ) ; $array2 = Array( "0" => 'a', '1' => 'b', '2' => 'c', '3' => 'd', '4' => 'e', '5' => 'f', '6' => 'g' ); $resultArray = array(); foreach ($array2 as $key2 => $value2 ) { $found = false; foreach ($array1 as $key1 => $value1...
32,644,644
I am trying to input sendKeys to a calendar date element in FireFox browser using Selenium. The element is displayed but I keep getting below exception: ``` Caused by: **org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with** Build info: version: '2.47.1', r...
2015/09/18
[ "https://Stackoverflow.com/questions/32644644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349020/" ]
Found solution for your question. ``` <?php $arr1 = array( '0' => '1800', '5' => '1500', '6' => '4545' ); $arr2 = array( '0' => 'a', '1' => 'b', '2' => 'c', '3' => 'd', '4' => 'e', '5' => 'f', '6' => 'g', ); $arr3 = array(); foreach($arr2 as $key => $value){ if(!em...
Please try with below code ``` $arr1 = array( 0 => 1800 ,5 => 1500 ,6=> 4545 ); $arr2 = array( 0 => 'a' ,1 => 'b', 2=> 'c',3 => 'd' ,4 => 'e' ,5 => 'f' ,6 => 'g' ); $newarr = ""; if(count($arr2) >0){ foreach($arr2 as $key2 => $val2){ $newVal = isset($arr1[$key2])?$arr1[$key2] : 0; $newarr[$key2...
32,644,644
I am trying to input sendKeys to a calendar date element in FireFox browser using Selenium. The element is displayed but I keep getting below exception: ``` Caused by: **org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with** Build info: version: '2.47.1', r...
2015/09/18
[ "https://Stackoverflow.com/questions/32644644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349020/" ]
Found solution for your question. ``` <?php $arr1 = array( '0' => '1800', '5' => '1500', '6' => '4545' ); $arr2 = array( '0' => 'a', '1' => 'b', '2' => 'c', '3' => 'd', '4' => 'e', '5' => 'f', '6' => 'g', ); $arr3 = array(); foreach($arr2 as $key => $value){ if(!em...
This might help you ``` <?php $array1 = Array( "0"=>1800,"5" => 1500, "6" => 4545 ) ; $array2 = Array( "0" => 'a', '1' => 'b', '2' => 'c', '3' => 'd', '4' => 'e', '5' => 'f', '6' => 'g' ); $resultArray = array(); foreach ($array2 as $key2 => $value2 ) { $found = false; foreach ($array1 as $key1 => $value1...
21,540,177
Let's take this simple example: ``` #include <iostream> namespace foo { constexpr int main(int argc, char* argv[]) { // code } } int main(int argc, char* argv[]) { return foo::main(argc, argv); } ``` Depend on what **code** is, clang will complain or no. If code is: ``` cout << "Hello!"; return ...
2014/02/03
[ "https://Stackoverflow.com/questions/21540177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3267823/" ]
You compile your code in C++1y mode which contains wording to relax `constexpr` restrictions including all looping statements. Have a look at [N3652](http://isocpp.org/files/papers/N3652.html) which introduced these changes.
So gcc 4.8.1 does not implement relaxed constexpr restraints, but clang 3.5 does. My mistake was that clang and gcc both have variable length array extensions. if I had used std::array instead, both compilers would reject the code. What I still don't understand is if clang allows relaxed constexpr, then why is it not a...
21,540,177
Let's take this simple example: ``` #include <iostream> namespace foo { constexpr int main(int argc, char* argv[]) { // code } } int main(int argc, char* argv[]) { return foo::main(argc, argv); } ``` Depend on what **code** is, clang will complain or no. If code is: ``` cout << "Hello!"; return ...
2014/02/03
[ "https://Stackoverflow.com/questions/21540177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3267823/" ]
***Clang is correct here.*** **First example** Here, the code is: ``` constexpr int foo::main(int argc, char* argv[]) { std::cout << argv[i]; return 0; } ``` *In C++11*, this code is ill-formed, because the body contains an *expression-statement*, which is not permitted in a `constexpr` function definition. *...
You compile your code in C++1y mode which contains wording to relax `constexpr` restrictions including all looping statements. Have a look at [N3652](http://isocpp.org/files/papers/N3652.html) which introduced these changes.
21,540,177
Let's take this simple example: ``` #include <iostream> namespace foo { constexpr int main(int argc, char* argv[]) { // code } } int main(int argc, char* argv[]) { return foo::main(argc, argv); } ``` Depend on what **code** is, clang will complain or no. If code is: ``` cout << "Hello!"; return ...
2014/02/03
[ "https://Stackoverflow.com/questions/21540177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3267823/" ]
***Clang is correct here.*** **First example** Here, the code is: ``` constexpr int foo::main(int argc, char* argv[]) { std::cout << argv[i]; return 0; } ``` *In C++11*, this code is ill-formed, because the body contains an *expression-statement*, which is not permitted in a `constexpr` function definition. *...
So gcc 4.8.1 does not implement relaxed constexpr restraints, but clang 3.5 does. My mistake was that clang and gcc both have variable length array extensions. if I had used std::array instead, both compilers would reject the code. What I still don't understand is if clang allows relaxed constexpr, then why is it not a...
46,786,800
I have an **Azure Function** with a **Blob Store** input. I can access the input file using the `$inputFile` variable, which is super easy. To allow for dynamic blob selection, I pass a `config` query parameter which contains the name of the config to select. The only issue I have is that if someone passes the name o...
2017/10/17
[ "https://Stackoverflow.com/questions/46786800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567059/" ]
Because you are splitting a string using any sequence of digits as the separator. If your string was `'name1000name'` your response would be `['name', 'name']`.
There is a mistake in our regex. A solution is : ``` n = re.split('(\d+)', s) ```
3,759,816
> > **Possible Duplicate:** > > [Parsing Huge XML Files in PHP](https://stackoverflow.com/questions/911663/parsing-huge-xml-files-in-php) > > > I am trying to parse a 70Mb XML file under PHP. After a while the resources are not enough and the script crashes. If there is a larger XML file it ends sooner. I can'...
2010/09/21
[ "https://Stackoverflow.com/questions/3759816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/243782/" ]
You can use the [XMLReader](http://docs.php.net/xmlreader) class. It doesn't read the entire document as an object model into the memory but is a [pull parser](http://en.wikipedia.org/wiki/XML#Pull_parsing).
In general, when you want to parse large XML documents in a constrained environment, you should use a SAX parser, that does not store the entire document in any form. SAX parsers make calls to user defined functions when they encounter an opening or closing tag for example.
1,364,280
I've 3 tables. Users (id, mail, username, etc..) Practices (id, name) UsersPractices (userId, practiceId) The last one is the relational table which is n-n. I'd like to update this one, depending on the user's will. It means, that he could want to add, or remove some his practices. What algorithm could i use to ...
2009/09/01
[ "https://Stackoverflow.com/questions/1364280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61337/" ]
Assuming you have InnoDB tables, do it as a transaction. The basic idea here is to wipe the slate clean and then create/re-create the associations. This is easier than determining the delta of each update (i.e., inspecting each row individually and determining if it's an INSERT, UPDATE, or DELETE action). Here's the ...
Check out Doctrine (<http://www.doctrine-project.org/>). It's an Object Relational Mapper (ORM) framework for PHP. It can easily handle what you want to accomplish.
1,364,280
I've 3 tables. Users (id, mail, username, etc..) Practices (id, name) UsersPractices (userId, practiceId) The last one is the relational table which is n-n. I'd like to update this one, depending on the user's will. It means, that he could want to add, or remove some his practices. What algorithm could i use to ...
2009/09/01
[ "https://Stackoverflow.com/questions/1364280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61337/" ]
Check out Doctrine (<http://www.doctrine-project.org/>). It's an Object Relational Mapper (ORM) framework for PHP. It can easily handle what you want to accomplish.
Well - the easiest way I could think of to handle this sort of thing would be to build a `<select>` element something like this: ``` function getUserPractices($userId) { $data = array(); $result = mysql_query("SELECT Practices.* FROM UsersPractices LEFT JOIN Practices on UsersPractices.practiceId = Practices.id WH...
1,364,280
I've 3 tables. Users (id, mail, username, etc..) Practices (id, name) UsersPractices (userId, practiceId) The last one is the relational table which is n-n. I'd like to update this one, depending on the user's will. It means, that he could want to add, or remove some his practices. What algorithm could i use to ...
2009/09/01
[ "https://Stackoverflow.com/questions/1364280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61337/" ]
Assuming you have InnoDB tables, do it as a transaction. The basic idea here is to wipe the slate clean and then create/re-create the associations. This is easier than determining the delta of each update (i.e., inspecting each row individually and determining if it's an INSERT, UPDATE, or DELETE action). Here's the ...
Well - the easiest way I could think of to handle this sort of thing would be to build a `<select>` element something like this: ``` function getUserPractices($userId) { $data = array(); $result = mysql_query("SELECT Practices.* FROM UsersPractices LEFT JOIN Practices on UsersPractices.practiceId = Practices.id WH...
1,364,280
I've 3 tables. Users (id, mail, username, etc..) Practices (id, name) UsersPractices (userId, practiceId) The last one is the relational table which is n-n. I'd like to update this one, depending on the user's will. It means, that he could want to add, or remove some his practices. What algorithm could i use to ...
2009/09/01
[ "https://Stackoverflow.com/questions/1364280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61337/" ]
Assuming you have InnoDB tables, do it as a transaction. The basic idea here is to wipe the slate clean and then create/re-create the associations. This is easier than determining the delta of each update (i.e., inspecting each row individually and determining if it's an INSERT, UPDATE, or DELETE action). Here's the ...
If you're executing SQL statements directly using the `Zend_Db` adapter, you could build an `UPDATE` query based on the choices the user wants to make. For example: ``` $db->query('UPDATE UsersPractices SET practiceId = CASE practiceId WHEN 21 THEN 15 ELSE practiceId END WHERE userI...
1,364,280
I've 3 tables. Users (id, mail, username, etc..) Practices (id, name) UsersPractices (userId, practiceId) The last one is the relational table which is n-n. I'd like to update this one, depending on the user's will. It means, that he could want to add, or remove some his practices. What algorithm could i use to ...
2009/09/01
[ "https://Stackoverflow.com/questions/1364280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61337/" ]
If you're executing SQL statements directly using the `Zend_Db` adapter, you could build an `UPDATE` query based on the choices the user wants to make. For example: ``` $db->query('UPDATE UsersPractices SET practiceId = CASE practiceId WHEN 21 THEN 15 ELSE practiceId END WHERE userI...
Well - the easiest way I could think of to handle this sort of thing would be to build a `<select>` element something like this: ``` function getUserPractices($userId) { $data = array(); $result = mysql_query("SELECT Practices.* FROM UsersPractices LEFT JOIN Practices on UsersPractices.practiceId = Practices.id WH...
117,013
I) I know that virtual-photons are known to be the force-carriers for the Electromagnetic force, and that they are called "virtual" because the Energy-Time-inequality version of the Heisenberg Uncertainty Principle allows for particles that are high enough energy that they are very difficult to observe (because higher ...
2014/06/05
[ "https://physics.stackexchange.com/questions/117013", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/40021/" ]
There is only one kind of photon. Indeed, when we describe elementary interactions between two electrons for example, we call the photon "virtual" as opposed to a physical photon that might exist outside of this process. Still, these are the same particles, i.e. excitations of the same fundamental field, as the photo...
A major difference between real and virtual photons is that virtual particles are not required to have energy and momentum [on the "mass shell"](https://en.wikipedia.org/wiki/On_shell_and_off_shell). That is, virtual photons may have $E^2-p^2 \neq m^2$, while real photons must obey $E^2-p^2=m^2=0$. My memory disagrees...
44,786,871
I am currently developing a Spring Boot Starter which will host a Restful web service with some meta-data about the running application. I am having difficulties extracting my artifactId and versionId from my mainfest file. I believe my issue is that the autoconfiguration classes are being loaded before the main Test ...
2017/06/27
[ "https://Stackoverflow.com/questions/44786871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4944649/" ]
After a lot of effort, I found a surprisingly simple answer. This is how spring-boot-actuator gets the information. The Spring Boot Maven plugin comes equipped with a build-info goal. As long as this goal is triggered in the main project Spring has a BuildProperties class you can wire in for the information. ``` ...
The other answer is completely correct. Just for others finding this question in case you are using Gradle instead of Maven: Generating build info is as simple as adding this to your `build.gradle` file: ``` plugins { id 'org.springframework.boot' version '<your-boot-version>.RELEASE' } // ... springBoot { ...
15,613,944
I am using phonegap. I need to load external website depending on the input. The input data are passed as an Object from previous page.Then combined to generate the url. URL will be stored in variable $link. And then use `load()` to get the website. However it seems not work for putting url variable in `load()`. How ca...
2013/03/25
[ "https://Stackoverflow.com/questions/15613944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2132708/" ]
remove following from web.xml ``` <taglib> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> <taglib-location>/WEB-INF/lib/jstl-1.2.jar</taglib-location> </taglib> ``` You do not need this anymore since Servlet 2.0 specification. And also, **taglib-location** is used to specify the path of \*.tld file.
This error message is always caused by the invalid XML content in the beginning element. For example, extra small dot “.” in the beginning of XML element. [see here](http://www.mkyong.com/java/sax-error-content-is-not-allowed-in-prolog/)
526,531
I'm trying to design a liquid fueled rocket engine, with copper walls cooled by kerosene. While designing it, the following formula comes out: $$Q=qA=wc(T-T(0))$$ Where: * Q = total heat transferred * q = average heat transfer rate * A = heat transfer area * w = coolant flow rate * c = specific heat of coolant * T ...
2020/01/22
[ "https://physics.stackexchange.com/questions/526531", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/252300/" ]
This is essentially the *definition* of energy in quantum mechanics -- it is $\hbar$ times the rate of change of phase. That's one of the fundamentally new ideas in quantum mechanics, so it can't be derived from anything you already know classically. If that's not very satisfying, we can say the same thing in more ste...
The reason that we take it to be the energy is that this is closely related to the classical energy, when one follows the standard rules and conventions of "quantizing" the classical quantities. In a similar manner, you can take any classical quantity $A$, and then from the classical concept of the Hamiltonian (which ...
2,457,367
I've got the entire contents of a text file (at least a few KB) in string `myStr`. Will the following code create a copy of the string (less the first character) in memory? `myStr = myStr[1:]` I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do t...
2010/03/16
[ "https://Stackoverflow.com/questions/2457367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
At least in 2.6, slices of strings are always new allocations; string\_slice() calls PyString\_FromStringAndSize(). It doesn't reuse memory--which is a little odd, since with invariant strings, it should be a relatively easy thing to do. Short of the buffer API (which you probably don't want), there isn't a more effic...
As with most garbage collected languages, strings are created as often as needed, which is very often. The reason for this is because tracking substrings as described would make garbage collection more difficult. What is the actual algorithm you are trying to implement. It might be possible to give you advice for ways...
2,457,367
I've got the entire contents of a text file (at least a few KB) in string `myStr`. Will the following code create a copy of the string (less the first character) in memory? `myStr = myStr[1:]` I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do t...
2010/03/16
[ "https://Stackoverflow.com/questions/2457367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
At least in 2.6, slices of strings are always new allocations; string\_slice() calls PyString\_FromStringAndSize(). It doesn't reuse memory--which is a little odd, since with invariant strings, it should be a relatively easy thing to do. Short of the buffer API (which you probably don't want), there isn't a more effic...
One (albeit slightly hacky) solution would be something like this: ``` f = open("test.c") f.read(1) myStr = f.read() print myStr ``` It will skip the first character, and then read the data into your string variable.
2,457,367
I've got the entire contents of a text file (at least a few KB) in string `myStr`. Will the following code create a copy of the string (less the first character) in memory? `myStr = myStr[1:]` I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do t...
2010/03/16
[ "https://Stackoverflow.com/questions/2457367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
At least in 2.6, slices of strings are always new allocations; string\_slice() calls PyString\_FromStringAndSize(). It doesn't reuse memory--which is a little odd, since with invariant strings, it should be a relatively easy thing to do. Short of the buffer API (which you probably don't want), there isn't a more effic...
Depending on what you are doing, `itertools.islice` *may* be a suitable memory-efficient solution (should one become necessary).
2,457,367
I've got the entire contents of a text file (at least a few KB) in string `myStr`. Will the following code create a copy of the string (less the first character) in memory? `myStr = myStr[1:]` I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do t...
2010/03/16
[ "https://Stackoverflow.com/questions/2457367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
As with most garbage collected languages, strings are created as often as needed, which is very often. The reason for this is because tracking substrings as described would make garbage collection more difficult. What is the actual algorithm you are trying to implement. It might be possible to give you advice for ways...
One (albeit slightly hacky) solution would be something like this: ``` f = open("test.c") f.read(1) myStr = f.read() print myStr ``` It will skip the first character, and then read the data into your string variable.
2,457,367
I've got the entire contents of a text file (at least a few KB) in string `myStr`. Will the following code create a copy of the string (less the first character) in memory? `myStr = myStr[1:]` I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do t...
2010/03/16
[ "https://Stackoverflow.com/questions/2457367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
As with most garbage collected languages, strings are created as often as needed, which is very often. The reason for this is because tracking substrings as described would make garbage collection more difficult. What is the actual algorithm you are trying to implement. It might be possible to give you advice for ways...
Depending on what you are doing, `itertools.islice` *may* be a suitable memory-efficient solution (should one become necessary).
20,791,639
I am looking to add a small circle to a Pseudo element using `:hover but` my wanted result is for the circle to appear `::before` without moving the text itself. I am looking to apply this method eventually to navbar's using images. Here is my HTML example: ``` <div class="bla"> <p><a class="circle">Hello Circle</...
2013/12/26
[ "https://Stackoverflow.com/questions/20791639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3137755/" ]
You can use absolute-positioning for your circle: ``` .circle:hover::before{ content: ""; height: 20px; width: 20px; background-color:#D13335; border-radius: 50%; webkit-border-radius: 50%; position:absolute; left:-20px; } ``` Demo: <http://jsfiddle.net/U5H3y/>
You can use `position: absolute; left: -20px` to prevent the text from moving. **[Demo](http://jsfiddle.net/G66cP/1/)** `left: -20px` just matches the width of the circle, so if you want to give it some more space, you can increase this. Using `position: absolute;` takes it out of the flow, so it won't push/pull the t...
60,283,092
Good morning, I am new to Spring Boot, and I am performing a rest service that must invoke a procedure stored in the database, the question is that you receive the mobile and must return a code and result, as shown below: [![enter image description here](https://i.stack.imgur.com/MbPb4.png)](https://i.stack.imgur.com/...
2020/02/18
[ "https://Stackoverflow.com/questions/60283092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11559150/" ]
**SOLVED** I managed to solve my problem, using the @Query annotation, and building an interface for the response I was going to receive, in these cases with 2 methods (according to the number of parameters that I will receive), and With this I got my answer in a Json, I leave the interface code below: ``` public int...
Try this - ``` @GetMapping("/service/{movil}") public RespuestaVo ConsultarMovil(@PathVariable("movil") String movil) { return dao.validarClienteBonifiado(movil); } ```
1,561,606
In my page there is two links, register and login. The important one now is register. When I click it, it loads a .tpl file using jquery load function. In this tpl file I include a new js file with `<script>` ofcourse, and it works perfectly in safari, ff, opera and chrome, but of course, Why should it be working in I...
2009/10/13
[ "https://Stackoverflow.com/questions/1561606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189150/" ]
Make sure that the script tag is not in this form: ``` <script ... /> ``` IE only accepts: ``` <script>...</script> ```
IE considers injection of script tags as a security issue. Change the script tag to: ``` document.write("<scri" + "pt src=...></scri" + "pt>"); ```
1,561,606
In my page there is two links, register and login. The important one now is register. When I click it, it loads a .tpl file using jquery load function. In this tpl file I include a new js file with `<script>` ofcourse, and it works perfectly in safari, ff, opera and chrome, but of course, Why should it be working in I...
2009/10/13
[ "https://Stackoverflow.com/questions/1561606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189150/" ]
Make sure that the script tag is not in this form: ``` <script ... /> ``` IE only accepts: ``` <script>...</script> ```
Are you sure that your loaded javascript executes properly in IE. Perhaps it have a javascript quirk that is throwing an error and is making it appear as if it's not loading? To test this out, non-dynamically including the javascript (include it in the page or similar) and set up a break-point in the script code and s...
1,561,606
In my page there is two links, register and login. The important one now is register. When I click it, it loads a .tpl file using jquery load function. In this tpl file I include a new js file with `<script>` ofcourse, and it works perfectly in safari, ff, opera and chrome, but of course, Why should it be working in I...
2009/10/13
[ "https://Stackoverflow.com/questions/1561606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189150/" ]
If the script is "ignored" if there's a $(document)ready then there may be an error in that block of the script and your IE is set to stop running scripts on error. Try to simplify your issue a bit to try to pin point it. For example, copy the following code into a brand new html file and try it out (NOTE: you'll nee...
Make sure that the script tag is not in this form: ``` <script ... /> ``` IE only accepts: ``` <script>...</script> ```
1,561,606
In my page there is two links, register and login. The important one now is register. When I click it, it loads a .tpl file using jquery load function. In this tpl file I include a new js file with `<script>` ofcourse, and it works perfectly in safari, ff, opera and chrome, but of course, Why should it be working in I...
2009/10/13
[ "https://Stackoverflow.com/questions/1561606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189150/" ]
If the script is "ignored" if there's a $(document)ready then there may be an error in that block of the script and your IE is set to stop running scripts on error. Try to simplify your issue a bit to try to pin point it. For example, copy the following code into a brand new html file and try it out (NOTE: you'll nee...
IE considers injection of script tags as a security issue. Change the script tag to: ``` document.write("<scri" + "pt src=...></scri" + "pt>"); ```
1,561,606
In my page there is two links, register and login. The important one now is register. When I click it, it loads a .tpl file using jquery load function. In this tpl file I include a new js file with `<script>` ofcourse, and it works perfectly in safari, ff, opera and chrome, but of course, Why should it be working in I...
2009/10/13
[ "https://Stackoverflow.com/questions/1561606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189150/" ]
If the script is "ignored" if there's a $(document)ready then there may be an error in that block of the script and your IE is set to stop running scripts on error. Try to simplify your issue a bit to try to pin point it. For example, copy the following code into a brand new html file and try it out (NOTE: you'll nee...
Are you sure that your loaded javascript executes properly in IE. Perhaps it have a javascript quirk that is throwing an error and is making it appear as if it's not loading? To test this out, non-dynamically including the javascript (include it in the page or similar) and set up a break-point in the script code and s...
65,103,868
How do I define in a simple single line a temporary constant table in BigQuery (or Postgres the syntax of which will likely work in BigQuery)? ```sql with my_fruits as ( --- ??? define a table --- consisting of a single column fruit_name --- with values ('apple', 'pear', 'gooseberry', ... (12 more fruits)) ) select ...
2020/12/02
[ "https://Stackoverflow.com/questions/65103868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4605070/" ]
You can use [UNNEST](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#unnest): ``` select * from unnest(['apple', 'pear', 'gooseberry']) as fruit_name ``` You also can join with UNNEST [directly](https://cloud.google.com/bigquery/docs/reference/standard-sql/arrays#flattening_arrays).
With Postgres you can easily create a multi-column constant table: ``` select * from (values (1,1,1), (1,2,3)) as x(one, two, three) ``` Unfortunately above doesn't work for BigQuery and not sure if there is a proper substitute for it.
3,028,899
Is there any clear definition of RPC and Web Service? A quick wikipedia search shows: > > RPC: Remote procedure call (RPC) is an > Inter-process communication technology > that allows a computer program to > cause a subroutine or procedure to > execute in another address space > (commonly on another computer on ...
2010/06/12
[ "https://Stackoverflow.com/questions/3028899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166482/" ]
> > Is Web Service a higher level > representation of RPC? > > > Yes, it is. A web service is a specific implementation of RPC. At its lowest level, Web Service connects to the Socket, using the HTTP protocol, to negotiate sending a payload that is executed in a remote space (remote space can be the same computer...
• Data is formatted for transfer using XML, improving or eliminating marshalling, unmarshalling, and various other translation-related requirements normally coded by a developer. • Data is passed using standardized protocols such as HTTP or SMTP, which have published well-defined standards. • The underlying exposed s...
3,028,899
Is there any clear definition of RPC and Web Service? A quick wikipedia search shows: > > RPC: Remote procedure call (RPC) is an > Inter-process communication technology > that allows a computer program to > cause a subroutine or procedure to > execute in another address space > (commonly on another computer on ...
2010/06/12
[ "https://Stackoverflow.com/questions/3028899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166482/" ]
> > Is Web Service a higher level > representation of RPC? > > > Yes, it is. A web service is a specific implementation of RPC. At its lowest level, Web Service connects to the Socket, using the HTTP protocol, to negotiate sending a payload that is executed in a remote space (remote space can be the same computer...
Remote Procedure Call (RPC) and WebService, in the sake of Functionality both go parallely. But there is a subtle difference in their way of invoking. An Web Service can be invoked by any application, using XML format over HTTP protocol for proceedings and its interoperable in nature, whereas in case of RPC the functi...
3,028,899
Is there any clear definition of RPC and Web Service? A quick wikipedia search shows: > > RPC: Remote procedure call (RPC) is an > Inter-process communication technology > that allows a computer program to > cause a subroutine or procedure to > execute in another address space > (commonly on another computer on ...
2010/06/12
[ "https://Stackoverflow.com/questions/3028899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166482/" ]
> > Is Web Service a higher level > representation of RPC? > > > Yes, it is. A web service is a specific implementation of RPC. At its lowest level, Web Service connects to the Socket, using the HTTP protocol, to negotiate sending a payload that is executed in a remote space (remote space can be the same computer...
I see this question. The question has been asked long time ago, but I think anyone's answer in this community, giving more information and clarity on this topic, will be helpful for the future questioners. So, I would like to add my enhancement pointing out key differences and I hope, it will be helpful for future read...
3,028,899
Is there any clear definition of RPC and Web Service? A quick wikipedia search shows: > > RPC: Remote procedure call (RPC) is an > Inter-process communication technology > that allows a computer program to > cause a subroutine or procedure to > execute in another address space > (commonly on another computer on ...
2010/06/12
[ "https://Stackoverflow.com/questions/3028899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166482/" ]
Remote Procedure Call (RPC) and WebService, in the sake of Functionality both go parallely. But there is a subtle difference in their way of invoking. An Web Service can be invoked by any application, using XML format over HTTP protocol for proceedings and its interoperable in nature, whereas in case of RPC the functi...
• Data is formatted for transfer using XML, improving or eliminating marshalling, unmarshalling, and various other translation-related requirements normally coded by a developer. • Data is passed using standardized protocols such as HTTP or SMTP, which have published well-defined standards. • The underlying exposed s...
3,028,899
Is there any clear definition of RPC and Web Service? A quick wikipedia search shows: > > RPC: Remote procedure call (RPC) is an > Inter-process communication technology > that allows a computer program to > cause a subroutine or procedure to > execute in another address space > (commonly on another computer on ...
2010/06/12
[ "https://Stackoverflow.com/questions/3028899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/166482/" ]
I see this question. The question has been asked long time ago, but I think anyone's answer in this community, giving more information and clarity on this topic, will be helpful for the future questioners. So, I would like to add my enhancement pointing out key differences and I hope, it will be helpful for future read...
• Data is formatted for transfer using XML, improving or eliminating marshalling, unmarshalling, and various other translation-related requirements normally coded by a developer. • Data is passed using standardized protocols such as HTTP or SMTP, which have published well-defined standards. • The underlying exposed s...
2,168
I have an [English walnut](http://en.wikipedia.org/wiki/Juglans_regia) sapling that grows vigorously all summer, but at the beginning of Fall the leaves dry up and fall. It has been two years now. Is that a problem with the tree?
2011/09/25
[ "https://gardening.stackexchange.com/questions/2168", "https://gardening.stackexchange.com", "https://gardening.stackexchange.com/users/419/" ]
First, let me say I've no experience doing battle with [Bermuda grass](http://en.wikipedia.org/wiki/Cynodon_dactylon). Second, I've spent the past 24 hours reading up on removing Bermuda grass from a cool-season lawn, for the moment lets just say there's no easy answer, solution... Eradicating Bermuda grass from a lan...
To paraphrase a common saying, "One man's weed is another man's lawn". Bermuda grass is low maintenance and drought resistant. If sown with other thin bladed grasses that are more cold resistant it can result in a lawn that stays green all year long. That being said, if you are determined to eradicate it from your law...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
Promises allow you to write async code pretty much directly from sync code because they restore exception bubbling and return value composition. Assuming you have already rewritten the other methods to promises: ``` var Promise = require("bluebird"); ... _makePostAppend: function (params, body, options) { var ful...
Callback hell is a scary place :) You could use something like [Step.js](https://github.com/creationix/step) which makes callbacks a more readable sequence of steps. There are many other async management libs out there too, but I'm not sure that will really save you here... You'll still have a jumbled mess, it just wo...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
If I was writing code like yours I would prefer to use the [async](https://github.com/caolan/async) library and it's [waterfall](https://github.com/caolan/async#waterfall) function so that I don't have to wrap the asynchronous API with a promise version of it. It's extremely straightforward. Promises are great too and ...
Callback hell is a scary place :) You could use something like [Step.js](https://github.com/creationix/step) which makes callbacks a more readable sequence of steps. There are many other async management libs out there too, but I'm not sure that will really save you here... You'll still have a jumbled mess, it just wo...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
Callback hell is a scary place :) You could use something like [Step.js](https://github.com/creationix/step) which makes callbacks a more readable sequence of steps. There are many other async management libs out there too, but I'm not sure that will really save you here... You'll still have a jumbled mess, it just wo...
This one is a bit of a cheaty non-answer, but hopefully at least a tiny bit illuminating. The first thing I would do is simplify the synchronous version of the code itself. You start with something like this: ``` _makePostAppend: function (params, body, options) { // ...and in the darkness, bind them (if needed) _...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
If I was writing code like yours I would prefer to use the [async](https://github.com/caolan/async) library and it's [waterfall](https://github.com/caolan/async#waterfall) function so that I don't have to wrap the asynchronous API with a promise version of it. It's extremely straightforward. Promises are great too and ...
Promises allow you to write async code pretty much directly from sync code because they restore exception bubbling and return value composition. Assuming you have already rewritten the other methods to promises: ``` var Promise = require("bluebird"); ... _makePostAppend: function (params, body, options) { var ful...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
Promises allow you to write async code pretty much directly from sync code because they restore exception bubbling and return value composition. Assuming you have already rewritten the other methods to promises: ``` var Promise = require("bluebird"); ... _makePostAppend: function (params, body, options) { var ful...
This one is a bit of a cheaty non-answer, but hopefully at least a tiny bit illuminating. The first thing I would do is simplify the synchronous version of the code itself. You start with something like this: ``` _makePostAppend: function (params, body, options) { // ...and in the darkness, bind them (if needed) _...
19,874,973
So, I'm being a bit creative in searching through persistent graphical objects in HTML5 canvas by using PouchDB and MapRepduce. (I'm trying to tell if the user's clicked on that object with simple bounding box logic) That part isn't all that important; it might be silly, but I just want to do it, because I'm a dork lik...
2013/11/09
[ "https://Stackoverflow.com/questions/19874973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/351531/" ]
If I was writing code like yours I would prefer to use the [async](https://github.com/caolan/async) library and it's [waterfall](https://github.com/caolan/async#waterfall) function so that I don't have to wrap the asynchronous API with a promise version of it. It's extremely straightforward. Promises are great too and ...
This one is a bit of a cheaty non-answer, but hopefully at least a tiny bit illuminating. The first thing I would do is simplify the synchronous version of the code itself. You start with something like this: ``` _makePostAppend: function (params, body, options) { // ...and in the darkness, bind them (if needed) _...
387,453
I downloaded a video that's 11 parts the other day. Today I tried to extract it but it tells me that part04 is corrupt. So I checked "keep broken files", but of course it only gave me the beginning of the video. So I'm wondering if it's possible to extract it starting at part05. If that can't be done, does anyone know ...
2012/02/08
[ "https://superuser.com/questions/387453", "https://superuser.com", "https://superuser.com/users/117402/" ]
As long as you have the first part of the archive, it will be possible to at least partially extract the files. In WinRAR, use the advanced extraction (`Extract to...`) and tick the `Keep broken files` checkbox. When the errors come up, before closing the error box, navigate to the destination of the extraction and cop...
1. Try to **Repair archive** option of the WinRAR to repair *part4* and start to extract from 1st archive. 2. If it doesn't help, you can start to extract from part5. Simply, get rid of first 4 parts (move to another location etc.) before extract. But, if there is only one file to extract, this will fail. You can extra...
387,453
I downloaded a video that's 11 parts the other day. Today I tried to extract it but it tells me that part04 is corrupt. So I checked "keep broken files", but of course it only gave me the beginning of the video. So I'm wondering if it's possible to extract it starting at part05. If that can't be done, does anyone know ...
2012/02/08
[ "https://superuser.com/questions/387453", "https://superuser.com", "https://superuser.com/users/117402/" ]
As long as you have the first part of the archive, it will be possible to at least partially extract the files. In WinRAR, use the advanced extraction (`Extract to...`) and tick the `Keep broken files` checkbox. When the errors come up, before closing the error box, navigate to the destination of the extraction and cop...
If the file is archived with no actual compression (“store” mode) then it is possible to access its contents with a hexadecimal editor, and copy-paste each segment manually (minus the header / footer). It is possible that a single byte is corrupted, in which case the video file should be read by most media players, wi...
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
Since a format is known, and shouldn't change Substring should work for you ``` string data = "bsarbirthd0692"; string name, desc, date; name = data.Substring(0, 4); desc = data.Substring(4, 6); date = data.SubString(10); ``` **EDIT** There's also extension methods you can create to do what ever you want. This is o...
There is nothing like that, however writing something to implement: ``` IEnumerable<string> inputString.BreakIntoLengths(4, 6, 4) ``` with signature: ``` public IEnumerable<string> BreakIntoLengths(this string input, params int[] lengths); ``` is very easy: ``` public IEnumerable<string> BreakIntoLengths(this st...
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
Since a format is known, and shouldn't change Substring should work for you ``` string data = "bsarbirthd0692"; string name, desc, date; name = data.Substring(0, 4); desc = data.Substring(4, 6); date = data.SubString(10); ``` **EDIT** There's also extension methods you can create to do what ever you want. This is o...
Better from what? Something like this? ``` var listStrings = new List<string>(); var tempIndex = 0; var indexList = new List<int>{4, 6, 4} foreach(var length in indexList) { listStrings.Add(string.Substring(tempIndex , length); tempIndex += length } ```
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
Since a format is known, and shouldn't change Substring should work for you ``` string data = "bsarbirthd0692"; string name, desc, date; name = data.Substring(0, 4); desc = data.Substring(4, 6); date = data.SubString(10); ``` **EDIT** There's also extension methods you can create to do what ever you want. This is o...
No, there's no built-in way. I would use string methods like `Substring`: ``` string name, desc, date; if (input.Length >= 4) { name = input.Substring(0, 4); if (input.Length >= 10) { desc = input.Substring(4, 6); if (input.Length >= 14) { date = input.Substring(10, 4); ...
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
Since a format is known, and shouldn't change Substring should work for you ``` string data = "bsarbirthd0692"; string name, desc, date; name = data.Substring(0, 4); desc = data.Substring(4, 6); date = data.SubString(10); ``` **EDIT** There's also extension methods you can create to do what ever you want. This is o...
You can use Regexp for this ``` string str= "bsarbirthd0692"; var regex = "(?<name>.{4})(?<desc>.{6})(?<date>.{4})"; MatchCollection matches = Regex.Matches(str, regex); foreach(Match m in matches){ Console.WriteLine(m.Groups["name"].ToString()); Console.WriteLine(m.Groups["desc"].ToString()); Console.Writ...
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
There is nothing like that, however writing something to implement: ``` IEnumerable<string> inputString.BreakIntoLengths(4, 6, 4) ``` with signature: ``` public IEnumerable<string> BreakIntoLengths(this string input, params int[] lengths); ``` is very easy: ``` public IEnumerable<string> BreakIntoLengths(this st...
Better from what? Something like this? ``` var listStrings = new List<string>(); var tempIndex = 0; var indexList = new List<int>{4, 6, 4} foreach(var length in indexList) { listStrings.Add(string.Substring(tempIndex , length); tempIndex += length } ```
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
There is nothing like that, however writing something to implement: ``` IEnumerable<string> inputString.BreakIntoLengths(4, 6, 4) ``` with signature: ``` public IEnumerable<string> BreakIntoLengths(this string input, params int[] lengths); ``` is very easy: ``` public IEnumerable<string> BreakIntoLengths(this st...
No, there's no built-in way. I would use string methods like `Substring`: ``` string name, desc, date; if (input.Length >= 4) { name = input.Substring(0, 4); if (input.Length >= 10) { desc = input.Substring(4, 6); if (input.Length >= 14) { date = input.Substring(10, 4); ...
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
You can use Regexp for this ``` string str= "bsarbirthd0692"; var regex = "(?<name>.{4})(?<desc>.{6})(?<date>.{4})"; MatchCollection matches = Regex.Matches(str, regex); foreach(Match m in matches){ Console.WriteLine(m.Groups["name"].ToString()); Console.WriteLine(m.Groups["desc"].ToString()); Console.Writ...
Better from what? Something like this? ``` var listStrings = new List<string>(); var tempIndex = 0; var indexList = new List<int>{4, 6, 4} foreach(var length in indexList) { listStrings.Add(string.Substring(tempIndex , length); tempIndex += length } ```
29,653,995
I am using zeroMQ to realize the send-recv message. I use this pattern: PUB-SUB. However, it seems that I can send some message from the publisher but I couldn't receive it from the subscriber. Here is my code: //subscriber: ``` int main(int argc, char** argv){ void * context = zmq_ctx_new(); void * subsc...
2015/04/15
[ "https://Stackoverflow.com/questions/29653995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305546/" ]
You can use Regexp for this ``` string str= "bsarbirthd0692"; var regex = "(?<name>.{4})(?<desc>.{6})(?<date>.{4})"; MatchCollection matches = Regex.Matches(str, regex); foreach(Match m in matches){ Console.WriteLine(m.Groups["name"].ToString()); Console.WriteLine(m.Groups["desc"].ToString()); Console.Writ...
No, there's no built-in way. I would use string methods like `Substring`: ``` string name, desc, date; if (input.Length >= 4) { name = input.Substring(0, 4); if (input.Length >= 10) { desc = input.Substring(4, 6); if (input.Length >= 14) { date = input.Substring(10, 4); ...
11,099,083
I've been looking at the sorl-thumbnail's documentation, and I still can't figure out how to: 1. upload images to sorl-thumbnail. 2. selectively show images from sorl-thumbnail. (for example, load a specific image from sorl-thumbnail from a view and show it, with customized size, etc.) Could you give some specific ex...
2012/06/19
[ "https://Stackoverflow.com/questions/11099083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269334/" ]
If you want greater flexibility you can generate the thumbnail right in the view. The following is straight from the [sorl-thumbnail documentation](http://sorl-thumbnail.readthedocs.org/en/latest/examples.html#low-level-api-examples): ``` from sorl.thumbnail import get_thumbnail im = get_thumbnail(my_file, '100x100',...
You can use sorl.thumbnail using the thumbnail template tags. Here's an example: ``` {% load thumbnail %} {% thumbnail recipe.image "430x250" as thumb %} <img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" alt="{{ recipe.title }}" /> {% endthumbnail %} ``` You don't upload images t...
11,099,083
I've been looking at the sorl-thumbnail's documentation, and I still can't figure out how to: 1. upload images to sorl-thumbnail. 2. selectively show images from sorl-thumbnail. (for example, load a specific image from sorl-thumbnail from a view and show it, with customized size, etc.) Could you give some specific ex...
2012/06/19
[ "https://Stackoverflow.com/questions/11099083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269334/" ]
You can use sorl.thumbnail using the thumbnail template tags. Here's an example: ``` {% load thumbnail %} {% thumbnail recipe.image "430x250" as thumb %} <img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" alt="{{ recipe.title }}" /> {% endthumbnail %} ``` You don't upload images t...
When I have to use sorl-thumbnail I make difference between 2 kind of images: **Django objects with ImageField** ================================== When I have an object in Django with an ImageField I render it with thumbnail like this: ``` # Let's supose our object imagefield is called img {% thumbnail obj.img "100...
11,099,083
I've been looking at the sorl-thumbnail's documentation, and I still can't figure out how to: 1. upload images to sorl-thumbnail. 2. selectively show images from sorl-thumbnail. (for example, load a specific image from sorl-thumbnail from a view and show it, with customized size, etc.) Could you give some specific ex...
2012/06/19
[ "https://Stackoverflow.com/questions/11099083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269334/" ]
If you want greater flexibility you can generate the thumbnail right in the view. The following is straight from the [sorl-thumbnail documentation](http://sorl-thumbnail.readthedocs.org/en/latest/examples.html#low-level-api-examples): ``` from sorl.thumbnail import get_thumbnail im = get_thumbnail(my_file, '100x100',...
When I have to use sorl-thumbnail I make difference between 2 kind of images: **Django objects with ImageField** ================================== When I have an object in Django with an ImageField I render it with thumbnail like this: ``` # Let's supose our object imagefield is called img {% thumbnail obj.img "100...
14,762,282
I am making a calculator that has a roman numeral mode. I have the operations performed in the model view, and a view controller. My problem is that I need to convert the roman numeral to a NSNumber. There is a UILabel, and the view controller takes what is in the label and sets it as the operand of the model view. Doe...
2013/02/07
[ "https://Stackoverflow.com/questions/14762282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1402027/" ]
Here are a couple of resources that may help you: [Roman Numbers Convert](https://bitbucket.org/exister/roman-numbers-converter/src/ed0559cc63ee/roman_converter/RomanNumber.m) -This one is probably the better of the two as this has forward/backward translation [pzearfoss / NSNumber-RomanNumerals](https://github.com/p...
you can try this function ``` -(NSString*)numberToRomanNumerals:(int)num{ if (num < 0 || num > 9999) { return @""; } // out of range NSArray *r_ones = [[NSArray alloc]initWithObjects:@"I", @"II", @"III", @"IV", @"V", @"VI", @"VII", @"VIII",@"IX",nil]; NSArray *r_tens = [[NSArray alloc]initWithObjects:@"X...
14,762,282
I am making a calculator that has a roman numeral mode. I have the operations performed in the model view, and a view controller. My problem is that I need to convert the roman numeral to a NSNumber. There is a UILabel, and the view controller takes what is in the label and sets it as the operand of the model view. Doe...
2013/02/07
[ "https://Stackoverflow.com/questions/14762282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1402027/" ]
Here are a couple of resources that may help you: [Roman Numbers Convert](https://bitbucket.org/exister/roman-numbers-converter/src/ed0559cc63ee/roman_converter/RomanNumber.m) -This one is probably the better of the two as this has forward/backward translation [pzearfoss / NSNumber-RomanNumerals](https://github.com/p...
Just wrote one, because everything I've seen before was a bit weird, so you're welcome to try: <https://github.com/shoumikhin/RomanNumeral> ``` //============================================================================== @implementation NSNumber (RomanNumeral) //----------------------------------------------------...
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
use `$regex` in mongodb [how to use regex](https://docs.mongodb.com/manual/reference/operator/query/regex/) example ``` select * from table where abc like %v% ``` in mongo ``` var colName="v"; models.customer.find({ "abc": { $regex: '.*' + colName + '.*' } }, function(err,data){ console.log('data'...
You can run a regex lookup with dynamic values using `RegExp`: ```js var promise = UserSchema.find({name: new RegExp(req.params.keyword, 'i') }).limit(5); ``` Notice the `'i'` option for case insensitivity.
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
You can use the RegExp object to make a regex with a variable, add the 'i' flag if you want the search to be case insensitive. ``` const mongoose = require('mongoose'); const User = mongoose.model('user'); const userRegex = new RegExp(userNameVariable, 'i') return User.find({name: userRegex}) ```
``` select * from table where abc like %_keyword% ``` in mongo it is ``` const list = await ProductModel.find({{ pname :{ $regex : '.*'+ _keyword + '.*' }}); ``` here `_keyword` can be any text eg. fruit, pen, etc. as i am searching products model.
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
use `$regex` in mongodb [how to use regex](https://docs.mongodb.com/manual/reference/operator/query/regex/) example ``` select * from table where abc like %v% ``` in mongo ``` var colName="v"; models.customer.find({ "abc": { $regex: '.*' + colName + '.*' } }, function(err,data){ console.log('data'...
You can use the RegExp object to make a regex with a variable, add the 'i' flag if you want the search to be case insensitive. ``` const mongoose = require('mongoose'); const User = mongoose.model('user'); const userRegex = new RegExp(userNameVariable, 'i') return User.find({name: userRegex}) ```
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
Or just simply ``` const name = "John" UserSchema.find({name: {$regex: name, $options: 'i'}}).limit(5); ``` **i** for case-insensitive
This is how i have done it to find if search string present in name/email. Hope it helps someone. ```js const getPeerSuggestions = async (req, res, next) => { const { search } = req.query; const rgx = (pattern) => new RegExp(`.*${pattern}.*`); const searchRgx = rgx(search); const peers = await User.find({ ...
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
``` select * from table where abc like %_keyword% ``` in mongo it is ``` const list = await ProductModel.find({{ pname :{ $regex : '.*'+ _keyword + '.*' }}); ``` here `_keyword` can be any text eg. fruit, pen, etc. as i am searching products model.
You can run a regex lookup with dynamic values using `RegExp`: ```js var promise = UserSchema.find({name: new RegExp(req.params.keyword, 'i') }).limit(5); ``` Notice the `'i'` option for case insensitivity.
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
This is how i have done it to find if search string present in name/email. Hope it helps someone. ```js const getPeerSuggestions = async (req, res, next) => { const { search } = req.query; const rgx = (pattern) => new RegExp(`.*${pattern}.*`); const searchRgx = rgx(search); const peers = await User.find({ ...
``` select * from table where abc like %_keyword% ``` in mongo it is ``` const list = await ProductModel.find({{ pname :{ $regex : '.*'+ _keyword + '.*' }}); ``` here `_keyword` can be any text eg. fruit, pen, etc. as i am searching products model.
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
use `$regex` in mongodb [how to use regex](https://docs.mongodb.com/manual/reference/operator/query/regex/) example ``` select * from table where abc like %v% ``` in mongo ``` var colName="v"; models.customer.find({ "abc": { $regex: '.*' + colName + '.*' } }, function(err,data){ console.log('data'...
Or just simply ``` const name = "John" UserSchema.find({name: {$regex: name, $options: 'i'}}).limit(5); ``` **i** for case-insensitive
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
This is how i have done it to find if search string present in name/email. Hope it helps someone. ```js const getPeerSuggestions = async (req, res, next) => { const { search } = req.query; const rgx = (pattern) => new RegExp(`.*${pattern}.*`); const searchRgx = rgx(search); const peers = await User.find({ ...
You can use the RegExp object to make a regex with a variable, add the 'i' flag if you want the search to be case insensitive. ``` const mongoose = require('mongoose'); const User = mongoose.model('user'); const userRegex = new RegExp(userNameVariable, 'i') return User.find({name: userRegex}) ```
43,729,199
I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank. This my code return blank. ``` var promise = UserSchema.find({name: /req.params.keyword/ })...
2017/05/02
[ "https://Stackoverflow.com/questions/43729199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5361328/" ]
This is how i have done it to find if search string present in name/email. Hope it helps someone. ```js const getPeerSuggestions = async (req, res, next) => { const { search } = req.query; const rgx = (pattern) => new RegExp(`.*${pattern}.*`); const searchRgx = rgx(search); const peers = await User.find({ ...
You can run a regex lookup with dynamic values using `RegExp`: ```js var promise = UserSchema.find({name: new RegExp(req.params.keyword, 'i') }).limit(5); ``` Notice the `'i'` option for case insensitivity.