texts
sequence | tags
sequence |
---|---|
[
"sharepoint website modification and user activity interception",
"There are several topics I have questions about, where googling did no good to me, neither did it lead me to any valuable resources.\n\nCan I modify the SharePoint page to my needs, like can I customize it so much that I can add something like a 'calculator of services'(like there are dropdowns and depending on different selected ones calculated results change)on it. I saw that I can embed html, but everything I saw and stumbled up-on is kind of abstract.\nCan I intercept the users who e.g.: click on a button. I have a SharePoint webpage with users within it, if user1 clicked a button can I be informed about that or can I trigger some actions as a result ?\nCan I have a file upload on SharePoint page ?\n\nAny resource/comment/friendly advice will be valuable for me.\nThanks."
] | [
"sharepoint",
"microsoft365"
] |
[
"Looking for a guide using FXML with Java 7",
"I need to target Java 7 and would like to use JavaFX and FXML on that project. We have some working code for Java 8 and it would save an immense amount of time if we can retro-fit those modules to Java 7.\n\nI'm posting because I'm getting compile errors on the first attempt. In the first instance, I can't find the @FXML annotation, package:\n\n\nimport javafx.fxml.FXML\n\n\nIn Java 8 JDK. However that just a for instance example. \n\nI was hoping to find Java 7 JDK JavaFX documentation. The searches and tutorials seem to be either aimed at Java 8 and/or not about things that work differently between the two\n\nThe solution is some documentation describing what's different in Java 8 JDK JavaFX to Java 7's JavaFS JDK? Google isn't giving me much satisfaction and most of the Stackoverflow questions are going the other way. I suppose it is rare for someone to ask how to go back a version. Any one seen, know of or some release notes on code differences (or a migration guide??). Many thanks in advance."
] | [
"java",
"javafx",
"compatibility",
"java-7",
"fxml"
] |
[
"Check if an int is between two items in an array",
"Alright, so I'm working on a leveling system in java. I have this from my previous question for defining the level \"exp\" requirements:\n\n int[] levels = new int[100];\n for (int i = 1; i < 100; i++) {\n levels[i] = (int) (levels[i-1] * 1.1);\n }\n\n\nNow, my question is how would I determine if an exp level is between two different integers in the array, and then return the lower of the two? I've found something close, but not quite what I'm looking for here where it says binary search. Once I find which value the exp falls between I'll be able to determine a user's level. Or, if anyone else has a better idea, please don't hesitate to mention it. Please excuse my possible nooby mistakes, I'm new to Java. Thanks in advance to any answers.\n\nSolved, thanks for all the wonderful answers."
] | [
"java",
"arrays"
] |
[
"Perl map block local variable usage",
"This code compiles a set by way of hash keys of the unique basename stubs in a set of paths.\n\n%stubs = map { $f=basename $_; $f =~ /^([A-Za-z]+[0-9]+)\\./ ; $1=>() } @pathlist;\n\n\nWhy do I need the $f references here? I thought I'd be ok with:\n\n%stubs = map { basename; /^([A-Za-z]+[0-9]+)\\./; $1=>() } @pathlist;\n\n\nBut I get no match. Am I not permitted to modify $_ in the map block?\n\n\nFor those wondering what the code is doing:\n\nFor each $path (@pathlist), it's getting the basename, matching the first letter-number sequence, and then returning the first bracket match as the key on an empty list value. Example:\n\n/some/dir/foo123.adfjijoijb\n/some/dir/foo123.oibhobihe\n/some/dir/bar789.popjpoj\n\n\nreturns\n\nfoo123 => ()\nbar789 => ()\n\n\nAfter which I use the keys of the map as the set of values so process."
] | [
"perl",
"map",
"implicit",
"local-variables"
] |
[
"PyTorch code stops with message \"Killed\". What killed it?",
"I train a network on GPU with Pytorch. However, after at most 3 epochs, code stops with a message :\nKilled\nNo other error message is given.\nI monitored the memory and gpu usage, there were still space during the run. I reviewed the /var/sys/dmesg to find a detailed message regarding to this, however no message with "kill" was entered. What might be the problem?\nCuda version: 9.0\nPytorch version: 1.1.0"
] | [
"linux",
"pytorch"
] |
[
"Transparent Section in TableViewController",
"In my TableView I use static cells. I take one section and in this section there are five cells(static cells). Now I want to make the whole section or these five cells transparent. That means I can see the Table View Controller background through the cells. How can I do that?\n\nI have gone through many solutions. But not solved. \n\nEdit:\n\nMay be many of you are not clear about my question. I want the cell like the below image. it is downloaded image and there will be section which is not available in this image. I am just using this image to clear the question. Look at the image the cell background is transparent."
] | [
"ios",
"objective-c",
"uitableview"
] |
[
"Neural Network stuck at training",
"Hello everyone I started training a network ana it got stuck, it did not finish the first epoch.\n\n\n\n\nHere is the code I used:\n\ntop_model_weights_path = '/data/fc_model.h5'\nimg_width, img_height = 150, 150 \n-train_data_dir = '/data/train'\nvalidation_data_dir = '/data/validation'\nnb_train_samples = 2000\nnb_validation_samples = 800\nepochs = 50\nbatch_size = 16\nmodel = applications.VGG16(weights='imagenet', include_top=False, input_shape=(150, 150, 3))\nprint('Model loaded.')\ntop_model = Sequential()\ntop_model.add(Flatten(input_shape=model.output_shape[1:]))\ntop_model.add(Dense(256, activation='relu'))\ntop_model.add(Dropout(0.5))\ntop_model.add(Dense(1, activation='sigmoid'))\ntop_model.load_weights(top_model_weights_path)\nmodel = Model(inputs= model.input, outputs= top_model(model.output))\nfor layer in model.layers[:25]:\n layer.trainable = False\nmodel.compile(loss='binary_crossentropy',\n optimizer=optimizers.SGD(lr=1e-4, momentum=0.9),\n metrics=['accuracy'])\ntrain_datagen = ImageDataGenerator(\n rescale=1. / 255,\n shear_range=0.2,\n zoom_range=0.2,\n horizontal_flip=True)\ntest_datagen = ImageDataGenerator(rescale=1. / 255)\ntrain_generator = train_datagen.flow_from_directory(\n train_data_dir,\n target_size=(img_height, img_width),\n batch_size=batch_size,\n class_mode='binary')\nvalidation_generator = test_datagen.flow_from_directory(\n validation_data_dir,\n target_size=(img_height, img_width),\n batch_size=batch_size,\n class_mode='binary')\nmodel.fit_generator(\n train_generator,\n samples_per_epoch=nb_train_samples,\n epochs=epochs,\n validation_data=validation_generator,\n nb_val_samples=nb_validation_samples)\n\n\nI am using Transfer Learning. I followed this tutorial online :\nTutorial\n\nPlease help thank you."
] | [
"keras",
"deep-learning",
"transfer-learning"
] |
[
"Docker compose: meaning of {} in volume definition",
"What is the meaning of {} in volume definition?\n\nFor example\n\nversion: '2'\n\nvolumes:\n dataelasticsearch: {}\n\nservices: \n elasticsearch:\n image: docker.elastic.co/elasticsearch/elasticsearch:5.4.3\n volumes:\n - ./dataelasticsearch:/usr/share/elasticsearch/data"
] | [
"docker",
"docker-compose",
"yaml",
"docker-volume"
] |
[
"If JOIN value is greater than X then set value to true",
"SELECT X(Coordinates) AS `latitude`, Y(Coordinates) AS `longitude`, `AtcoCode` AS `atcocode`, `CommonName` as `name`,\n(\n SELECT COUNT(`jptl`.`id`)\n FROM `a`.`jps` `jptl`\n JOIN `a`.`journpat` `jp` ON `jp`.`journey_pattern_section_reference` = `jptl`.`journey_pattern_section_reference`\n JOIN `a`.`serv` ON `service`.`reference` = `jp`.`service_reference`\n JOIN `a`.`op` ON `operator`.`reference` = `service`.`operator_reference`\n JOIN `a`.`operator` `fmbo` ON fmbo.operator_reference = operator.reference\n WHERE `jptl`.`stop_from` = AtcoCode\n) AS subscriber\nFROM `a`.`qwerty`\nWHERE MBRContains(\n GeomFromText( concat('LINESTRING(',50.922538,-1.301773,',',50.916856,-1.306708,')') ),\n Coordinates)\n\n\nIf the value of subscriber is greater than 1 then the subscriber value should be true, otherwise it should be false. How can I do this?"
] | [
"mysql",
"sql"
] |
[
"Strings and UIImages in the same Dictionary Swift",
"I am quite new to Swift and Xcode. I have made a UITableView to display specific posts from instagram. Due to other changes I have made recently (to get other things to work) I need to add both UIImages and Strings to a Dictionary (which the data is then put into the table) so everything will run smoothly. For example I need the image and the caption.\n\nThis is what I have done so far, but it doesn't seem to work.\n\ninstagramDataDictionary[\"image_standard\"] = image as UIImage!\n\n\n('image' is the image loaded asynchronously)\n\nvar cellImageView = UIImageView(image: allDataArray[indexPath.section][\"image_standard\"] as UIImage!)\n\n\nThen I try to add the Image to the table but when I run the app nothing displays (I add the subview after the above code). Do I need to save the image in some other way? \n\nThanks!"
] | [
"ios",
"xcode",
"string",
"swift",
"uiimage"
] |
[
"How to Rewrite make .htaccess for site \"replacement\" (old site to subfolder, new site in root) while keeping the Google Love",
"I have a site on a domain existing for many years (10+) and are now changing the site from one CMS to another. This is a lengthy process to move the content and some of it will not move and should co-exist for some years forward.\n\nI alleready moved the old site from the root (www.example.com) to a subfolder (www.example.com/_old). The old site had the follwing .htaccess to force www. on my domain since early 2007. I have deleted this on the .htaccess in the (www.example.com/_old/) folder.\n\nRewriteCond %{HTTP_HOST} !^www\\.\nRewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]\n\n\nNow I stated the news site in another sub-dir (www.example.com/dp/) to keep the root empty with just a .htaccess and rewrite but what I really want is:\n\n\nI want to access the new site on the root of the domain w/o www (example.com)\nI want the old site to still serve as the main landing page for all old links from the \"world\" - primarily Google (www.example.com/_old/[whatever] from www.example.com/[whatever]\nI want to make sure that when I move a page to the new site (www.example.com/_old/oldpage.html to example.com/newpage.html) I can redirect that URL specifically to the new site to avoid duplicate content.\n\n\nI am here:\n\nRewriteCond %{HTTP_HOST} www.example.com\nRewriteRule ^(.*)$ /_old/$1 [L,R=301]\n\nRewriteCond %{HTTP_HOST} example.com\nRewriteCond %{REQUEST_URI} /dp/\nRewriteRule ^(.*)$ http://example.com/$1 [L,R=307]\n\nRewriteCond %{HTTP_HOST} example.com\nRewriteRule ^(.*)$ http://www.example.com/_old/$1 [L,R=301]\n\n\nThis is still with the new site in the sub-folder /dp/"
] | [
".htaccess",
"mod-rewrite",
"rewrite"
] |
[
"Compass background mixin with variable argument",
"Here is a very reduced test case of what I am trying to accomplish:\n\nThis works:\n\nhtml\n $gradient: red, salmon\n +background(linear-gradient($gradient))\n\n\nThis does not work:\n\nhtml\n $gradient: top, red, salmon\n +background(linear-gradient($gradient))\n\n\nAnd it gives me this error: \"At least two color stops are required for a linear-gradient()\"\n\nYet, $gradient: top, red 10%, salmon 10% doesn't work. Nor does $gradient: 35% 10%, red 10%, salmon 10%. I need to be able to pass any valid CSS3 combination of the gradient syntax into the mixin, even multiple gradients.\n\n+background(linear-gradient(35% 10%, red 10%, salmon 10%)) works, so I assume it should with a variable placeholder as well.\n\nHow can I get +background to accept any valid CSS I pass it?"
] | [
"sass",
"compass-sass"
] |
[
"Have firestore put document ID in a struct property",
"Is it possible when adding document to firestore with go to have the ID of that document stored in one of the properties of the added struct ?\n\ntype MyStruct struct {\n ID string `json:\"id\" firestore:\"id,omitempty\"`\n}\n\n\nI would like the ID of the document to be in the ID of the struct."
] | [
"go",
"google-cloud-firestore"
] |
[
"Data types in ASP.NET Core 3.1 MVC models",
"I am extremely new to coding and have struck a problem. I am doing an ASP.NET Core 3.1 MVC app. I am trying to create a model using a date column and I am not having any success. The code I am using is shown below.\nMy thought is that there must be a way to store a date in SQL but to no avail. Any conversation or comments great appreciated.\nThe error occurs on this line\npublic Date CreationDate { get; set; }\n\nIt will not accept Date as a data type.\nRegards Steve\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\nusing System.Linq;\nusing System.Threading.Tasks;\n\nnamespace SalesAccount.Models\n{\n public class Contract\n {\n [Key]\n public int Id { get; set; }\n [Required]\n **public Date CreationDate { get; set; }**\n [Required]\n public char ContractNumber { get; set; }\n \n }\n}"
] | [
"sql",
"model-view-controller",
"types"
] |
[
"Eclipse: Programmatically manipulate class",
"I just came across the issue that I had 10 (or so) Java classes for all of which I wanted to:\n\n\nAdd a formal parameter \"String newparam\" to their constructor\nAdd this as an actual parameter to the super() call to the super class constructor (thus, the result should be super(..., newparam)).\n\n\nThe reason is, obviously, that the common super class of those classes now has one constructor parameter more and all extending classes had to adapt.\n\nI just can't believe that I need to do this by hand for all classes. Eclipse must have all required concepts like \"constructor\", \"parameter\" etc. in its internals. Any way to create a script for this?\n\nI apologize if this is trivial/well known, I have to confess that I really don't know and appreciate any hints."
] | [
"java",
"eclipse",
"automation"
] |
[
"Service worker with SSL certificate cache",
"We have a number of sites hosted on a Google Cloud server.\n\nWe have added a renewed SSL certificate to the server recently; all our sites loaded the new certificate afterward, except the one that has service-worker setup. It seems like that site is still loading the old certificate (that is still valid at the moment - expires tomorrow).\n\nIt looks like it is related to the cache - after clearing the browser cache the new certificate is also loaded for this site.\n\nWould it be an issue for the client when the certificate does expire? When the browsers (Chrome, Firefox, etc.) find the expired certificate in the cache, will they check the server for the new certificate automatically, or will they show a SSL warning page (like https://expired.badssl.com/)?\n\nIs there a way that we could ensure that the client/browsers will load the renewed certificate from the server?"
] | [
"ssl",
"caching",
"ssl-certificate",
"browser-cache",
"service-worker"
] |
[
"How to configure Nginx for different subdomains via different ports?",
"I've struggled for couple of weeks on this configuration.What I want to achieve can be listed as follows.\n\n1.I registered a domain not long ago.And I've set up some web service on my VPS,such as a blog,a forum and Owncloud. Now I want to configured the Nginx so that I can run all the service on one VPS and one IP address. In order to run owncloud,I have to modify the /etc/php5/fpm/pool.d/www.confto listen = 9000.In this case,I can only get one service (Owncloud)function,because if I want to run the forum I must uncomment the listen = /var/run/php5-fpm.sock.What's more,I've tried to uncomment both of them,Nginx showed 502 afterwards.\n\n2.I'm using Hexo as my blog.When I start the server,I can access into my blog on IP:4000.So I wonder if I could run my blog server on background and edit the posts online via a subdomain which has been redirected to port 4000.If it's possible,should I modify the nginx.conf or add something in sites-available?\n\n3.Can I deploy different web services on different subdomain?Which file is to modify?It's said that I can achieve this by using reverse proxy?\n\nSorry for the pathetic English and expression.Thanks in advance."
] | [
"nginx"
] |
[
"C++11 creating new threads in a detached thread",
"I am thinking about the possibility of creating a std::thread, detach() it from the main thread while the detached thread creates threads and waits for a join() before running the next thread. \n\nBut I dont this as being possible as I am always crashing after the first thread but before the next.\n\nSomeplace in code:\n\nstd::thread t1(&B::start, this); //Launch a thread\nt1.detach();\n\n\ninside B::start:\n\nstd::thread t2(&C::start, this); //Launch a thread\nt2.join();\n\nstd::thread t3(&D::start, this); //Launch a thread\nt3.join();\n\nstd::thread t4(&D::start, this); //Launch a thread\nt4.join();\n\n\ninside C::start:\n\nstd::cout << \"Thread t2 is starting\" << std::endl;\nauto start = std::chrono::high_resolution_clock::now();\nstd::this_thread::sleep_until(start + std::chrono::seconds(60));\nstd::cout << \"Thread t2 waited for 60 seconds\" << std::endl;\n\n\ninside D::start:\n\nstd::cout << \"Thread t3 is starting\" << std::endl;\nauto start = std::chrono::high_resolution_clock::now();\nstd::this_thread::sleep_until(start + std::chrono::seconds(60));\nstd::cout << \"Thread t3 waited for 60 seconds\" << std::endl;\n\n\ninside E::start:\n\nstd::cout << \"Thread t4 is starting\" << std::endl;\nauto start = std::chrono::high_resolution_clock::now();\nstd::this_thread::sleep_until(start + std::chrono::seconds(60));\nstd::cout << \"Thread t4 waited for 60 seconds\" << std::endl;\n\n\nSo here is what I would be expecting to happen:\n\na thread, t1 would be created and detached from the main thread so the main app keeps running\nin t1, t2 is created and sleeps for 60 seconds.\nafter the 60 seconds, t3 is created and sleeps for 60 seconds.\nafter the 60 seconds, t4 is created and sleeps for 60 seconds.\n\nAll while my main thread keeps running doing its thing.\n\nUPDATE: How does one take this std::thread t1(&B::start, this); //Launch a thread and break it up so that I declare std::thread t1; in a header but do the (&B::start, this); where I need to and then detach();"
] | [
"c++",
"multithreading",
"c++11",
"stdthread"
] |
[
"Excel VBA - Fill down to bottom of sheet",
"I have a macro I've made, but when I run the macro it fills down the updated value to the bottom of the sheet instead of to the bottom of the data set, is there a way to make it only fill down partially?\nWith ActiveSheet\n .AutoFilterMode = False\n \n With Range("I1", Range("I" & Rows.Count).End(xlDown))\n .AutoFilter Field:=1, Criteria1:="="\n \n On Error Resume Next\n .Resize(.Rows.Count - 1).Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = "1"\n On Error GoTo 0\n End With\n .AutoFilterMode = False\nEnd With"
] | [
"excel",
"vba"
] |
[
"How is the Windows 10 Game-Bar implemented?",
"Pressing +G in Windows 10 causes the Xbox Game Bar to open - it overlays the current application, regardless of if it's a game or not (though Windows maintains its own database of games as a hint to show the bar automatically on process startup or not)\n\nI wondered how this is possible - I don't have any Windows 10 Xbox App-related processes running on my computer.\n\nProcess Explorer shows that when WinKey+G is pressed, the following happens:\n\n\nAn svchost.exe instance (which is hosting the BrokerInfrastructure, DcomLaunch, LSM, PlugPlay Power, and SystemEventsBroker services) invokes \"%windir%\\System32\\bcastdvr.exe\" -ServerName:Windows.Media.Capture.Internal.BroadcastDVRServer\nbcastdvr.exe then invokes \"C:\\Windows\\System32\\GamePanel.exe {hexString} /eventType=8 (where {hexString} is a 16-hex digit (8 byte) string, presumably a window handle or equivalent).\nGamePanel.exe then creates the window.\n\n\nBut the overlay window itself is special - it doesn't seem to be a normal hWnd - for example, I observe that my mouse cursor loses its drop-shadow and the \"sonar pulse\" effect (when I tap the Ctrl key to show my cursor location) stays in-place where my mouse cursor was when I opened the Game bar. I also noticed how smooth and fluid the game-bar's animations are - quite unlike a typical Win32 window. Is it using the XAML UI framework? If so, how is it doing it outside of the Windows UWP Sandbox?\n\nCuriously, the game-bar is also able to target elevated windows too.\n\nI tried - and failed - to inspect the windows using Spy++ because it disappears as soon as another window gets focus - but when I elected to start recording a window (so you get the recording overlay, which always remains on-screen), the overlay disappeared as soon as I used Spy++'s \"Find Window\" tool. How is the GameBar Recording Overlay doing this?"
] | [
"windows-10"
] |
[
"Why does Spring not provide reactive (non-blocking) clients for relational databases?",
"I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs?"
] | [
"java",
"spring-data",
"spring-webflux",
"reactive",
"r2dbc"
] |
[
"Why javascript function recognize a global variable as undefined?",
"In the following code why undefined is printed instead of 1 ?\n\nvar foo = 1; \nfunction bar() { \n if (false) { \n var foo = 10; \n }\n alert(foo); \n} \nbar();\n\n\nThe foo variable will never be re-declared as if(false) block will never be reached so I don't understand why the function doesn't recognize the outer value of foo. Does hoisting apply even if the declaration statement is never reached ?"
] | [
"javascript",
"hoisting"
] |
[
"'Exceeded maximum allocated IDs' in production GAE",
"I'm trying to copy models over from one entity to another, preserving their auto-generated ID. I'm using the following code:\n\nkey = db.Key.from_path('TargetEntity', source.key().id())\ndb.allocate_id_range(app, start = source.key().id(), end = source.key().id())\nTargetEntity(key = key).put()\n\n\nThis works fine in dev_appserver, but when running this in production, allocate_id_range throws \"Exceeded maximum allocated IDs\". The ID it is trying to allocate is 5093058741796864L.\n\nOther issues on StackOverflow mentioning this either started using their own ID generator (which is not a solution), or seem to be due to an issue with unusually high IDs from years ago with a new ID generator (which doesn't seem to apply anymore)."
] | [
"google-app-engine",
"google-cloud-datastore",
"google-app-engine-python"
] |
[
"Tkinter Class structure (class per frame) issue with duplicating widgets",
"Ive been trying out OOP for use with Tkinter - Im getting there (I think) slowly...\n\nI wanted to build a structure where each frame is handled by its own class, including all of its widgets and functions. Perhaps I am coming from the wrong angle but that is what makes most logical sense to me. - Feel free to tell me if you agree / disagree!\n\nI know why the problem is happening - when im calling each class my __init__ runs everytime and builds the relevant widgets regardless of whether they are already present in the frame. However, the only way I can think of getting round this would be to build each frame in the __init__ of my primary class GUI_Start. - Although this seems like a messy and un-organised soloution to the problem. \n\nIs there a way I can achieve a structure where each class takes care of its own functions and widgets but doesn't build the frame each time?\n\nSee below for minimal example of the issue:\n\nfrom Tkinter import *\n\nclass GUI_Start:\n\n def __init__(self, master):\n self.master = master\n self.master.geometry('300x300')\n self.master.grid_rowconfigure(0, weight=1)\n self.master.grid_columnconfigure(0, weight=1)\n self.win_colour = '#D2B48C'\n self.frames = {}\n\n for window in ['win1', 'win2']:\n frame = Frame(self.master, bg=self.win_colour, bd=10, relief=GROOVE)\n frame.grid(row=0, column=0, sticky='news')\n setattr(self, window, frame)\n self.frames[window] = frame\n\n Page_1(self.frames)\n\n def Next_Page(self, frames, controller):\n controller(frames)\n\n\nclass Page_1(GUI_Start):\n\n def __init__(self, master):\n self.master = master\n self.master['win1'].tkraise()\n\n page1_label = Label(self.master['win1'], text='PAGE 1')\n page1_label.pack(fill=X)\n\n page1_button = Button(self.master['win1'], text='Visit Page 2...', command=lambda: self.Next_Page(self.master, Page_2))\n page1_button.pack(fill=X, side=BOTTOM)\n\n\nclass Page_2(GUI_Start):\n\n def __init__(self, master):\n self.master = master\n self.master['win2'].tkraise()\n\n page2_label = Label(self.master['win2'], text='PAGE 2')\n page2_label.pack(fill=X)\n\n page2_button = Button(self.master['win2'], text='Back to Page 1...', command=lambda: self.Next_Page(self.master, Page_1))\n page2_button.pack(fill=X, side=BOTTOM)\n\n\nroot = Tk()\ngui = GUI_Start(root)\nroot.mainloop()\n\n\nFeel free to critique the structure as I may be trying to approach this from the wrong angle!\n\nAny feedback would be much appreciated!\nLuke"
] | [
"python",
"python-2.7",
"class",
"oop",
"tkinter"
] |
[
"PHP multi dimensional array intersect",
"I've written this code:\n\n<?php\n\n$aArray = array\n( \narray(0,0,0), \narray(1,0,0),\narray(2,0,0),\narray(3,0,0),\narray(4,0,0),\narray(5,0,0),\narray(6,0,0),\narray(7,0,0)\n);\n\n$jump = array\n( \narray(0,0,0), \narray(1,0,0),\narray(9,7,4),\narray(3,0,0),\narray(4,0,0),\narray(5,0,0),\narray(6,0,0),\narray(7,0,0)\n);\n\n$result = array_intersect($aArray, $jump);\n\necho var_dump($result);\n\n\nthe result I'm getting is this: \n\narray(8) { \n[0]=> array(3) { \n [0]=> int(0) \n [1]=> int(0) \n [2]=> int(0) } \n[1]=> array(3) { \n [0]=> int(1) \n [1]=> int(0) \n [2]=> int(0) } \n[2]=> array(3) { \n [0]=> int(2) \n [1]=> int(0) \n [2]=> int(0) } \n[3]=> array(3) { \n [0]=> int(3) \n [1]=> int(0) \n [2]=> int(0) } \n[4]=> array(3) { \n [0]=> int(4) \n [1]=> int(0) \n [2]=> int(0) } \n[5]=> array(3) { \n [0]=> int(5) \n [1]=> int(0) \n [2]=> int(0) } \n[6]=> array(3) { \n [0]=> int(6) \n [1]=> int(0) \n [2]=> int(0) } \n[7]=> array(3) { \n [0]=> int(7) \n [1]=> int(0) \n [2]=> int(0) } \n }\n\n\nwhy isn't the second index returning null? I've tried emptying my cache in case it had old values stored in there. I've also noticed that if I delete the last array from the jump array, it still produces 7,0,0. Is this a weird anomaly?"
] | [
"php",
"arrays",
"array-intersect"
] |
[
"Multi-variable switch statement in C#",
"I would like use a switch statement which takes several variables and looks like this:\nswitch (intVal1, strVal2, boolVal3)\n{\n case 1, "hello", false:\n break;\n case 2, "world", false:\n break;\n case 2, "hello", false:\n\n etc ....\n}\n\nIs there any way to do something like this in C#? (I do not want to use nested switch statements for obvious reasons).\nThe question was answered by .net dev team by implementing of exactly this fearture: Multi-variable switch statement in C#"
] | [
"c#",
".net",
"switch-statement",
"logic",
"switch-expression"
] |
[
"inner join is taking forever",
"I am trying to update one variable on a table with ~1m rows in mysql with an update statement with the following code, however, it is taking over 10hrs to run which is just odd! Is there a more efficient or better way to do it? This is mysql code:\n\nUPDATE test.ratings as a \nINNER JOIN test.fgform as b ON a.race_id = b.race_id \nSET a.FGspeed = b.FG;"
] | [
"mysql",
"sql-update",
"inner-join"
] |
[
"Best way for limit rate downloads in play framework scala",
"Problem: limit binary files download rate. \n\n def test = {\n Logger.info(\"Call test action\")\n\n val file = new File(\"/home/vidok/1.jpg\")\n val fileIn = new FileInputStream(file)\n\n response.setHeader(\"Content-type\", \"application/force-download\")\n response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"1.jpg\\\"\")\n response.setHeader(\"Content-Length\", file.lenght + \"\")\n\n val bufferSize = 1024 * 1024\n val bb = new Array[Byte](bufferSize)\n val bis = new java.io.BufferedInputStream(is)\n var bytesRead = bis.read(bb, 0, bufferSize)\n while (bytesRead > 0) {\n bytesRead = bis.read(bb, 0, bufferSize)\n //sleep(1000)?\n response.writeChunk(bytesRead)\n }\n }\n\n\nBut its working only for the text files. How to work with binary files?"
] | [
"scala",
"streaming",
"playframework",
"binaryfiles"
] |
[
"How to change the timezone?",
"So the default time for Python is London, but I am trying to change it to EDT/New York time. This is what I did:\nimport datetime\n\ntime = datetime.datetime.now()\nprint('{}:{}'.format(time.strftime('%I'), time.strftime('%M')))\n\nI want to make it EDT time, so I looked up ways to do it, but every time i got something different and it wouldn't work. I am very confused.\nP.S I'm using onlineGDB as a compiler, so some things don't work."
] | [
"python",
"python-3.x",
"python-datetime"
] |
[
"capture data between 1st and second occurrence of the pattern in a loop",
"I need the data between the pattern in the file \n\nData in File is as follows\n\ncat file1\n# Wed 06-02-2017\nfield1=abc\nfield2=xyz\nfield3=ijk\n# Wed 06-02-2017\nfield1=123\nfield2=456\nfield3=789\n# Wed 06-02-2017\nfield1=a1a\nfield2=c1c\nfield3=d1d\n\n\nI want to run the loop and in first loop find the data between 1st and 2nd occurrence of pattern <#> and then in second loop i want data between 2nd and 3rd pattern <#> and so on.\n\nBelow is the code written for the same, but its not working\n\ncat caturedata\n#!/bin/sh\n\nlastlineno=$(wc -l file1 | awk {'print$1'})\necho $lastlineno\nfor (( i=1;i<=$lastlineno;i=a))\ndo\n echo \"Inside Loop : $i\"\n sed '\"$i\",/#/d;/#/,$d' file1\n temp=$(sed '\"$i\",/#/d;/#/,$d' file1 | wc |awk '{print $1}')\n a=i+temp+1\ndone\n\n\nI am trying to find the last line number of the file\nthen run a loop between 1st and last line number\nthen run sed command to capture data between line number first and second occurrence of the pattern\nthen identify the next line number to start with \n\nOutput should be as below \n\nInside Loop : 1\nfield1=abc\nfield2=xyz\nfield3=ijk\nInside Loop : 5\nfield1=123\nfield2=456\nfield3=789\nInside Loop : 9\nfield1=a1a\nfield2=c1c\nfield3=d1d"
] | [
"linux",
"unix"
] |
[
"Spring boot server port range setting",
"Is it possible to set an acceptable range for the server.port in the application.yml file for a spring boot application.\n\nI have taken to setting server.port=0 to get an automatically assigned port rather than a hard coded one.\n\nOur network ops people want to restrict the available range for this port assignment. \n\nAny idea?"
] | [
"spring-boot"
] |
[
"Is there any good way to determine the \"actual content width\" of a web page?",
"Here's what StackOverflow looks like on my (huge) work monitor:\n\n\n\nThat is a lot of white space on either side of the site's actual content.\n\nI get that this is how a very large percentage of websites are designed—so I'm not singling out SO here—but that's actually exactly why I'm asking this question. I'm thinking it'd be really nice if I had some reliable way (say, via JavaScript) of determining the \"actual\" width of a website, which I could then use to write a quick script that would auto expand any site I'm browsing to fill the available width on my monitor. As it is, I find it absurd that sometimes I still squint before reading tiny text before realizing/remembering to zoom in to take advantage of my enormous screen.\n\n\n\nAhh... much better.\n\nI suspect this is possible, at least to a reasonable degree via some heuristic, as my Android phone appears to do something a lot like this when I double-tap on the screen while browsing the web."
] | [
"javascript",
"html",
"screen-resolution"
] |
[
"Psychopy vertical and horizontal simon task",
"I am new to Psychopy and I am trying to build a Simon Task consisting of 2 item-sets 1 horizontal set (1, 4, 6, 9) and a vertical set (2, 3, 7, 8). It means that the numbers of the horizonzal set can appear on the left or right side of the screen and the numbers of the vertical set can appear at the top or at the button.\nThe difficulty is that the sets should switch after each trial (horizontal - vertical - horizontal - veritcal) but the numbers of each set should appear randomly on either the left/right or top/down site of the screen. Task is to tell if the presented number is < 5 participants reacht with the arrow keys.\nI tried to build a loop with 2 routines in it (1 horizonzal 1 vertical) but in that case it pairs the sets so if in the vertical set 1 was presented it Always presents 3 in the horizontal set.\nDo you have any ideas how to build an Experiment like this? Thank you in advance!"
] | [
"psychopy"
] |
[
"trying to solve ACM 295 (fatman). Looking for an algorithm",
"I am trying to solve ACM problem 295. The problem basically says that there is a set of point obstacles in a corridor which is W units wide and L units long. I need to find the widest\nobject that can go from left to right avoiding those point obstacles. My initial thinking was to somehow do a depth first search to find all possible paths through the set of obstacles. But cannot formulate the algorithm.\n\nCan anyone give a hint on which direction I should think about?"
] | [
"algorithm"
] |
[
"Print Batch results to a text file?",
"I created a batch file to lookup my external ip.\n\nand it works well .\n\nThis is the code.\n\n @echo off\n>\"%temp%\\ip.vbs\" echo Set objHTTP = CreateObject(\"MSXML2.XMLHTTP\")\n>>\"%temp%\\ip.vbs\" echo Call objHTTP.Open(\"GET\", \"http://checkip.dyndns.org\", False)\n>>\"%temp%\\ip.vbs\" echo objHTTP.Send()\n>>\"%temp%\\ip.vbs\" echo strHTML = objHTTP.ResponseText\n>>\"%temp%\\ip.vbs\" echo wscript.echo strHTML\nfor /f \"tokens=7 delims=:<\" %%a in ('cscript /nologo \"%temp%\\ip.vbs\"') do set ip=%%a\necho %ip:~1% \npause\n\n\nWhat i want is to Print the results to a text file named \"IPlog.txt\"\n\nand every time i run the bat file it has to do the same thing and print the new results to the next line in the text file. So please can anyone help me with this."
] | [
"file",
"batch-file",
"text",
"printing"
] |
[
"Transaction isolation levels relation with locks on table",
"I have read about 4 levels of isolation:\n\nIsolation Level Dirty Read Nonrepeatable Read Phantom Read \nREAD UNCOMMITTED Permitted Permitted Permitted\nREAD COMMITTED -- Permitted Permitted\nREPEATABLE READ -- -- Permitted\nSERIALIZABLE -- -- --\n\n\nI want to understand the lock each transaction isolation takes on the table \n\nREAD UNCOMMITTED - no lock on table\nREAD COMMITTED - lock on committed data\nREPEATABLE READ - lock on block of sql(which is selected by using select query)\nSERIALIZABLE - lock on full table(on which Select query is fired)\n\n\nbelow are the three phenomena which can occur in transaction isolation\n\nDirty Read- no lock\n\nNonrepeatable Read - no dirty read as lock on committed data\n\nPhantom Read - lock on block of sql(which is selected by using select query) \n\nI want to understand where we define these isolation levels : only at jdbc/hibernate level or in DB also \n\nPS: I have gone through the links in Isolation levels in oracle, but they looks clumsy and talk on database specific"
] | [
"java",
"transactions",
"isolation-level"
] |
[
"Shadow memory and fPie error when running code with thread sanitizer?",
"The following code sample is compiled with the subsequent command line input \n\n#include <pthread.h>\n#include <stdio.h>\n#include <string>\n#include <map>\n\ntypedef std::map<std::string, std::string> map_t;\n\nvoid *threadfunc(void *p) {\n map_t& m = *(map_t*)p;\n m[\"foo\"] = \"bar\";\n return 0;\n}\n\nint main() {\n map_t m;\n pthread_t t;\n pthread_create(&t, 0, threadfunc, &m);\n printf(\"foo=%s\\n\", m[\"foo\"].c_str());\n pthread_join(t, 0);\n}\n\n\nCommand line input: \n\ng++ thread.cpp -fsanitize=thread -fPIE -pie -lpie -g\n\n\nIt compiles fine, but when the code is run there are runtime errors.\n\nFATAL: ThreadSanitizer can not mmap the shadow memory (something is mapped at 0x56167ae3b000 < 0x7cf000000000)\nFATAL: Make sure to compile with -fPIE and to link with -pie.\n\n\nI am running this with a version of g++ that has fSanitize so I am unsure about where the source of the problem is?\n\ng++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)"
] | [
"c++11",
"g++",
"thread-sanitizer"
] |
[
"How to get country place details from Twitter using Tweetsharp?",
"Can anyone help me to get country details from Twitter using the Tweetsharp API? I have written a snippet from a program to get the details of the user, but I am unable to get the country details of the user.\n\n string tweetText = string.Empty;\n int count;\n StringBuilder sbWebsite = new StringBuilder();\n StringBuilder sbCountry = new StringBuilder();\n TwitterTest obj = new TwitterTest();\n\n TwitterService twitterService = obj.GetAuthentication();\n\n TwitterUser objUser = twitterService.GetUserProfile(new GetUserProfileOptions { IncludeEntities = true, SkipStatus = false });\n ListFollowersOptions objFollowerOptions = new ListFollowersOptions();\n\n objFollowerOptions.UserId = objUser.Id;\n objFollowerOptions.ScreenName = objUser.ScreenName;\n objFollowerOptions.IncludeUserEntities = true;\n objFollowerOptions.SkipStatus = false;\n objFollowerOptions.Cursor = -1;\n\n TwitterCursorList<TwitterUser> followers = twitterService.ListFollowers(objFollowerOptions);\n\n for (int i = 0; i < followers.Count; i++)\n {\n if (followers[i].Status != null)\n {\n if (followers[i].Status.Place != null)\n {\n if (followers[i].Status.Place.Country != null)\n sbCountry.Append(followers[i].Status.Place.Country + \",\");\n }\n\n }\n sbWebsite.Append(followers[i].Url + \",\");\n }"
] | [
"c#",
"twitter",
"tweetsharp"
] |
[
"C++ Snake clone: timer function ignores given stop time and stops at it's own fixed time",
"I'm trying to make a Snake clone using C++ and OpenGL/GLUT. However, I've been having trouble programming the short time intervals allowed for input between movements. I've tried a few timing methods, and I ended up making a class for it (as you'll see below). This seems to be the best way to program the input delays (rather than glutTimerFunc() or sleep()), because the timer runs separately from the game loop, instead of putting the whole program on hold. This is important because I want the player to be able to pause at any time. Unfortunately, I'm having issues with this method now too. My timer class seems to ignore the double I give it for the time limit (simply represented as double \"limit\").\n\nTo test the class, I've set up a simple, looping console program that displays directional input from the user at the point when the timer reaches the time limit. It's supposed to display input every 0.33 seconds. Instead, it displays input at fixed intervals that seem to be around 0.8 seconds apart, regardless of what value has been given for the time limit. Why won't it display input at the given time intervals, and why has it made it's own time limit?\n\nThis also happens to be my first major C++/OpenGL project without a tutorial, so any comments or advice on my code/methods is appreciated!\n\n#include <iostream>\n#include \"timer.h\"\n// Include all files necessary for OpenGL/GLUT here.\n\nusing namespace std;\n\nTimer timer;\n\n// Insert necessary OpenGL/GLUT code for display/looping here.\n\nvoid update(int value)\n{\n if (timer.checkTime())\n {\n if (GetAsyncKeyState(VK_LEFT))\n cout << \"You pressed LEFT!\" << endl;\n else if (GetAsyncKeyState(VK_RIGHT))\n cout << \"You pressed RIGHT!\" << endl;\n else if (GetAsyncKeyState(VK_UP))\n cout << \"You pressed UP!\" << endl;\n else if (GetAsyncKeyState(VK_DOWN))\n cout << \"You pressed DOWN!\" << endl;\n }\n\n glutTimerFunc(1000/60, update, 0);\n glutPostRedisplay();\n}\n\n\ntimer.h\n\n#pragma once\n#include <time.h>\n\nclass Timer\n{\npublic:\n Timer();\n bool checkTime(double limit = 0.33);\nprivate:\n double getElapsed();\n time_t start;\n time_t now;\n double elapsed;\n bool running;\n};\n\n\ntimer.cpp\n\n#include \"timer.h\"\n\nTimer::Timer()\n{\n running = false;\n}\n\nbool Timer::checkTime(double limit)\n{\n elapsed = getElapsed();\n\n if (elapsed < limit)\n {\n return false;\n }\n else if (elapsed >= limit)\n {\n running = false;\n return true;\n }\n}\n\ndouble Timer::getElapsed()\n{\n if (! running)\n {\n time(&start);\n running = true;\n return 0.00;\n }\n else\n {\n time(&now);\n return difftime(now, start);\n }\n}"
] | [
"c++",
"opengl",
"timer",
"delay",
"2d-games"
] |
[
"Update combobox fail",
"i'm trying to use comboboxes for quantity in Virtuemart instead of quantity text and update button.\n\nWhen i have only one article in the cart it works perfectly, but when i have more than one, it's not working.\n\nHere's the form code \n\n <form action=\"<?php echo JRoute::_ ('index.php'); ?>\" method=\"post\" class=\"inline\" name=\"frm\">\n <input type=\"hidden\" name=\"option\" value=\"com_virtuemart\"/>\n\n\n <input type=\"text\" title=\"<?php echo JText::_ ('COM_VIRTUEMART_CART_UPDATE') ?>.2\" class=\"inputbox\" size=\"3\" maxlength=\"4\" name=\"quantity\" value=\"<?php echo $prow->quantity ?>\" style=\"display:none;\"/>\n <select name=\"cantidad\" id=\"cantidad\" onchange=\"getval(this);\" value=\"<?php echo $prow->quantity ?>\" title=\"<?php echo JText::_ ('COM_VIRTUEMART_CART_UPDATE') ?>\"> <script type=\"text/javascript\">\n function getval(sel) {\n document.frm.quantity.value = (sel.value);\n document.getElementById('actualizar').click();\n }\n </script>\n <option value=\"<?php echo $prow->quantity ?>\"><?php echo $prow->quantity ?></option>\n <option value=\"1\">1</option>\n <option value=\"2\">2</option>\n <option value=\"3\">3</option>\n <option value=\"4\">4</option>\n <option value=\"5\">5</option>\n <option value=\"6\">6</option>\n <option value=\"7\">7</option>\n <option value=\"8\">8</option>\n <option value=\"9\">9</option>\n <option value=\"10\">10</option>\n <option value=\"11\">11</option>\n <option value=\"12\">12</option>\n <option value=\"13\">13</option>\n <option value=\"14\">14</option>\n <option value=\"15\">15</option>\n <option value=\"16\">16</option>\n <option value=\"17\">17</option>\n <option value=\"18\">18</option>\n <option value=\"19\">19</option>\n <option value=\"20\">20</option>\n </select> \n <input type=\"hidden\" name=\"view\" value=\"cart\"/>\n <input type=\"hidden\" name=\"task\" value=\"update\"/>\n <input type=\"hidden\" name=\"cart_virtuemart_product_id\" value=\"<?php echo $prow->cart_item_id ?>\"/>\n <input type=\"submit\" class=\"vmicon vm2-add_quantity_cart\" id=\"actualizar\" name=\"update\" title=\"<?php echo JText::_ ('COM_VIRTUEMART_CART_UPDATE') ?>\" align=\"middle\" value=\" \" style=\"display:none;\"/>\n\n </form>\n\n\nThank you"
] | [
"php",
"combobox"
] |
[
"WPF is it possible to showdialog() on top of Windows lock screen?",
"I wrote a desktop alerts application that sends a variety of notifications to all clients that are currently logged in. The app lives in the system tray, with a right-click menu to select an alert. When an alert is sent, a pop-up displays on each client's desktop with the type of alert. The pop-up is a simple Window class:\n\nalertWindow.showDialog();\n\n\nOur PC's have a policy on them to automatically lock the screen after 10 minutes of inactivity. What I'd like to know is if there's any way to have the alerts display while the screen is locked. Any help would be appreciated."
] | [
"c#",
"wpf",
"winforms"
] |
[
"Datetime sorting very slow on postgresql",
"I have a review table which has, app_id(string), reviews_updated_at(timestamp), description(text) and other stuff. The table has around 90 million entries, I have around 2000 read IOPS limit on my database instance and the below mentioned query takes 30-40 sec to complete, Is there any way i can make this query execute faster?.\n\nI have two indexes app_id(btree), reviews_updated_at(btree)\n\nQuery:\n\nselect * from reviews\nwhere app_id = '2332223'\norder by review_updated_at\noffset 200 limit 100\n\n\nQuery Plan:\n\nLimit (cost=243270.84..364905.97 rows=100 width=258) (actual time=23212.698..32806.020 rows=100 loops=1)\n -> Index Scan using index_reviews_on_review_updated_at on reviews (cost=0.57..327489222.63 rows=269239 width=258) (actual time=237.720..32805.359 rows=300 loops=1)\n Filter: ((app_id)::text = '2332223'::text)\n Rows Removed by Filter: 36376\nPlanning time: 0.160 ms\nExecution time: 32806.216 ms"
] | [
"sql",
"performance",
"postgresql"
] |
[
"How to add code to the standard signal handler?",
"I have a C application running on Linux where I need to add some code to the standard signal handler. The idea was to setup my handler saving the pointer to the standard one and call the saved handler from my code. Unfortunately, neither signal() nor sigaction() return pointer to the standard handler. Both of them return NULL instead. \nIs there any way of doing custom handling and continuing with the standard handling without removal of the custom handler and sending the same signal again?"
] | [
"c",
"linux",
"handler",
"signals"
] |
[
"How to control the position of a scollable div inside another div?",
"I am trying to make the scrollable inner div jump back up whet it reaches the bottom but neither .css() nor .animate() seem to work.\n\nhttp://jsfiddle.net/1yzpot2b/\n\n\r\n\r\nvar $fixedHolder = $('#fixedHolder'),\r\n $slidingHolder = $('#slidingHolder');\r\n\r\n$fixedHolder.on('scroll', function onScroll() {\r\n var scrollTop = $fixedHolder.scrollTop();\r\n\r\n console.log('scrollTop', scrollTop);\r\n\r\n if (scrollTop >= 290) {\r\n console.info('jump up');\r\n\r\n $fixedHolder.off('scroll');\r\n\r\n $slidingHolder.css({\r\n top: '10px'\r\n });\r\n\r\n $slidingHolder.animate({\r\n scrollTop: 0\r\n }, 200);\r\n }\r\n});\r\n#fixedHolder {\r\n width: 30px;\r\n height: 100px;\r\n overflow-y: scroll;\r\n border: 1px solid #ccc;\r\n position: relative;\r\n}\r\n#slidingHolder {\r\n position: absolute;\r\n}\r\n<div id=\"fixedHolder\">\r\n <div id=\"slidingHolder\">a b c d e f g h i j k l m n o p q r s t v z x</div>\r\n</div>"
] | [
"jquery",
"scroll",
"overflow"
] |
[
"How can i create a contact view interface in android?",
"How can i create a view like Contact book in android phones. Alphabets list on one side and while i tap on any alphabet it should go to the contacts of that particular alphabet. Any built in mechanism to make that?"
] | [
"android",
"android-layout"
] |
[
"Adding doubles in x86_64 assembly problems",
"Hello I am trying to learn assembly and learn how to work with floating point numbers in x86_64. From what I understand arguments are passed in xmm0, xmm1, xmm2, and so on, and the result is returned in xmm0. So I am trying to make a simple assembly function that adds to double together. Here is the function\n\n.text\n\n.global floatadd\n.type floatadd,@function\n\nfloatadd:\n addsd %xmm1,%xmm0\n ret\n\n\nAnd here is the C code I am using as well. \n\n#include<stdio.h>\n\nint main(){\n double a = 1.5;\n double b = 1.2;\n double c = floatadd(a,b);\n printf(\"result = %f\\n\",c);\n}\n\n\nI have been trying to following what is happening in gdb. When I set a breakpoint in my function I can see xmm0 has 1.5 and xmm1 has 1.2 and when they are added together they 2.7. In gdb print $xmm0 gives v2_double = {2.7000000000000002, 0} However when my function returns from main and calls\n\ncvtsi2sd %eax,%xmm0 \n\n\nPrint $xmm0 becomes v2_double = {2, 0}. I am not sure why gcc calls that or why it is uses the 32bit register instead of the 64bit register. I have tried using the modifier %lf, and %f and both of them do the same thing. \n\nWhat is happening?"
] | [
"c",
"assembly",
"floating-point",
"x86",
"x86-64"
] |
[
"Cakephp exit admin mode",
"Say for example you are logged in as admin on your site and want to go to http://yourdomain/cake/admin/controller/action.\n\nNow in view you have a link\n\n<?php echo $this->Html->link(__('Back to Normal'), array('controller' =>'pages', action' => 'index'); ?>\n\n\nNow this should lead you back to a NON admin page however in my case when you click this link you go to:\n\nhttp://yourdomain/cake/admin/pages/index\n\n\nAnd since there is no admin index (since i don't want to go to admin index) i get a not found exception.\n\nThe only way to fix this right now is if i Manuel remove the Admin infront of the url.\n\nMy question is how do i exit admin mode?"
] | [
"php",
"cakephp"
] |
[
"Testing Cells in isolation with Rspec - any recommandation?",
"I'm giving a try to Apotonick's Trailblazer gem, which brings more structure on top of Rails, and I really like what I tried so far, while not having embraced all of it yet. And this is one strength of Trailblazer, you can dive into it progressively, bringing it step by step into your Rails projects. I bought the Trailblazer book, which I'm following now and that leads to my question.\n\nI'm working on the sample app ( @see https://github.com/apotonick/gemgem-trbrb ) but I'm using rspec. \n\nI wanted to test cells output in isolation. In the book, the testing framework is Test::Unit and some helper methods ship with cells for Test::Unit.\n\nWith rspec it's another story ... I tried rspec-cells but it seems not to work with current cells version (4.0), which is used in Trailblazer.\nSo I tried to do some salmon coding, the goal being to have the smallest setup possible for retreiving the cell's output. This led to a module with a simple helper\n\nHere is the code (also here : https://github.com/demental/gemgem-trbrb/blob/3ec9df1d5f45b880f834486da3c150d4b65ec627/spec/support/cells.rb )\n\nmodule Cell\n module Rspec\n private\n def concept(name, *args)\n controller_stub = double(\n url_options: {\n host: '',\n optional_port: 80,\n protocol: 'http',\n path_parameters: ''\n }\n )\n Capybara.string(Cell::Concept.cell name, controller_stub, *args)\n end\n end\nend\n\nRSpec.configure do |config|\n config.include Cell::Rspec, type: :cell\nend\n\n\nThe reason why I needed to make a stubbed url_options method was for the pathHelpers methods to work in cell views, without having to setup a full controller (with a full request object).\n\nI like it in a way that it makes a very minimalistic setup. But I'm wondering if it's not gone too dummy, as I just mimic a controller, but I am feel like I don't get rid of its dependency. What do you think ?"
] | [
"ruby-on-rails",
"rspec",
"rails-cells",
"trailblazer"
] |
[
"Sending large JAXB objects with Jersey generates OutOfMemoryError",
"I am using Jersey as my REST implementation and JAXB to represent my classes.\nI have done a tiny file transfer mechanism. At the client side the file is converted to a BASE64 string before I set it to the JAXB object. The JAXB object is then sent to the server with Jersey.\n\nIt works with files not larger than 50 MB or so, but when I try to send a 500 MB file I get OutOfMemoryError on my client. I have set the -Xms and -Xmx to 2048m but it does not help, I still get the error. \n\nWhat can I do to get it work with very large files?"
] | [
"java",
"jaxb",
"jersey",
"out-of-memory"
] |
[
"nodetool repair taking too much time",
"To repair the entire cluster it is taking 20 days which is really more than the gc_grace_seconds. But, Im not expecting this kind delay to do the repair. My question, Is there any chance to reduce the repair to 7-8 days?"
] | [
"cassandra",
"cassandra-2.0",
"cassandra-3.0",
"cassandra-2.1"
] |
[
"How to get data by query ref object in mongoose",
"I have an issue and failed to find what i am exactly looking for.\ni have this Ads schema with references of others too:\n link: {\n type: String,\n default: 'n/a',\n },\n page: {\n type: mongoose.Schema.ObjectId,\n ref: 'AdsPage',\n required: true,\n },\n slot: {\n type: mongoose.Schema.ObjectId,\n ref: 'AdsSlot',\n required: true,\n },\n\nand i want to get data by applying condition on page property, page is a schema which has url property in it.\npage schema:\n {\n title: {\n type: String,\n required: [true, 'Please add page title'],\n unique: true,\n trim: true,\n maxlength: [50, 'Name cannot be more then 50 characters'],\n },\n url: {\n type: String,\n required: [true, 'Add page URL'],\n },\n createdAt: {\n type: Date,\n default: Date.now,\n },\n},\n\ni want to get all ads that matches provided page url.\nmy query looks like:\nif (req.params.pageUrl) {\n const ads = await Ads.find({\n 'page.url': req.params.pageUrl,\n });\n\n return res.status(200).json({\n success: true,\n message: 'Successfully fetched ads for specific page',\n count: ads.length,\n data: ads,\n });\n}\n\npage url in param is good, but somehow this filter is not working, i got no error but with zero results.\ni have tried $match property but got some upper level error.\nany help on query on nested ref object is much appreciated."
] | [
"node.js",
"mongodb",
"mongoose",
"mean-stack",
"mongoose-schema"
] |
[
"How to customize menu in electron app?",
"I have one frameless electron app which can be run on windows and mac system. I have learned how to set ApplicationMenu and contextmenu(right click only). But, I want to set an Image like settings and clicking on that will open the customized menu (which have its HTML, CSS and js) which catch the events like focusedWindow to get the current focusedWindow. How can I achieve this functionality? Below is the image which describes what I am trying to do."
] | [
"node.js",
"electron"
] |
[
"how do I search an array of objects and return only those objects with certain uids in objective c",
"I have an array of uids, and another array of objects. The objects structure is such that it has a name and a uid. I would like to search the array or objects, and return an array of those objects that match the uids from the first array. I was exploring using undersore.m but I'm not sure if this is appropriate."
] | [
"ios",
"objective-c",
"arrays",
"object"
] |
[
"Cannot remove \"Internal test track\" build from Google Play Console",
"I've been developing my first app for work and am having trouble removing an earlier version from the Google Play Console.\n\nMy first release was version 2, which I released on the Internal Test track, as much as an experiment to understand the working of things. I have subsequently release the app up to version 8, always targeting Alpha/Closed Track and had no problems with them.\n\nHowever my first release, the one in Internal test track, simply refuses to go away. All the others I have found I can click MANAGE then RELEASE TO BETA then DISCARD (at the bottom) and they go away, but not this one.\n\nCan anyone help me with this please. I have to say that the websites for releasing to both Android and to Apple do leave much to be desired - a bit of a baptism of fire to get your first app out there, even just to testers."
] | [
"android",
"release",
"google-play-console"
] |
[
"Z3 variable name causing \"unknown\" satisfiability",
"Using Z3 to check the satisfiability of\n(declare-fun length ((Array Int Int)) Int)\n\n(declare-const lindx2 (Array Int Int))\n(declare-const findx1 (Array Int Int))\n(declare-const orig_findx1 (Array Int Int))\n\n(assert (and\n (forall ((i Int) (j Int))\n (let ((a!1 (and (<= 0 i)\n (<= i (- (length findx1) 1))\n (<= 0 j)\n (<= j (- (length orig_findx1) 1))\n (= i j))))\n (=> a!1 (= (select findx1 i) (select orig_findx1 j)))))\n (= (length lindx2) 11)\n (forall ((i Int)) (=> (and (<= 3 i) (<= i 25)) (= (select findx1 i) (- 1))))))\n(check-sat)\n\nreturns unknown. This essentially tries to assert that all elements in findx1 and orig_findx1 are equal, that length(lindx2)=11, and that findx1[i]=-1 for i=[3,25]. However, changing "findx1" to "indx1" allows Z3 to return satisfiable. Does anyone know what might be causing the unknown satisfiability? I am using Z3 version 4.8.8 on Ubuntu 18.04"
] | [
"z3"
] |
[
"Should I be using an abstract base class for this purpose at this time?",
"I only very recently began developing professionally. I studied OOP while at University, but don't feel as if I ever really used it in a \"real world\" scenario.\n\nBasically, in trying to create/manipulate a specific type of document within the organization, I created a class for it, with the thinking that anytime we wanted to create/manipulate that specific type of document, we could just create an instance of it and give it certain information and have it take care of itself.\n\nI know we're planning on working with other types of documents (I guess I should note, when I say types of documents, I mean something like \"expense report\" or \"inventory list\", as in I'm referring to the content.) I assumed all of these kinds of documents would share certain kinds of functionality (for example, working with shared strings or defined names in Excel), so I then created an abstract Document class, and thought each type of document we wanted to create could extend this class.\n\nOf course, I'm still only working with one type of document, so while I sort of have an idea of methods that might be common to all documents, I still at this point only have one abstract class and one that extends it, so it seems sort of unneccesary.\n\nI guess my questions are:\n1) Should I even be using an abstract class here. Like does this seem like the appropriate use of one or have I completely missed the point?\n2) If I should be using one, should I not be using it this early? I mean, should I wait until I actually have several documents in front of me so I can actually determine what kind of functionality is shared between all of them rather than sort of assume I know for now even though I only have one class implementing it?\n\nThanks."
] | [
"c#",
"oop",
"openxml"
] |
[
"Bootstrap Glyphicons don't show in IE10 or FF",
"I'm having trouble getting the bootstrap glyphicons to show in IE10 or FF. I'm using the latest bootstrap 3 code and am including the glyphicons the standard way:\n\n<span class=\"glyphicon glyphicon-edit\"></span>\n\n\nThey work fine in Chrome, however in IE10 they aren't visible and generate errors in console:\n\nCSS3111: @font-face encountered unknown error. \nglyphicons-halflings-regular.eot\nCSS3111: @font-face encountered unknown error. \nglyphicons-halflings-regular.woff\nCSS3111: @font-face encountered unknown error. \nglyphicons-halflings-regular.ttf\n\n\nInterestingly, they work locally in IE10, but not remotely.\n\nIn FF they show the \"E034\" icon, which I assume means image not found?"
] | [
"internet-explorer",
"firefox",
"twitter-bootstrap",
"twitter-bootstrap-3",
"glyphicons"
] |
[
"iOS - warning on a webview: Assigning to 'id' from incompatible type",
"I have this code. the reference to theWebView is a WebView element that I put on the page.\n\nI have this code:\n\n- (void)viewDidLoad\n{\n [super viewDidLoad];\n // Do any additional setup after loading the view.\n self.view.backgroundColor = [UIColor colorWithWhite:0.859 alpha:1.000];\n theWebView.delegate = self;\n}\n\n\nAnd I get a warning on this line:\n\nself.view.backgroundColor = [UIColor colorWithWhite:0.859 alpha:1.000];\n\n\nsaying:\n\nAssigning to 'id<UIWebViewDelegate>' from incompatible type 'BalanceSheetController *const_strong'\n\n\nWould anyone know why this warning happens? without that line, clicks on links on the UIWebView do not get recognized.\n\nThanks!"
] | [
"ios",
"uiwebview"
] |
[
"MySQL delete duplicate reverse values",
"I have MySQL MyISAM table:\n\nTable friends(id, friend_id):\n\n1, 5\n\n5, 1\n\n2, 6\n\n6, 2\n\n3, 7\n\nHow to delete reverse records? If for record values «1, 5» exist record with values «5, 1» i need to delete «5, 1».\n\nThanx for help!"
] | [
"php",
"mysql",
"myisam",
"duplicate-removal"
] |
[
"Using sysctl interface from kernel module",
"I am trying to access tcp_pacing_ss_ratio defined in tcp_input.c from a kernel module. The variable can be modified using the sysctl command in user space.\nIt is however not exported and cannot be referenced directly from the module.\n\nWhat is the simplest way to access a sysctl entry from a kernel module?"
] | [
"c",
"linux",
"linux-kernel",
"kernel"
] |
[
"CSS bar graph - very simple",
"I have some very basic code and it works except everything aligns to the top...ideally the bars would align to the bottom. I suppose I could use fixed positioning as the dimensions are squared at 50px by 50px but I'd prefer something a little less \"fixed\".\n\n <div style=\"border: 1px solid #aeaeae; background-color: #eaeaea; width: 50px; height: 50px;\">\n <div style=\"position: relative; bottom: 0; float: left; width: 8px; height: 22px; background-color: #aeaeae; margin: 1px;\"></div>\n <div style=\"position: relative; bottom: 0; float: left; width: 8px; height: 11px; background-color: #aeaeae; margin: 1px;\"></div>\n <div style=\"position: relative; bottom: 0; float: left; width: 8px; height: 6px; background-color: #aeaeae; margin: 1px;\"></div>\n <div style=\"position: relative; bottom: 0; float: left; width: 8px; height: 49px; background-color: #aeaeae; margin: 1px;\"></div>\n <div style=\"position: relative; bottom: 0; float: left; width: 8px; height: 28px; background-color: #aeaeae; margin: 1px;\"></div>\n </div>\n\n\nI don't want to use a library or JS add on. Keeping this light weight is mission critical.\n\nAlso I'd prefer the bars were vertical. Any CSS guru care to shed the bit of light I seem to be missing? I've googled and most examples are far to complicated/sophisticated,"
] | [
"css",
"charts"
] |
[
"MongoDB - Handle error event",
"I have a custom validation when I upload an image to mongoDb. The original name should be unique. If it passes the validation, the code runs properly. But if it fails, it produces error. It says that custom validators that take 2 arguments) are deprecated in mongoose >= 4.9.0. Is there another way to validate the uniqueness of the originalname? Or a way to catch the error? Please help.\n\nrouter.post('/upload',function(req,res){\n\n Item.schema.path('originalname').validate(function(value, done) {\n Item.findOne({originalname: value}, function(err, name) {\n if (err) return done(false);\n if (name) return done(false);\n\n done(true);\n });\n });\n\n upload(req,res,function(err, file) {\n if(err){\n throw err;\n }\n else{\n var path = req.file.path;\n var originalname = req.file.originalname;\n var username = req.body.username;\n\n var newItem = new Item({\n username: username,\n path: path,\n originalname: originalname\n });\n\n Item.createItem(newItem, function(err, item){\n if(err) throw err;\n console.log(item);\n });\n\n console.error('saved img to mongo');\n req.flash('success_msg', 'File uploaded');\n res.redirect('/users/welcome');\n\n }\n });\n});\n\n\nmodel\n\nvar ItemSchema = mongoose.Schema({\nusername: {\n type: String,\n index: true\n},\n path: {\n type: String\n },\n originalname: {\n type: String\n }\n});\n\nvar Item = module.exports = mongoose.model('Item',ItemSchema);\n\nmodule.exports.createItem = function(newItem, callback){\n newItem.save(callback);\n}"
] | [
"node.js",
"mongodb",
"express"
] |
[
"Numpy N-D Matrix to a 3D Mesh Graph",
"I tried looking this up a lot and there are lot of information on specific examples but they are too specific to understand.\n\nHow do I put data in a Numpy N-D Matrix to a 3D graph. please refer below example\n\n import numpy as np\n X =20\n\n Y = 20\n Z = 2\n sample = np.zeros(((X,Y,Z)))\n sample[1][2][2]=45\n sample[1][3][0]=52\n sample[1][8][1]=42\n sample[1][15][1]=30\n sample[1][19][2]=15\n\n\nI Want to use values on X,Y,Z positions to be on a 3D graph (plot).\n\nThanks in advance\n\n import numpy as np\n import matplotlib.pyplot as plt\n from mpl_toolkits.mplot3d import axes3d\n\n # Define size of data\n P= 25\n X = 70\n Y = 25\n Z = 3\n\n # Create meshgrid\n x,y = np.meshgrid(np.arange(X),np.arange(Y))\n\n # Create some random data (your example didn't work)\n sample = np.random.randn((((P,X,Y,Z))))\n\n # Create figure\n fig=plt.figure()\n ax=fig.add_subplot(111,projection='3d')\n fig.show()\n\n # Define colors\n colors=['b','r','g']\n\n # Plot for each entry of in Z\n for i in range(Z):\n ax.plot_wireframe(x, y, sample[:,:,:,i],color=colors[i])\n plt.draw()\n plt.show()\n\n\nBut I only want to draw X,Y,Z only.\n when I used above code python throws me lots of errors like ValueError: too many values to unpack"
] | [
"python",
"numpy",
"matrix",
"matplotlib",
"graph"
] |
[
"WebView bug - replace selected text in ContentEditable",
"So, here's the thing. I have a WebView displaying a contenteditable div. Now, when I select text, everything's all fine and good, and via javascript interfaces I can see that document.getSelection() returns what it ought. However, when I type something, rather than replace the selected text in the current node, it appears to replace the text in the first node at the corresponding offsets. For instance, if I have\n\nBlah1\nBlah2\nBlah3\nBlah4\n\n\nand I select \"ah4\" and type \"q\", I end up with\n\nBlq\nBlah2\nBlah3\nBlah4\n\n\ninstead of\n\nBlah1\nBlah2\nBlah3\nBlq\n\n\nI've noticed that if I run it on the emulator with the hardware keyboard rather than the soft keyboard, it works fine.\n\nI've tried to intercept the event to do stuff manually, but neither the onKeyListener nor the javascript onKeyDown nor onKeyPress registers an event when it's replacing text. Javascript onInput registers, but only after the replacement has occurred.\n\nAny ideas how to circumvent this?\n\n\n\nFurther info:\n\nAs it turns out, when text is selected and a key is pressed on the soft keyboard, that keypress does not pass through the activity's dispatchKeyEvent method. I hypothesize that this difference is fundamental to occurrence of the glitch. Anybody know why and how this would happen, as well as why it would cause a glitch? I'm going to go see if I can trace the path of code execution."
] | [
"javascript",
"android",
"webview",
"contenteditable"
] |
[
"How to create an element auto-instantiated array such as the int arrays of an user-defined type?",
"Upon declaring an int array such as: \n\nint[] test = new int[5];\n\n\nAll of the elements of the array are automatically initialized to 0. Is there anyway I can create a class that will auto-initialized when an array is created such as the int arrays? \n\nFor example:\n\nMyClass[] test2 = new MyClass[5];\n\n\nWill still require me to call the constructor; but with int the constructor is magically called. \n\nWhat code/operators of the int class that allows this behavior?"
] | [
"c#",
".net",
"arrays"
] |
[
"Can I delete an object of a model from view even though the user doesn't have permission? Django",
"I have created a model X, now created a user U, I assigned a group to this user G, G has only create and change permissions for the model X, Now I created a view where it lists all model X objects and delete button across each object, now when I am logging in with my user U, he can access that view( I am not restricting him here ) and he is able to delete that object from that model? Is it how it works? I need to restrict him from view too as well as at user permission level(groups)?"
] | [
"django",
"django-models",
"django-views"
] |
[
"IE 11 : Select dropdown with finger Touch is not the same with Mouse Click",
"I have an select input witch shows some options in its drop down: \n\n<select name=\"vendorSelect\" class=\"col-xs-12 \" id=\"vendorSelect\" [(ngModel)]=\"currentVendor\">\n <option [hidden]=\"true\" disabled [value]=\"selectUndefinedOptionValue\" ></option> \n <option *ngFor=\"let vendor of listVendor\" [ngValue]=\"vendor\">\n {{vendor.name}}\n </option>\n</select>\n\n\nWhen running , it goes well in chrome , firefox , safari.\n\nThe difference appears with IE11 and within Tablet: \n\n\nWhen using the mouse click : the dropdown appears normally and with its own scroll bar\nWhen using finger (Touch) : the dropdown appearence got different (with a mobile inspired scrolling with swiping and no scrollbar).\n\n\nI want to unify this behavior , so when Touching with finger , i want to display my normal Select-dropdown and not the special one.\n\nThe problem is specifically with IE and EDGE \n\nAny suggestions or ideas about the problem origin ??"
] | [
"javascript",
"html",
"css",
"angular",
"internet-explorer"
] |
[
"How can I create graphql objects on the backend?",
"If I have var obj = { name: 'Bill', ... etc} and a GraphQLObjectType like const Person = new GraphQLObjectType({name: 'person', fields: { ...some fields with graphql types ... }});\n\nHow do I get a hydrated GraphQL object like the ones that are returned from the server: { name 'Bill', age: null, __typename: 'Person' }\n\nNote: I need to get this object and use it on the server."
] | [
"graphql",
"graphql-js"
] |
[
"ASP.NET MVC Controllers/Views invoked",
"When I invoke a controller, it's possible that the view response calls other controllers. Is there a way to determine, in MVC, all of the views and/or controllers were called in a single response?\n\nThanks."
] | [
"asp.net",
"asp.net-mvc",
"view",
"controller"
] |
[
"grouping / comparing the similar news stories together which are gathered from different sources",
"grouping / comparing the similar news stories together which are gathered from different sources using RSS feeds.\n\nAre there any API / Code available for this.\n\nPlease help.\n\nRegards,\nGourav"
] | [
"java",
"c++",
"cluster-analysis",
"rss"
] |
[
"Push Docker image to registry before using for azure pipelines",
"For my tests in azure-pipeline, I want to use a container that I then push to Docker Hub.\n\nActually, the steps are the following:\n\n\nPull image from registry\nDo the tests\nPush the new image with the new commits in the code in the Registry\n\n\nThe problem: The image Pulled from the registry contains the previous code, not the one that I am testing.\n\nWhat I want to do: \n\n\nFirst, deploy the image with the new code in the Docker registry\nThen, steps 1 to 3 mentionned before, so that the image that I pull is the up-to-date.\n\n\nHere is my actual code:\n\ntrigger:\n- master\n\nresources:\n containers:\n - container: moviestr_backend\n image: nolwenbrosson/cicd:moviestr_backend-$(SourceBranchName)\n ports:\n - 5000:5000\n - container: backend_mongo\n image: mongo\n ports:\n - 27017:27017\n\npool:\n vmImage: 'ubuntu-latest'\nstrategy:\n matrix:\n Python37:\n python.version: '3.7'\n\nservices:\n moviestr_backend: moviestr_backend\n backend_mongo: backend_mongo\nsteps:\n- task: UsePythonVersion@0\n inputs:\n versionSpec: '$(python.version)'\n displayName: 'Use Python $(python.version)'\n\n- script: |\n python -m pip install --upgrade pip\n pip install -r requirements.txt\n pip install -r requirements.dev.txt\n pip install pytest-azurepipelines\n displayName: 'Install dependencies'\n- script: |\n python -m pytest\n displayName: 'Make Unit tests'\n- task: Docker@2\n displayName: Login to Docker Hub\n inputs:\n command: login\n containerRegistry: cicd\n- task: Docker@2\n displayName: Build and Push\n inputs:\n command: buildAndPush\n repository: nolwenbrosson/cicd\n tags: |\n moviestr_backend-master\n- task: Docker@2\n displayName: Logout of ACR\n inputs:\n command: logout\n containerRegistry: cicd\n\n\nThe problem is ressources is unique for the whole pipeline, and it will Pull the image at the beginning, not after I build my image with my up-to-date code. So, how can I do?"
] | [
"python",
"azure-devops",
"docker-registry"
] |
[
"want to search a record from table based on search string",
"We want to search a record from table based on search string.\nThis search is a part of Stored procedure.\n\nFollowing is what we need: \n1. In table ppl there is column name which contains data in format of name,surname \nSay records are \nbarack,oba\nbar,obama \nand barack,obama.\n\n\nWe want to select record based on search string. Search string can be name OR surname.\nWe want exact search based on search string. \nMeans if search string is bar; it should not return barack,obama record and should only return only bar,obama. \nSimilar exact search for surname part.\nWe don’t know if the search string will have name or surname. \nSo search string can even be “oba” ..and it should return only “barack,oba” record.\n\n\nFollowing approaches we have tried untill now; but none of these worked :\n\n\nselect name from ppl where name like 'bar,%' or name like '%,bar';\nThis is working for name part but not working for surname part. \n\n\nselect name from ppl where name like 'oba,%' or name like '%,oba';\nis not giving proper results.\n\n\nselect name from ppl where name = ANY('%,oba',oba,%'); - not working\nselect name from ppl where regexp_like (name,'^,oba$') OR regexp_like (name,'oba$,^'); - not working\n\n\nI request you to share your thoughts in this case."
] | [
"oracle",
"java-stored-procedures"
] |
[
"makecert.exe - WS2012 fail to acquire a security provide from the issuer's certificate - Failed",
"I'm trying to create a new sel certificate in order to specify a duration different than the one created by default from an application.\nUsing the command:\nmakecert.exe -b 10/10/2015 -m 36 -n \"CN=MYSERVER.domain.com\" -sk \"MYSERVER.domain.com\" -sky \"exchange\" -sr localmachine -ss my -in \"SelfSignedCA\" -ir localmachine -is root\n\nbut system prevent me providing \"Fail to acquire a security provide from the issuer's certificate - Failed\".\nI'm not so confident in creating the certificates...any help?\nthanks in advance!"
] | [
"ssl",
"certificate",
"ssl-certificate",
"makecert"
] |
[
"Hibernate mapping of two classes to a single row in a table",
"Is it possible to map two classes into single row in a table in Hibernate\n\nI have two classes:\n\npublic class Student implements java.io.Serializable {\nprivate int studentId;\nprivate String studentName;\n\npublic Student() {\n}\npublic int getStudentId() {\n return this.studentId;\n}\n\npublic void setStudentId(int studentId) {\n this.studentId = studentId;\n}\n\npublic String getStudentName() {\n return this.studentName;\n}\n\npublic void setStudentName(String studentName) {\n this.studentName = studentName;\n}\n}\n\n\nand :\n\npublic class Address implements java.io.Serializable {\n\nprivate String street;\nprivate String city;\n\npublic Address() {\n}\n\npublic String getStreet() {\n return street;\n}\n\npublic void setStreet(String street) {\n this.street = street;\n}\n\npublic String getCity() {\n return city;\n}\n\npublic void setCity(String city) {\n this.city = city;\n}\n\n\nI would like to create a table :\n\nCREATE TABLE \"STUDENT\" \n(\"STUDENTID\" NUMBER(10,0) PRIMARY KEY, \n\"STUDENTNAME\" VARCHAR2(250), \n\"STREET\" VARCHAR2(250), \n\"CITY\" VARCHAR2(250)\n)\n\n\nand map STUDENTID and STUDENTNAME from STUDENT class and STREET and CITY from the ADDRESS class.\n\nMappings I have done currently is the following:\n\n<hibernate-mapping>\n<class name=\"com.vaannila.student.Address\" table=\"STUDENT\">\n<id>\n<generator class=\"assigned\"/>\n</id>\n<property name=\"street\" column=\"SREET\" type=\"string\" length=\"250\"/>\n<property name=\"city\" column=\"CITY\" type=\"string\" length=\"250\"/>\n</class>\n</hibernate-mapping>\n\n\nand :\n\n<hibernate-mapping>\n<class name=\"com.vaannila.student.Student\" table=\"STUDENT\">\n<id name=\"studentId\" column=\"STUDENTID\" type=\"int\"/>\n<property name=\"studentName\" column=\"STUDENTNAME\" type=\"string\" length=\"250\"/>\n</class>\n</hibernate-mapping>\n\n\nI am getting error:\n\nCaused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/vaannila/student/Address.hbm.xml\nCaused by: org.hibernate.MappingException: must specify an identifier type: com.vaannila.student.Address\n\n\nPlease help"
] | [
"java",
"oracle",
"hibernate",
"hibernate-mapping"
] |
[
"MongoDB Charts Error while testing connection",
"I am trying to deploy mongo charts on containers. While testing i get below error\n\nI tried serching web .. but did not get right fix\n\ndocker run --rm quay.io/mongodb/charts:19.06.1 charts-cli test-connection mongodb://unsername:[email protected]:7041,mon001.abc.com:7041/pub_mongo?replicaSet=mongo7041\n\ni get below error .. any clue??\n\nUnable to connect to MongoDB using the specified URI.\n\nThe following error was returned while attempting to connect:\n\nMongoParseError: Incomplete key value pair for option"
] | [
"mongodb"
] |
[
"Can I force Apache and PHP to use lowercase/uppercase filenames?",
"I am developing under Windows and need to use upper/lowercase filenames in my PHP project.\nIs there some way to force Apache+PHP (XAMPP) to respect difference between upper & lowercase characters in filenames? My production server is Linux, so I always end up with some links not working."
] | [
"php",
"apache",
"xampp"
] |
[
"Why does my Python regular expression not match \\r\\n for newline in Windows?",
"I'm still fairly new to Python, and am having trouble with one of my regular expressions. I've researched this online and tried lots of things in Python, but am stuck. Since I'm using Windows, I'm expecting \\r\\n to match a new line break in a text file because that's how lines are terminated in Windows. But what I'm finding is that only \\n matches. Why is that?\n\nHere's my code (using \\r\\n, which doesn't match)\n\nfilename = 'C:\\\\Users\\\\jason\\\\OneDrive\\\\Documents\\\\LTspice_my_work\\\\example_ac_analysis_2.raw'\nwith open (filename, 'r' ) as f:\n content = f.read()\n print(content)\n pattern3 = r'Variables:\\r\\n(.*)Values:' \n print(\"Here's what matches:\")\n text = re.search( pattern3,content,re.DOTALL).group(1)\n print(text)\n\n\n\nwhich returns:\n\nCommand: Linear Technology Corporation LTspice XVII\nVariables:\n 0 frequency frequency\n 1 V(v1) voltage\n 2 V(vout) voltage\n 3 I(C1) device_current\n 4 I(R1) device_current\n 5 I(V1) device_current\nValues:\n0 1.000000000000000e+000,0.000000000000000e+000\n 2.000000000000000e+000,0.000000000000000e+000\n 1.998028025380720e+000,-6.276990166202591e-002\n 3.943949238559487e-007,1.255398033240518e-005\n -3.943949238559341e-007,-1.255398033240518e-005\n -3.943949238559568e-007,-1.255398033240518e-005\n1 3.162277660168380e+000,0.000000000000000e+000\n 2.000000000000000e+000,0.000000000000000e+000\n 1.980453705393099e+000,-1.967499214255068e-001\n 3.909258921380289e-006,3.934998428510137e-005\n -3.909258921380277e-006,-3.934998428510137e-005\n -3.909258921380287e-006,-3.934998428510137e-005\n\n\nHere's what matches:\nTraceback (most recent call last):\n\n File \"C:\\Users\\jason\\OneDrive\\Documents\\Python\\Python_scripts\\example_ltspice_pytool.py\", line 176, in <module>\n text = re.search( pattern3,content,re.DOTALL).group(1)\n\nAttributeError: 'NoneType' object has no attribute 'group'\n\n\nBut when I use only \\n I get the match I'm looking for with this code\n\nfilename = 'C:\\\\Users\\\\jason\\\\OneDrive\\\\Documents\\\\LTspice_my_work\\\\example_ac_analysis_2.raw'\nwith open (filename, 'r' ) as f:\n content = f.read()\n print(content)\n pattern3 = r'Variables:\\n(.*)Values:' \n print(\"Here's what matches:\")\n text = re.search( pattern3,content,re.DOTALL).group(1)\n print(text)\n\n\n\nwhich returns\n\n\nCommand: Linear Technology Corporation LTspice XVII\nVariables:\n 0 frequency frequency\n 1 V(v1) voltage\n 2 V(vout) voltage\n 3 I(C1) device_current\n 4 I(R1) device_current\n 5 I(V1) device_current\nValues:\n0 1.000000000000000e+000,0.000000000000000e+000\n 2.000000000000000e+000,0.000000000000000e+000\n 1.998028025380720e+000,-6.276990166202591e-002\n 3.943949238559487e-007,1.255398033240518e-005\n -3.943949238559341e-007,-1.255398033240518e-005\n -3.943949238559568e-007,-1.255398033240518e-005\n1 3.162277660168380e+000,0.000000000000000e+000\n 2.000000000000000e+000,0.000000000000000e+000\n 1.980453705393099e+000,-1.967499214255068e-001\n 3.909258921380289e-006,3.934998428510137e-005\n -3.909258921380277e-006,-3.934998428510137e-005\n -3.909258921380287e-006,-3.934998428510137e-005\n\n\nHere's what matches:\n 0 frequency frequency\n 1 V(v1) voltage\n 2 V(vout) voltage\n 3 I(C1) device_current\n 4 I(R1) device_current\n 5 I(V1) device_current\n\n\nThanks for your help in advance!"
] | [
"python",
"regex"
] |
[
"How to keep all rows different in two DataTable?",
"I have two DataTable, dt1, dt2. I write a class to compare two DataTable and get rows different.\n\ntable dt1:\n\nCol 1 Col 2 Col 3\n\nA 8 @\nB 21 ()\n\n\ntable dt2:\n\nCol 1 Col 2 Col 3\n\nA 8 ^%^%^%\nC 827 _++)\n\n\nIt show line different like: \n\nB 21 ()\n\nI post my function to compare:\n\npublic static DataTable CompareDataTables(DataTable first, DataTable second)\n{\n first.TableName = \"FirstTable\";\n second.TableName = \"SecondTable\";\n\n //Create Empty Table\n DataTable table = new DataTable(\"Difference\");\n\n try\n {\n //Must use a Dataset to make use of a DataRelation object\n using (DataSet ds = new DataSet())\n {\n //Add tables\n ds.Tables.AddRange(new DataTable[] { first.Copy(), second.Copy() });\n\n //Get Columns for DataRelation\n DataColumn[] firstcolumns = new DataColumn[ds.Tables[0].Columns.Count];\n\n for (int i = 0; i < 2; i++)\n {\n firstcolumns[i] = ds.Tables[0].Columns[i];\n }\n\n DataColumn[] secondcolumns = new DataColumn[ds.Tables[1].Columns.Count];\n\n for (int i = 0; i < 2; i++)\n {\n secondcolumns[i] = ds.Tables[1].Columns[i];\n }\n\n //Create DataRelation\n DataRelation r = new DataRelation(string.Empty, firstcolumns, secondcolumns, false);\n\n ds.Relations.Add(r);\n\n //Create columns for return table\n for (int i = 0; i < first.Columns.Count; i++)\n {\n table.Columns.Add(first.Columns[i].ColumnName, first.Columns[i].DataType);\n }\n\n //If First Row not in Second, Add to return table.\n table.BeginLoadData();\n\n foreach (DataRow parentrow in ds.Tables[0].Rows)\n {\n DataRow[] childrows = parentrow.GetChildRows(r);\n if (childrows == null || childrows.Length == 0)\n table.LoadDataRow(parentrow.ItemArray, true);\n }\n\n table.EndLoadData();\n\n }\n }\n catch (Exception ex) { }\n return table;\n}\n\n\ntableDifferent will contain all rows different.\n\nDataTable tableDifferent;\ntableDifferent = CompareDataTables(dt1, dt2);\n\n\nI tried with code:\n\nvar rowsToDelete = from r1 in dt1.AsEnumerable()\n join r2 in tableDifferent.AsEnumerable()\n on r1.Field<String>(\"StudentID\") equals r2.Field<String>(\"StudentID\")\n select r1;\n\n\nNow, I want to remove all rows in dt1 and dt2, only keep all rows in tableDifferent.\n\nHave any method to do this?"
] | [
"c#",
"linq"
] |
[
"Segmented speech data, save it as a .wav file and play it in Matlab",
"I have speech data, which I segment into some parts. I am trying to create a .wav file for each segmented data and play this .wav file. \n\nFor example, suppose the speech data is an 1x1000 array called data. I segment this data into 4 parts using the indices of seg_data.\n\nseg_data\n 1 250\n 251 500\n 501 750\n 751 1000\n\n\nCode:\n\nfor i=1:size(seg_data(:,1))\n w(i)=data(seg_data(i,1): seg_data(i,2));\n wavwrite(w(i),'file_%d \\n ',i);\nend\n\n\nFirst thing I need to create one folder in which the .wav file that is created in every iteration is stored. Then, I can read the stored file one by one and can play it."
] | [
"matlab",
"speech"
] |
[
"align center two elements different width",
"How to make two elements aligned so they will be at same distance from line in center which should be in center of wrapper. Also wrapper width is not fixed and may change.\nhttp://jsfiddle.net/x2b2ax37/2/\n\n <div id=\"block\">\n<div id=\"wrapper\">\n <span id=\"div1\">2222</span>\n <span id=\"div2\">2 %</span>\n</div>\n<div id=\"wrapper\">\n <span id=\"div1\">11</span>\n <span id=\"div2\">100 %</span>\n</div>\n<div id=\"wrapper\">\n <span id=\"div1\">21</span>\n <span id=\"div2\">0 %</span>\n</div>\n</div>\n\n\n\n\n1 - Initial 2 - What I expect"
] | [
"css"
] |
[
"Check if ActionPerform method occured but from another class",
"How to check from a class ModalDialog extends JDialog implements ActionListener if actionPerformed(ActionEvent e) method ocurred in another class (Connect extends JFrame implements ActionListener)? And one step further, how to check which of two buttons that I have in ModalDialog fired ActionPerformed method? (I know about event.getSource, but I need to check it from another class).\n\npublic ModalDialog()\n{\n btn8 = new Button(\"human\");\n btn8.setMaximumSize(new Dimension(60,40));\n btn8.addActionListener(this);\n\n btn9 = new Button(\"robot\");\n btn9.setMaximumSize(new Dimension(60,40));\n btn9.addActionListener(this);\n}\npublic void actionPerformed(ActionEvent e)\n{\n\n}\nclass Connect extends JFrame implements ActionListener \n{\npublic void actionPerformed(ActionEvent e) \n{\n ModalDialog md = new ModalDialog();\n if(md.ActionPerformed(e)....)...something like that...\n}\n}"
] | [
"java",
"swing"
] |
[
"Apache jmeter - parsing json limit on size",
"Is there a limit on the size of a json that can be parsed by jmeter?\n\nI am trying to use a json in my jmeter initialization script. The size of json is quite huge. I see that if i truncate the json, the parsing is error-free. But for the original size i get an error.\n\nRest assured, the json itself is proper, as i have tested in other javascript parsers.\n\nUpdate: Since it is established that there indeed is a limit, the question is if there is a way to work-around the limit?"
] | [
"json",
"jmeter"
] |
[
"CLS compliant types in P/Invoke helper assembly",
"Having a separate helper assembly containing only P/Invoke declarations for legacy 3rd party components, I wonder which of these two ways is The Better One™ if the assembly must be marked CLS compliant:\n\n\nUse Int32 in a public P/Invoke declaration where the unmanaged declaration has unsigned int.\nUse UInt32 in an internal P/Invoke declaration where the unmanaged declaration has unsigned int, and wrap it in a public method that takes an Int32 and converts it to UInt32 when calling the internal method.\n\n\nWhat are the up- and downsides of these?"
] | [
"c#",
".net",
"assemblies",
"marshalling",
"cls-compliant"
] |
[
"How to find the number of times a WebElement is present in the HTML DOM?",
"I have a function which returns WebElement. Now I need to find out its occurrences or say the times it is present.\n\nE.g.\n\n@Test\npublic void elementCount() {\n navigate(\"https://www.msn.com\");\n WebElement element = driver.findElement(By.xpath(\"//a\"));\n if (elementCount(element)>0){\n foo();\n } else {\n bar();\n }\n}\n\n\nI have another method which takes the parameter as string:\n\npublic int elementCount(String string) {\n int i = driver.findElements(By.xpath(string)).size();\n if (i > 0) {\n System.out.println(\"Element count is \"+i);\n } else {\n System.out.println(\"Element not found);\n }\n return i;\n}\n\n\nI need another method which takes WebElement as a parameter and gives me the count. I tried to cast it with By but it gave me error org.openqa.selenium.remote.RemoteWebElement cannot be cast to org.openqa.selenium.By Can't think of anything else. \n\nI am using Windows, Java, Selenium, testNg, Maven"
] | [
"java",
"list",
"selenium",
"selenium-webdriver",
"webdriver"
] |
[
"get error when json_decode string from ajax post",
"I try send string to controller, the string is json format, when send to controller, i get error and can't decode my json string in that controller. I try to encode first in my controller, but still get error. And the error is \n\n\n \"json_decode() expects parameter 1 to be string, array given\",\n exception: \"ErrorException\",\n\n\nhere in my json string \n\n\"{ \"data\" : \n[{\n\"id\": \"TNI01\",\n \"jenis_bayar\": \"TUNAI\",\n\"no_kartu\": \"kosong\",\n\"nominal\": \"10000\",\n\"seq\": \"1\"\n} , \n{\n\"id\": \"DEB01\",\n\"jenis_bayar\": \"DEBIT BCA\",\n\"no_kartu\": \"786382432432\",\n\"nominal\": \"20000\",\n\"seq\": \"2\"\n}]\n}\"\n\n\nhere the controller\n\npublic function ArrayPostToTablePembayaran(Request $request)\n {\n\n $data = json_decode($request->datajson, true);\n\n foreach ($data->data as $datas) \n {\n $id = $datas->id;\n $jenisbayar = $datas->jenis_bayar;\n $nokartu = \"\";\n\n if($datas->no_kartu == \"kosong\")\n {\n $nokartu =\"\";\n }\n\n $nominal = $datas->nominal;\n $seq = $data->seq;\n $this->PosToTablePembayaran1($id , $jenisbayar , $nokartu , $nominal , $seq); \n }\n }\n\n\nand here the ajax script for parse json string to controller\n\nfunction PembayaranKeDatabase1(arraystring)\n {\n $.ajax(\n {\n type : \"POST\",\n url : \"{{ url('/trx_bayar') }}\",\n data : { datajson : JSON.parse(arraydata) } ,\n dataType: \"json\",\n success: function(data){\n\n },\n error: function() {\n\n }\n });\n }\n\n\nthanks before"
] | [
"javascript",
"php",
"json",
"laravel"
] |
[
"Cannot set custom type object in plpgsql to null. Instead fields of that object becomes null",
"I am trying to attach null to a custom type object to null. But only the fields inside that object becomes null instead of the object itself.\n\nI have tried using the FOUND flag to determine whether any row was assigned to my object. If found was false, then the custom type object is set to null. But when I print the object, in pgadmin console it looks like (,,,,,,). \n\nSelect id,provider_id,beneficiary_name,beneficiary_branch,beneficiary_account_number,swift_code,\n payment_terms,currency,bank_name,payment_entity,payment_type,invoice_due_date_type,last_updated_time\n INTO provider_payment_method_result\n from provider_info.provider_payment_method where provider_id = provider_id_param;\n IF NOT FOUND\n THEN provider_payment_method_result := NULL::provider_info_api.payment_method;\n END IF;\n raise notice 'found : %', found;\n raise notice 'payment_method % ', provider_payment_method_result;\n return provider_payment_method_result;\n\n\nI expect \n\nNOTICE: found : f NOTICE: payment_method null\n\n\nActual result\n\nNOTICE: found : f NOTICE: payment_method (,,,,,,,,,,,,)"
] | [
"sql",
"postgresql",
"plpgsql"
] |
[
"Go: Finding the lower time value",
"I'm using C# my entire life and now trying out GO. How do I find the lower time value between two time structs?\n\nimport (\n t \"time\"\n \"fmt\"\n)\n\nfunc findTime() {\n timeA, err := t.Parse(\"01022006\", \"08112016\")\n timeB, err := t.Parse(\"01022006\", \"08152016\")\n Math.Min(timeA.Ticks, timeB.Ticks) // This is C# code but I'm looking for something similar in GO\n}"
] | [
"go",
"time"
] |
[
"Database replication SQL Server 2012 to Bigrock server and Windows Server on AWS",
"I am developing windows application where I am trying to create SQL Server 2012 database replication to Bigrock server and Windows Server on AWS\nbut failed to perform database replication.\n\nI publish database on SQL Server 2012 and trying to add subscription of Bigrock server and Windows Server on AWS server database but it gives me following error :\n\n\n SQL Server replication requires the actual server name to make a\n connection to the server. Specify the actual server name\n\n\nI also refer Transactional Replication in SQL Server link \n\ncan anyone tell me it is possible ? if yes then how ?"
] | [
"c#",
"amazon-web-services",
"sql-server-2012",
"web-hosting",
"transactional-replication"
] |
[
"How to get unique device id in iOS",
"I am working on iOS app for push notification feature i need to send unique device id of iOS device to server ,in android secure androd id getting for every device,is there any way to get unique device id of iOS.\nI found some answers vendor id and ad id are they unique\n\ncode:\nSecure.getString(getContext().getContentResolver(),Secure.ANDROID_ID);"
] | [
"ios",
"objective-c",
"swift",
"deviceid"
] |
[
"Top-left pixel outside 100% width of the browser window",
"Is it possible to load my webpage so that top-left pixel isn't the first one but rather somewhere else? \n\nThis is my current webpage layout and I'd like my webpage to be loaded so that top-left pixel is right where red arrow lands"
] | [
"javascript",
"jquery",
"html",
"css"
] |
[
"Why connection is timed out in Javamail?",
"I'm trying to use javamail in eclipse to send out an email via gmail. Each time I get javax.mail.MessagingException\n\nException\n\n DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map\n DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]\n DEBUG SMTP: useEhlo true, useAuth true\n DEBUG SMTP: useEhlo true, useAuth true\n DEBUG SMTP: trying to connect to host \"smtp.gmail.com\", port 587, isSSL false\n javax.mail.MessagingException: Could not connect to SMTP host: \n\nsmtp.gmail.com, port: 587;\n nested exception is:\n java.net.ConnectException: Connection timed out: connect\n\n\nCode\n\npackage org.itc.utility;\n\nimport java.util.Properties;\n\nimport javax.mail.Message;\nimport javax.mail.PasswordAuthentication;\nimport javax.mail.Session;\nimport javax.mail.Transport;\nimport javax.mail.internet.InternetAddress;\nimport javax.mail.internet.MimeMessage;\n\nimport org.itc.model.User;\n\npublic class SendEmail {\n public User sendingEmail(User user)\n {\n Properties props = new Properties(); \n props.put(\"mail.smtp.host\", \"smtp.gmail.com\"); \n props.put(\"mail.smtp.auth\", \"true\"); \n props.put(\"mail.debug\", \"true\"); \n props.put(\"mail.smtp.port\", 587); \n props.put(\"mail.smtp.socketFactory.port\", 587); \n props.put(\"mail.smtp.starttls.enable\", \"true\");\n props.put(\"mail.transport.protocol\", \"smtp\");\n Session mailSession = null;\n\n mailSession = Session.getInstance(props, \n new javax.mail.Authenticator() { \n protected PasswordAuthentication getPasswordAuthentication() { \n return new PasswordAuthentication(\"<[email protected]>\", \"<zc516z918>\"); \n } \n }); \n\n\n try {\n\n\n Transport transport = mailSession.getTransport();\n\n MimeMessage message = new MimeMessage(mailSession);\n\n message.setSubject(\"Sample Subject\");\n message.setFrom(new InternetAddress(\"[email protected]\"));\n String []to = new String[]{\"[email protected]\"};\n message.addRecipient(Message.RecipientType.TO, new InternetAddress(to[0]));\n String body = \"Sample text\";\n message.setContent(body,\"text/html\");\n transport.connect();\n\n transport.sendMessage(message,message.getRecipients(Message.RecipientType.TO));\n transport.close();\n } catch (Exception exception) {\n System.out.println(exception);\n }\n return user;\n }\n}\n\n\nEach time it is skipping the try block and I'm getting the exception. Any help on this?"
] | [
"java",
"email",
"jakarta-mail"
] |
[
"R - Linking two different sets of coordinates",
"I have two data sets - let's call them 'plot'(734 rows) and 'stations'(62 rows). A while ago I worked out that this code should let me link each 'plot' to its nearest 'station' based on their coordinates\n\ndata set is a little like this - (but without the headers of Long and Lat)\n\nplot - Long Lat stations - Long Lat\n 13.2 60.5 14.6 55.4\n 15.4 62.6 15.5 62.9\n 15.6 62.4 16.4 58.9\n 16.5 58.7 19.3 64.0\n 16.5 58.5\n\n\n#print results to \"results.csv\"\nsink(\"results.csv\")\n\n#identifyl long + lat coords of each data set\np_coord<-SpatialPoints(plot[,c(1,2)]) \ns_coord<-SpatialPoints(stations[,c(1,2)])\n\n#link coordinates \nrequire(FNN)\ng = get.knnx(coordinates(s_coord), coordinates(p_coord),k=1)\nstr(g)\nplot(s_coord_2, col=2, xlim=c(-1e5,6e5))\nplot(p_coord, add=TRUE)\nsegments(coordinates(p_coord)[,1], coordinates(p_coord)[,2], coordinates(s_coord[g$nn.index[,1]])[,1], coordinates(s_coord[g$nn.index[,1]])[,2])\n\n#print result in results.csv\nprint(g)\n\n\nI've since realised that the results i get are slightly wrong - for example plots #3 and #4 are linked to station #4, when it would be more applicable that plots #4 and #5 are linked to station #4.\n\nSo this leads me to think that something in the code is slightly off, but only by one row\n\nwould appreciate any comments on my code, or am equally interested into suggestions on simpler ways to connect two series of coordinates\nThanks"
] | [
"r",
"coordinates"
] |
[
"Enable GD support in PHP",
"I'm trying to install pixelpost on an Apache server on windows. The installer is failing because:\n\n\n Pixelpost will not run if your PHP\n installation is not compiled with the\n GD graphics library.\n\n\nI've added the following line to php.ini\n\nextension=php_gd2.dll\n\n\nBut I still get the same error message. When I run phpinfo() I don't see any reference to GD, so I guess it really isn't installed. I searched for php_gd2.dll and it's in the ext subfolder of my PHP root dir.\n\nI know nothing about PHP, so be gentle with me.\n\nUpdate\n\nTo answer the questions raised in the comments:\n\n\nI restarted Apache after modifying php.ini\nphp.ini is in the root dir of my PHP installation C:\\php\\php.ini"
] | [
"php",
"gd2"
] |
[
"Django: Best way to give Stripe ACH deposit verification Error",
"I'm working on Stripe ACH verification where I have the user input two numbers corresponding to deposits in their bank account. What's the best way to error out the html field when they enter a value that isn't a integer between 1 and 99. Should this be done javascript side (jquery?) or in my view. My gut tells me that it needs to be done in the view, but I don't know how to relay an error message back to the user. Should I create a form for this? I wouldn't think so since I'm not saving things to the database.\n\nThoughts?\n\nMy View in Django\n\ndef ach_payment_verify_updateview(request):\n request.stripe_id = request._post['token']\n print('hi')\n try:\n if not isinstance(request._post['deposit_1'], int):\n ### some kind of error message here\n print(request._post['deposit_1'])\n print(request._post['deposit_2'])\n\n\nMy current javascript code.\n\ndocument.querySelector('form.ach-payment-verify-form').addEventListener('submit', function(e) {\n e.preventDefault();\n var nextUrl = paymentForm.attr('data-next-url');\n var deposit_1 = document.getElementById('deposit-1').value;\n var deposit_2 = document.getElementById('deposit-2').value;\n stripeDepositHandler(nextUrl, deposit_1, deposit_2)\n });\nfunction stripeDepositHandler(nextUrl, deposit_1, deposit_2){\n var paymentMethodEndpoint = '/billing/ach-payment-verify/create/'\n var data = {\n 'token': 'ba_1CWoJSFAasdfafsdReMae',\n 'deposit_1':deposit_1,\n 'deposit_2':deposit_2,\n }\n $.ajax({\n data: data,\n url: paymentMethodEndpoint,\n method: \"POST\",\n success: function(data){\n var successMsg = data.message || \"Success! Your account has been verified.\"\n $(\"form.ach-payment-verify-form\")[0].reset();\n if (nextUrl){\n successMsg = successMsg + \"<br/><br/><i class='fa fa-spin fa-spinner'></i> Redirecting...\" //<i class> - 'font awesome'\n }\n if ($.alert){ // if alert message is installed\n $.alert(successMsg)\n } else {\n alert(\"\")\n } \n redirectToNext(nextUrl, 1500)\n },\n error: function(error){\n console.log(error)\n }\n })\n}"
] | [
"javascript",
"django",
"stripe-payments"
] |
[
"Change Text on another Div",
"Good evening Community,\nI have a problem with my code.\n\nHTML:\n\n <a href=\"aboutme.php\">\n <div class='aboutus'>\n <div id=\"mbubble\">\n stuff inside here\n </div>\n </div>\n </a>\n <div id='title'>\n <div class=\"thome\"><p style=\"letter-spacing:10;\">Text BEFORE</p></div>\n <div class=\"tabout\"><p style=\"letter-spacing:10;\">Text AFTER</p></div>\n\n\nI want if I hover over the div \"mbubble\" that the class \"thome\" will change it's text. I tried to do that by making them visible / invisible.\n\nCSS:\n\n#mbubble:hover ~ .thome { visibility:hidden; }\n#mbubble:hover ~ .tabout { visibility:visible; }\n\n\nBut it's sowhing no affect?\n\nCan you tell me how you would do that? Or at least any way that's working to change the text by hovering?\n\nBest regards,\nMichael"
] | [
"javascript",
"jquery",
"html",
"css"
] |
[
"Why am I getting \"Segmentation Fault\" when I run my program?",
"My program decodes an image that is covered by random pixels, to decode the image, I have to multiply each pixel's red color component by 10. The green and blue color components are the same values as the new red component. I've created multiple helper functions, to make the code easier to read in main, but when I try to run my a.out, I keep getting \"Segmentation Fault\". I can't seem to find my mistakes! Help is appreciated.\n\nvoid check_argument(int arg_list)\n{\n if (arg_list < 2)\n {\n perror(\"usage: a.out <input file>\\n\");\n }\n}\n\nvoid print_pixel(int a, FILE *out)\n{\n int r, g, b;\n\n r = a * 10;\n\n if (r > 255)\n {\n r = 255;\n }\n\n g = r;\n b = r;\n\n fprintf(out, \"%d\\n\", r);\n fprintf(out, \"%d\\n\", g);\n fprintf(out, \"%d\\n\", b);\n}\n\nvoid read_header(FILE *in)\n{\n char str[20];\n\n for (int i = 0; i < 3; i++)\n {\n fgets(str, 20, in);\n }\n}\n\nFILE* open_files(FILE *infile, char *input[])\n{\n infile = fopen(input[1], \"r\");\n\n if (infile == NULL)\n {\n perror(\"Error: Cannot read file.\\n\");\n }\n\n return infile;\n}\n\nvoid decode(int arg_list, char *in[])\n{\n FILE *input, *output;\n\n int check, red, green, blue;\n\n open_files(input, in);\n output = fopen(\"hidden.ppm\", \"w\");\n\n fprintf(output, \"P3\\n\");\n fprintf(output, \"%d %d\\n\", 500, 375);\n fprintf(output, \"255\\n\");\n\n read_header(input);\n check = fscanf(input, \"%d %d %d\", &red, &green, &blue);\n\n while (check != EOF)\n {\n print_pixel(red, output);\n check = fscanf(input, \"%d %d %d\", &red, &green, &blue);\n }\n\n fclose(input);\n fclose(output);\n}\n\nint main(int argc, char *argv[])\n{\n check_argument(argc);\n decode(argc, argv);\n}"
] | [
"c",
"image",
"segmentation-fault",
"ppm"
] |
[
"Leaderboard design using SQL Server",
"I am building a leaderboard for some of my online games. Here is what I need to do with the data: \n\n\nGet rank of a player for a given game across multiple time frame (today, last week, all time, etc.)\nGet paginated ranking (e.g. top score for last 24 hrs., get players between rank 25 and 50, get rank or a single user)\n\n\nI defined with the following table definition and index and I have a couple of questions.\n\nConsidering my scenarios, do I have a good primary key? The reason why I have a clustered key across gameId, playerName and score is simply because I want to make sure that all data for a given game is in the same area and that score is already sorted. Most of the time I will display the data is descending order of score (+ updatedDateTime for ties) for a given gameId. Is this a right strategy? In other words, I want to make sure that I can run my queries to get the rank of my players as fast as possible.\n\nCREATE TABLE score (\n [gameId] [smallint] NOT NULL,\n [playerName] [nvarchar](50) NOT NULL,\n [score] [int] NOT NULL,\n [createdDateTime] [datetime2](3) NOT NULL,\n [updatedDateTime] [datetime2](3) NOT NULL,\nPRIMARY KEY CLUSTERED ([gameId] ASC, [playerName] ASC, [score] DESC, [updatedDateTime] ASC)\n\nCREATE NONCLUSTERED INDEX [Score_Idx] ON score ([gameId] ASC, [score] DESC, [updatedDateTime] ASC) INCLUDE ([playerName])\n\n\nBelow is the first iteration of the query I will be using to get the rank of my players. However, I am a bit disappointed by the execution plan (see below). Why does SQL need to sort? The additional sort seem to come from the RANK function. But isn’t my data already sorted in descending order (based on the clustered key of the score table)? I am also wondering if I should normalize a bit more my table and move out the PlayerName column in a Player table. I originally decided to keep everything in the same table to minimize the number of joins.\n\nDECLARE @GameId AS INT = 0\nDECLARE @From AS DATETIME2(3) = '2013-10-01'\n\nSELECT DENSE_RANK() OVER (ORDER BY Score DESC), s.PlayerName, s.Score, s.CountryCode, s.updatedDateTime\nFROM [mrgleaderboard].[score] s\nWHERE s.GameId = @GameId \n AND (s.UpdatedDateTime >= @From OR @From IS NULL)\n\n\n\n\nThank you for the help!"
] | [
"sql",
"sql-server",
"database",
"database-design",
"azure-sql-database"
] |
[
"Get input value from Bootstrap Form Input",
"I'm using a Bootstrap Form Input to allow the user to pass in some text. How do I go about saving that text and using it as a parameter in a function?\n\nHere's my HTML:\n\n<!--Directory Input Form-->\n<div class=\"row\">\n <div class=\"input-group\">\n <span class=\"input-group-addon\" id=\"basic-addon3\">Directory</span>\n <input type=\"text\" class=\"form-control\" id=\"basic-url\" aria-describedby=\"basic-addon3\">\n </div>\n</div>\n\n<!--Convert Button-->\n<div class=\"panel-body\">\n <button type=\"button\" class=\"btn btn-primary\" (click)=\"convert(inputString);\">Convert</button>\n</div>\n\n\nAs you can see, I have a call to a method called convert(inputString) that takes in a string parameter (convert(string s) is implemented in my TypeScript folder). I placed 'inputString' inside the method to better illustrate my question even though I know I don't have an id for inputString anywhere else. Is that the proper way to go about this - creating an id with the name inputString and linking it to the text the user inputs? If so, how do I go about doing that?"
] | [
"jquery",
"html",
"angularjs",
"twitter-bootstrap",
"angular"
] |
[
"Altering and showing uploaded image in Dash app",
"I'm new to Dash apps. I'm interested in creating a web app where the user uploads their own image, and then I alter it in some way, and show the resulting image (ideally using pillow v 6.0.0). A basic example would be to take in an image, rotate it, and show the rotated image. I've been using this example as a template for uploading an image and showing the same image. How can I alter the example to rotate the image rather than just displaying the same image?"
] | [
"python",
"plotly-dash"
] |
[
"Mounting a copy of a managed disk on AKS",
"I am trying to create a pod that uses an existing Managed Disk as the source for the disks that are mounted. I can attach the managed disk directly, but I can't make it work via PV and a PVC. \n\nThese are the files I'm using \n\npvclaim.yml\n\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n name: mongo-pvc\n annotations:\n volume.beta.kubernetes.io/storage-class: default\nspec:\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 256Gi\n storageClassName: default\n\n\npvdisk.yml\n\napiVersion: v1\nkind: PersistentVolume\nmetadata:\n name: mongo-pv\nspec:\n capacity:\n storage: 256Gi\n storageClassName: default\n azureDisk:\n kind: Managed\n diskName: Mongo-Data-Test01\n fsType: xfs\n diskURI: /subscriptions/<SubId>/resourceGroups/Static-Staging-Disks-Centralus/providers/Microsoft.Compute/disks/Mongo-Data-Test01\n accessModes:\n - ReadWriteOnce\n claimRef:\n name: mongo-pvc\n namespace: default\n\n\npvpod.yml\n\napiVersion: v1\nkind: Pod\nmetadata:\nname: adisk\nspec:\ncontainers:\n - image: nginx\n name: azure\n volumeMounts:\n - name: azuremount\n mountPath: /mnt/azure\nvolumes:\n - name: azuremount\n persistentVolumeClaim:\n claimName: mongo-pvc\n\n\nThe ultimate goal is to create a Statefulset that will deploy a cluster of Pods with the same Managed disk as the source for them all. \n\nAny pointers would be appreciated! \n\nUpdated to add\n\nThe above will create a new disk for each instance (pod) that is launched. I am looking to create a new disk using the createOption: fromImage\n\nSo I'm looking for the underlying Azure infrastructure to create a copy of the existing managed disk, and then attach that to the pod(s) that are launched."
] | [
"azure",
"kubernetes",
"azure-aks"
] |
Subsets and Splits