texts
sequence | tags
sequence |
---|---|
[
"How to share objects and data between python processes in real-time?",
"I'm trying to find a reasonable approach in Python for a real-time application, multiprocessing and large files.\n\nA parent process spawn 2 or more child. The first child reads data, keep in memory, and the others process it in a pipeline fashion. The data should be organized into an object,sent to the following process, processed,sent, processed and so on.\n\nAvailable methodologies such as Pipe, Queue, Managers seem not adequate due to overheads (serialization, etc).\n\nIs there an adequate approach for this?"
] | [
"python",
"multiprocessing"
] |
[
"Using ASP.NET mobile choose an existing photo, iPhone picture capture",
"<input type=\"file\" accept=\"image/*\" capture=\"camera\" />\n\n\nUsing this file input using iPhone safari used to display an option to the select a photo from the existing photo from the library or the Camera. Now in iOS10+ it just goes to the camera, wihtout the options.\n\nI assume its a security option which needs to enabled, but we're using asp.net so we can't add the option to enable access.\n\nIs there any way of allowing the user to access existing Photos to upload, using asp.net alone?"
] | [
"html",
"iphone",
"mobile",
"camera",
"photo"
] |
[
"How can I expand a Gtk Label to fill the entire Horizontal Space?",
"I'm trying to insert a text label in a dialog but when I set the aligment to (X=0, Y=0.5) and the line wrap to True, the text doesn't fill the entire horizontal space.\n\nHere is an image \n\nIt is the example code in python:\n\nimport gtk\n\nif __name__ == \"__main__\":\n\n lbl = gtk.Label('Presione el botón \"Adelante\" para iniciar la instalación del sistema. Después de este paso no podrá detener la instalación, así que asegúrese de que sus datos son correctos.')\n lbl.set_line_wrap(True)\n lbl.set_alignment(0, 0.5)\n lbl.set_justify(gtk.JUSTIFY_FILL)\n lbl.show()\n\n diag = gtk.Dialog()\n diag.set_size_request(640, 480)\n diag.vbox.pack_start(lbl)\n diag.run()"
] | [
"gtk",
"label",
"pygtk"
] |
[
"Validating a user site-wide with Django's auth system",
"How can I display content side-wide (on every page) based on if the user is logged in or not? I have a sidebar area defined in my base.html which is either populated with login/register forms (if the user is not logged in) or a dashboard (if the user is logged in).\n\nHow can I make this universal to every single web page on my site? Do I have to manually check the user each time a new view is called and pass a user variable to my render_to_response()? There's got to be a simpler way."
] | [
"python",
"django",
"authentication"
] |
[
"Unable to open files, with the path in Jupyter notebook",
"I have reinstalled the anaconda after formatting my machine, since I am getting error while opening the files in jupyter notebook.\n\nInitially I tried access the file from desktop location, as I got an error again tried to access from D drive. both were not successful attempts.\n\nsalaries = pd.read_excel('D:\\\\housesales.xlsx')\n\n\nBelow is the error\n\n\n FileNotFoundError Traceback (most recent call last) <ipython-input-13-6d8e17cbb085> in <module> ----> 1 salaries = pd.read_excel('D:\\housesales.xlsx') ~\\Anaconda3\\lib\\site-packages\\pandas\\util_decorators.py in wrapper(*args, **kwargs) 186 else: 187 kwargs[new_arg_name] = new_arg_value --> 188 return func(*args, **kwargs) 189 return wrapper 190 return _deprecate_kwarg ~\\Anaconda3\\lib\\site-packages\\pandas\\util_decorators.py in wrapper(*args, **kwargs) 186 else: 187 kwargs[new_arg_name] = new_arg_value --> 188 return func(*args, **kwargs) 189 return wrapper 190 return _deprecate_kwarg ~\\Anaconda3\\lib\\site-packages\\pandas\\io\\excel.py in read_excel(io, sheet_name, header, names, index_col, parse_cols, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skip_footer, skipfooter, convert_float, mangle_dupe_cols, **kwds) 348 349 if not isinstance(io, ExcelFile): --> 350 io = ExcelFile(io, engine=engine) 351 352 return io.parse( ~\\Anaconda3\\lib\\site-packages\\pandas\\io\\excel.py in init(self, io, engine) 651 self._io = _stringify_path(io) 652 --> 653 self._reader = self._enginesengine 654 655 def fspath(self): ~\\Anaconda3\\lib\\site-packages\\pandas\\io\\excel.py in init(self, filepath_or_buffer) 422 self.book = xlrd.open_workbook(file_contents=data) 423 elif isinstance(filepath_or_buffer, compat.string_types): --> 424 self.book = xlrd.open_workbook(filepath_or_buffer) 425 else: 426 raise ValueError('Must explicitly set engine if not passing in' ~\\Anaconda3\\lib\\site-packages\\xlrd__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows) 109 else: 110 filename = os.path.expanduser(filename) --> 111 with open(filename, \"rb\") as f: 112 peek = f.read(peeksz) 113 if peek == b\"PK\\x03\\x04\": # a ZIP file FileNotFoundError: [Errno 2] No such file or directory: 'D:\\housesales.xlsx'"
] | [
"jupyter",
"python-3.7"
] |
[
"Passing collections in scala actors",
"When I need to pass typed collections to an actor, I get an \"unchecked\" warning in my react method:\n\nval actor = actor {\n loop {\n react {\n case a:List[String] => // do something\n }\n }\n}\n\n\nHow can I work around this? I tried boxing collection in a separate class (but that is ugly and cumbersome), and just casting collection (case a:List[_] => a.asInstanceOf[List[String]]) after receiving it by actor is not type-safe and dangerous."
] | [
"scala",
"actor"
] |
[
"Adding android:layoutAnimation to a LinearLayout causes FC",
"I have the following XML in menu.xml, it's a LinearLayout that I need to animate, so I use the layoutAnimation property. Without this property the layout shows flawlesly, but with this property set I get a nasty forceclose and I don't understand why:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n android:orientation=\"vertical\"\n android:layout_width=\"fill_parent\"\n android:layout_height=\"fill_parent\"\n android:background=\"@drawable/bkgrnd\"\n android:layoutAnimation=\"@anim/menu_anim\" <=== adding this results in FC\n...etc...\n\n\nanim/menu_anim.xml:\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:shareInterpolator=\"false\">\n <alpha\n android:fromAlpha=\"0.0\"\n android:toAlpha=\"1.0\"\n android:duration=\"500\">\n </alpha> \n\n</set>\n\n\nHelp please! Thanks!"
] | [
"android-animation",
"forceclose"
] |
[
"How do I use AnkoComponent inside FirebaseRecyclerAdapter?",
"I have this FirebaseRecyclerAdapter:\n\nmAdapter = new FirebaseRecyclerAdapter<Chat, ChatHolder>(\nChat.class, \n// Below layout is where I want the AnkoComponent\nandroid.R.layout.two_line_list_item, \nChatHolder.class, \nmRef) {\n @Override\n public void populateViewHolder(ChatHolder chatMessageViewHolder, Chat chatMessage, int position) {\n chatMessageViewHolder.setName(chatMessage.getName());\n chatMessageViewHolder.setText(chatMessage.getText());\n }\n};\nrecycler.setAdapter(mAdapter);\n\n\nI want to use an AnkoComponent that is in a different file than the adapter. If anybody could help me with this I would be so grateful.\n\nJust in case it helps, below is the AnkoComponent that I want to use as my list item in the viewHolder.\n\nclass PriorityUI : AnkoComponent<Priority> {\n override fun createView(ui: AnkoContext<Priority>) = with(ui) {\n\n relativeLayout {\n id = R.id.priority_item_layout\n linearLayout {\n orientation = LinearLayout.HORIZONTAL\n\n textView {\n id = R.id.textView_priority\n textAlignment = Gravity.CENTER\n }.lparams {\n width = matchParent\n }\n\n }.lparams {\n width = matchParent\n }\n }\n }\n}"
] | [
"android",
"firebase-realtime-database",
"kotlin",
"firebaseui",
"anko"
] |
[
"Log4J API not printing messages in the java program",
"I am trying to implement Log4J API in my java project.\nTo do that, I have created a properties as shown in the image below (highlighted in yellow):\nProject Structure Image\n\nThese are the properties I set in the file:\n\n# TRACE < DEBUG < INFO < WARN < FATAL\nlog4j.rootLogger=TRACE, DEBUG, INFO, file\n\n# Console\n# log4j.appender.toConsole=org.apache.log4j.ConsoleAppender\n# log4j.appender.toConsole.layout=org.apache.log4j.PatternLayout\n# log4j.appender.toConsole.layout.ConversionPatter=%d{HH:mm:ss} %5p [%t] - $c.%M - %m%n\n\n# Redirecting log messages to console\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\nlog4j.appender.stdout.Target=System.out\nlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout\nlog4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n\n\n\nI declared the LOGGER object in my class as following:\n\nimport org.apache.log4j.Level;\nimport org.apache.log4j.Logger;\npublic class Credits{\n\n Logger LOGGER = null;\n public Credits(String sources) {\n LOGGER = Logger.getLogger(ChunkRecon.class.getName());\n LOGGER.setLevel(Level.DEBUG);\n String creditNames = \"select tablename, creditNumbers, credit_type from schema.table where credit_type in (\"sources\")\";\n LOGGER.debug(\"This is a debug message\");\n system.out.println(\"This message is from println\");\n }\n}\n\n\nIn the output, I see the message from sysout: This message is from println but not the debug message.\n\nCould anyone let me know what is the mistake I am doing here ?"
] | [
"java",
"log4j"
] |
[
"How to scale my stratus application?",
"Stratus is currently in beta ! \n\nSo, if I create a simple app with stratus tecnology and I get millions of users, then how can I scale the application ?\n\nHow chatroulette have resolved the scaling issue ?"
] | [
"apache-flex",
"flash",
"actionscript-3",
"adobe",
"stratus"
] |
[
"libspotify API: when does password blob expire?",
"As per API document, credentials_blob_updated callback is called when storable credentials have been updated. But in \"spshell\" example, blob for storage is kept refreshing from time to time even if there is no credential change. Is it normal? \n\nThanks."
] | [
"spotify"
] |
[
"AUAudioFilePlayer silences whole graph after playing",
"In order to play sound fragments from a file, I have setup a Audio Graph with three units, a AUAudioFilePlayer unit, a mixer unit, and an output unit, according to the code in this SO question. That works fine, and plays my sound fragments perfectly.\n\nThen I have added another AUAudioFilePlayer unit, and fed its output in the mixer as well, so I can play from two files in parallel and mix them together. That also works fine, as long as I keep scheduling fragments on both AUAudioFilePlayer units (that is, I have a timer that schedules a new 2-second fragment every 2 seconds). But as soon as I stop scheduling fragments on one of the AUAudioFilePlayer units, the whole graph falls silent. My timer still happily schedules a new fragment on the first AUAudioFilePlayer unit, and I don't get any errors on any of the system calls, but no sound comes through.\n\nAnybody knows how to prevent this?\n\nI have tried doing an AudioUnitReset on the second player, and even to remove it from the graph with AUGraphDisconnectNodeInput, all to no avail. \n\nMy code to schedule a fragment is here:\n\nCheckError(AudioUnitReset(fileAU, kAudioUnitScope_Global, 0), \"AudioUnitReset\");\n\nScheduledAudioFileRegion rgn;\nmemset (&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));\nrgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;\nrgn.mTimeStamp.mSampleTime = -1;\nrgn.mCompletionProc = NULL;\nrgn.mCompletionProcUserData = NULL;\nrgn.mAudioFile = inputFile;\nrgn.mLoopCount = 0;\nrgn.mStartFrame = startFrame;\nrgn.mFramesToPlay = 88200;\n\nCheckError(AudioUnitSetProperty(fileAU, kAudioUnitProperty_ScheduledFileRegion, kAudioUnitScope_Global, 0,&rgn, sizeof(rgn)), \"AudioUnitSetProperty[kAudioUnitProperty_ScheduledFileRegion] failed\");"
] | [
"ios",
"core-audio",
"audiounit"
] |
[
"InvalidDataAccessApiUsageException",
"I'm running a Grails application in \"PRODUCTION ENV.\" with version 2.3.1. It runs fine for some time. But after some time, it starts failing with exception \"InvalidDataAccessApiUsageException\". Again when I delete target folder and re run the application, it works good.\n\nThere is no error while working in \"DEVELOPMENT ENV\". \n\nDetailed exception is \n\n[[ErrorType:class org.springframework.dao.InvalidDataAccessApiUsageException],\n [ErrorMessage:The given object has a null identifier: com.test.model.Test;\n nested exception is org.hibernate.TransientObjectException:\n The given object has a null identifier: com.test.model.Test]]"
] | [
"grails",
"gorm"
] |
[
"Laravel orderBy() not working with groupBy() in query builder",
"Im using below query to display users quiz result which is ordered by recent date.\n\n$query = \\DB::table('users_quiz_result');\n $query->join('users', 'users_quiz_result.user_id', '=', 'users.id');\n $query->join('user_profiles', 'users_quiz_result.user_id', '=', 'user_profiles.user_id');\n $query->join('quiz', 'users_quiz_result.quiz_id', '=', 'quiz.id');\n $query->select('users_quiz_result.id as quizresultid', 'users_quiz_result.invest_percent' ,'user_profiles.first_name','user_profiles.last_name', 'users.email AS email', 'quiz.name AS quizname', 'users_quiz_result.year AS quizyear', 'users_quiz_result.invest_percent AS investment','users_quiz_result.integration_percent AS integration', 'users_quiz_result.institution_percent AS institutionalisation', 'users_quiz_result.impact_percent AS impact', 'users_quiz_result.created_at AS quizdate');\n\n if(isset($_REQUEST['lastresult']) && trim($_REQUEST['lastresult'])==1)\n { \n $query->groupBy('users_quiz_result.user_id');\n }\n if(isset($_REQUEST['username']) && trim($_REQUEST['username'])!='')\n {\n $query->where(function ($query) {\n $query->orwhere('user_profiles.first_name','LIKE', \"%\".trim($_REQUEST['username']).\"%\")\n ->orwhere('user_profiles.last_name','LIKE', \"%\".trim($_REQUEST['username']).\"%\") \n ->orwhere(\\DB::raw('CONCAT(user_profiles.first_name,\" \",user_profiles.last_name)'),'LIKE', \"%\".trim($_REQUEST['username']).\"%\") ; \n });\n }\n\n if(isset($_REQUEST['useremail']) && trim($_REQUEST['useremail'])!='')\n {\n $query->where('users.email','LIKE', \"%\".trim($_REQUEST['useremail']).\"%\");\n }\n\n if(isset($_REQUEST['quizname']) && trim($_REQUEST['quizname'])!='')\n {\n $query->where('quiz.name','LIKE', \"%\".trim($_REQUEST['quizname']).\"%\");\n }\n\n if(isset($_REQUEST['quizname']) && trim($_REQUEST['quizname'])!='')\n {\n $query->where('quiz.name','LIKE', \"%\".trim($_REQUEST['quizname']).\"%\");\n }\n\n if(isset($_REQUEST['fromdate']) && trim($_REQUEST['fromdate'])!='')\n {\n $from = trim($_REQUEST['fromdate']).\" 00:00:00\";\n $to = trim($_REQUEST['fromdate']).\" 23:59:59\";\n\n if(isset($_REQUEST['todate']) && trim($_REQUEST['todate'])!='')\n {\n $to = trim($_REQUEST['todate']).\" 23:59:59\";\n }\n\n $query->whereBetween('users_quiz_result.created_at', [$from, $to]);\n } \n\n $query->orderBy('users_quiz_result.created_at', 'DESC');\n $quizresult = $query->get();\n\n\nI have search for the user records like name, email, date and also Last result of all the users. Single user can do more than one quiz. \n\nIm using below query to display last record of all users\n\nif(isset($_REQUEST['lastresult']) && trim($_REQUEST['lastresult'])==1)\n { \n $query->groupBy('users_quiz_result.user_id');\n }\n\n\nUsing groupBy the Single user record is displaying but i cant get last record based on date.\n\nI dont know how solve this issue please help me. Thanks in advance."
] | [
"php",
"laravel-5"
] |
[
"Using SQLCMD to get multiple result sets",
"How does one write, using SQLCMD:\n\nmultiple result sets to one output file?\nor, multiple result sets to separate output files?\n\nDiscussion\nAfter prototyping in SSMS, then moving to SQLCMD called from batch file, it's necessary to stay within the same connection (due to building some #temp tables along the way). The batch files will then be provided to production operations who will run them and give the output back to me for further processing.\nCREATE TABLE #BatchFileType ( ... )\nINSERT INTO #BatchFileType ( ... )\nSELECT (...) FROM ...\nCREATE NONCLUSTERED INDEX ...\n\nCREATE TABLE #BrandingServiceDates ( ... )\nINSERT INTO #BrandingServiceDates (\nSELECT (...) FROM #BatchFileType JOIN (other tables)\nCREATE NONCLUSTERED INDEX ...\n\nSELECT [result set 1]\nSELECT [result set 2]\nSELECT [result set n]\n...\n\nThen, based on #BrandingServiceDates, create multiple result sets which we want to write to output files. Each run is based on a date range. The goal here is to not have to redo the #temp table processing time for each result set.\nThis is a one-time run so looking to solve this with sqlcmd, batch files, and parameters.\nsqlcmd -S %1 -i %2 -W -o %3 -k -s,\n\nWhere -o (from what I can tell) doesn't take an array of filenames.\nAlternatives to SQLCMD are also welcome."
] | [
"sql-server",
"tsql",
"sqlcmd"
] |
[
"Debugging in the past and now",
"I'm enrolled now in this course on Udacity Software Development Process and the instructor said that one of the methods used to fill the gap between the software complexity and developers productivity debugging moved from printing lines to symbolic debugging.\nAnyone can illustrates what that actually means?"
] | [
"debugging",
"testing",
"software-design"
] |
[
"SDK Manager does not pop up when clicked",
"I am having a problem with my SDK Manager. It doesn't pop up when I click the icon of the window.\n\nI have downloaded the file for the 2nd time but it still doesn't pop up, I followed the instructions in here After Installing ADT Plugin, Welcome to Android Development Doesnt Appear as well i must have missed something but all is well I'm just missing google com.google.android.gms. And for that I cant continue with my project.\n\nHow can I fix this mess."
] | [
"android"
] |
[
"error: '>' is not a prefix unary operator in Int switch case",
"I'm writing this very simple completion handler, but then now I have this error in my case saying :\n\n\n error: '>' is not a prefix unary operator\n\n\nI looked here but that doesn't seem to answer my question. I added space between the operator and 5 but still it didn't work. I'm sure the fix is simple but I couldn't figure it out. All other cases for Ints I've seen had a range, but this is just a comparison\n\nfunc completeTasks(number: Int, completionHandler : (_ flag : Bool) -> () ){\n switch number {\n case <5 :\n completionHandler(true)\n case >5 :\n completionHandler(false)\n default:\n fatalError()\n }\n}\n\ncompleteTasks(number: 10){ result in print(result)\n}"
] | [
"swift",
"switch-statement",
"operators"
] |
[
"Finding records where ID matches but other value does not",
"The education department at my job is wanting some reports pulled from their online scholarship application, but before I can pull them I need to clean up the data. One thing they need is a list of any student who has changed degrees. Currently in the table that contains the degree information I have:\n\nSchoolYearID, StudentID, InstID, Degree, Major, Minor, IsCurrent, OtherSchool, OtherSchoolHours, DateCreated, and InstStudentID.\n\nHow this app was built, the SchoolYearID is the primary Key, student ID is assigned to a student on signup, InstID is the ID given to the university. In the app itself, a student can select that they are going for a Masters degree plan, but then on the next page choose that they're a Freshmen. Inevitably I'll change this to be conditional, but for right now there are just a lot of students who have put the wrong degree plan down so we need to go in and change them.\n\nThe thing I can't figure out is how to select the individual student ID's as well as the Degree plan, but show ONLY the students whose degree has changed from one school year to another. \n\nEdit: \nThe SchoolYearID is just a number assigned to each application as it is created, it doesn't really have anything to do with the calendar year. A new SchoolYearID is generated for every new application, and students can apply for 3 different semesters (spring, summer, fall) so one student could have 3 different SchoolYearID's from the same calendar year. \n\nSo like\n\n SELECT *\n FROM CpnServicePortal.dbo.SchoolEnrollment\n\n\nwill return a result like\n\n SchoolYearID StudentID InstID Degree DegreeOther ...\n 55 12 3232 M.B.A NULL\n 56 13 3235 Other NULL\n 60 20 3426 A.S. NULL\n\n\nAnd what I'm trying to come up with is\n\n SchoolYearID StudentID InstID Degree DegreeOther ...\n 55 12 3232 M.B.A NULL\n 123 12 3232 A.S. NULL\n 60 20 3426 A.S. NULL\n 728 20 3426 B.S. NULL\n\n\nWhere the studentID is matched (and if possible the InstID matches as well) but the Degree fields do not match."
] | [
"sql",
"sql-server",
"tsql"
] |
[
"easy Jquery about selecting children and browsing DOM",
"Well I think it should be easy to do it. However I just cant wrap my head around it.. this is the code i have.. In my app i am having the .scroller class selected. From there i used the .parent() to get to #exerciseWrapper class. My goal is the h2 tag. I dont know how to go on from here nothing works. find() browses whole DOM and children() only browses one child..\n\n$('.scroller').parent() something something ?? hmm.. \n\n var append='<div class=\"exerciseWrapper\"><div class=\"allTextWrapper\"><div class=\"headerWrapper\"><h2 class=\"exerciseHeaderName\">'+exerciseName+'</h2></div><div class=\"lastConfigUsedHeader\">Last configuration used:</div><div class=\"lastUsedConfig\">Sets: 10, Kg: 12302, Time:10.30</div></div><div class=\"scroller\">'+ \n'<div class=\"divImgContainer\"><img src=\"../images/exercises/logo.png\" class=\"scrollImages\"></div>'+\n'<div class=\"divImgContainer\"><img src=\"../images/exercises/MuscleGroup1.png\" class=\"scrollImages\"></div>'+\n'<div class=\"divImgContainer\"><img src=\"../images/exercises/logo.png\" class=\"scrollImages\"></div>'+\n'<div class=\"divImgContainer\"><img src=\"../images/exercises/MuscleGroup1.png\" class=\"scrollImages\"></div>'+\n'<div class=\"divImgContainer\"><img src=\"../images/exercises/logo.png\" class=\"scrollImages\"></div>'+\n'<div class=\"divImgContainer\"><img src=\"../images/exercises/MuscleGroup1.png\" class=\"scrollImages\"></div>'+\n '</div></div>'"
] | [
"jquery",
"html",
"dom"
] |
[
"Rails and HTML5: Making date_select dropdowns look better",
"Is there a way to get the drop downs for month and year to look like the input fields where they are thicker? \n\n\n\nhere's my rails code, it's part of a partial. I used the form-control on the input fields but it looks like it doesn't work so well on those dropdowns.\n\n<div class=\"new_cert\"> \n\n <div class=\"field\">\n <%= ff.label :certification_name, 'Certification Title' %>\n <%= ff.text_field :certification_name, class: \"form-control\" %> \n </div>\n <div class=\"field\">\n <%= ff.label :certification_authority %>\n <%= ff.text_field :certification_authority, class: \"form-control\" %> \n </div>\n <div class=\"field\">\n <%= ff.label :certification_number %>\n <%= ff.text_field :certification_number, class: \"form-control\" %> \n </div>\n\n <table>\n <tr>\n <td>\n <div class=\"field\">\n <%= ff.label :certification_from, \"From\" %><br />\n <%= ff.date_select :certification_from, :order => [:day, :month, :year],\n :start_year => Date.current.year, :end_year => 1960,\n :prompt => {day: 'Day', month: 'Month', year: 'Year'}, :discard_day => true, class: 'form-control' %>\n </div> \n </td>\n <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>\n <td>\n <div class=\"field\">\n <%= ff.label :certification_to, \"To\" %><br />\n <%= ff.date_select :certification_to, :order => [:day, :month, :year], \n :start_year => Date.current.year + (10), :end_year => 1960,\n :prompt => {day: 'Day', month: 'Month', year: 'Year'}, :discard_day => true, class: 'form-control' %> \n </div> \n </td>\n </tr>\n </table> \n\n <div>\n <%= ff.label :cert_never_expires, \"This certification does not expire\", class: \"l\" %>\n <%= ff.check_box :cert_never_expires, class: 'cb' %>\n </div>\n <br />\n\n</div><!-- ./new_cert -->\n\n\nhere's the form\n\n <%= form_for(@user) do |f| %>\n\n <%= f.fields_for :achievements, Achievement.new do |ff| %>\n\n <!-- a partial is rendered based on the user dropdown selection --> \n <div id=\"cert\">\n <%= render partial: \"achievements/new_certification\", locals: { ff: ff } %>\n </div>\n\n <% end %><!-- fields_for -->\n\n <%= f.submit 'Save', id: \"submit-achievement\", class: 'btn btn-primary form-control' %>\n\n </div><!-- modal body -->\n\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n </div>\n\n <% end %><!-- form_for -->"
] | [
"ruby-on-rails",
"html",
"twitter-bootstrap"
] |
[
"Cannot download google-services.json from firebase console",
"I'm trying to download google-services.json from firebase console. The error is There was an error. The config file cannot be downloaded at this time. as it can be seen in the below screenshot.\n\n\n\nThere are answers on Stackoverflow which didn't work for me (one and two). Specifically, clearing cache and history, using a newly installed chrome, trying with firefox and edge, using incognito tabs, didn't work.\n\nWhat else can be done to get rid of this annoying error?"
] | [
"firebase",
"firebase-console"
] |
[
"Android Convert Pixels to inchec, millimeter",
"I want to accurately convert pixels to inches and mm.\nI had tried to use all the properties of displayMetrics but was unsuccessful in getting the exact physical units in mobile.\nI also tried to use TypedValue.applyDimension but as the documentation is not much explanatory still was unlucky..\nCan anyone suggest me or even give me a small hint..\n\nThanks in Advance\n\nEDIT\nThis is the code I tried with displayMetrics\n\ndisplayMetrics = new DisplayMetrics();\ngetWindowManager().getDefaultDisplay().getMetrics(displayMetrics);\n\nand when i tried to get Pixels Per Inch by using \ndisplayMetrics.ydpi or displayMetrics.xdpi\nI am not getting the exact values as I am checking it by drawing a line of that much length on canvas and checked with actual ruler."
] | [
"android",
"pixel",
"dpi",
"ppi",
"inches"
] |
[
"Silver Stripe dataObject and multipage form",
"I need help wrapping my head around how to complete a system in Silverstripe.\n\nThere is a page where an authorized user can manage archives. This is NOT in the cms. It is a front end system.\n\nI need to be able to walk the user through creating the following:\n\n1. Archive (it has a year and title)\n2. every archive can have many sections with (title, description)\n3. every section can have many items with (photo, description)\n\n\nI can create the three dataObjects but I can not figure out how to:\n\n1. relate them using $many_many or $has_many\n2. create a form for each step so the user can add the three different pieces.\n\n\nThis would be easy in straight PHP/MySql but Silverstripe is new to me. I don't need the code per se, just an explanation of how the pieces work together to get what I want. The docs and forums are scarce on silverstripe.org"
] | [
"php",
"silverstripe"
] |
[
"Sitecore Duplicate Sublayouts/Controls after adding standard values presentation",
"I have added a control to a specific placeholder in the standard values section of an item's template. The problem is that older items that already have this control in the same placeholder now have duplicate controls in the same placeholder because of the standard values. Is there a way to either remove the duplicate control from the item or only allow these standard values to be used when new items are created?"
] | [
"sitecore"
] |
[
"Data contained in an array/json, want to inject into page via DOM, does jQ have templates?",
"Say I have an array, that contains data that I want to display in a html table. (sort of how gmail has all the data in js objects)\n\nI have this data in an array so I can do ajax type operations like updating/deleting/sorting of the data.\n\nDoes jQuery have templates where I can create a template for a given row, and then just loop through my javascript array/json object and then inject the row into the table?\n\nthis is a common pattern, but I don't have any experience with it so I am looking for the best practice. I know people use templates for this."
] | [
"javascript",
"jquery",
"json",
"templates"
] |
[
"\"@Output\" decorator doesn't emit event if \"event.stopPropagation()\" called",
"I have one main component and one child\n\n<main>\n <child \n [nodes]=\"nodes\" \n (nodeChanged)=\"someFunction(output)\">\n </child>\n<main>\n\n\nChild component renders multilevel tree structure recursively (i.e. it renders itself if there are children) in which every node is clickable, irrespective of it is terminal node or not.\n\nIn child component every node has a click event registered \"clickedNode()\". Now because I don't want my click event to bubble up to clicked node's head I wrote \"event.stopPropagation()\" in \"clickedNode()\" function.\n\n@Output() nodeChanged = new EventEmitter<Object>();\n\nclickedNode(selectedNode, e:MouseEvent){\n this.nodeChanged.emit(selectedNode);\n e.stopPropagation();\n}\n\n\nNow the problem is @output emitter doesn't if inner level of component gets clicked. It emits only if level one nodes are clicked."
] | [
"javascript",
"angular",
"angular6",
"angular-components"
] |
[
"A JTextPane that looks like a JTextArea",
"Since we started on the wrong foot, I ask again, previous question deleted. Please check it out, the border of JTextPane IS NOT the same as the border of JTextArea, not by default:\n\nSo I need a JTextPane that looks exactly like a JTextArea.\n\nI set the border of the JTextPane to new JTextArea().getBorder();. It looks like it should, however, focus isn't being drawn properly... How do I fix it?\n\nI'm using Nimbus here, if it's any help...\n\nTHE SSCCE:\n\nimport javax.swing.BoxLayout;\nimport javax.swing.JFrame;\nimport javax.swing.JTextArea;\nimport javax.swing.JTextPane;\nimport javax.swing.UIManager;\nimport javax.swing.UnsupportedLookAndFeelException;\nimport javax.swing.UIManager.LookAndFeelInfo;\n\n\npublic class Main\n{\npublic static void main(String[] args)\n{\n for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())\n {\n if (\"Nimbus\".equals(info.getName()))\n {\n try\n {\n UIManager.setLookAndFeel(info.getClassName());\n }\n catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e)\n\n {\n System.out.println(\"No Nimbus!\");\n }\n\n break;\n }\n }\n\n JFrame a = new JFrame(\"Test\");\n a.setSize(200, 400);\n a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n a.getContentPane().setLayout(new BoxLayout(a.getContentPane(), BoxLayout.Y_AXIS));\n\n JTextPane[] b = new JTextPane[5];\n\n for (int i = 0; i < 5; i++)\n {\n b[i] = new JTextPane();\n b[i].setBorder(new JTextArea().getBorder());\n b[i].setText(Integer.toString(i));\n a.getContentPane().add(b[i]);\n }\n\n a.setVisible(true);\n}\n}\n\n\nI've set the border to be the same one as on JTextArea, but the focus is not being painted or moved properly. If you comment out that line, there will be no border whatsoever."
] | [
"java",
"swing",
"look-and-feel",
"nimbus"
] |
[
"One interface and Two implementing classes (proxy) in C#",
"I'm trying to add a feature to an existing code in C# and call an api, say MyAPI(arg1,arg2).\nI have an interface,Lets say IProvider, which has a set of client side API definitions. I have two client Proxy classes- Provider and ProviderNew that has some wrapper implementations for the API's - within each of those wrapper functions (for API's) we call eventually call the service API hosted at a remote server. Only Under the ProviderNew(Not Provider) Project class - under Service references - I see that MyAPI being defined ( or auto-generated, as I'm not sure how these files are created) in WSDL,xsd files. Adding to these, I see some references.cs file for the ProviderNew alone that has some definitions for MyAPI. These things clearly suggest that only ProviderNew implements the client side Proxy code for MyAPI.\n\nMy Problem now is that since IProvider interfaces MyAPI signature , the system expects both the implementing classes (Provider and ProviderNew) to implement client code for MyAPI, which is not the case as only ProviderNew has definitions added for MyAPI. When I try to implement MyAPI client code in Provider.cs alone, I see an error saying - \n\nProvider.ProviderServiceReference.ProviderServiceClient does not contain a definition for 'MyAPI' and no extension method 'MyAPI' accepting a first argument of type 'Provider.ProviderServiceReference.ProviderServiceClient' could be found (are you missing a using directive or an assembly reference?) MyPath..\\Provider.cs\n\nBut, when I leave without implementing them in Provider.cs, I see an error (This is a classic case that every class(if there are multiple implementations) that implements an interface, should implement all its functions individually by itself and not an subset of functions.)\n\n'Provider' does not implement interface member 'IProvider.MyAPI(int , int)' MyPath ...Provider.cs \n\nI have tried my best to make this clear as possible, let me know for more clarity. \n\nHow do I proceed ? Any suggestions ?"
] | [
"c#",
"wcf",
"web-services",
"api",
"oop"
] |
[
"Pumping Bytes Directly into Response.OutputStream - how to deal with byte count?",
"I have a need to transfer large streams of data from a web service. Rather than increase the IIS buffer size in the metabase, I'd like to pump the bytes directly into the unbuffered Response.OutputStream. \n\nResponse.ClearHeaders();\nResponse.Clear();\nResponse.ContentType = \"text/xml\";\nResponse.Buffer = false;\nint len = GetReport(protocolName, sourceName, reportName, pageIndex, pageSize, Response.OutputStream);\nResponse.End();\n\n\nThis works fine, but I can only know how many bytes have been retrieved after retrieving them, so I can't set the ContentLength header. The following line throws an exception (can't add headers after you start returning content): \n\nint len = GetReport(protocolName, sourceName, reportName, pageIndex, pageSize, Response.OutputStream);\nResponse.AddHeader(\"Content-Length\", len.ToString()); // can't do this\n\n\nQuestion: I guess there really aren't many options. I suppose the only way to handle this would be to introduce an intermediate stream, e.g., memory stream, get the length of the stream, set the header, and then pump that stream into the Response.Output stream. Any other ideas?'"
] | [
"c#",
"iis"
] |
[
"how to prevent libraries from modifying the root logger?",
"Some libraries like oslo_log modify the root logger, which completely wipes out my own logging configuration.\n\nTo prevent this, I monkey patched the standard logging library like this:\n\ndef hackyCustomGetLogger(name=None, true_behavior=False):\n \"\"\"\n a replacement for the logging.getLogger function that returns a fake\n root logger if called with name=None and true_behavior=False.\n\n this is to prevent third party libraries from altering the root logger\n configuration.\n \"\"\"\n if name:\n return logging.Logger.manager.getLogger(name)\n else:\n if true_behavior:\n return logging.root\n # if no name is specified, and `true_behavior` is not forced to True,\n # we return a fake logger\n warning = ('you called an altered version of logging.getLogger, '\n 'that returns a fake root logger. see {} ({})')\n logging.root.warning(warning.format(__name__, __file__))\n return logging.RootLogger(logging.WARNING)\n\nlogging.getLogger = hackyCustomGetLogger\n\n\nIt works, but eww... monkey patching the python standard library sounds like a very bad idea. Is there a better way to achieve this?"
] | [
"python",
"logging"
] |
[
"Sending a message without Flushing in Serilog",
"Usually, in order to be sure all events are sent to Serilog, one has to call CloseAndFlush method. Is it possible to configure Serilog so that certain events (e.g. Fatals) are sent immediately?"
] | [
"c#",
"serilog"
] |
[
"Selection in mysql with hours available like right outer join",
"I have two tables in my database. I use MySQL.\nBasically, I created an app to manage 'Futsal's Field Order'\nSo, here we go :\n\nThe first table is named Lapangan means \"Field in Indonesian\" :\n\nmysql> SELECT id,nama_lapangan FROM lapangan;\n+----+---------------+\n| id | nama_lapangan |\n+----+---------------+\n| 1 | Lap 01 |\n| 2 | Lap 02 |\n| 3 | Lap 03 |\n+----+---------------+\n3 rows in set (0.00 sec)\n\n\nAnd The Second Table is Booking : , \n\nmysql> SELECT id, nomor_booking, date_booking, date_end_booking, lapangan_id FROM `yfutsal`.`booking` LIMIT 1000;\n+----+---------------+---------------------+---------------------+-------------+\n| id | nomor_booking | date_booking | date_end_booking | lapangan_id |\n+----+---------------+---------------------+---------------------+-------------+\n| 1 | 1 | 2017-07-16 10:00:00 | 2017-07-16 12:00:00 | 1 |\n| 2 | 2 | 2017-07-16 15:00:00 | 2017-07-16 16:00:00 | 3 |\n+----+---------------+---------------------+---------------------+-------------+\n\n\nFor example, The user start at 08.00 AND end in 23.00.\nIt means, lap 1 is not available on 10.00 - 12.00.\nAnd same too that lap 3 is not available on 15.00 - 16.00.\n\nThe goal is, I want to display the Lapangan (field) that available with hour so, the cashier can choice it.\nSomething like this :\n\n+----+---------------+----------------------+-----------------------+\n| id | nama_lapangan | Available Start | Available End |\n+----+---------------+----------------------+-----------------------+\n| 1 | Lap 01 | 2017-07-16 08:00:00 | 2017-07-16 09:59:00 |\n| 1 | Lap 01 | 2017-07-16 12:01:00 | 2017-07-16 23:00:00 |\n| 2 | Lap 02 | 2017-07-16 08:00:00 | 2017-07-16 23:00:00 |\n| 3 | Lap 03 | 2017-07-16 08:00:00 | 2017-07-16 14:59:00 |\n| 3 | Lap 03 | 2017-07-16 16:01:00 | 2017-07-16 23:00:00 |\n+----+---------------+----------------------+-----------------------+\n\n\nPlease advise."
] | [
"mysql"
] |
[
"vararg parameter in a Kotlin lambda",
"I'd like to define a function f() as follows (just an example) :\nval f: (vararg strings: String) -> Unit = { for (str in it) println(str) }\n\nso that I could invoke it with f("a","b","c"). For the above definition of f() I get the compilation error, pointing at the vararg modifier (Kotlin v. 1.3.60 ) :\nUnsupported [modifier on parameter in function type]\n\nHow can I define a lambda that accepts a vararg parameter ?"
] | [
"lambda",
"kotlin"
] |
[
"The menu is not displayed in mac os 10.9.1",
"In my application used \"Application is agent(UIElement)\" = YES.\n\nI use it to hide the second process.\nBut first process need show.\n\nFor show process I used code:\n\n// display dock icon\nTransformProcessType(&psn, kProcessTransformToForegroundApplication);\n\n// enable menu bar\nSetSystemUIMode(kUIModeNormal, 0);\n\n// switch to Dock.app\n[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@\"com.apple.dock\" options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifier:nil];\n\n// switch back\n[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];\n\n\nThe problem is that the menu is not displayed. But if you switch to some other program and back, the menu appears."
] | [
"macos",
"cocoa",
"menubar"
] |
[
"Add font awesome icon on image",
"I need to add an icon on image onclick.\nI added a border and its is shown correctly onclick but not the font awesome icon\nHTML\n\r\n\r\n.couleursProduits input[type=radio] { \n position: absolute;\n opacity: 0;\n width: 0;\n height: 0;\n}\n.couleursProduits input[type=radio] + img {\n cursor: pointer;\n float: left;\n outline: 1px solid #d0cdcd;\n outline-offset: -2px;\n}\n.couleursProduits input[type=radio]:checked + img {\n outline: 2px solid #ceb284;\n outline-offset: -2px;\n}\n.couleursProduits input[type=radio]:checked + img:after {\n content: \"\\f112\";\n font-family: \"woodmart-font\";\n display: inline-block;\n font-size: 16px;\n line-height: 50px;\n font-weight: 600;\n}\r\n<label class=\"couleursProduits\">\n <input type=\"radio\" name=\"couleur\" value=\"v1\">\n <img width=\"25%\" src=\"https://picsum.photos/id/100/367/\">\n</label>\n<label class=\"couleursProduits\">\n <input type=\"radio\" name=\"couleur\" value=\"v2\">\n <img width=\"25%\" src=\"https://picsum.photos/id/101/367/\">\n</label>\n<label class=\"couleursProduits\">\n <input type=\"radio\" name=\"couleur\" value=\"v3\">\n <img width=\"25%\" src=\"https://picsum.photos/id/102/367/\">\n</label>\n<label class=\"couleursProduits\">\n <input type=\"radio\" name=\"couleur\" value=\"v4\">\n <img width=\"25%\" src=\"https://picsum.photos/id/103/367/\">\n</label>\r\n\r\n\r\n\nFull code :\nhttps://jsfiddle.net/rxvdm8ok/"
] | [
"css"
] |
[
"UIPickerView initializes with null (Objective-C)",
"I'm creating an app that uses UIPickerView. When I run the app, if I don't manually move the picker, the default value is \"null\" (even though is SHOWS that a value is selected).\n\nI've tried running [picker selectRow:0 inComponent:0 animated:YES] within the viewDidAppear method, but the value for the picker is still \"null\".\n\nBelow is a screen shot of the picker as it is initialized, BEFORE being moved manually, but AFTER the method mentioned above has been run:\n\n\n\nAnd the output if you select \"GO!\" without manually moving the picker\n\n\n\nAny thoughts? This is the same question as can be found in this thread, which has yet to have been answered.\n\nThanks much.\n\nEDIT:\n\nI use the following code to initialize the picker and obtain the value:\n\n- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {\n return 1;\n}\n-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {\n return [self.pickerArray count];\n}\n-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {\n self.valueOne = (NSNumber *)[self.pickerArray objectAtIndex:row];\n}\n-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {\n return [self.pickerArray objectAtIndex:row];\n}\n\n\nLooking at it now, I think the simplest solution is to just set self.valueOne (name changed solely for this thread) to the desired value straight away. So in my viewDidLoad method, I've included:\n\nself.valueOne = @45;\n\n\nThis does the job, so I'll just leave it at that. Simple enough work-around. But please feel free to add to a different solution"
] | [
"objective-c",
"uipickerview"
] |
[
"Xna converting 3D coordinate into 2D screen coordinate",
"I know others have asked this, but I was wondering if there was a really good function to use to convert 3D points into 2D points. I tried it on my own, and it did not work. I used:\n\nprotected Vector2 ScreenCoords(Vector3 v, Matrix viewMatrix, Matrix projectionMatrix) \n{\n Matrix viewProj = viewMatrix * projectionMatrix;\n float w = viewProj.M14 * v.X + viewProj.M24 * v.Y + viewProj.M34 * v.Z + viewProj.M44;\n return new Vector2(\n (viewProj.M11 * v.X + viewProj.M21 * v.Y + viewProj.M31 * v.Z + viewProj.M41) / w,\n (viewProj.M12 * v.X + viewProj.M22 * v.Y + viewProj.M32 * v.Z + viewProj.M42) / w); \n}\n\n\nIs this correct? Am I doing something wrong? I tried putting a square at the origin, and put the camera at (10, 10, 10), and pointed at (0, 0, 0), but the square did not show up."
] | [
"3d",
"xna",
"2d"
] |
[
"How to execute a page object programme in eclipse?",
"I am basically trying to run a sample page object framework in java in Selenium .I have tried to run some sample classes given by some of the sites and forums. But for some reason, it doesnt seem to work. I dont know if I am missing out anything. Please help. Thank You\n\nI have tried these examples - \nhttps://weblogs.java.net/blog/johnsmart/archive/2010/08/09/selenium-2web-driver-land-where-page-objects-are-king \n\nhttp://www.wakaleo.com/blog/selenium-2-webdriver-quick-tips-page-object-navigation-strategies\n\n package google;\n\n import org.junit.After;\n import org.junit.Before;\n import org.openqa.selenium.chrome.ChromeDriver;\n import org.openqa.selenium.support.PageFactory;\n import org.testng.annotations.Test;\n\n public class WhenAUserSearchesOnGoogle {\n\nprivate GoogleSearchPage page;\n\n@Before\npublic void openTheBrowser() {\n page = PageFactory.initElements(new ChromeDriver(), GoogleSearchPage.class);\n page.open(\"http://google.co.nz/\");\n }\n\n@After\npublic void closeTheBrowser() {\n page.close();\n}\n\n@Test\npublic void whenTheUserSearchesForCatsTheResultPageTitleShouldContainCats() {\n page.searchFor(\"cats\");\n //assertThat(page.getTitle(), containsString(\"cats\") );\n} \n }\n\n\nAbove is the page factory class that I am using.\n\nFollowing is the Page object.\n\n package google;\n import org.openqa.selenium.WebDriver;\n import org.openqa.selenium.WebElement;\n //import org.openqa.selenium.firefox.FirefoxDriver;\n\n\n\n public class GoogleSearchPage {\n\nprotected WebDriver driver;\n\nprivate WebElement q; \n\nprivate WebElement btnG;\n\npublic GoogleSearchPage(WebDriver driver) {\n this.driver = driver;\n}\n\npublic void open(String url) {\n driver.get(url);\n}\n\npublic void close() {\n driver.quit();\n}\n\npublic String getTitle() {\n return driver.getTitle();\n}\n\npublic void searchFor(String searchTerm) {\n q.sendKeys(searchTerm);\n btnG.click();\n}\n\npublic void typeSearchTerm(String searchTerm) {\n q.sendKeys(searchTerm);\n}\n\npublic void clickOnSearch() {\n btnG.click();\n}\n }\n\n\nThe stack trace says\nFAILED: whenTheUserSearchesForCatsTheResultPageTitleShouldContainCats"
] | [
"java",
"eclipse",
"selenium"
] |
[
"pyspark 3.x in pypi limited to hadoop 2.7.4",
"I want to pip install pyspark into my python3 virtual environment but the only choice I have is the PyPI version compiled with Hadoop 2.7.4 dependencies. I need a Hadoop 3.x version since 2.7.4 is too old for modern AWS S3 integration.\nDoes anyone know why there isn't an option to pip install pyspark with Hadoop 3.x support?\nIs my only option to build my own pyspark from source?"
] | [
"hadoop",
"pyspark",
"pypi"
] |
[
"How to return multiple variables from python to bash",
"I have a bash script that calls a python script. At first I was just returning one variable and that is fine, but now I was told to return two variables and I was wondering if there is a clean and simple way to return more than one variable.\n\narchiveID=$(python glacier_upload.py $archive_file_name $CURRENTVAULT)\n\n\nIs the call I make from bash\n\nprint archive_id['ArchiveId']\narchive_id['ArchiveId']\n\n\nThis returns the archive id to the bash script\n\nNormally I know you can use a return statement in python to return multiple variables, but with it just being a script that is the way I found to return a variable. I could make it a function that gets called but even then, how would I receive the multiple variables that I would be passing back?"
] | [
"python",
"bash",
"scripting",
"return",
"multiple-value"
] |
[
"Magic Functions causing error",
"I've implemented the magic functions __get() and __set():\n\nfunction __get($property) {\n if(isset($this->$property)) {\n return $this->$property;\n } else {\n return null;\n }\n }\n\n function __set($property, $value) {\n $this->$property = $value;\n }\n\n\nThe following code works fine:\n\n$connect->Hammer = \"DoubleClawed\";\necho $connect->Hammer;\n\n\nHowever, when I run some of my unit tests, the line:\n\n$this->Id = (int) $configXML->ConfigurationFindResults->Configuration->Id;\n\n\nGives me:\n\n\n Trying to get property of non-object\n\n\nThere are other magically set variables before that that work. I've also tested this code using non-magic methods and it works. Why does this line set it off? ($configXML is a SimpleXML object)"
] | [
"php",
"magic-methods"
] |
[
"Go lang closure pipeline deadlock",
"I'm working on a data import job using the Go language, I want to write each step as a closure, and use channels for communication, that is, each step is concurrent. The problem can be defined by the following structure.\n\n\nGet Widgets from data source\n\nAdd translations from source 1 to Widgets.\nAdd translations from source 2 to Widgets.\nAdd pricing from source 1 to Widgets.\nAdd WidgetRevisions to Widgets.\n\nAdd translations from source 1 to WidgetRevisions\nAdd translations from source 2 to WidgetRevisions\n\n\n\n\nFor the purposes of this question, I'm only dealing with the first three steps which must be taken on a new Widget. I assume on that basis that step four could be implemented as a pipeline step, which in itself is implemented in terms of a sub-three-step pipeline to control the *WidgetRevision*s\n\nTo that end I've been writing a small bit of code to give me the following API:\n\n// A Pipeline is just a list of closures, and a smart \n// function to set them all off, keeping channels of\n// communication between them.\np, e, d := NewPipeline()\n\n// Add the three steps of the process\np.Add(whizWidgets)\np.Add(popWidgets)\np.Add(bangWidgets)\n\n// Start putting things on the channel, kick off\n// the pipeline, and drain the output channel\n// (probably to disk, or a database somewhere)\ngo emit(e)\np.Execute()\ndrain(d)\n\n\nI've implemented it already ( code at Gist or at the Go Playground) but it's deadlocking with a 100% success failure rate\n\nThe deadlock comes when calling p.Execute(), because presumably one of the channels is ending up with nothing to do, nothing being sent on any of them, and no work to do...\n\nAdding a couple of lines of debug output to emit() and drain(), I see the following output, I believe the pipelining between the closure calls is correct, and I'm seeing some Widgets being omitted.\n\nEmitting A Widget\nInput Will Be Emitted On 0x420fdc80\nEmitting A Widget\nEmitting A Widget\nEmitting A Widget\nOutput Will Drain From 0x420fdcd0\nPipeline reading from 0x420fdc80 writing to 0x420fdd20\nPipeline reading from 0x420fdd20 writing to 0x420fddc0\nPipeline reading from 0x420fddc0 writing to 0x42157000\n\n\nHere's a few things I know about this approach:\n\n\nI believe it's not uncommon for this design to \"starve\" one coroutine or another, I believe that's why this is deadlocking\nI would prefer if the pipeline had things fed into it in the first place (API would implement Pipeline.Process(*Widget)\n\nIf I could make that work, the drain could be a \"step\" which just didn't pass anything on to the next function, that might be a cleaner API\n\nI know I haven't implemented any kind of rung buffers, so it's entirely possible that I'll just overload the available memory of the machine\nI don't really believe this is good Go style... but it seems to make use of a lot of Go features, but that isn't really a benefit\nBecause of the WidgetRevisions also needing a pipeline, I'd like to make my Pipeline more generic, maybe an interface{} type is the solution, I don't know Go well enough to determine if that'd be sensible or not yet.\nI've been advised to consider implementing a mutex to guard against race conditions, but I believe I'm save as the closures will each operate on one particular unit of the Widget struct, however I'd be happy to be educated on that topic.\n\n\nIn Summary: How can I fix this code, should I fix this code, and if you were a more experienced go programmer than I, how would you solve this \"sequential units of work\" problem?"
] | [
"concurrency",
"go",
"deadlock",
"pipeline"
] |
[
"For each element in javascript array, add to select html, then remove on change",
"Essentially I'm trying to display a second \"select\" block when a certain option is chosen from the first select block if the value matches. If this does occur, the second select options will be populated from a javascript array.\n\nI've managed to complete the first step, however I'm struggling with the second step. Using append will work fine providing the option isn't changed again, otherwise it appends more array values to the options.\n\nHtml:\n\n<select class='upload_location' name='upload_location'>\n <option value=\"home\" selected=\"selected\">Home</option>\n <option value=\"contact\">Contact</option>\n <option value=\"blog\">Blog</option>\n</select>\n\n<div class='picture_slider' style='display:none;'>\n <select name='sub_dir' class='sub_dir'>\n // Add elements here\n </select>\n</div>\n\n\njQuery:\n\n<script type=\"text/javascript\">\n $(\".upload_location\").change(function(){\n\n if ($(this).val() == \"contact\") {\n $('.picture_slider').show();\n var arr = ['element_01', 'element_02']\n } else if ($(this).val() == \"blog\") {\n $('.picture_slider').show();\n var arr = ['place_01', 'place_02']\n }\n\n for (var index = 0; index < arr.length; ++index) {\n $(\".sub_dir\").append(\"<option value='\"+arr[index]+\"'>\"+arr[index]+\"</option>\");\n }\n\n });\n</script>\n\n\nHere's an example of how it currently works:\nhttp://jsfiddle.net/G8rdL/"
] | [
"javascript",
"jquery"
] |
[
"panic: runtime error: invalid memory address or nil pointer dereference",
"I'm currently working with a Soundcloud wrapper for Go, I want to print the user's followers but it is the first time I face pointer issues.\n\nAfter building error\n\npanic: runtime error: invalid memory address or nil pointer dereference\n[signal 0xb code=0x1 addr=0x10 pc=0xc9c26]\n\n\nCode\n\npackage main\n\nimport (\n \"fmt\"\n \"github.com/njasm/gosoundcloud\"\n)\n\n\nfunc main() {\n // callback url is optional - nil in example\n s, _ := gosoundcloud.NewSoundcloudApi(\"Client_Id\", \"Client_Secret\", nil)\n var userID uint64 = 1\n member, err := s.GetUser(userID)\n if err != nil {\n panic(err)\n }\n fmt.Println(member.Followers)\n}\n\n\nAfter building\n\ngoroutine 1 [running]:\npanic(0x3508c0, 0xc82000a0b0)\n /usr/local/go/src/runtime/panic.go:481 +0x3e6\nnet/http.(*Client).doFollowingRedirects(0x0, 0xc8200d0000, 0x4611c8, 0x0, 0x0, 0x0)\n /usr/local/go/src/net/http/client.go:429 +0x66\nnet/http.(*Client).Do(0x0, 0xc8200d0000, 0x8, 0x0, 0x0)\n /usr/local/go/src/net/http/client.go:188 +0xff\ngithub.com/njasm/gosoundcloud.(*SoundcloudApi).do(0xc8200c8720, 0xc8200d0000, 0xc820012f00, 0x0, 0x0)\n /Users/ManuelDao/Documents/GoBot/src/github.com/njasm/gosoundcloud/soundcloud.go:217 +0x4b\ngithub.com/njasm/gosoundcloud.(*SoundcloudApi).Get(0xc8200c8720, 0xc820012f00, 0x22, 0x0, 0x1, 0x0, 0x0)\n /Users/ManuelDao/Documents/GoBot/src/github.com/njasm/gosoundcloud/soundcloud.go:92 +0xe1\ngithub.com/njasm/gosoundcloud.(*SoundcloudApi).GetUser(0xc8200c8720, 0x1, 0x417a80, 0x0, 0x0)\n /Users/ManuelDao/Documents/GoBot/src/github.com/njasm/gosoundcloud/soundcloud.go:276 +0xc6\nmain.main()\n /Users/ManuelDao/Documents/GoBot/src/GoBot/GoBot.go:24 +0x70\nexit status 2"
] | [
"pointers",
"go",
"soundcloud"
] |
[
"How to slideToggle table row using Jquery?",
"I was wondering how I can slideToggle a table row from my script.\n\nI have a php file that is included in an html page inside a div called 'output-listings'.\n\nPHP FILE:\n\n<?php\nfunction outputListingsTable()\n{\n $mysql = new mysqli('localhost', 'root', 'root', 'ajax_demo') or die('you\\'re dead');\n $result = $mysql->query(\"SELECT * FROM explore\") or die($mysql->error);\n\n if($result) \n {\n echo \"<div class=\\\"main-info\\\"> \\n\";\n echo \"<table class=\\\"listings\\\"> \\n\";\n echo \"<tbody> \\n\";\n\n while($row = $result->fetch_object()) \n {\n $id = $row->id;\n $siteName = $row->site_name;\n $siteDescription = $row->site_description;\n $siteURL = $row->site_url;\n $sitePrice = $row->site_price;\n\n\n echo \" <tr id=\\\"more-info-\" .$id. \"\\\" class=\\\"mi-\" .$id. \"\\\"> \\n\";\n echo \" <td> \\n\";\n echo \" <div id=\\\"more-\" .$id. \"\\\" class=\\\"more-information\\\"></div> \\n\";\n echo \" </td> \\n\";\n echo \" </tr> \\n\";\n\n echo \" <tr id=\\\"main-info-\" .$id. \"\\\"> \\n\";\n echo \" <td>\" . $siteName . \"</td> \\n\";\n echo \" <td>\" . $siteURL . \"</td> \\n\";\n echo \" <td><a id=\\\"link-\" . $id . \"\\\" class=\\\"more-info-link\\\" href=\\\"#\\\">More info</a></td> \\n\"; \n echo \" </tr> \\n\";\n }\n echo \"</tbody> \\n\";\n echo \"</table> \\n\";\necho \"</div> \\n\"; \n\n }\n\n}\n\n?>\n\n\nAs you can see the script above creates dynamic id's and classes which confuses me on how to select them with Jquery.\n\nHere is the jquery that I have so far, but does not work sadly.\n\n$(function() {\n\n$(\"a.more-info-link\").click(function() {\n\n$(\"#more-info-\" + this.id).load(\"getinfo.php\").slideToggle(\"slow\");\n\nreturn false;\n\n});\n\n});\n\n\nAny help would be great."
] | [
"jquery",
"string",
"dynamic",
"slider",
"html-table"
] |
[
"Error when try to read datetime field in db2 by odbc with mono",
"this is my problem. \nI have an application that need to work with different database. \nWith mysql all works fine, with IBM db2 I have some problem. \nDetails: \nI need to take data from a database IBM db2 using unixODBC and the ODBC driver \"IBM i Access Client Solutions\" (the last available from IBM). \nI have problem only if I read value from a timestamp field, and I don't have problem for all other types of data. \nThe GetFieldType of the column that I want to read is System.DateTime,\nbut when I try to read this field with: \nreader.GetDateTime(1) or (DateTime) reader[1] \n(where reader is IDataReader object) \nthe application return the follow error message: \n\n Unhandled Exception:\n System.ArgumentOutOfRangeException: Argument is out of range.\n Parameter name: Parameters describe an unrepresentable DateTime.\n at System.DateTime..ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond) [0x00000] in <filename unknown>:0 \n at System.DateTime..ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second) [0x00000] in <filename unknown>:0 \n at System.Data.Odbc.OdbcDataReader.GetValue (Int32 i) [0x00000] in <filename unknown>:0 \n at System.Data.Odbc.OdbcDataReader.get_Item (Int32 i) [0x00000] in <filename unknown>:0 \n at OLAP.OLAPprocessor.Run (IDbCommand OLAPSource, IDbCommand OLAPDest, DateTime TimeLimit) [0x00000] in <filename unknown>:0 \n at OLAP.OLAPprocessor.Run (IDbCommand OLAPSource, IDbCommand OLAPDest) [0x00000] in <filename unknown>:0 \n at OLAPbuilder.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 \n[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Argument is out of range.\nParameter name: Parameters describe an unrepresentable DateTime.\n at System.DateTime..ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond) [0x00000] in <filename unknown>:0 \n at System.DateTime..ctor (Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second) [0x00000] in <filename unknown>:0 \n at System.Data.Odbc.OdbcDataReader.GetValue (Int32 i) [0x00000] in <filename unknown>:0 \n at System.Data.Odbc.OdbcDataReader.get_Item (Int32 i) [0x00000] in <filename unknown>:0 \n at OLAP.OLAPprocessor.Run (IDbCommand OLAPSource, IDbCommand OLAPDest, DateTime TimeLimit) [0x00000] in <filename unknown>:0 \n at OLAP.OLAPprocessor.Run (IDbCommand OLAPSource, IDbCommand OLAPDest) [0x00000] in <filename unknown>:0 \n at OLAPbuilder.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 \n\n\nMy Pc is a openSUSE 13.2 64bit, with mono 3.8.0, unixODBC 2.3.2, IBM i Access Client Solutions 1.1.0 \n\nThanks in advance to anyone will try to help me. \nMirco \n\nThe source code: \n\nIDbCommand DatabaseSource;\n\nIDbConnection Connection;\nConnection = new OdbcConnection(\"DSN={0};UID={1};PWD={2};\");\n\nDatabaseSource = Connection.CreateCommand();\nDatabaseSource.Connection = Connection;\n\nDatabaseSource.CommandText = \"select DTTMS from TABTMS \" +\n \" where ......... \" + \n \" order by DTTMS asc\"; \n\nIDataReader reader;\n\nreader = DatabaseSource.ExecuteReader();\n\nwhile(reader.Read()==true) \n{ \n DateTime tms = reader.GetDateTime(0);\n\n // ..... process this tms\n}\n\nreader.Close();\nreader = null;\n\n\nThe error will happen when the application try to execute the row: \nDateTime tms = reader.GetDateTime(0);"
] | [
"c#",
"datetime",
"mono",
"db2",
"odbc"
] |
[
"RDBMS Ref. Integrity: A child with too many parents?",
"I have a general design question. Consider these 3 tables:\n\nTable Restaurants:\n RID pk auto_increment\n etc...\n\nTable Vacations:\n VID pk auto_increment\n etc...\n\nTable Movies:\n MID pk auto_increment\n etc...\n\n\nAnd now imagine we want to create a list \"Top things to do when COVID is over\" of selected records from these 3 different tables. The list may contain any mix of records from these tables. What comes to mind then is:\n\nTable Todo:\n Type [ one of R, V, M ]\n ID [ the ID of the parent item ]\n\n\nBut how would you enforce referential integrity on this thing? I.e., how do we ensure that when a restaurant is deleted from Restaurants, it will also drop from Todo?\n\n(I am aware of how to accomplish these things with triggers; Curious if there's a combination of entities that will accomplish this with pure RDBMS ref. int.)\n\nThank you!"
] | [
"rdbms",
"referential-integrity"
] |
[
"Git add from specified directory. How?",
"I am following the symfony2 tutorial http://www.slideshare.net/weaverryan/symfony2-get-your-project-started. On slide 22 i must perform a git add .\n\nI have github open and have a public repository helloise/helloises.\n\nI want to add and commit to the above.\n\nI also followed the commands on slide 17 which stated i must do a git init and a git status.\n\nMy directory structure is:\n\n~/symfony2/Symfony$ ls -lah\ntotal 56K\ndrwxr-xr-x 8 helloises helloises 4.0K 2012-01-16 16:00 .\ndrwxr-xr-x 3 helloises helloises 4.0K 2012-01-16 15:37 ..\ndrwxr-xr-x 6 helloises helloises 4.0K 2012-01-16 14:11 app\ndrwxr-xr-x 2 helloises helloises 4.0K 2012-01-16 14:03 bin\n-rw-r--r-- 1 helloises helloises 1.6K 2012-01-06 08:56 deps\n-rw-r--r-- 1 helloises helloises 830 2012-01-06 08:56 deps.lock\ndrwxr-xr-x 8 helloises helloises 4.0K 2012-01-16 16:01 .git\n-rw-r--r-- 1 helloises helloises 91 2012-01-16 15:41 gitignore\n-rw-r--r-- 1 helloises helloises 1.1K 2012-01-06 08:56 LICENSE\n-rw-r--r-- 1 helloises helloises 0 2012-01-16 16:00 README\n-rw-r--r-- 1 helloises helloises 6.3K 2012-01-06 08:56 README.md\ndrwxr-xr-x 3 helloises helloises 4.0K 2012-01-16 14:03 src\ndrwxr-xr-x 13 helloises helloises 4.0K 2012-01-16 14:11 vendor\ndrwxr-xr-x 3 helloises helloises 4.0K 2012-01-06 08:56 web"
] | [
"git"
] |
[
"Sending message with Facebook Api without webhook",
"there is a FB login on my website, i can see Facebook app scoped user id which login to my website via fb login. I need to notify them with Fb messenger, is there need Webhook? can i send them message without waiting send message to my page.\nWhen i used them app scoped user id, graph api return an error and it says \"No matching user found\". What is the problem?"
] | [
"python",
"django",
"facebook-graph-api",
"django-allauth"
] |
[
"click Menu item with same ID using Selenium Python",
"Below is my HTML snippet and code I tried. I need to Click the Integrated Consoles menu item. I tried like below, But nothing happens and no error as well. Kindly help me to select the Specific Menu Item using the text inside the tag.\n\ndriver.find_element_by_xpath(\".//td[contains text(),'Integrated Consoles']\").click()\n\n\nHTMl sample Snippet \n\n<td nowrap=\"\" id=\"MENU_TD110\">&nbsp;&nbsp;&nbsp;&nbsp;Integrated Consoles&nbsp;</td>\n<td nowrap=\"\" id=\"MENU_TD110\">&nbsp;&nbsp;&nbsp;&nbsp;System Information&nbsp;</td>\n<td nowrap=\"\" id=\"MENU_TD110\">&nbsp;&nbsp;&nbsp;&nbsp;More Tools&nbsp;</td>"
] | [
"python",
"selenium"
] |
[
"CakePHP URL Parameter",
"How can I get the parameter in the URL and save it to a varialble so I can save it to my database?\n\n\n example: www.mydomain.com/item/products/3 <-\n\n\nThis is for my upload image, so I can specify what product ID will I use for that image.\n\nfunction add() {\n if ($this->request->is('post')) {\n $this->Upload->create();\n\n if(empty($this->data['Upload']['image']['name'])) {\n unset($this->request->data['Upload']['image']);\n }\n\n if(!empty($this->data['Upload']['image']['name'])) {\n $filename = $this->request->data['Upload']['image']['name'];\n $new_filename = STring::uuid().'-'.$filename;\n $file_tmp_name = $this->request->data['Upload']['image']['tmp_name'];\n $dir = WWW_ROOT.'img'.DS.'uploads';\n\n move_uploaded_file($file_tmp_name,$dir.DS.$new_filename);\n\n $this->request->data['Upload']['image'] = $new_filename;\n if($this->Upload->save($this->request->data)) {\n $this->Session->setFlash(__('Uploaded.'));\n $this->redirect(array('action' => 'index'));\n }\n }\n }\n }\n\n\nHow will I add it here. Thank you in advance :)\nIm using cakePHP"
] | [
"database",
"url",
"cakephp",
"parameters",
"get"
] |
[
"dimentions of images as an input of LeNet_5",
"I am still a beginner in deep learning, I am wondering is it necessary to have for the input images of a size equal to 32*32 (or X*X)? the dimensions of my images are 457*143.\nThank you."
] | [
"tensorflow",
"keras",
"deep-learning"
] |
[
"How to sort a JTable column that contains icons?",
"I have a JTable with the first column containing icons. I have read the tutorial on sorting and cannot figure out how to sort icons.\n\nWhen the user clicks on the column header I need the icons to be sorted by color. The icons are circles that are green, red, or yellow.\n\nHow do I sort a column containing icons in a JTable?"
] | [
"java",
"swing",
"jtable",
"awt",
"imageicon"
] |
[
"yam.platform.getLoginStatus invokes callback without response.user",
"When I call yam.platform.getLoginStatus right after logging in using yam.platform.login (shows the popup etc.) I get a different object passed to the callback than when the user is already logged in. Specifically, the 'user' field is missing on the LoginStatus response object, otherwise it looks the same as far as I can see.\n\nI have the following controller for a 'login with yammer' area on my angular app:\n\nfunction YammerLoginController($scope, $compile) {\n\n $scope.isLoggedIn = false;\n $scope.userName = \"-\";\n $scope.login = function () {\n yam.platform.login(function (response) {\n if (response.authResponse) {\n console.log(\"logged in\");\n }\n refreshLoginStatus();\n });\n }\n\n refreshLoginStatus(); // initialize values\n function refreshLoginStatus() {\n yam.getLoginStatus(function (response) {\n console.dir(response);\n if (response.authResponse) {\n if (response.user) {\n console.log(\"YammerLogin: Logged in as \" + response.user.full_name);\n console.dir(response);\n $scope.$apply(function () {\n $scope.isLoggedIn = true;\n $scope.userName = response.user.full_name;\n });\n }\n else {\n console.log(\"WTF Yammer API!\"); // THIS HAPPENS.\n }\n }\n else {\n console.log(\"YammerLogin: Not logged in.\");\n $('#loggedInView').popover(\"hide\");\n $scope.$apply(function () {\n $scope.isLoggedIn = false;\n $scope.userName = \"-\";\n });\n }\n });\n }\n\n\nWhen the controller is created it already queries the current login status using the refreshLoginStatus function. If a yammer user is already logged in the app will display the user name and a logout button on the page (done with ng-show=\"isLoggedIn\"). If the user is not logged in, a login button will be shown instead. When the user clicks on that login button, the $scope.login function will be called, invoking yam.platform.login and, if successful, calls refreshLoginStatus again in order to retrieve and set the user's name. In this scenario, the object returned from both, login and getLoginStatus do not contain the user information like in the 'user is already logged in' scenario. I tried calling the SDK-API again after some timeout, but apparently the response is cached - I always get the same. Only refreshing the whole page clears out the current response, querying the status again and receiving a 'complete' response object.\n\nI thought it could be a scoping problem, but by now I'm not sure whether it's a problem in the SDK itself. :S\n\nEDIT: I kind of found a solution, which however only gives me worse problems. Apparently the request is indeed cached. A refresh can be forced by using 'force refresh' on yam.platform.getLoginStatus(callback, [forceRefresh]). This, however gives me the following error on the browser console:\n\n\n XMLHttpRequest cannot load\n https://www.yammer.com/platform/login_status.json?client_id=2h4U2Hndg5kdWQ8xxxxxx.\n No 'Access-Control-Allow-Origin' header is present on the requested\n resource. Origin 'http://localhost:9000' is therefore not allowed\n access.\n\n\nBasically, the SDK fails to getLoginStatus, completely, and reports this back to my code as 'no connection'. I'm not sure what's worse... or, what am I doing wrong?"
] | [
"javascript",
"angularjs",
"yammer"
] |
[
"Function look-up in clojure",
"Help me I need to write look up function that finds value in the list-of-lists in that every element is in order (key value).\nFor example \n\n((key1 value1) (key2 value2) ....)\n\n\nThis function needs to be \n\n(look-up key list-of-lists)\n\n\nAnd returns value of the list that has key.\nFor example:\n\n(look-up b '(((a b) 1) (c 2) (b 3)))3\n(look-up (a b) '(((a b) 1) (c 2) (b 3)))1\n(look-up d '(((a b) 1) (c 2) (b 3)))nil\n\n\nI have this code: \n\n(defn look-up [key list-of-lists]\n (if (= key (first(first list-of-lists))) (second(first list-of-lists)))\n (:else (look-up (rest list-of-lists key))))"
] | [
"clojure"
] |
[
"Access ArangoDB data from client side",
"I am new to ArangoDB, it is very nice that it can host micro-services directly in the database. \n\nHow would I go about sending queries / loading data directly from the client side (Jquery or Angular or whatever) across different domain names? assuming I have node on www.example.com (port 80) and would like to serve an application that (only) reads data directly from ArangoDB."
] | [
"arangodb",
"foxx"
] |
[
"Pub/Sub and Redis Clustering",
"On this link it says \"The current implementation will simply broadcast all the publish messages to all the other nodes\" and adds that it will be improved in future.\n\nFor current implementation: If loosing messages is not important; does it make sense to use redis for pub/sub for now? It looks like one instance is better to stop broadcast traffic. Because beside writes; reads should be propgated to other nodes too! (so that the client will not be notified twice.)\n\nAm I missing something?"
] | [
"redis"
] |
[
"adding classes to multiple elements",
"i'm a novice to jquery and i'm trying to do the following:\n\ni've got multiple instances of a div. to each instance i randomly add a class (for changing some attributes). the added classes are taken from a list.\n\nthis works well — but now i'm trying to additionally add the same (random) class to a child-div of the previous. \n\nmy html is:\n\n<div class=\"random\">\n <div class=\"alsorandom\"> </div>\n</div>\n\n<div class=\"random\">\n <div class=\"alsorandom\"> </div>\n</div>\n\n\nhere's my current jquery (the randomization takes place so that 2 classes are never added after one another):\n\nvar classes = ['blue', 'yellow', 'lightorange', 'violet', 'green'];\nvar prevClass = \"\";\n$('.randomcolor').each(function() {\n var classes2 = [];\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] !== prevClass) {\n classes2.push(classes[i]);\n }\n }\n $(this).addClass(prevClass = classes2[Math.floor(Math.random()*classes2.length)]);\n});\n\n\nthe following i have tried and it doesn't work:\n\n$('.randomcolor, .alsorandom').each(function() { ...\n\n\ni'd be gracious for any help. thank you."
] | [
"jquery",
"html",
"css",
"random"
] |
[
"Add claims to a JWT token in OpenAM?",
"I’m using openAM access token end point to get a refresh token and id_token. But jti claim is missing in my id_token. How can I include this into id_token?\n\nMy id_token claims are as following,\n\n{\n“at_hash”: “kZVRzMbiEVbhH9cn1NlPTw”,\n“sub”: “user1”,\n“iss”: “http://openam.example.com:80/openam/oauth2”,\n“tokenName”: “id_token”,\n“aud”: [\n“MyClientId”\n],\n“c_hash”: “mWLBu83Jg3Y1Kj6em3kQDQ”,\n“org.forgerock.openidconnect.ops”: “bcf12880-a3f6-46d8-aad7-98250ab9a43f”,\n“azp”: “MyClientId”,\n“auth_time”: 1489831204,\n“realm”: “/”,\n“exp”: 1489834804,\n“tokenType”: “JWTToken”,\n“iat”: 1489831204\n}"
] | [
"jwt",
"openid",
"openam"
] |
[
"how to ignore input from the user entered through the URL using php",
"I would like others to explain how to ignore any input from the user that is provided through the URL?\n\nFor example; if i have a URL like viewitem.php?id=23 and if the user replaces the id with 34 i want to redirect them to an error page even if that id is available, can anyone show me how to do that?"
] | [
"php"
] |
[
"Jdeveloper : rebuild not supported during debug",
"While I debug my application in Jdeveloper, at instances when I change an unit and try to rebuild it, changes don't reflect and I get the following error description:\n\n\"The debugger was unable to redefine the recompiled classes.\n Unsupported operation: changes to class modifiers.\"\n\nAny suggestions?."
] | [
"debugging",
"jdeveloper"
] |
[
"Access servlet init parameters from filter",
"I have a servlet like this:\n\n\n@WebServlet(\"/a/path\")\n@WebInitParam(name=\"name\", value=\"name_value\")\npublic class MyServlet extends HttpServlet {\n//...\n\n\nOn this servlet I have put a filter:\n\n\n@WebFilter(dispatcherTypes = { DispatcherType.REQUEST }, urlPatterns = { \"/a/*\" })\npublic class MyFilter implements Filter {\n\npublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {\n//...\n HttpServletRequest req = (HttpServletRequest)request;\n //problem comes here\n System.out.println(req.getServletContext().getInitParameter(\"name\"));\n//...\n}\n\n\n\nThe problem is, that even if I set the @WebInitParameter in MyServlet, the programs prints out a null string (see the commented line //problem comes here in MyFilter). I verified and saw that init() method from servlet is executed before of doFilter(). \nSo can anyone light me on this issue? Why the initParameter \"name\" is null, if it is set up to a value?\n\nThanks!"
] | [
"initialization",
"servlet-filters",
"servlet-3.0",
"init-parameters"
] |
[
"NSClassFromString() in ARC semantic issue \"No known instance method for selector 'xxx:",
"the Code: [NSClassFromString(@\"Test\") gotoTest];\n\n\nusage ARC with Error: No known class method for selector 'gotoTest'\nbut in MRC warning no error. \n\n\nWay ARC from warning becomes an error ? do you have any reference? I want to know the essential reason."
] | [
"objective-c",
"xcode",
"automatic-ref-counting"
] |
[
"How to broadcast/share a variable/property from a slave to the others?",
"I have a JMeter script that is executed in distributed mode with 4 nodes. One of them is the controller and does not do any request and the other 3, as workers do the requests.\n\nI can currently set one of the workers as a master worker, setting a property in the user.properties file for that specific worker. This \"master\" worker perform some requests that has to be done only once, so these requests can't be done by the other workers.\n\nNow I have the need of extract some values from the response of these unique request and send this information to the other slaves.\n\nIs it possible to do this?\nHow can data be sent form one worker to the other workers at run time?"
] | [
"jmeter"
] |
[
"Perl right way to write macros",
"In order to simplify my program, I would like to write some macros that I can use in different subroutines. \n\nHere's what I wrote:\n\nmy @m = ();\nsub winit { @m = (); }\nsub w { push @m, shift; }\nsub wline { push @m, ''; }\nsub wheader { push @m, commentHeader(shift); }\nsub walign { push @m, alignMakeRule(shift); }\nsub wflush { join($/, @m); }\n\nsub process {\n winit;\n\n w \"some text\";\n wline;\n\n wheader 'Architecture'; \n w getArchitecture();\n wline;\n\n say wflush;\n}\n\n\nIs there a better way or a smarter way to do what I want to do?"
] | [
"perl"
] |
[
"How to avoid clearcase to have never_merge_binary element type?",
"Every time I create an element, it is created with the \"never_merge_binary\" element type. \n\nHow can I avoid this in future to have it \"compressed_file\" rather than \"never_merge_binary\"?\nWhat param in C:\\Program Files\\Rational\\ClearCase\\config\\magic\\default.magic does this?"
] | [
"clearcase",
"clearcase-ucm"
] |
[
"How to use more than 1 Script in FPDF",
"I'm using FPDF to render a document. I've downloaded 2 scripts from the website: \"Force justification\" and \"EPS / AI support\".\n\nThe problem is that when I use FPDF with the script \"Forced Justification\" everything works fine but when I add \"EPS / AI support\" I always get this message:\n\nFatal error: Cannot declare class FPDF, because the name is already in use in ...\n\nIs it maybe because force_justify.php and fpdf_eps.php are not made to work together or there's a solution? These are the links:\n\nFORCED JUSTIFICATION\n\nEPS / AI support\n\nThanks for your help in advance.\n\nRegards\n\n----------------EDITED----------------------\n\nI have adddata.php where I have this:\n\nrequire('force_justify.php');\n$pdf = new PDF();\n$pdf->AddPage();\n\n\nThen I have the 1st script force_justify.php with:\n\nrequire('fpdf.php');\n\nclass PDF extends FPDF\n{\n\n\nAnd the 2nd script fpdf_eps.php with:\n\nrequire('fpdf.php');\n\nclass PDF_EPS extends FPDF{\n\n\nI try to follow the steps in the FAQ but I'm not sure how to do the last one:\n\nand make your own class extend B:\n\nrequire('b.php');\n\nclass PDF extends B\n{\n...\n}\n\n$pdf = new PDF();"
] | [
"fpdf"
] |
[
"Spring @EnableWebsocketMessageBroker + reacting to \"onClose\"-events",
"I am currently using Spring's @EnableWebsocketMessageBroker to configure STOMP-endpoints.\nUntil now I have been unable to find out how to react to onClose-events in this setup as\nthere is no @ServerEndpoint-class.\nFurthermore, I need to inject the Principal into the onClose-handling-method.\nAny tips on how to achieve these two things would be appreciated!"
] | [
"spring",
"spring-websocket"
] |
[
"Enum Type Constraint returns error \"The signature and implementation are not compatible...\"",
"I've been trying to follow the guide from MSDN - Constraints (F#) on creating a type within a module which has a generic type constraint of an enum, as follows:\n\ntype Mapper<'TEnum when 'TEnum : enum<uint32>>() = \n let dict = new Dictionary<'TEnum, string>()\n\n member this.Add (key: 'TEnum) (value: string) = \n dict.Add(key, value)\n\n\nHowever, I'm getting the error:\n\n\n The signature and implementation are not compatible because the\n declaration of the type parameter 'TEnum' requires a constraint of the\n form 'TEnum : equality\n\n\nIs there a way to fix this code example so that I'm able to constrain a type to an enum?"
] | [
"f#"
] |
[
"EF Code First 4.3 conditionally load navigation property",
"Is it possible using DbContext / DbSet / DbQuery to conditionally eagerly load a navigation property. The query below will return parties that have a particular role. \n\nWhat I need is to additionally only load the matching roles.\n\nfirst attempt\n\nvar peopleWithRole = (from p in Party\n from r in p.Roles\n where r.RoleTypeId == 1\n select p).Include(_ => _.Roles);\n\n\nThis loads all the roles, and it's obvious why once you look at it.\n\nI have tried a few things. If I have to cast and create an objectquery to do it that would be fine, I just can't figure out how.\n\nsecond attempt\n\nvar objectContext = ((IObjectContextAdapter)this).ObjectContext;\nvar set = objectContext.CreateObjectSet<Party>();\nvar result = (from p in set.Where(\"it.Roles.RoleTypeId == 1\")\n select p)\n;\nresult.Dump();\n\n\nThe iterator cannot be used like this?\n\nAny ideas?"
] | [
"entity-framework",
"navigation",
"code-first",
"eager-loading"
] |
[
"Is there a way to specify which browser heroku uses with `heroku open`?",
"In a folder with a heroku application running heroku open or heroku apps:open will open the page with firefox. My default browser is google-chrome and running:\n\nxdg-open http://www.google.com\n\n\nopens this. Is there a way to set heroku to open the correct default browser? (I could not find any useful help on the internet or through heroku help open)"
] | [
"heroku-toolbelt"
] |
[
"Informix - Nothing happening when creating a db_space",
"So Im trying to create a new db_space for my informix database.\nI already created a file ( /matiasInformixDBSpaces/dbspace_proyectoUTU ) and gave necessary permissions to the informix user and group.\n\nNow, logged in as root user I am attempting to create a new db_space. The first one was 500 MB and this one I intended to be 1 GB. the problem I am facing is that when I run the command below, it says \"Verifying physical disk space, please wait...\" and it just stays there forever.\n\nNo errors or warnings are thrown. The first time I did it it was super fast. I dont know what is going on now.\n\nonspaces -c -d proyectoUTUinformix -p /matiasInformixDBSpaces/dbspace_proyectoUTU -o 5000 -s 1000240\n\n\nCan someone help me to figure out what is going wrong?"
] | [
"informix",
"space"
] |
[
"How to set StyleSheet for an specific label in QMessageBox?",
"I Want to have a bigger QMessageBox and centered texts in it but when I increase the size of it by stylsheet it'll be like this:\n\nif I could give it Some Padding or margin it would be fixed but I can't.\nvoid MainWindow::showMsg()\n{\n QMessageBox m_MsgBox;\n m_MsgBox.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);\n m_MsgBox.setIcon(QMessageBox::Warning);\n m_MsgBox.setText("Your Trial is finished! Please purachase a plan.");\n m_MsgBox.setStandardButtons(QMessageBox::Ok);\n m_MsgBox.setStyleSheet("QLabel{min-width:200 px; font-size: 13px;} QPushButton{ width:25px; font-size: 13px; }");\n if(m_MsgBox.exec() == QMessageBox::Ok)\n m_MsgBox.close();\n}\n\nI want to give different css properties to each QLabel(QMessageBox::Warning & setText) in this QMessageBox."
] | [
"c++",
"qt",
"qtstylesheets",
"qmessagebox"
] |
[
"Should all elements have unique class name in a native Android application?",
"I used UI automation viewer to get an xpath selector for class and Appium driver states (correctly) that:\n*** Capybara::Ambiguous Exception: Ambiguous match, found 4 elements matching visible xpath \"//android.widget.Button\"\n\nElements have different text property, so I could identify by this property, however I imagine things would get complicated in case the app has multiple languages available.\n\nThe article below seems to hint that because elements can share class names, locating by class only is not recommended:\nhttps://seleniumbycharan.com/2016/08/07/finding-elements-using-locators-in-appium/\n\nOne solution would be to form an array of these elements and simply refer to an index. \nAnother is to use the text property.\nI do not like either of these solutions. \n\nShould I recommend the developer to assign some IDs or just varied class names, or are identical class name chains common in native app dev and this is not an anti-pattern in any way?"
] | [
"android",
"android-uiautomator"
] |
[
"The image does not appear - Android",
"I wrote this code using recyclerview and I got the image that I got from the url why, my picture didn't appear\n\nthis is my activity_main.xml\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\nxmlns:app=\"http://schemas.android.com/apk/res-auto\"\nxmlns:tools=\"http://schemas.android.com/tools\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"match_parent\"\ntools:context=\".MainActivity\">\n\n <androidx.recyclerview.widget.RecyclerView\n android:id=\"@+id/rvMain\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n tools:listitem=\"@layout/item_hero\"\n />\n\n</RelativeLayout>\n\n\nthis is my tools:listitem\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"wrap_content\"\nandroid:orientation=\"horizontal\"\nandroid:padding=\"8dp\">\n\n\n<ImageView\n android:id=\"@+id/imgHeroes\"\n android:layout_width=\"80dp\"\n android:layout_height=\"80dp\"\n android:scaleType=\"centerCrop\"/>\n\n\n<TextView\n android:id=\"@+id/txtHeroName\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"center_vertical\"\n android:layout_marginLeft=\"16dp\" />\n</LinearLayout>\n\n\nthis is my MainActivity.kt\n\nclass MainActivity : AppCompatActivity() {\n\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n val listHeroes = listOf(\n Hero(\n name = \"Thor\",\n image = \"https://media.skyegrid.id/wp-content/uploads/2019/06/Thor-4-1.jpg\"\n ),\n Hero(\n name = \"Captain America\",\n image = \"https://i.annihil.us/u/prod/marvel/i/mg/1/c0/537ba2bfd6bab/standard_xlarge.jpg\"\n ),\n Hero(\n name = \"Iron Man\",\n image = \"https://i.annihil.us/u/prod/marvel/i/mg/6/a0/55b6a25e654e6/standard_xlarge.jpg\"\n )\n )\n\n val heroesAdapter = HeroAdapter(listHeroes) {hero ->\n Toast.makeText(this, \"hero clicked ${hero.name}\", Toast.LENGTH_SHORT).show()\n }\n\n\n rvMain.apply {\n layoutManager = LinearLayoutManager(this@MainActivity)\n adapter = heroesAdapter\n }\n}\n\n\n}\n\nthis is my adapter\n\nclass HeroAdapter(\nprivate val heroes: List<Hero>,\nprivate val adapterOnclick: (Hero) -> Unit\n\n\n) : RecyclerView.Adapter() {\n\noverride fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HeroAdapter.HeroHolder {\n return HeroHolder(\n LayoutInflater.from(parent.context).inflate(\n R.layout.item_hero,\n parent,\n false\n )\n )\n}\n\noverride fun getItemCount(): Int = heroes.size\n\noverride fun onBindViewHolder(holder: HeroAdapter.HeroHolder, position: Int) {\n holder.binHero(heroes[position])\n}\n\ninner class HeroHolder(view: View) : RecyclerView.ViewHolder(view) {\n fun binHero(hero: Hero) {\n itemView.apply {\n txtHeroName.text = hero.name\n Picasso.get().load(hero.image).into(imgHeroes)\n\n setOnClickListener {\n adapterOnclick(hero)\n }\n }\n }\n\n}\n\n\n}\n\nthis is my emulator\nhttps://i.stack.imgur.com/0ePUC.png\n\nI wrote this code using recyclerview and I got the image that I got from the url, why my image didn't appear, I wrote this code using the kotlin programming language\n\nplease help me"
] | [
"android",
"android-studio",
"kotlin",
"android-recyclerview"
] |
[
"JQuery Tabs - change background colour of tab on input entry",
"I'm creating a simple application which has 5 tabs and corresponding DIV's which contain some parts data and two input fields. What I'm trying to achieve is when someone types a value in the .qty input, it changes the background colour of the currently selected tab - I've created a simple fiddle with the code I've currently got; it's dynamically created, but I've created the fiddle with static data.\n\nTo attempt to change the background I've done;\n\n$('.qty').on('keyup', function() {\n if ($(this).val().length > 0) {\n $('.ui-tabs-active').addClass('tab-ok');\n }\n})\n\n\nBut it doesn't do anything. I'm not sure if I'm selecting the correct element, but from messing around with it, I did find a way of achieving it, but it broke the style in quite a bad manner.\n\nWhat's the correct way to do this?\n\nFiddle"
] | [
"jquery",
"css",
"jquery-ui",
"jquery-ui-tabs"
] |
[
"is it possible to see the local declared variables in a function in \"window\" from the console?",
"I am sorry if this has been asked but I don't know if it's possible to see local variables of a function that is declared globally.\n\nvar a = function(a) {\nvar b = 2; // i need to see this in window\nreturn a+b;\n} \n\n\nwhen i look at [[Scopes]]:Scopes[1] in window it only has Global index. \n\nI need to know if this is possible and how to do it. Thank you"
] | [
"javascript"
] |
[
"angular.js select doesn't show the option value in the begining",
"I am using angular.js and bootstarp - angular-ui-bootstarp. and I found a problem that when using the select, even the option is not empty, the select in the page always show nothing until you click the option list.\nThe first thing I tried is directly put options in the select, and make one option with ng-selected=\"selected\", but no working\n\n <select class=\" input-sm pull-right\" style=\"margin-right: 5px;\" ng-change=\"selectUserFilter()\" ng-model=\"user_filter_key\" >\n <option >All</option>\n <option ng-selected=\"selected\">Active</option>\n </select>\n\n\nThe second thing I tried is to embedded a model with options list into the select, still not working\n\n $scope.user_options = ['All','Active'];\n <select class=\" input-sm pull-right\" style=\"margin-right: 5px;\" ng-change=\"selectUserFilter()\" ng-model=\"user_filter_key\" ng-options=\"opt for opt in user_options\">\n </select>"
] | [
"angularjs",
"angular-ui-bootstrap"
] |
[
"NSOutlineView with badge of unread messages like Mail.app",
"I'm trying to create a user interface similar to the iTunes source list or the Mail.app mailbox list where a badge with a number (e.g. unread emails, new podcasts) is shown at the right hand side of an element.\n\nBased on Apple's SourceList example, I have an NSOutlineView set up to display a couple of groups and a few items in each group. \n\nIs there a standard UI element to represent the \"badge\" with a number for each entry? I could not find anything in the docs. I suspect I will have to extend NSTextFieldCell and do the drawing myself.\n\nAre there any examples out there of how to do this?"
] | [
"cocoa",
"macos",
"nsoutlineview",
"badge",
"nstextfieldcell"
] |
[
"Assigning to an optional variable in swift 3.0 using ? operator returns nil",
"Consider the following code.\n\nvar a:Int?\n\na? = 10\n\nprint(a)\n\n\nHere the variable a isn't getting assigned the value 10. If it is because of the '?' operator, why compiler doesn't show a compilation error?."
] | [
"swift",
"optional"
] |
[
"Simultaneous Multimicrophone recording with pyaudio",
"I'm pretty new and unexperienced to Python in general. As a small project I try to program a small piece of code which allows to record audio simultaneously via cheap usb-microphones. As a first try I explicitly implemented the recording for two microphones. This following code works as expected and gives two files roughly about the same size: test_0.wav (~60kb) and test_1.wav (~60kb)\nimport pyaudio\nimport wave\nimport time\n\nform_1 = pyaudio.paInt16 # 16-bit resolution\nchans = 1 # 1 channel\nsamp_rate = 44100 # 44.1kHz sampling rate\nwav_output_filename0 = 'test_0.wav' # name of .wav file\nwav_output_filename1 = 'test_1.wav' # name of .wav file\n\naudio = pyaudio.PyAudio() # create pyaudio instantiation\n\ndef prepare_file(fname, mode='wb'):\n wavefile = wave.open(fname, mode)\n wavefile.setnchannels(chans)\n wavefile.setsampwidth(audio.get_sample_size(form_1))\n wavefile.setframerate(samp_rate)\n return wavefile\n\nwavefile0 = prepare_file(wav_output_filename0)\nwavefile1 = prepare_file(wav_output_filename1)\n\ndef callback0(in_data, frame_count, time_info, status):\n wavefile0.writeframes(in_data)\n return in_data, pyaudio.paContinue\ndef callback1(in_data, frame_count, time_info, status):\n wavefile1.writeframes(in_data)\n return in_data, pyaudio.paContinue\n\nstream0 = audio.open(format=form_1,\n channels=chans,\n rate=samp_rate,\n input=True,\n input_device_index = 0,\n frames_per_buffer=1024,\n stream_callback=callback0)\n\nstream1 = audio.open(format=form_1,\n channels=chans,\n rate=samp_rate,\n input=True,\n input_device_index = 1,\n frames_per_buffer=1024,\n stream_callback=callback1)\n\nstream0.start_stream()\nstream1.start_stream()\ntime.sleep(1.0)\nstream0.stop_stream()\nstream1.stop_stream()\n\nwavefile0.close()\nwavefile1.close()\n\nAs the next step I tried to generalize this code to be able to record audio from more than two microphones without beeing forced to retype very similar code again and again. So I introduced some lists and added some loops. The following code shows the result of my attemps.\nimport pyaudio\nimport wave\nimport time\n\nform_1 = pyaudio.paInt16 # 16-bit resolution\nchans = 1 # 1 channel\nsamp_rate = 44100 # 44.1kHz sampling rate\naudio = pyaudio.PyAudio() # create pyaudio instantiation\nnumMicros = 2\n\ndef prepare_file(fname, mode='wb'):\n wavefile = wave.open(fname, mode)\n wavefile.setnchannels(chans)\n wavefile.setsampwidth(audio.get_sample_size(form_1))\n wavefile.setframerate(samp_rate)\n return wavefile\n\nwaveFiles = []\nstreams = []\ncallbacks = []\nfor i in range(0, numMicros):\n waveFiles.append(prepare_file("test_" + str(i) + ".wav"))\n def callback(in_data, frame_count, time_info, status):\n waveFiles[i].writeframes(in_data)\n return in_data, pyaudio.paContinue\n callbacks.append(callback)\n streams.append(audio.open(format=form_1,\n channels=chans,\n rate=samp_rate,\n input=True,\n input_device_index = i,\n frames_per_buffer=1024,\n stream_callback=callbacks[i]))\n\nfor s in streams:\n s.start_stream()\ntime.sleep(1.0)\nfor s in streams:\n s.stop_stream()\n \nfor w in waveFiles:\n w.close()\n\nBut somehow this second code does not give the expected result like the first code, even for only two microphones. For one microphone it works, but not for more than one. The result for e.g. two microphones is a very small test_0.wav (~44bytes) and a larger test_1.wav (~116kb) file.\nCan someone help me find the bug? I double and triple checked everything for typos or missing indices, but cannot see the problem. I'm beginning to think that I have a lack in understanding fundamental python concepts."
] | [
"python",
"pyaudio"
] |
[
"Java Rainbow Table Implementation - Chain Lookup not working properly",
"I am currently working on a simple implementation of a rainbow table in Java. And have been having issues writing the chain lookup method. This is my current code:\nprivate static HashMap<Long, HashMap<Boolean, String>> chainLookup(long hashVal, HashMap<String, String> rainbowTable){\n HashMap<Long, HashMap<Boolean, String>> toRet = new HashMap<Long, HashMap<Boolean, String>>();\n HashMap<Boolean, String> toRetInternal = new HashMap<Boolean, String>();\n\n /*\n 1. get a list of all end values in given rainbow table\n 2. keep applying reduction method on the hash value and comparing to end values\n 3. if reduced value in end value array, find the index and look through the corresponding table\n */\n\n long temp = hashVal;\n ArrayList<String> endVals = new ArrayList<String>(rainbowTable.values());\n int indexOfTable = -1;\n\n String reducedVal;\n\n for(int i=0; i<10000;i++){\n reducedVal = reductionFunction(temp, i);\n temp = hashFunction(reducedVal);\n\n if(endVals.contains(reducedVal)){\n System.out.println("In if");\n indexOfTable = endVals.indexOf(reducedVal);\n break;\n }\n }\n System.out.println(indexOfTable);\n\n if(indexOfTable==-1){\n toRetInternal.put(false, "null");\n toRet.put(hashVal, toRetInternal);\n return toRet;\n }else{\n String start = (String) rainbowTable.keySet().toArray()[indexOfTable];\n String temp1 = start;\n long hashedTemp;\n\n for (int j=0; j<10000;j++){\n hashedTemp = hashFunction(temp1);\n if (hashedTemp == hashVal){\n toRetInternal.put(true, temp1);\n toRet.put(hashVal, toRetInternal);\n return toRet;\n }else{\n temp1 = reductionFunction(hashedTemp, j);\n }\n }\n }\n toRetInternal.put(false, "null");\n toRet.put(hashVal, toRetInternal);\n return toRet;\n }\n\nHowever, for hash values that I know can be cracked using the chains I hardcoded into the rainbow table, the first loop doesnt seem to be able to find them. Thus indexOfTable remains -1. I have no idea why this is happening, as the code is simple enough. Would appreciate any help."
] | [
"java",
"hashmap",
"rainbowtable"
] |
[
"Jboss 4.2.3 GA additional deploy directory",
"I have some troubles setting up my jboss 4.2.3 GA. I want a second deploy directory outside the jboss structure in order to place some ejb jars there.\nI found a thread with the information but it isn't working.\n\nI opened the jboss/server/default/conf/jboss-service.xml\n\nand changed\n\n <attribute name=\"URLs\">\n deploy/ \n </attribute>\n\n\nto\n\n <attribute name=\"URLs\">\n deploy/ \n file:/C:/dev/deploy/\n </attribute>\n\n\nWhen I restart the server I get this message:\n\n10:27:44,507 WARN [URLDeploymentScanner] Scan URL, caught java.io.FileNotFoundE\nxception: Not pointing to a directory, url: file:/C:/dev/20110803_jboss/server/d\nefault/deploy/\n file:/C:/dev/deploy/\n\n\nI am using windows during the development process and later on linux. The example from this page (link) is for linux and not windows. I also tried\n\nfile:///C:/dev/deploy/\nfile:/C:\\dev\\deploy\\\nfile:/C:\\\\dev\\\\deploy\\\\\nfile:C:/dev/deploy/\n\n\nand many other. Can somebody help me out here?"
] | [
"java",
"deployment",
"jboss",
"ejb",
"jboss-4.2.x"
] |
[
"use axios globally in all my components vue",
"I am testing with axios within a Vue application and the CLI. I've been using vue-resource and I could access it on all my components by simply passing it to Vue.use (VueResource). How can I achieve this with axios, so I do not have to import it into a component, but simply define it once in the main.js file?"
] | [
"vue.js",
"axios",
"vue-cli"
] |
[
"Use web project config.json when doing integration testing",
"I am using ASP.NET 5 RC1 and I need to write integration tests ...\n\nSo on the Test project, ASPNET5_WEB_TEST, I have the following:\n\npublic class IntegrationTests {\n\n private readonly TestServer _server;\n private readonly HttpClient _client;\n\n public IntegrationTests() {\n\n _server = new TestServer(TestServer.CreateBuilder().UseStartup<Startup>());\n _client = _server.CreateClient();\n\n }\n\n // Test methods ...\n}\n\n\nThe Startup class is from the ASP.NET 5 project I am testing: ASPNET5_WEB\n\nWhen I run the test I get the following error:\n\nThe configuration file 'C:\\Projects\\ASPNET5_TEST\\config.json' was not found and is not optional.\n\n\nI know I get this error because on Startup I have:\n\n builder\n .AddJsonFile(\"config.json\", false)\n .AddJsonFile($\"config.{environment.EnvironmentName}.json\", true);\n\n\nTo fix this error I need to copy, at least, config.json from my web project, ASPNET5_WEB, to my test project, ASPNET5_WEB_TEST. But this means I will need to maintain duplicate config.json or at least copy it every time I make a change.\n\nCan't I tell TestServer to use Startup of the web project and also its config.*.json files?\n\nAnd can I have a config.testing.json and set on the TestServer the environment to Testing so the Startup code uses config.json and config.testing.json?"
] | [
"testing",
"integration-testing",
"asp.net-core"
] |
[
"PHP Using Language constructs in combination with magic methods",
"This question made me curious about using language constructs in combination with PHP's magic methods. I have created a demo code:\n\n<?php\nclass Testing {\n\n public function scopeList() {\n echo \"scopeList\";\n }\n\n public function __call($method, $parameters) {\n if($method == \"list\") {\n $this->scopeList();\n }\n }\n\n public static function __callStatic($method, $parameters) {\n $instance = new static;\n call_user_func_array([$instance, $method], $parameters);\n }\n}\n\n//Testing::list();\n$testing = new Testing();\n$testing->list();\n\n\nWhy does Testing::list() throw a syntax error and $testing->list() does not? \n\nDue to php reserved keywords both should fail?"
] | [
"php"
] |
[
"What format should ClaimTypes.DateOfBirth use?",
"I can't find it specified anywhere. I did find a Microsoft example that had \"5/5/1955\". Is that d/m/y or y/m/d.\n\nI'm guessing that I probably ought to use ISO 8601, but it would be nice to know for sure."
] | [
"wif"
] |
[
"MSSQL Finding Total of a column and carry other data with it",
"I have the following table to work with, which I can not change. I have to work with what I have.\n\n Id (int auto int)\n CustomerName (varchar)\n CustomerNumber (int)\n Date (date)\n WeeklyAmount (int)\n\n\nWhat I would like to do is grab all the data per customer and add all the weekly amounts for a specific year. Eventually I will want to compare two years together, but right now I am working on the data to sum up the weekly totals per CustomerNumber.\n\nI am using:\n\n Select\n CustomerNumber, SUM (WeeklyAmount) as Total from \n Customers.RECORDS GROUP BY CustomerNumber; \n\n\nThis works fine, however, I want to return the CustomerName as well. Eventually I will have to place in the SQL for getting specific years and compare them. However, I have to tackle this part first."
] | [
"sql-server",
"stored-procedures",
"group-by",
"sum"
] |
[
"Generating onclick text at the bottom of my SVG, modifying 'selected' colour",
"With the aid of a tutorial, I've built a map of five regions of England in SVG. I've used Raphael to work with it a little. Most of it seems to be turning out alright so far:\nhttp://codepen.io/msummers40/pen/EjExeO\nI'm trying to add two more features and am just not sure how to do it. Are you able to help, please?\n\nI'd like to: Set up the effect of the regions turning red upon clicking so that only the most recently clicked region is coloured. Can you help explain what I'm supposed to do to make this shift from region to region? At the moment, a region gets clicked and stays highlighted.\n\nI'd like to figure out how to add more text to the bottom of the canvas. It may mean adding more information to my JSON but I'm hoping that I can add the text - about two paragraphs with a hyperlink - as a string. \n\nCan you please let me know if you have thoughts about ways that I can do the two things outlined above?\n\nThank you,\nMatt\n\nThe full code is on Codepen. What I've added below is a representative sample of the code. \n\nvar regions = [\n{'title':\"northeast_england\", 'path' : \"M219.02,6.876l-0.079,0.05l-0.482,0.371L218.23,7.47l-0.858,0.346h-0.008l-0.307,0.26l-0.779,0.666 l-0.104,0.278l-0.005,0.019l0.056,0.481l0.116,0.846l0.048,0.395l-0.344,1.05l-0.052-0.007v0.007l-0.635-0.081l-0.375,0.167 l-0.148,0.061v0.006l-0.1,0.328l0.178,0.338l-0.104,0.353h-0.006l-0.32,0.179l-0.056,0.031l-0.161,0.729h-0.006v0.012l-0.271,0.117 l-0.08,0.031l-0.031-0.019l-0.043,0.019l-0.327-0.167l-0.147-0.079l-0.117-0.007h-0.021l-0.216-0.006l-0.419,0.252l-0.009,0.007 l-0.004,0.302v0.605l-0.117,0.292l-0.037,0.11h-0.006v0.006h-0.025l-0.37,0.056l-0.536,0.079l-0.562,0.372l0.017,0.165l0.033,0.187 l0.481,0.788l0.023,0.038l0.008,0.013l-0.988,0.425l-0.594,0.637l-0.011,0.03l-0.187,0.637l-0.068,0.062l-0.801,0.747l-0.409,0.617 l0.062,0.414l0.068,0.414l-0.012,0.012l-0.203,0.228h-0.008l-0.123,0.05l-0.006,0.005l-0.377,0.136l-0.073,0.074l-0.13,0.143 l-0.401,0.426l-0.081,0.08l-0.055,0.055l-0.116,0.136l-0.05,0.364l0.646,0.191l0.025,0.119l0.05,0.153l-0.265,0.148l-0.26,0.155 l-0.155-0.006l-0.005,0.006l-0.309-0.006l-0.648-0.365l-0.624,0.142l-0.363,0.087l-......LOTS MORE COORDINATES....\"},\n\nTHERE ARE SEVERAL OTHER SVG REGIONS/SHAPES IN THE CODEPEN LINK\n\n\nvar MAP_WIDTH = 600;\nvar MAP_HEIGHT = 600;\n\nvar mapContainer = document.getElementById(\"map\");\nvar map = new Raphael(mapContainer, MAP_WIDTH, MAP_HEIGHT);\nvar group = map.set();\n\nvar style = {\n fill: \"#ddd\",\n stroke: \"#aaa\",\n \"stroke-width\": 1,\n \"stroke-linejoin\": \"round\",\n cursor: \"pointer\"\n};\n\n\nregions.forEach(function(region){\n group.push(\n map.path(region.path).attr('title', region.title)\n ); \n});\n\ngroup.attr(style);\ngroup.click(function(){\n var slug = this.attr('title');\n var title;\n var fill = this.attr('fill') == 'red' ? '#1f1f1f' : 'red';\n\n // format the title\n title = slug.split('-')\n .map(function(subString){\n return subString[0].toUpperCase() + subString.substr(1);\n })\n .join(' ')\n .trim();\n\n\n // add some color\n this.attr('fill', fill);\n\n // do something useful\n document.getElementById('title').textContent = title;\n});"
] | [
"javascript",
"dictionary",
"svg",
"raphael"
] |
[
"ng-pattern not working when limiting to 24 characters with regex",
"We have the following input field and we want the error message to show when the user has inputted 25 characters. However, it is only showing when the user has put in 26 characters.\n\nHere is the input field.\n\n\n\nHere is the RegEx: /^.{0,24}$/ \nI have also tried: ^.{0,24}$\n\nWhy is this not working when the user hits 25 characters?\nAlso, we are using angular 1.3.10 if this helps."
] | [
"javascript",
"angularjs",
"regex",
"forms",
"input"
] |
[
"How to share a linked list to all process with MPI",
"Im kinda new with MPI and Im having troubles with this.\n\nLets say I have this list\n\nstruct list{\n int number;\n int process;\n list *next;\n}\n\n\nI already created the linked list in the main process, but I dont know how to send the linked list to all process so every process can do some operation in a portion of the list."
] | [
"c",
"multithreading",
"linked-list",
"mpi"
] |
[
"How to get the image of the reports & dashboard in salesforce using API?",
"I have the requirement to get the image of the dashboard to reproduce it in the another app connected to Salesforce. How can I able to get the image? Is there any API for that?\n\nI have searched in the workbench for the similar API to meet my requirement. But I can't able to find anything that meets my requirement.\n\nThanks in advance"
] | [
"salesforce",
"salesforce-service-cloud"
] |
[
"Run SELECT query recursively using DISTINCT rows from column",
"I'm running a query to count the number of occurrences of each value on each column. \n\nI've managed to accomplish this by running a for loop outside from SQL, but it is quite slow. \n\nThe source table looks like this: \n\nColumn 0 Column 1 Column 2 Column 3 Column 4\n-------- -------- -------- -------- --------\n111 AA BB CC DD \n111 AA BBBBB CC DD \n222 MM 3535 678 CHARLY \n222 MM 3535 678a CHARLY \n333 XX 8989 699 DAVIDaaa\n333 XX 8989 699 DAVID \n444 YY 456 351 MIGUEL \n444 YY 456 351m MIGUEL \n555 AA 963x 568 969zzzzz\n555 AA 963 568a 969 \n\n\nThis counts the number of occurrences of each column based on Column 0:\n\nselect \ncount(*) over ( partition by g.[Column 0] ) as Count0,\ncount(*) over ( partition by g.[Column 1] ) as Count1,\ncount(*) over ( partition by g.[Column 2] ) as Count2,\ncount(*) over ( partition by g.[Column 3] ) as Count3,\ncount(*) over ( partition by g.[Column 4] ) as Count4\n\nFROM Diff g\n\nWHERE [Column 0]='111'\n\nORDER BY [Column 0]\n\n\nWhich outputs: \n\nCount0 Count1 Count2 Count3 Count4\n----------- ----------- ----------- ----------- -----------\n2 2 1 2 2\n2 2 1 2 2\n\n\nI'm manually changing the ID number on the WHERE [Column 0]='###' \nstatement, and then inserting the results into another table using another software.\n\nSince a value can exist several times on each column, I need the number of occurrences of each value on the subset regarding one ID, followed by the number of occurrences of each value on the subset regarding the next ID, and so on.\n\nThis works efficiently with a couple thousand of rows, but takes a lot of time when processing 200k - 300k rows and 30 columns. \n\nI'm sure there is a smarter and more efficient way to recursively run that count-query on every distinct row on Column 0. \n\nThe result I expect looks like this: \n\nColumn 0 Column 1 Column 2 Column 3 Column 4\n-------- -------- -------- -------- --------\n2 2 1 2 2 \n2 2 1 2 2 \n2 2 2 1 2 \n2 2 2 1 2 \n2 2 2 2 1 \n2 2 2 2 1 \n2 2 2 1 2 \n2 2 2 1 2 \n2 2 1 1 1 \n2 2 1 1 1 \n\n\nAny smarter alternative to achieve this?"
] | [
"sql",
"recursive-query"
] |
[
"illegal string body character after dollar sign in Jenkins pipeline",
"I am able to fetch VAULT Secrets from shell script "vault kv get -field=vCenter test/hello" but unable to do same using Jenkins pipeline because of the syntax.\ncd $WORKSPACE@script && ./getvms.py -u zzz -p $(vault kv get -field=vCenter test/hello\n\n\nerror\nWorkflowScript: 5: illegal string body character after dollar sign;\nsolution: either escape a literal dollar sign "$5" or bracket the value expression "${5}" @ line 5, column 81.\[email protected] -p $(vault kv"
] | [
"jenkins",
"hashicorp-vault"
] |
[
"Segue not performing",
"I'm currently facing something I find rather strange.\nIn my storyboard, there is a TableViewController filled with static cells.\n\nI would like to perform a simple segue (a push to another view controller) when I select one of the rows. \nSo I \"ControlDrag\" from the concerned table cell to the sibling controller, but when tap one the cell, nothing happens. Next to that, I did try assigning the segue triggering to the accessory view of the cell (a disclosure button). And in that case, the segue is effectively triggered.\n\nSo here is my question : Should I use the \"programmatic way\" to handle the tap on the cell (tableview delegate methods and manual segue performing), or is there something I'm missing in the interface builder? And btw how could we explain the behavior difference with the accessory button view ?\n\nHere is two screenshot\n\n\nCell selection that should trigger segue\n\n\n\nAnd, the accessory action which performs the segue"
] | [
"iphone",
"ios",
"segue"
] |
[
"imagemagick -colorspace Gray splits image into three",
"I'm running ImageMagick 6.7.7-6 on an AMI EC2. I am executing the following command in a shell script executed on the command line:\n\nconvert orig.jpg -colorspace Gray final.jpg\n\n\nor\n\nconvert orig.jpg -type Grayscale final.jpg\n\n\nThe expected result was for the image to be turned into a gray scale image. The result I get is quite different. It is split into three images and there are still small amounts of colour in it ?!?\n\norig.jpg:\n\n\n\nfinal.jpg:"
] | [
"imagemagick"
] |
[
"How would I construct a MySQL trigger which updates based on information in other tables?",
"I have a table called booking which has an start_date, expiry_date and course_id field, and another table called course which stores the duration in months.\n\nWhat I want to do is whenever a booking is made, to automatically set the expiry field based on the the course that was selected. So if course_id 5 was selected, and it has a duration of 12 months, then when the booking is inserted or updated it will get the duration, add that to the start_date and then update expiry_date accordingly.\n\nAny thoughts? I know MySQL triggers will do this, but I really have no idea where to begin constructing them and what I can actually do with them."
] | [
"mysql",
"triggers"
] |
[
"Invalid sunrise/set times?",
"I'm getting bogus values for sunrise/set times (e.g. for Nevada):\n\nlet url = \"http://api.openweathermap.org/data/2.5/weather?q=Nevada,us&APPID=<app_id>&units=metric\"\nlet req = new Request(url)\nlet json = await req.loadJSON()\n\nfunction convertTime(unixTime){\n let dt = new Date(unixTime * 1000)\n let h = dt.getHours()\n let m = \"0\" + dt.getMinutes()\n let t = h + \":\" + m.substr(-2)\n return t\n}\n\nlet sRise = convertTime(json.sys.sunrise)\nlet sSet = convertTime(json.sys.sunset)\n\nalert(convertTime(sRise));\n// Shows: 14:32 should be 05:24\n\nalert(convertTime(sSet));\n// Shows: 05:10 should be 19:55\n\n\nAm I missing something? (P.S. I'm in Europe but got the same results through a proxy)."
] | [
"javascript",
"openweathermap"
] |
[
"Public member 'Contains' on type 'String()' not found",
"I have 3 string arrays but the third, 'a3', throws:\n\n\n Public member 'Contains' on type 'String()' not found.\n\n\nat a3.Contains(\"a\")\n\nPublic Class Form1\n\n Dim a1 As String() = {\"a\", \"b\", \"c\"}\n Dim a3 = {\"a\", \"b\", \"c\"}\n\n Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load\n Dim a2 = {\"a\", \"b\", \"c\"}\n a1.Contains(\"a\")\n a2.Contains(\"a\")\n a3.Contains(\"a\")\n End Sub\nEnd Class\n\n\nAll 3 are of type System.String[]."
] | [
"vb.net",
"variables"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.