_id
stringlengths
2
6
partition
stringclasses
3 values
text
stringlengths
4
46k
language
stringclasses
1 value
title
stringclasses
1 value
d19201
test
I'm not sure what you exactly want but according to your input/output I think you want to flatten the nested object(?) and for that you can use the next piece of code- nested_obj = {"message": "Hey you", "nested_obj": {"id": 1}} flattened_obj = Object.assign( {}, ...function _flatten(o) { return [].concat(...Object.keys(o) .map(k => typeof o[k] === 'object' ? _flatten(o[k]) : ({[k]: o[k]}) ) ); }(nested_obj) ) console.log(JSON.stringify(flattened_obj));
unknown
d19202
test
Use .toUpperCase() on each letter and compare it to the letter capitalized, if it is the same, then it's in capital. Otherwise it's not, you don't actualy need any databases. Try following this code: client.on("message", async msg => { let sChannel = msg.guild.channels.find(c => c.name === "guard-log"); if (msg.channel.type === "dm" || msg.author.bot || msg.content.length < 15) return; // Use `||` (OR) to make it cleaner. let non_caps, caps; // Create the variables. for (x=0;x<msg.content.length;x++) { if (msg.content[x].toUpperCase() === msg.content[x]) caps++; else non_caps++; } // `caps` is the amount of capital letters, while `non_caps` is the amount of non-capital letters. This checks for each letter of the message and gets the amount of `caps` and `non_caps`. const textCaps = (caps / message.content.length) * 100; // Gets a percentage of the capital letters. if (textCaps >= 60 && !msg.member.permissions.has('ADMINISTRATOR')) { // If the capital letters is over or equals to 60% of the message, // and if the user isn't an ADMINISTRATOR, then... let embed = new Discord.RichEmbed() .setColor(0xffa300) .setFooter('Retro Guard', client.user.avatarURL) .setTitle("Caps-lock Engel") .setDescription("Fazla caps lock kullanımı yakalandı!") .addField("Kanal Adı", msg.channel.name, true) .addField('Kişi', 'Kullanıcı: '+ msg.author.tag +'\nID: '+ msg.author.id, true) .addField('Engellenen mesaj', "```" + msg.content + "```", true) .setTimestamp() sChannel.send(embed); msg.delete(); // Deletes the capped message. return msg.reply(`fazla caps kullanıyorsun.`) // `message.reply()` mentions the user that sent the message and is cleaner. .then(m => m.delete(5000)) } }) Do be careful, since this will delete the message if they put too much caps, including them quoting someone, whether they mean it or not. If you still don't understand, here are some reference: * *How can I test if a letter in a string is uppercase or lowercase using JavaScript?
unknown
d19203
test
A dplyr solution which relies on group_by to identify vehicle names. library(dplyr) # code each pair with a trip id by dividing by 2 - code each trip as 1 = from, 0 = to df <- df %>% group_by(name) %>% mutate(trip_id = (1 + seq_along(address)) %/% 2, from_to = (seq_along(address) %% 2)) # seprate into from and to df_from <- df %>% filter(from_to %% 2 == 1) %>% select(-from_to) df_to <- df %>% filter(from_to %% 2 == 0) %>% select(-from_to) # join the result result <- inner_join(df_from, df_to, by = c("name", "trip_id")) A: library(tidyverse) library(lubridate) df <- read.csv('https://raw.githubusercontent.com/smitty1788/Personal-Website/master/example.csv', header = T) # Remove 1st and Last row of each group df_clean <- df %>% mutate(Time = mdy_hm(Time)) %>% group_by(name) %>% arrange(name, Time) %>% filter(row_number() != 1, row_number() != n()) df_tripID <- df_clean %>% group_by(name) %>% mutate(trip_id = (1 + seq_along(address)) %/% 2, from_to = (seq_along(address) %% 2)) # seprate into from and to df_from <- df_tripID %>% filter(from_to %% 2 == 1) %>% select(-from_to) df_to <- df_tripID %>% filter(from_to %% 2 == 0) %>% select(-from_to) # join the result car2go_trips <- inner_join(df_from, df_to, by = c("name", "trip_id"))
unknown
d19204
test
The segment registers get initialized by the OS. For most modern OSes they point to the same Segment that is referring to the whole address-space, as most OSes use a Flat Memory model (i.e. no segmentation). The reason for not using only ds (the default for almost all memory accesses) here is that the operands for movs are implicit, and made sense in times of DOS. In times of DOS (Real Mode), there was an actual use of them, since registers where limited to 16Bit and so limited to 64K of address-space. The address space(1M) was divided into overlapping 64K segments.
unknown
d19205
test
I suspect calling navigateTo where you are might be too soon for some reason. To test this theory try move this code. if (dataservice.isAuthenticated() === true) { app.setRoot('viewmodels/shell', 'entrance'); router.navigateTo('home'); } else { app.setRoot('viewmodels/public'); router.navigateTo('#/public'); } into an "activate" method on your publicviewmodel, and in the main.js just leave this: app.setRoot('viewmodels/public'); EDIT: Old suggestion I believe on your viewmodel for the root you need a router property. So modify your public viewmodel to add one: define(['durandal/app', 'durandal/plugins/router', 'services/dataservice'], function (app, router, dataservice) { var publicViewModel = function () { self.router = router; self.logIn = function () { app.setRoot('viewmodels/shell'); router.navigateTo('#/home'); }; (where do you define self though?)
unknown
d19206
test
Try to Restart/Reboot your Device. It's work for me. A: Try to kill the debugger an re-attach it while process is running - * *Run | Stop -> kill the debugger *Run | Attach debugger to android process (last option in the menu) | choose your app's process. -> re-attaches your debugger to your app process while it's alive. A: remove -D from your command: $ adb shell am start -n "com.example.nagamacmini.retrofitomdb/com.example.nagamacmini.retrofitomdb.activities.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER A: Remove your debuggeable device or close emulator and reconnect it or relaunch it. It will work.
unknown
d19207
test
Ok, found it. kernel.Bind<IPrincipal>() .ToMethod(context => HttpContext.Current.User) .InRequestScope(); Will allow anyone injecting IPrincipal to get the current user name.
unknown
d19208
test
minSdkVersion.apiLevel 16 targetSdkVersion.apiLevel 21 instead of minSdkVersion 16 targetSdkVersion 21 and moduleName = 'ndktest' instead of moduleName "ndktest" it should be apply plugin: 'com.android.model.application' model { android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "me.stupideme.shuclass" minSdkVersion.apiLevel 16 targetSdkVersion.apiLevel 21 versionCode 1 versionName "1.0" vectorDrawables.useSupportLibrary = true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } android.ndk { moduleName = 'ndktest' ldLibs.addAll(['log']) cppFlags.add("-std=c++11") cppFlags.add("-fexceptions") platformVersion 16 stl 'gnustl_shared' } buildTypes { release { minifyEnabled false //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles += file('proguard-rules.pro') } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:cardview-v7:23.4.0' compile 'io.github.yavski:fab-speed-dial:1.0.1' compile 'com.github.akashandroid90:imageletter:1.5' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support:support-annotations:23.4.0' } buildTypes { release { minifyEnabled false //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' proguardFiles += file('proguard-rules.pro') } } } }
unknown
d19209
test
Try: heartBeatThread = (HANDLE)_beginthreadex(NULL, 0 , _StartAddress/*&TestFunction*/, (void*)this, CREATE_SUSPENDED, &hbThreadID); A: I'd strongly suggest making a typedef for the function pointer, and using this everywhere else: typedef unsigned int _stdcall (*Pfn)(void*); // typedefs to "Pfn" void ExecuteLocalThread(Pfn _StartAddress) { HANDLE heartBeatThread; unsigned int hbThreadID; heartBeatThread = (HANDLE)_beginthreadex(NULL, 0, _StartAddress, (void*)this, CREATE_SUSPENDED, &hbThreadID); ResumeThread( heartBeatThread ); } It's easier to type, easier to read and harder to mess up ;) Even casting gets easier with it: To cast somePtr to your function pointer type: (Pfn)somePtr
unknown
d19210
test
Each time the microcontroller starts up it is seeing exactly the same internal state as any other time it starts up. This means its output will always be the same regardless of any algorithm you might use. The only way to get it to produce different behaviour is to somehow modify its state at startup by introducing some external information or by storing state between startups. Some ideas for how to do the first option might be to measure the duration of a user key press (if your system has buttons) or sensing a temperature or other external input and using this to seed the algorithm. However the simplest option is probably to just store a counter in EEPROM that is incremented after each startup and use this to generate the seed.
unknown
d19211
test
You could break up text into two arrays of sentences and then use a function like the similar_text function to recursively check for similar strings. Another idea, to find outright pauperism. You could break down text into sentences again. But then put into a database and run a query that selects count of index column and groups by sentence column. If any results comes back greater than 1, you to have an exact match for that sentence.
unknown
d19212
test
You can create a custom directive like bellow import { Directive, HostListener } from '@angular/core'; @Directive({ selector: '[scroller]' }) export class ScrollerDirective { @HostListener('scroll') scrolling(){ console.log('scrolling'); } @HostListener('click') clicking(){ console.log('clicking...'); } constructor() { } } And then assuming you have a html template like <div class="full-width" scroller> <div class="double-width"></div> </div> use the following css .full-width{ width: 200px; height: 200px; overflow: auto; } .double-width{ width:400px; height: 100%; } the console will print "scrolling" on running the app if you move the horizontal scroll bar. Here the key is that - the scoller directive should be in the parent not in the child div. A: @HostListener('document:wheel', ['$event.target']) public onWheel(targetElement) { console.log() } A: Set (scroll)="yourFunction($event)" within the template at the corresponding element. A: You could do it by the following code as well: import { HostListener} from "@angular/core"; @HostListener("window:scroll", []) onWindowScroll() { //we'll do some stuff here when the window is scrolled } A: For those who were still not managed to figure this out with any of above solutions, here's a running code that is tested on Angular 12 @HostListener('document:wheel', ['$event.target']) onScroll(): void { console.log("Scrolling"); } A: In angular 10 and above, when listening to window events do the following: import { HostListener } from '@angular/core'; @HostListener('window:scroll', ['$event']) onScroll($event: Event): void { if($event) { console.log($event)); } } A: Assuming you want to display the host scroll (and not the windows one) and that you are using angular +2.1 @HostListener('scroll', ['$event']) private onScroll($event:Event):void { console.log($event.srcElement.scrollLeft, $event.srcElement.scrollTop); };
unknown
d19213
test
Try like this: <a href="javascript:void(0)" title="Update" onclick="fnUpdate('<s:property value='roleTypeUid'/>');"> A: The called function within onclick has to be a string, you can't reference variables directly in it. onclick="fnUpdate(\"<s:property value='roleTypeUid'/>\");" That string is evalled onclick and thus becomes a function. That's why it may be better to add handlers unobtrusive
unknown
d19214
test
If you really want to understand why you can't enter while() {...}, you need to consider the following. First, your call to odbc_connect(), which expects database source name, username and password for first, second and third parameter. It should be something like this (DSN-less connection): <?php ... $connStr = odbc_connect("Driver={MySQL ODBC 8.0 Driver};Server=server;Database=database;", "user", "pass"); if (!$connStr) { echo 'Connection error'; exit; } ... ?> Second, check for errors after odbc_exec(): <?php ... $rs = odbc_exec($connStr, $query); if (!$rs) { echo 'Exec error'; exit; } ... ?> A: you can do it with just SQL check it here, like: INSERT INTO test_data(cardnumber, peoplename, creditlimit, cbalance, minpay) SELECT cardnumber, peoplename, creditlimit, ROUND(cbalance,2) as cbalance, minpay from IVR_CardMember_Info where cardnumber not like '5127%'
unknown
d19215
test
You could loop through an array of file extensions and check them i've made a sample script to show what i mean listed below $array = array('.jpg','.png','.gif'); foreach($array as $key => $value){ $file = 'images/img_' . $post->_id . $value; // images/img_1.jpg if (file_exists($file) && is_file($file)) { $filefound = '<img src="' . $file . '" class="img-responsive" />'; } } if(isset($filefound)){ echo $filefound; }else{ echo '<img src="images/default.gif" class="img-responsive" />'; } A: The most efficient way to do this is probably to store the extension in the database, that way you're not scanning your file system for matches. However, you could also use the glob();; function and check if results has anything. $result = glob('images/img_' . $post->_id . '.*'); If you want to further narrow down your extension types you can do that like this: $result = glob('images/img_' . $post->_id . '.{jpg,jpeg,png,gif}', GLOB_BRACE) New code might look something like this (untested but you get the idea): $result = glob('images/img_' . $post->_id . '.{jpg,jpeg,png,gif}', GLOB_BRACE); if(!empty($result)) { //show the image echo '<img src="' . $result[0]. '" class="img-responsive" />'; } else { // show default image echo '<img src="images/default.gif" class="img-responsive" />'; } A: It is obvious that your script will check only for .jpg not for others because you have written statically the file extension. $file = 'images/img_' . $post->_id . '.jpg'; ^ Now Make change in this line to make available the extension dynamically. I am supposing that you are storing the image name with extension than: $file = 'images/img_' . $post->_id . $post->image_name; Note : $post->image_name should be like : $post->image_name = abc.png (image_name.extension);
unknown
d19216
test
Use html_entity_decode() instead of html_entity_encode() A: If you check the html_entity_decode() manual: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an empty string, that's because the ' ' entity is not ASCII code 32 (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset. You can nest your html_entity_decode() function inside a str_replace() to ASCII #160 to a space: <?php echo str_replace("\xA0", ' ', html_entity_decode('ABC &nbsp; XYZ') ); ?> A: Use htmlspecialchars_decode is the opposite of htmlspecialchars. Example from the PHP documentation page: $str = '<p>this -&gt; &quot;</p>'; echo htmlspecialchars_decode($str); //Output: <p>this -> "</p> A: html_entity_decode() is the opposite of htmlentities() in that it converts all HTML entities in the string to their applicable characters. $orig = "I'll \"walk\" the <b>dog</b> now"; $a = htmlentities($orig); $b = html_entity_decode($a); echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now echo $b; // I'll "walk" the <b>dog</b> now A: I know my answer is coming in really late but thought it might help someone else. I find that the best way to extract all special characters is to use utf8_decode() in php. Even for dealing with &nbsp; or any other special character representing blank space use utf8_decode(). After using utf8_decode() one can manipulate these characters directly in the code. For example, in the following code, the function clean() replaces &nbsp; with a blank. Then it replaces all extra white spaces with a single white space using preg_replace(). Leading and trailing white spaces are removed using trim(). function clean($str) { $str = utf8_decode($str); $str = str_replace("&nbsp;", "", $str); $str = preg_replace("/\s+/", " ", $str); $str = trim($str); return $str; } $html = "&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Hello world! lorem ipsum."; $output = clean($html); echo $output; Hello world! lorem ipsum.
unknown
d19217
test
I suggest you to check the following thread: Thread 1: signal SIGABRT in Xcode 9 Quoting from my answer: SIGABRT happens when you call an outlet that is not there. * *No view is connected *Duplicate might be there Outlets are references to storyboard/xib-based UI elements inside your view controller. Make sure whatever you are trying to call is there.
unknown
d19218
test
For some reason I don't know, your npm tries to install Electron with the ia32 architecture, resulting in a downloadable zip file which is not provided by the Electron maintainers. That's why you're getting a 404 HTTP status code. Going back in Electron's releases page, I cannot seem to find any darwin-ia32 assets (darwin is the codeame for macOS). You can try forcing npm to install the appropriate architecture using npm install --arch=x64 electron as suggested in Electron's installation guide.
unknown
d19219
test
Order the collection before calling the Select extension method: var emp = test.ToList() .OrderBy(x => lstRanksOrder.IndexOf(x.RPosition)) .ThenBy(x => x.LastName) .ThenBy(x => x.FirstName) .Select(x => new { EID = x.IBM, Description = string.Format("{0} {1}", x.FirstName, x.LastName), Group = x.RPosition }) .Distinct() .ToList(); A: Distinct then Order the collection before calling the Select extension method: var emp = test.ToList() .Distinct() .OrderBy(x => lstRanksOrder.IndexOf(x.RPosition)) .ThenBy(x => x.LastName) .ThenBy(x => x.FirstName) .Select(x => new { EID = x.IBM, Description = string.Format("{0} {1}", x.FirstName, x.LastName), Group = x.RPosition }) .ToList();
unknown
d19220
test
From Firebase documentation for persistenceEnabled property: Note that this property must be set before creating your first Database reference and only needs to be called once per application. As such, the standard practice is to set it once in your AppDelegate class. For instance: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { FIRApp.configure() FIRDatabase.database().persistenceEnabled = true ... return true }
unknown
d19221
test
I'm not sure why Visual Studio express is fine as opposed to full VS.NET given your reasons. Both develop for Windows based platforms. Have you looked at the WCF Test Client (WcfTestClient.exe)? You can find out more information about it here: http://msdn.microsoft.com/en-us/library/bb552364.aspx A: This is really simple, or I found it really simple when I did it with our Java based web-service hosted in tomcat. * *Start a new Solution of any kind in Visual Studio (should work in express). *Right click the References folder in your Project and select Service Reference. *Then put in your wsdl path into the address box and click Go. *This retrieves information about your webservice from the wsdl and you'll be able to create a WebService reference from that. *Then you can just use this like a Class and call the methods. Sorry this isn't really well written and thought out but I don't currently have much time, good luck.
unknown
d19222
test
A: don't add stuff to the end of the content description. It is an accessibility violation and in almost ALL circumstances just makes things less acessible (will explain more later). B: A lot of contextual things are communicated to TalkBack users via earcons (bips, beeps, etc), you may just not be noticing. C: Yes, this is confusing and difficult to determine, no images are not announced, though I think this is for good reason. For example, an image with a click listener may just be a fancy styled button. In iOS there are traits for you to change for this, Android has omitted this highly useful feature, so we're stuck with odd workarounds. The ideal solution would be for the Accessibility APIs to allow the developer to communicate this information. As for links, typically inline links in text views are announced (basically anything android detects and underlines automatically), but otherwise are not. So, in practice A LOT of links are missed. Now, as for when you should/should not supply this information yourself. If unsure, just don't and you'll obtain a reasonably high level of accessibility by following the above guidelines. In fact, any of the considerations below are really just fighting the Android OS limitations, and are their problem! However, the Android Accessibility Ecosystem is very weak, and if you want to provide a higher level of accessibility, it is understandable, however, difficult! In your attempts you can actually end up working against yourself. Let me explain: In Accessibility there is a line between providing information and consistency. By adding contextual information to a content description you are walking along this line. What if Google said "We're not going to share contextual information, add it yourself!". You would have buttons in music players across different music playing apps that announce in TalkBack like this: App1: "Play, Button" App2: "Play, Actionable" App3: "Play, Clickable" Do we have consistency here? Now a final example! App4: "Play, Double Tap to click if you're on TalkBack, Hit enter if you're a keyboard user, use your select key for SwitchAccess users....." Notice how complicated App4's Play Button is, this is illustrating that the information that TalkBack is using is NOT JUST FOR TALKBACK. The accessibility information from you app is consumed by a multitude of Accessibility services. When you "Hack" contextual information onto a content description, sure it might sound better for a TalkBack user, but what have you done to Braille Back users? To SwitchAccess users? In general, the content description of an element should describe the element, and leave contextual information for TalkBack to calculate/users to figure out given proximity to other controls. TO ANSWER YOUR TWO PARTICULAR ISSUES (Images and Links): What I recommend for images is in the content description make it obvious that the thing your describing is an image. Let's say you have a picture of a kitten. BAD: A kitten, Image Good: A picture of a kitten. See here, if TalkBack fails to announce this as an image (which it will) the user still gets the idea that it is a picture. You have added contextual information to the content description in a way that has ACTUALLY BETTER DESCRIBED THE CONTROL. This is actually the most accessible solution! Go figure. Links: For links this gets a bit tricky. There is a great debate in Accessibility about what constitutes a link vs a button. In the web browser world, this is a good debate. However, in native mobile I think we have a very clear definition: Any button that when activated takes you away from your current Application Context, is a link. The fact that the Context (Capital C Context!!!) is going to change significantly when a user interacts with a control is EXCEPTIONALLY important information. TalkBack fails to recognize links A LOT, and as such, for this very important piece of information, if you find that TalkBack is not sharing this information, go ahead and append ", link" to your content description for this element. THIS IS THE ONLY EXCEPTION TO THIS RULE I HAVE FOUND, but believe it is a good exception. Reason being, YES it does add a violation or two for other Assistive Technologies, but it conveys important enough information to justify doing so. YOU CANNOT create a WCAG 2.0 compliant application of reasonable complex User Interface using the Android Accessibility APIs. They have too many limitations, you simply can't do everything you need to do to accomplish this without "hacks". So, we have to make judgement calls sometimes.
unknown
d19223
test
As per the Java Docs of current build of Selenium Java Client v3.8.1 you cannot use public Actions doubleClick() as the documentation clearly mentions that DoubleClickAction is Deprecated. Here is the snapshot : Hence you may not be able to invoke doubleClick() from Package org.openqa.selenium.interactions Solution : If you need to execute doubleClick() two possible solutions are available as follows : * *Use Actions.doubleClick(WebElement) *Use JavascriptExecutor to inject a script defining doubleClick(). A: You have to pass element argument to doubleClick() menthod. actions.doubleClick(anyClickableWebElement).build().perform();
unknown
d19224
test
var thumbs = Directory.GetFiles("your thumbs directory"); var images = Directory.GetFiles("your images directory"); foreach (var image in images) { var thumbname = thumbs.Where(x => x.Substring(2) == image.Substring(2)); } I'm not sure if it's what you want, but if the files are in two seperate folders it will take their paths. You can also match thumb with image comparing their names. A: Use Database to store image name and Path. use reapeter control to show image list.
unknown
d19225
test
var a = 1, b = 2, c = 3; (function firstFunction(){ var b = 5, c = 6; (function secondFunction(){ var b = 8; console.log("a: "+a+", b: "+b+", c: "+c); //a: 1, b: 8, c: 6 (function thirdFunction(){ var a = 7, c = 9; (function fourthFunction(){ var a = 1, c = 8; })(); })(); })(); })(); A: var a = 1, b = 2, c = 3; (function firstFunction(){ var b = 5, c = 6; (function secondFunction(){ var b = 8; (function thirdFunction(){ var a = 7, c = 9; (function fourthFunction(){ var a = 1, c = 8; })(); })(); console.log("a: "+a+", b: "+b+", c: "+c); // it's here because of 'hoisting'. if you need more I can explain })(); })();
unknown
d19226
test
The only way is to use IndexIgnore carefully . For example ,if you put the following code : Options +Indexes IndexIgnore * The directory listing will be on but nothing will be shown so the use of IndexIgnore is to hide what you want when directory listing is done . Another example is to do the following : Options +Indexes IndexIgnore *.php *.jpg *.png *.txt *image The code above will hide all files with these extensions as well as image folder , so you should exclude all folderes and files that you don't want them to be shown , .html files are not listed above so,they will be shown.
unknown
d19227
test
I have found the solution, I should just add this tag to the SmtpAppender: <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="ERROR" /> <levelMax value="FATAL" /> </filter> A: Try using: <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> ... <threshold value="WARN"/> ... </appender> (or threshold value="ERROR" since you say you want to limit to Error and Fatallevels) rather than: <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> ... <evaluator type="log4net.Core.LevelEvaluator"> <threshold value="WARN"/> </evaluator> ... </appender> The log4net documentation or this message in the log4net user mailing list explains the difference.
unknown
d19228
test
The actual problem is you're trying to simultaneously read real status and simulate press/release the same mouse button. The only way to resolve this problem is (as you have suggested) to bind fire to additional key. For example, in the game config you assign both left mouse button and keyboard key combination CtrlP to "Fire". Please note that P without a modifier must be NOT assigned to any action in the game. And your script would be the following: EnablePrimaryMouseButtonEvents(true) function OnEvent(event, arg) if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsModifierPressed("lctrl") then repeat Sleep(15) PressKey("P") Sleep(15) ReleaseKey("P") until not IsMouseButtonPressed(1) or not IsModifierPressed("lctrl") end end
unknown
d19229
test
Basically I don't think this is possible with any widely available compiler. You would have to use program-counter relative addressing for all data in flash, but absolute addressing for addresses in RAM. While the ELF for ARM specification has these kinds of relocations, I don't think any compiler knows how to do generate code to use them. Also, it wouldn't know which to use in each case given that what is in flash and what is in RAM isn't decided until the linker stage. One solution (which I have used in production) is to compile all your sources once but link them twice with two different linker scripts with absolute addresses. You will then have to distribute a double-sized update image, only half of which is used on any occasion. Alternatively if you only want to have one image, then you need to do a double-shuffle. Have your working image write the new image to one area of internal flash, then reboot and have the bootloader copy it from there to the working location. You couldn't run it from the temporary location because the embedded addresses would be wrong (this is identical to your current solution but only uses the internal flash). A: You build the application as position independent, the startup code looks at the address it is executing from and adjusts the GOT before it launches into main() or whatever your C entry point is. Can certainly do this with gnu tools, I assume llvm supports position independent as well. Now you can only boot from one place and that is common to both paths so you do know which path you are taking because you have to create a non-volatile scheme to mark which path to try first or which path is the most recent. There are various ways to do that, too broad to answer here. That code can do the GOT thing just like a normal program loader would for an operating system, or each application can patch itself up before calling compiled code, or can do a hybrid. You can have the application run in sram instead of from flash and the single entry point code can copy whichever one is the current one to ram, and you do not need position independence you link for ram and either can be a copy and jump. You can link two versions of each application and part of the update process is to in some way (many ways to do it, too broad for here) determine which partition and write the one linked for that partition, then the common entry point can simply branch to the right address. Some mcus have banked flashes and a way to put one out front, you can buy one of those products. The common code can live in each image just in case and the A code assumed to be at the entry point for the chip will be the real bootloader that determines which partition to use and make adjustments as needed. Your chip might have an mmu and you can remap whichever into the same address space and link for that address space. Not only is this doable this is not complicated, there are too many ways to do it to describe and you have to simply pick the one you want to implement and maintain. The chip may or may not help in this decision. If you are already a bare-metal programmer then dealing with startup code and PIC and the GOT, and stuff are simple not scary. What does GOT mean. global offset table, a side effect of how at least gcc/binutils work. With position independent code. Just use the tools, no target hardware necessary.... flash.s .cpu cortex-m0 .thumb .thumb_func .word 0x20001000 .word reset .thumb_func reset: bl notmain .thumb_func hang: b . .thumb_func .globl lbounce lbounce: bx lr bounce.c void fbounce ( unsigned int x ) { } notmain.c void lbounce ( unsigned int ); void fbounce ( unsigned int ); unsigned int x = 9; int notmain ( void ) { x++; lbounce(5); fbounce(7); return(0); } flash.ld MEMORY { rom : ORIGIN = 0x00000000, LENGTH = 0x1000 mor : ORIGIN = 0x80000000, LENGTH = 0x1000 ram : ORIGIN = 0x20000000, LENGTH = 0x1000 } SECTIONS { .ftext : { bounce.o } > mor .text : { *(.text*) } > rom .data : { *(.data*) } > ram } build it position dependent arm-linux-gnueabi-as --warn --fatal-warnings -mcpu=cortex-m0 flash.s -o flash.o arm-linux-gnueabi-gcc -Wall -O2 -ffreestanding -mcpu=cortex-m0 -mthumb -c notmain.c -o notmain.o arm-linux-gnueabi-gcc -Wall -O2 -ffreestanding -mcpu=cortex-m0 -mthumb -c bounce.c -o bounce.o arm-linux-gnueabi-ld -nostdlib -nostartfiles -T flash.ld flash.o notmain.o bounce.o -o notmain.elf arm-linux-gnueabi-objdump -D notmain.elf > notmain.list arm-linux-gnueabi-objcopy -O binary notmain.elf notmain.bin arm-linux-gnueabi vs arm-none-eabi does not matter for this code, since the differences are not relevant here. This just happened to be what I had in this makefile. arm-none-eabi-objdump -d notmain.o notmain.o: file format elf32-littlearm Disassembly of section .text: 00000000 <notmain>: 0: 4a06 ldr r2, [pc, #24] ; (1c <notmain+0x1c>) 2: b510 push {r4, lr} 4: 6813 ldr r3, [r2, #0] 6: 2005 movs r0, #5 8: 3301 adds r3, #1 a: 6013 str r3, [r2, #0] c: f7ff fffe bl 0 <lbounce> 10: 2007 movs r0, #7 12: f7ff fffe bl 0 <fbounce> 16: 2000 movs r0, #0 18: bd10 pop {r4, pc} 1a: 46c0 nop ; (mov r8, r8) 1c: 00000000 .word 0x00000000 So the variable x is in .data the code is in .text, they are separate segments so you cannot make assumptions when compiling a module the pieces come together when linking. So this code is built so that the linker will fill in the value that is shown in this output as the 1c address. The address of x is read using that pc-relative load, then x itself is accessed using that address to do the x++; lbounce and fbounce are not known to this code they are external functions so the best the compiler can really do is create a branch link to them. Once linked: 00000010 <notmain>: 10: 4a06 ldr r2, [pc, #24] ; (2c <notmain+0x1c>) 12: b510 push {r4, lr} 14: 6813 ldr r3, [r2, #0] 16: 2005 movs r0, #5 18: 3301 adds r3, #1 1a: 6013 str r3, [r2, #0] 1c: f7ff fff7 bl e <lbounce> 20: 2007 movs r0, #7 22: f000 f805 bl 30 <__fbounce_veneer> 26: 2000 movs r0, #0 28: bd10 pop {r4, pc} 2a: 46c0 nop ; (mov r8, r8) 2c: 20000000 andcs r0, r0, r0 Per the linker script .data starts at 0x20000000 and we only have one item there so that is where x is. Now fbounce is too far away to encode in a single bl instruction so there is a trampoline or veneer created by the linker to connect them 00000030 <__fbounce_veneer>: 30: b401 push {r0} 32: 4802 ldr r0, [pc, #8] ; (3c <__fbounce_veneer+0xc>) 34: 4684 mov ip, r0 36: bc01 pop {r0} 38: 4760 bx ip 3a: bf00 nop 3c: 80000001 andhi r0, r0, r1 Note that is 0x80000000 with the lsbit set, the address is 0x80000000 not 0x80000001 look at the arm documentation (the lsbit means this is a thumb address and tells the bx instruction logic to go to or remain in thumb mode, then strip that bit off and make it a zero. Being a cortex-m it is always thumb mode if you have a zero there then the processor will fault because it does not have an arm mode, the tool generated that properly). Now position independent. arm-linux-gnueabi-as --warn --fatal-warnings -mcpu=cortex-m0 flash.s -o flash.o arm-linux-gnueabi-gcc -fPIC -Wall -O2 -ffreestanding -mcpu=cortex-m0 -mthumb -c notmain.c -o notmain.o arm-linux-gnueabi-gcc -fPIC -Wall -O2 -ffreestanding -mcpu=cortex-m0 -mthumb -c bounce.c -o bounce.o arm-linux-gnueabi-ld -nostdlib -nostartfiles -T flash.ld flash.o notmain.o bounce.o -o notmain.elf arm-linux-gnueabi-objdump -D notmain.elf > notmain.list arm-linux-gnueabi-objcopy -O binary notmain.elf notmain.bin on my machine gives 0000000e <lbounce>: e: 4770 bx lr 00000010 <notmain>: 10: b510 push {r4, lr} 12: 4b07 ldr r3, [pc, #28] ; (30 <notmain+0x20>) 14: 4a07 ldr r2, [pc, #28] ; (34 <notmain+0x24>) 16: 447b add r3, pc 18: 589a ldr r2, [r3, r2] 1a: 2005 movs r0, #5 1c: 6813 ldr r3, [r2, #0] 1e: 3301 adds r3, #1 20: 6013 str r3, [r2, #0] 22: f7ff fff4 bl e <lbounce> 26: 2007 movs r0, #7 28: f000 f806 bl 38 <__fbounce_veneer> 2c: 2000 movs r0, #0 2e: bd10 pop {r4, pc} 30: 1fffffea svcne 0x00ffffea 34: 00000000 andeq r0, r0, r0 00000038 <__fbounce_veneer>: 38: b401 push {r0} 3a: 4802 ldr r0, [pc, #8] ; (44 <__fbounce_veneer+0xc>) 3c: 4684 mov ip, r0 3e: bc01 pop {r0} 40: 4760 bx ip 42: bf00 nop 44: 80000001 andhi r0, r0, r1 There may be some other interesting PIC flags, but so far this already shows a difference. 12: 4b07 ldr r3, [pc, #28] ; (30 <notmain+0x20>) 14: 4a07 ldr r2, [pc, #28] ; (34 <notmain+0x24>) 16: 447b add r3, pc 18: 589a ldr r2, [r3, r2] 1c: 6813 ldr r3, [r2, #0] 1e: 3301 adds r3, #1 20: 6013 str r3, [r2, #0] Now it takes all of this to increment x. It is using a pc-relative offset in the literal pool at the end of the function to get from where we are to the GOT in .data. (important thing to note that means of you move .text around in memory you also need to move .data to be at the same relative offset for this to work). Then it has to do those math steps to get the address of x then it can do the read modify write. Also note that the trampoline doesn't change still has the hard-coded address for the section that contains fbounce, so this tells us that we cannot move fbounce as built. Disassembly of section .data: 20000000 <x>: 20000000: 00000009 andeq r0, r0, r9 Disassembly of section .got: 20000004 <.got>: 20000004: 20000000 andcs r0, r0, r0 So what is a GOT? It's a global offset table, in this trivial example there is this data item x in .data. There is a global offset table (okay correcting a statement above the .got section needs to be in the same place relative to .text for this to work as built, but .data can move and that is the whole point. .got for this to work needs to be in sram (and naturally that means a proper bootstrap needs to put it there just like .data needs to be placed from flash to sram before the C entry point). So if you wanted to move the .data to some other address in memory because you are copying it from flash to a different address than it was linked for. You would need to go through the global offset table and modify those addresses. If you think about the position dependent, every function every instances of the global variable x, there will be that word in the literal pool after all the functions that access it, in places you cannot unravel. you would have to know the dozens to hundreds of places to modify if you wanted to move .data. With this solution you need to know where the GOT is and update it. So if instead of 0x20000000 you put it at 0x20008000 then you would go through the got and add 0x8000 to each entry before you launched this code or at least before the code touches any .data item. And if you wanted to only move .text then at least as I have built this here, and not .data, then you need to move/copy the .text to the other address space and copy .got to the same relative address but not modify the got. In your case you want to execute from two different address spaces but not move .data. So ideally need to get the tools to have a fixed location for the .got which I did not dig into, exercise for the reader. If you can get the .got to be fixed and independent of the location of .text then a single build of your program can be executed from two different flash locations without any modification. Without the need for two separately linked, binaries, etc. .got : { *(.got*) } > rom Done. Disassembly of section .data: 20000000 <x>: 20000000: 00000009 andeq r0, r0, r9 Disassembly of section .got: 00000048 <.got>: 48: 20000000 andcs r0, r0, r0 that means the GOT is in the flash, which would end up being in the big binary blob that would get programmed in either flash location in the correct relative position. So my fbounce was for demonstration. If you build position independent and there is not enough flash to worry about the veneer, so a single binary can be created that will execute from two different flash locations without modification. Thus the term position independent code. But this is the trivial part of your problem, the part that takes little effort (took me a few minutes to see and solve the one issue I had). You still have other issues to solve that can be solved dozens of ways and you have to decide, design, and implement your solution. Way too broad for Stack Overflow.
unknown
d19230
test
Replace this for var i = 0; i <= inputString.count; ++i with this: for var i = 0; i < inputString.count; ++i Arrays are zero indexed. That means the first element has the index 0. The second element has index 1. ... . The last element has the index array.count-1. A: @dasdom is correct. but here is a more Swift-y way to do it: // input string var input = "ooooxxxxxxxoxoooxoxo" // difference between number of x's and number of o's var diff = 0 // perform this function for each character in `input.characters`: input.characters.forEach { switch $0 // $0 is the argument to our function (unnamed) { case "x": diff += 1 // x's are +1 case "o": diff -= 1 // o's are -1 default: fatalError() // we expect only 'x' or 'o'... if we get something else, just crash } } // use the ternary (?:) operator to print the answer. // (<result> = <condition> ? <if-true value> : <if-false value>) print( diff == 0 ? "equal" : "not equal" ) A shorter version, inspired by @Eendje's answer :) print( input.characters.reduce(0) { $0 + [ "x":1, "o":-1 ][ $1 ]! } != 0 ? "not" : "", "equal" ) A: While everyone is giving you an alternative, I thought this would be a nice addition as well: var input = "xxxxxoxoooxoxo" You can get the count by using filter: let xCount = input.characters.filter { $0 == "x" }.count let oCount = input.characters.filter { $0 == "o" }.count print( xCount == oCount ? "equal" : "not equal" ) In your case, using reduce would be more efficient and it's shorter: let result = input.characters.reduce(0) { $0 + ($1 == "x" ? 1 : -1) } print(result == 0 ? "equal" : "not equal") // not equal This is only if you're sure input only contains x and o. If not, then you'll have to change the evaluation to: { $0 + ($1 == "x" ? 1 : $1 == "o" ? -1 : 0) } A: You are enumerating pass the range of the array. Use this instead. for var i = 0; i < inputString.count; ++i { Or you can use this more idiomatic code: var input = "xxxoxoooxoxo" var xString = 0 var oString = 0 for c in input.characters { if c == "x" { xString++ } else if c == "o" { oString++ } } if oString == xString { print("equal") } else { print("Not Equal") }
unknown
d19231
test
I thought I would update how I resolved the issue in case someone is facing the same issue. There are number of things I did: * *Updated package.config as some of the packages were not using 4.6.1. I'm not sure how it worked until a certain point in time. *Deleted local repo. Cloned the code from the repository, built the solution, and tested if the local instance is working. At this point, it was not. *I noticed that the solution was compiling and producing libraries but the libraries were not copied into the \bin\Debug folder even though the output path was set to bin\Debug folder. So I updated the properties to change the output path to \bin, rebuilt the solution, and then changed the path back to bin\Debug and rebuilt it again. The local instance launched without any issues this time. *Added the new webform (.aspx) file again and rebuilt the solution. This time the local instance launched without any issues.
unknown
d19232
test
QThread should be subclassed only to extend threading behavior. I think you should read the following article before trying to use the moveToThread function: http://blog.qt.io/blog/2010/06/17/youre-doing-it-wrong/
unknown
d19233
test
HERMES accepts MAT files (*.mat) and Fieldtrip structures. MAT files should consist on one single matrix with as many columns as channels and as many rows as temporal points (and, in the case of event-related data, the third dimension will be for the different trials). For example, for one subject and condition: a matrix of (30 channels x 1000 samples (x 50 trials)). Therefore, to be able to load your data easily, you'll need to obtain your MAT files as described above. Thanks to Guiomar Niso for providing this answer.
unknown
d19234
test
I don't see any code that would set device to the MTKView. An MTKView without a device would be returning empty drawable. I'd suggest adding this to the viewDidLoad: mtlView.device = device
unknown
d19235
test
You forgot to use the sorted array! I made it easier to follow by renaming the variables a bit. {% assign sortedOrders = customer.orders | sort: 'order.shipping_address.name' %} {% for order in sortedOrders %} ... {% endfor %} Hope you're getting enough sleep!
unknown
d19236
test
this is angular2-modal open function: /** * Opens a modal window inside an existing component. * @param content The content to display, either string, template ref or a component. * @param config Additional settings. * @returns {Promise<DialogRef>} */ open(content: ContainerContent, config?: OverlayConfig): Promise<DialogRef<any>> {... } As you see you can provide a ref to template or custom modal component. See bootstrap-demo-page for details. A: You can use angular2 material. It gas a nice dialog where you can inject any component and that component will show up in that model. It also come with lots of nice features like afterClose(subscriber). You can pass data to its child component.
unknown
d19237
test
This error is often caused by the zip code not matching the city and state format. I would suggest using usps.com zip code verfication to make sure the zip matches the postal service city and state. You can find this tool here: https://tools.usps.com/go/ZipLookupAction!input.action Using this tool usually helps me clear the error. If this doenst help resolve the issue, please show the address and zip details that you are currently sending. Hope this helps. Thanks,
unknown
d19238
test
Missing the original data, let the given (intermediate) output be the starting point - the first statement (resulting in MV_Claim_Ranked) could be replaced with your selection from mys.mv_claim: WITH MV_Claim_Ranked AS ( SELECT fiscal_year, prac, claims, cost, annual_rank_by_claim, RANK() OVER (PARTITION BY fiscal_year ORDER BY claims DESC) annual_rank_by_claim_calc, prac_top_3_in_claims_2014 FROM MV_Claim_Grouped ) SELECT T1.*, CASE WHEN (SELECT annual_rank_by_claim_calc FROM MV_Claim_Ranked T2 WHERE T1.prac = T2.prac AND T2.fiscal_year = 2014) < 4 THEN 'YES' ELSE 'NO' END AS prac_top_3_in_claims_2014_calc FROM MV_Claim_Ranked T1 ORDER BY prac, fiscal_year ; Your aggregates are kept for reference. See it in action: SQL Fiddle. Please comment, if and as this requires adjustment / further detail. A: I've never seen GROUP BY and HAVING used in a partitioning spec; I suspect it's a syntax error. I think your query needs to look more like: WITH t as ( select fiscal_year, prac, count(*) "CLAIMS", sum(paid_amount) "COST" from mys.mv_claim where category = 'V' group by fiscal_year, prac ) SELECT t.*, rank() over (partition by fiscal_year order by claims desc) "Annual Rank by Claims", case when prac in(select prac from (select * from t where fiscal_year = 2014 order by claims desc ) where rownum <= 3) then 'YES' else 'NO' end "PRAC TOP 3 IN CLAIMS 2014" from t I've used rank instead of row number, as two identical claim counts will produce a rank value the same. Rank will then skip the next rank (two 999 claim counts will each rank 1, a 998 claim count will rank 3. If you want it to rank 2 use dense_rank) Let me know if you get any errors with this, as the only thing I'm not certain will work out is the subselect that retrieves the top 3 pracs. That can be done with a left join instead (which i have greater confidence in)
unknown
d19239
test
Add nodes to a JTree using the DefaultTreeModel's insertNodeInto method. To quote the API This will then message nodesWereInserted to create the appropriate event. This is the preferred way to add children as it will create the appropriate event. For example: ((DefaultTreeModel) tree.getModel()).insertNodeInto(newNode, root, 0);//inserts at beginning //((DefaultTreeModel) tree.getModel()).insertNodeInto(newNode, root, root.getChildCount() - 1);//inserts at end
unknown
d19240
test
None of your buttons have id submit_button. Which you have stated in the event handler: document.getElementById('submit_button').onclick { You need to add it to one of them like so: <p style="padding-bottom: 40px;"><button id="submit_button">A</button></p>
unknown
d19241
test
Problem fixed :) Below is the working code $(function(){ $('#datepicker').datepicker({ startDate: '-0m' //endDate: '+2d' }).on('changeDate', function(ev){ $('#sDate1').text($('#datepicker').data('date')); $('#datepicker').datepicker('hide'); }); })
unknown
d19242
test
Properties such as the desired parallelism and the maximum pool size can be configured using a ParallelExecutionConfigurationStrategy. The JUnit Platform provides two implementations out of the box: dynamic and fixed. Alternatively, you may implement a custom strategy. Keep in mind that the ParallelExecutionConfigurationStrategy class is still in the "EXPERIMENTAL" state and it is not yet stable. Unintended behaviour may occur. As you don't set a specific configuration strategy, the following section applies: If no configuration strategy is set, JUnit Jupiter uses the dynamic configuration strategy with a factor of 1. Consequently, the desired parallelism will be equal to the number of available processors/cores. Find more details at https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution-config
unknown
d19243
test
<button type="submit" class="_6j mvm _6wk _6wl _58mi _3ma _6o _6v" name="websubmit" id="u_0_s">Create Account</button> From above,I could see id for submit button is 'id='u_0_s'. Can you confirm that you are passing id correctly for submit?If not,please correct it with 'id='u_0_s',try and let me know if it works. Also,check if the Submit button is visible while your test case is getting executed.You can add code to maximize browser window for this. A: You can use this xpath: "//button[contains(text(), 'Create an account')]", it will solve your problem A: I have added implicit wait WebDriverWait(self.driver,10).until(expected_conditions.visibility_of_element_located((By.ID, self.__create_account_button_id))) And after that everything works good
unknown
d19244
test
I looked through sources of alert_dialog.xml layout in API 19 and found the following layout for inserting a custom view: <FrameLayout android:id="@+id/customPanel" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> <FrameLayout android:id="@+android:id/custom" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="5dip" android:paddingBottom="5dip" /> </FrameLayout> Then I tried to set background to see which view takes the space. customPanel was colored in red, custom view was colored in green. AlertDialog d = builder.create(); d.show(); View v = (View)d.getWindow().findViewById(android.R.id.custom).getParent(); v.setBackgroundColor(Color.RED); This picture means that customPanel should have some paddings, or custom should have non-zero layout params or something else. After checking those attributes which were equal to zero I tried to test minimumHeight of the customPanel and got 192 on xxhdpi or 64dp. This setting cause the frame to be larger than a nested custom view. I haven't figured out where this setting is applied, but here is the workaround: AlertDialog d = builder.create(); d.show(); View v = (View)d.getWindow().findViewById(android.R.id.custom).getParent(); v.setMinimumHeight(0); Tested on API 18,19. A: In addition to vokilam's answer: If you're using android.support.v7.app.AlertDialog. Tested on API 27 (pretty sure this works on API 28 too) The layout: <FrameLayout android:id="@+id/contentPanel" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="48dp"> <ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <Space android:id="@+id/textSpacerNoTitle" android:visibility="gone" android:layout_width="match_parent" android:layout_height="@dimen/dialog_padding_top_material" /> <TextView android:id="@+id/message" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="?attr/dialogPreferredPadding" android:paddingStart="?attr/dialogPreferredPadding" style="@style/TextAppearance.Material.Subhead" /> <Space android:id="@+id/textSpacerNoButtons" android:visibility="gone" android:layout_width="match_parent" android:layout_height="@dimen/dialog_padding_top_material" /> </LinearLayout> </ScrollView> </FrameLayout> <FrameLayout android:id="@+id/customPanel" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="48dp"> <FrameLayout android:id="@+id/custom" android:layout_width="match_parent" android:layout_height="wrap_content" /> </FrameLayout> The android:minHeight="48dp" for contentPanel and customPanel are causing the unwanted blank space. Unwanted space dialog What I did is: alertDialog.SetView(view); alertDialog.show(); ... View customPanel = (View) view.getParent().getParent(); if (customPanel != null) customPanel.setMinimumHeight(0); View contentPanel = (View) alertDialog.findViewById(android.R.id.message).getParent().getParent().getParent(); if (contentPanel != null) contentPanel.setMinimumHeight(contentPanel.getMinimumHeight() * 2 / 3); Result: Blank space removed A: Did you try playing around with paddings and margins? You could copy your layout in res/layout-vXX and set a specific (negative) margin.
unknown
d19245
test
Yes, there is a way to use this inside your IIFE's, you can bind the thisValue with bind() before calling the IIFE. (function() { this.css('color', '#f00') }).bind($('.' + c))(); A: You can use bind() or call() or apply() and pass 'this' through them as your scope changed for 'this'... It's always a good practice using these functions in javascript, rather then attach it to the function... The best option is call for your code... (function() { this.css('color', '#f00') }).call($('.' + c)); Also using click handler in your javascript, make your code much cleaner and can make your coding structure better, you also can use multiple selection in jQuery to keep HTML clean if needed more selectors handle this function...
unknown
d19246
test
I think this will work for you. select ip, question_id from poll_stat where ip in (select ip from poll_stat where answer_id = 767 group by ip) and answer_id <> 767 edit Hmm...you might check that there is an INDEX created on the ip column. If that isn't it, perhaps it doesn't like the IN clause. I will rewrite as a join: select ip, question_id from poll_stat ps1 inner join (select ip from poll_stat where answer_id = 767 group by ip) ps2 on ps1.ip = ps2.ip where answer_id <> 767
unknown
d19247
test
Since the static libraries end up "baked in" to your executable, you don't need to concern yourself with their linking anymore than you need your executable. Just set up the project dependencies so that the dependent framework builds first (so the .framework/Headers folder gets populated properly), then the libraries, then your app. I have done this in multiple apps with great success.
unknown
d19248
test
* *What's the difference between "newly created projects" and "a blank one"? *Did you change the HTML filename of the application in your-project\apps\your-app\common prior to deployment? *Also, while this is probably not related, but do note that if using Worklight 6.0, make sure that you have installed it in Eclipse 4.2.2; not 4.0 not 4.1 not 4.2.1, only 4.2.2. *Is this an upgraded installation of Worklight, or a new one in a new Eclipse instance and a new workspace?
unknown
d19249
test
This is a client error because the client specified a restaurant_id that didn't exist. The default code for any client error is 400, and it would be fitting here too. There are slightly more specific client error codes that might work well for this case, but it's not terribly important unless there is something a client can do with this information. * *422 - could be considered correct. The JSON is parsable, it just contains invalid information. *409 - could be considered correct, if the client can create the restaurant with that specific id first. I assume that the server controls id's, so for that reason it's probably not right here. So 400, 422 is fine. 500 is not. 500 implies that there's a server-side problem, but as far as I can tell you are describing a situation where the client used an incorrect restaurant_id.
unknown
d19250
test
Your configuration is incorrect. cakePHP attempts to send the e-mail via smtp to your localhost. Most likely you do not have an MTA (ie. exim, dovecot) installed locally and the request gets dropped. This should be visible as an error in you logs (if enabled). An easy solution is to change the configuration to a working email service for testing, for example Gmail. Example: Email::configTransport('gmail', [ 'host' => 'smtp.gmail.com', 'port' => 587, 'username' => '[email protected]', 'password' => 'secret', 'className' => 'Smtp', 'tls' => true ]); Note that the host and port point to Gmail. This example is indicative and was taken from the official documentation. More information on configuring email transports in cakePHP 3.0 here: http://book.cakephp.org/3.0/en/core-libraries/email.html#configuring-transports
unknown
d19251
test
You probably generated whatever file you're reading on Windows in UTF-16. You should read and write your files in UTF-8. See \377\376 Appended to file (Windows -> Unix) for more details on this pretty common problem. If you need to read files in UTF-16 in C++, see std::codecvt. That will help you get it over to UTF-8, which is what most of the Mac libraries expect.
unknown
d19252
test
Your imports should be something like the following in RxJS6: (1) rxjs: Creation methods, types, schedulers and utilities import { Observable, Subject } from 'rxjs'; (2) rxjs/operators: All pipeable operators: import { map, filter, scan } from 'rxjs/operators'; For more information read the migration guide and import paths. Also use pipe instead of chaining, for example: login(model: any) { const headers = new Headers({'Content-type': 'application/json'}); const options = new RequestOptions({headers: headers}); return this.http.post(this.baseUrl + 'login', model, options).pipe( map((response: Response) => { const user = response.json(); if (user) { localStorage.setItem('token', user.tokenString); this.userToken = user.tokenString; } })); }
unknown
d19253
test
You ask for "if any element in the list is greater than x". If you just want one element, you could just find the greatest element in the list using the max() function, and check if it's larger than x: if max(list) > x: ... There's also a one-liner you can do to make a list of all elements in the list greater than x, using list comprehensions (here's a tutorial, if you want one): >>> x = 22 >>> list = [10, 20, 30, 40] >>> greater = [i for i in list if i > x] >>> print(greater) [30, 40] This code generates a list greater of all the elements in list that are greater than x. You can see the code responsible for this: [i for i in list if i > x] This means, "Iterate over list and, if the condition i > x is true for any element i, add that element to a new list. At the end, return that new list." A: Use any, Python's natural way of checking if a condition holds for, well, any out of many: x = 22 lst = [10, 20, 30] # do NOT use list as a variable anme if any(y > x for y in lst): # do stuff with lst any will terminate upon the first truthy element of the iterable it is passed and, thus, not perform any spurious iterations which makes it preferable to max or list comprehension based approaches that have to always iterate the entire list. Asymptotically however, its time complexity is, of course, still linear. Also, you should not shadow built-in names like list. A: You could use filter and filter your list for items greater than 22, if the len of this filtered list is > 0 that means your original list contains a value larger than 22 n = 22 lst = [10,20,30] if len(list(filter(lambda x: x > n, lst))) > 0: # do something to lst A: List comprehension would suit your use case. In [1]: x=22 In [2]: l=[10,20,30] In [3]: exist = [n for n in l if n > x] In [4]: if exist: ...: print "elements {} are greater than x".format(exist) ...: elements [30] are greater than x If your list is very long, use generator so that you do not have to iterate through all elements of the list. In [5]: exist = next(n for n in l if n > x) In [6]: if exist: print "Element {} is greater than x".format(exist) ...: Element 30 is greater than x
unknown
d19254
test
if someone looks for this question, I have the answer: https://gjs-docs.gnome.org/clutter7~7_api/clutter.shadereffect#method-set_uniform_value value - a GObject.Value GObject.TYPE_FLOAT for float and in gjs GTK Javascript they have https://gjs-docs.gnome.org/clutter7~7_api/clutter.value_set_shader_float value_set_shader_float(value,[float]) method - Value must have been initialized using %CLUTTER_TYPE_SHADER_FLOAT. and in Javascript version of GTK they dont have any way to initialize that CLUTTER_TYPE_SHADER_FLOAT or GObject.TYPE_FLOAT The solution is: function make_float(val) { return Math.floor(val)==val?val+0.000001:val; } A: As of GJS 1.68.0 (GNOME 40), passing a GObject.Value works: let value = new GObject.Value(); value.init(GObject.TYPE_FLOAT); value.set_float(1); shader.set_uniform_value('value', value);
unknown
d19255
test
I use this simple replace Date: <input name=x size=10 maxlength=10 onkeyup="this.value=this.value.replace(/^(\d\d)(\d)$/g,'$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g,'$1/$2').replace(/[^\d\/]/g,'')"> Try it with jsfiddle A: I made a simple example for your purpose: var date = document.getElementById('date'); date.addEventListener('keypress', function (event) { var char = String.fromCharCode(event.which), offset = date.selectionStart; if (/\d/.test(char) && offset < 8) { if (offset === 2 || offset === 5) { offset += 1; } date.value = date.value.substr(0, offset) + char + date.value.substr(offset + 1); date.selectionStart = date.selectionEnd = offset + 1; } if (!event.keyCode) { event.preventDefault(); } }); Here is a fiddle A: Here is a shorter version: $("#txtDate").keyup(function(){ if ($(this).val().length == 2 || $(this).val().length == 5){ $(this).val($(this).val() + "/"); } });
unknown
d19256
test
' + data); client.destroy(); }); client.on('close', function() { console.log('Connection closed'); }); With the updated code, the timeout does not appear to take effect. When i start this client with no corresponding server, the result shows below with no 4 second wait. Is the server running at 9000? Is the server running at 9000? Is the server running at 9000? Is the server running at 9000? … Update (Barking up the wrong tree?) I went back to look at the socket.on('error') event and saw that the close event is called immediately after the error. So the code will close out the tcpclient without waiting for 4 seconds. Any better ideas? A: You're timeout is reversed. Should look like: var net = require('net'); var HOST = '127.0.0.1'; var PORT = 9000; var client = new net.Socket(); client.connect(PORT, HOST, function(){ console.log('CONNECTED TO: ' + HOST + ':' + PORT); client.write('I am Superman!'); }); client.on('error', function(e) { if(e.code == 'ECONNREFUSED') { console.log('Is the server running at ' + PORT + '?'); client.setTimeout(4000, function() { client.connect(PORT, HOST, function(){ console.log('CONNECTED TO: ' + HOST + ':' + PORT); client.write('I am the inner superman'); }); }); console.log('Timeout for 5 seconds before trying port:' + PORT + ' again'); } }); client.on('data', function(data) { console.log('DATA: ' + data); client.destroy(); }); client.on('close', function() { console.log('Connection closed'); }); The function you want to run after the timeout is the callback. That's the one that waits for execution. Also, change your while to an if, that condition won't change during a single error event. And your parens and brackets are mismatched. A: per my comment on accepted answer I discovered an issue using the .connect callback vs the 'connect' listener. Each time you call .connect it cues the callback (adds a listener) even though the connection fails. So when it finally does connect all those callbacks get called. So if you use .once('connect'.. instead that won't happen. Below are logging statements from my project's client code that led me to this observation. ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout ENOENT timeout (node:21061) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit ^=== if you timeout and try .connect again eventually you hit this limit ENOENT timeout <==== here is where the connection finally happens connecting <==== now all those listener callbacks fire. connecting connecting connecting connecting connecting connecting connecting connecting connecting connecting so try this version below instead const net = require('net') const HOST = '127.0.0.1' const PORT = 9000 const client = new net.Socket() const connect = () => {client.connect(PORT, HOST)} client.once('connect', function(){ console.log('CONNECTED TO: ' + HOST + ':' + PORT) client.write('I am Superman!') }) client.on('error', function(e) { if(e.code == 'ECONNREFUSED') { console.log('Is the server running at ' + PORT + '?') console.log('Waiting for 5 seconds before trying port:' + PORT + ' again') setTimeout(connect,5000) } }) connect() client.on('data', function(data) { console.log('DATA: ' + data) client.destroy() }) client.on('close', function() { console.log('Connection closed') })
unknown
d19257
test
Convert the AGE column to float first, to avoid trying to convert string to float: df['AGE'] = df['AGE'].str.replace('%', '', regex=True).astype(float) I would suppose to then replace missing AGE values with -1 instead of 'N/A' to simplify binning. df['AGE'] = df['AGE'].fillna(-1) So, strictly speaking, it would not have been necessary here to do the conversion to float first to avoid the error message. Nevertheless this is still the sensible order of steps. Then, define custom ranges and do the binning: ranges = [-1, 0, 18, 30, 50, 65, 75, np.inf] labels = ['Not_Availabe', '18 and under', '19-30', '31-50', '51-65', '66-75', '75+'] df['AGE_labeled'] = pd.cut(df['AGE'], bins=ranges, labels=labels) # print the result print(df['AGE_labeled'].value_counts()) Note: I created the following dummy data for testing (hope it fits the question, as no sample data was given) import numpy as np import pandas as pd # dummy data length = 1000 data = { 'STUDENT_ID': np.random.randint(1000, 9999, length), 'AGE': np.random.randint(0, 99, length), } df = pd.DataFrame (data) df['AGE'] = df['AGE'].astype(str) # convert AGE value to str (as I assume from your question that this is the case) df.loc[df.sample(frac=0.1).index,'AGE'] = np.nan # randomly set some values to nan
unknown
d19258
test
Ok, so you run INSERT INTO RegressionTable ( Ticker, TradeDate, HighPrice, LowPrice, TradePrice, TotalVolume, TotalValue ) VALUES (?, ?, ?, ?, ?, ?, ?) for every line in newregression.txt, and now you want to do it for multiple files. Why not wrap your code above in a subroutine, say insert_file(), then call it per file in a loop... my @files = qw(red.txt green.txt blue.txt); for my $file (@files) { insert_file($file); } Or if the target table varies per file, define a hash: my %files = ( 'red.txt' => 'RedTable', 'blue.txt' => 'BlueTable' ); while ( my ($file, $table) = each %files ) { insert_file($file, $table); }; Not sure how you'd use Bulk Insert given the field separator in your data file seems to be indeterminate (i.e. the regex /(.*)(..)(..)/ defines field boundaries). You may need to use the FORMATFILE option. Also, if you generate a BULK INSERT statement using DBI, be aware that the user your SQL Server runs as must be able to read your data files over the filesystem (networked, local or otherwise).
unknown
d19259
test
I have created a CSV tax rates import file for all EU countries based on the DE VAT rate (19%). Magento CSV Steuersätze Import-Datei für alle EU-Länder (2013). Ich habe eine CSV Steuersätze Import-Datei für alle EU-Länder auf dem DE MwSt.-Satz (19%) basiert. (magento_eu_tax_rates.csv) Code,Country,State,Zip/Post Code,Rate,Zip/Post is Range,Range From,Range To,default,germany AT,AT,*,,19,,,,VAT, BE,BE,*,,19,,,,VAT, BG,BG,*,,19,,,,VAT, HR,HR,*,,19,,,,VAT, CY,CY,*,,19,,,,VAT, CZ,CZ,*,,19,,,,VAT, DK,DK,*,,19,,,,VAT, EE,EE,*,,19,,,,VAT, FI,FI,*,,19,,,,VAT, FR,FR,*,,19,,,,VAT, DE,DE,*,,19,,,,VAT, GR,GR,*,,19,,,,VAT, HU,HU,*,,19,,,,VAT, IE,IE,*,,19,,,,VAT, IT,IT,*,,19,,,,VAT, LV,LV,*,,19,,,,VAT, LT,LT,*,,19,,,,VAT, LU,LU,*,,19,,,,VAT, MT,MT,*,,19,,,,VAT, NL,NL,*,,19,,,,VAT, PL,PL,*,,19,,,,VAT, PT,PT,*,,19,,,,VAT, RO,RO,*,,19,,,,VAT, SK,SK,*,,19,,,,VAT, SI,SI,*,,19,,,,VAT, ES,ES,*,,19,,,,VAT, SE,SE,*,,19,,,,VAT, GB,GB,*,,19,,,,VAT, A: An up to date CSV for EU tax rates in 2014 that works with Magento 1.9.0.1 (note that this is the current UK VAT rate of 20%). It should also be noted that Iceland, Liechtenstein, Norway and Switzerland are exempt from UK VAT. Code,Country,State,Zip/Post Code,Rate,Zip/Post is Range,Range From,Range To,default GB,GB,*,,20.0000,,,,VAT AL,AL,*,,20.0000,,,,VAT AD,AD,*,,20.0000,,,,VAT AT,AT,*,,20.0000,,,,VAT BY,BY,*,,20.0000,,,,VAT BE,BE,*,,20.0000,,,,VAT BA,BA,*,,20.0000,,,,VAT BG,BG,*,,20.0000,,,,VAT HR,HR,*,,20.0000,,,,VAT CY,CY,*,,20.0000,,,,VAT CZ,CZ,*,,20.0000,,,,VAT DK,DK,*,,20.0000,,,,VAT EE,EE,*,,20.0000,,,,VAT FO,FO,*,,20.0000,,,,VAT FI,FI,*,,20.0000,,,,VAT FR,FR,*,,20.0000,,,,VAT DE,DE,*,,20.0000,,,,VAT GI,GI,*,,20.0000,,,,VAT GR,GR,*,,20.0000,,,,VAT HU,HU,*,,20.0000,,,,VAT IS,IS,*,,0.0000,,,,VAT IE,IE,*,,20.0000,,,,VAT IT,IT,*,,20.0000,,,,VAT LV,LV,*,,20.0000,,,,VAT LB,LB,*,,20.0000,,,,VAT LI,LI,*,,0.0000,,,,VAT LT,LT,*,,20.0000,,,,VAT LU,LU,*,,20.0000,,,,VAT MT,MT,*,,20.0000,,,,VAT MD,MD,*,,20.0000,,,,VAT MC,MC,*,,20.0000,,,,VAT ME,ME,*,,20.0000,,,,VAT NL,NL,*,,20.0000,,,,VAT NO,NO,*,,0.0000,,,,VAT PL,PL,*,,20.0000,,,,VAT PT,PT,*,,20.0000,,,,VAT RO,RO,*,,20.0000,,,,VAT RS,RS,*,,20.0000,,,,VAT SK,SK,*,,20.0000,,,,VAT SI,SI,*,,20.0000,,,,VAT ES,ES,*,,20.0000,,,,VAT SJ,SJ,*,,20.0000,,,,VAT SE,SE,*,,20.0000,,,,VAT CH,CH,*,,0.0000,,,,VAT TR,TR,*,,20.0000,,,,VAT UA,UA,*,,20.0000,,,,VAT VA,VA,*,,20.0000,,,,VAT
unknown
d19260
test
Use glPushMatrix() to push the current matrix, do glTranslate and draw the wall, then glPopMatrix() and draw the plane. This should only translate the wall. The problem is you seem to be doing the translate in display instead of in DrawWall where it should be. A: A few things to expand on what Jesus was saying. When drawing the airplane you don't want to apply any transformations to it, so you need to have the identity matrix loaded: Push the current modelview matrix Load the identity matrix <=== this is the step you're missing Draw the airplane Pop the modelview matrix When drawing the wall you want the current transformations to apply, so you do not push the current matrix or else you've wiped out all of the translations you've built up. Remove the Push/Pop operations from DrawWall() At some point in your initialization, before Display is called for the first time, you need to set the modelview matrix to the identity matrix. For each subsequent call to Display, -0.02 will then be added to your translation in the y-direction.
unknown
d19261
test
How about this: select group_concat(name) as names, time from table t group by time having count(*) > 1; This will give you output such as: Names Time Richard,Luigi 8:00 . . . Which can then format on the application side.
unknown
d19262
test
Its ok! I find the answer here http://www.javajee.com/soap-binding-style-encoding-and-wrapping Bare option only can use one parameter. When we use Bare, the message request must have zero or one element into Body. The solution is make an object with all parameters we want , and send this object to the method.
unknown
d19263
test
a base solution. To split df by ID, then paste the Attributes together. Then rbind the list of results. do.call(rbind, by(df, df$ID, function(x) data.frame(ID=x$ID[1], Attributes=paste(x$Attributes, collapse=",")) )) data: df <- read.table(text="ID Attributes 1 apple 1 banana 1 orange 1 pineapple 2 apple 2 banana 2 orange 3 apple 3 banana 3 pineapple", header=TRUE) A: A tidyverse approach would be to group_by your ID and summarise with paste. library(dplyr) df <- read.table(text = " ID Attributes 1 apple 1 banana 1 orange 1 pineapple 2 apple 2 banana 2 orange 3 apple 3 banana 3 pineapple", header = TRUE, stringsAsFactors = FALSE) df %>% group_by(ID) %>% summarise( Attributes = paste(Attributes, collapse = ", ") ) # # A tibble: 3 x 2 # ID Attributes # <int> <chr> # 1 1 apple, banana, orange, pineapple # 2 2 apple, banana, orange # 3 3 apple, banana, pineapple
unknown
d19264
test
First of all, your network might not be able to handle this no matter what you do, but I would go with UDP. You could try splitting up the images into smaller bits, and only display each image if you get all the parts before the next image has arrived. Also, you could use RTP as others have mentioned, or try UDT. It's a fairly lightweight reliable layer on top of UDP. It should be faster than TCP. A: You should consider using Real-time Transport Protocol (aka RTP). The underlying IP protocol used by RTP is UDP, but it has additional layering to indicate time stamps, sequence order, etc. RTP is the main media transfer protocol used by VoIP and video-over-IP systems. I'd be quite surprised if you can't find existing C# implementations of the protocol. Also, if your image files are in JPEG format you should be able to produce an RTP/MJPEG stream. There are quite a few video viewers that already have native support for receiving and displaying such a stream, since some IP webcams output in that format. A: I'd recommend using UDP if: * *Your application can cope with an image or small burst of images not getting through, *You can squeeze your images into 65535 bytes. If you're implementing a video conferencing application then it's worth noting that the majority use UDP. Otherwise you should use TCP and implement an approach to delimit the images. One suggestoin in that regard is to take a look at the RTP protocol. It's sepcifically designed for carrying real-time data such as VoIP and Video. Edit: I've looked around quite a few times in the past for a .Net RTP library and apart from wrappers for non .Net libraries or half completed ones I did not have much success. I just had another quick look and this may be of this one ConferenceXP looks a bit more promising. A: The other answers cover good options re: UDP or a 'real' protocol like RTP. However, if you want to stick with TCP, just build yourself a simple 'message' structure to cover your needs. The simplest? length-prefixed. First, send the length of the image as 4 bytes, then send the image itself. Easy enough to write the client and server for. A: If the latest is more important than every picture, UDP should be your first choice. But if you're dealing with frames lager than 64K your have to-do some form of re-framing your self. Don't be concerned with fragmented frames, as you'll have to deal with it or the lower layer will. And you only want completed pictures. What you will want is some form of encapsulation with timestamps/sequences.
unknown
d19265
test
The question you want answered When you use variable interpolation, that value to interpolate is going to resolve before the original string. In this case, your Array.each is doing it's thing and printing out "1" then "2" and finally "3". It returns the original Array of [1, 2, 3] output> 123 # note new line because we used print Now that your interpolation is resolved, the rest of the puts finishes up and uses the returned value of [1, 2, 3] and prints: output> The numbers you entered in the array were: [1, 2, 3]\n To get the final output of: output> 123The numbers you entered in the array were: [1, 2, 3]\n The question everyone WANTS to answer :) http://www.ruby-doc.org/core-2.1.4/Array.html#method-i-each When calling Array.each with a block, the return is self. This is "bad" in your case, because you don't want self returned. It will always return the same thing, your original array. puts "The numbers you entered in the array were: #{array.each{|num| num*2}}" The numbers you entered in the array were: [1, 2, 3] # WAT? As a Sergio Tulentsev said, use .map and .join puts "The numbers you entered in the array were: #{array.map{|num| num*2}.join(' ')}" The numbers you entered in the array were: 2 4 6
unknown
d19266
test
In your password! method, you need to specify that you want to access the instance variable password_digest. Change to: def password! self.password_digest = Digest::SHA1.hexdigest(password) end
unknown
d19267
test
Ok the answer is simple. This is not XmlAttribute ... this is XmlElement. Change attribute to: [XmlElement("startDate")] public DateTime StartDate { get; set; } Are you sure element "weeks" works properly and is marked with XmlAttribute ?
unknown
d19268
test
For that i simply use my own path and the name of the file. fis = new FileInputStream(dirList[i]) ZipEntry anEntry = new ZipEntry(rootName + "/" + dirList[i].name) zos.putNextEntry(anEntry) with rootName = "" if your zip file does not contain any folder. Basically your path must be relative to the root of your zip file. I hope you understand what i mean. A: String name = new File(filesToZipP[i]).getName(); out.putNextEntry(new ZipEntry(name));
unknown
d19269
test
The Input text contains '\n' and that means that the string is not an alphanumeric string. When I read I push the enter button and that means one more character in the string.
unknown
d19270
test
You need to use UINavigationController's delegate: @property(nonatomic, assign) id<UINavigationControllerDelegate> delegate; Set it to an object of a class that conforms to this protocol, which implements this method: - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated; In this method you'll know when you have finished showing a view controller, thus if it was animated the animation has ended. Notice that if you push multiple view controllers you have to keep track of them. Documentation: UINavigationController UINavigationControllerDelegate
unknown
d19271
test
Asynchronously, by default. If you need them to be one-after-the-other, you can do a few things: * *Place the second in the callback of the first. *Set $.ajax({async:false}) *You could possibly even set these up in a queue. The cleanest way is probably option 2. A: Yes, the full call for load is: load( url, [data], [callback] ) the third optional parameter is a callback method that will be called when the asynchronous load method completes.
unknown
d19272
test
First, I will challenge your belief that you actually need to do that. with open("babar.txt", 'rb') as file: text = file.read() print(text[42]) then, what is the actual way to accomplish this: with open("babar.txt", 'rb') as file: file.seek(42) print(file.read(1)) The first loads everything in RAM, and (if your file fits on RAM) it is incredibly fast. The second way is incredibly slow. To go back one byte, you can do this: with open("babar.txt", 'rb') as file: file.seek(42) print(file.read(1)) file.seek(-1, 1) # goes back by one relative to current position print(file.read(1)) # reeds the same char file.seek(-1, 2) # goes at the end of the file print(file.read(1)) # reads the last char Check the whence argument of seek(). Generally, one can assume making a RAM access is 1000x faster than making a HDD access, so this is probably 1000x slower than the first option. A: i just found a solution using file.seek(file.tell()-1) so it goes back if i need it to go thank you all for your help and time.
unknown
d19273
test
A little feedback about my issue, I was looking at wrong place and should have open my eyes wider. I had a non relative link for an external font : <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic' rel='stylesheet' type='text/css'> Changed to <link href='//fonts... No more issues
unknown
d19274
test
The Nexus 7 has a screen resolution of 1280X800 (source). It is somewhat surprising then that the meta tag is changing, but not surprising that your website stays the same. EDIT: Ok, so it's not the width then. You might try reading this article from MDN and make sure that the meta viewport can do what you are expecting. It is not quite clear what you want it to do, but the meta viewport tag does not make drastic changes, so you might just be missing it.
unknown
d19275
test
If you want all possible combinations regardless or left/right order you can do: select a.player_id, b.player_id from player a join player b on b.player_id < a.player_id
unknown
d19276
test
the correct syntax is the following: agent.typeID==1 ? PRD6 : PRD7 but if you have lots of options, you should call a function here that returns a PalletRack and generate the if/else statement in that function
unknown
d19277
test
try document.select("tr.AccentDark td.tableheader")
unknown
d19278
test
It is possible. List of mobile user-agents. But instead of iterating over requests.get() result, you need to pass it to BeautifulSoup object, and then select a certain element (container with data) and iterate over it. # container with mobile layout data for mobile_result in soup.select('.xNRXGe'): title = mobile_result.select_one('.q8U8x').text link = mobile_result.select_one('a.C8nzq')['href'] snippet = mobile_result.select_one('.VwiC3b').text Code and example in the online IDE: from bs4 import BeautifulSoup import requests, lxml headers = { 'User-agent': 'Mozilla/5.0 (Linux; Android 7.0; LGMP260) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36' } params = { 'q': 'how to create minecraft server', 'gl': 'us', # country to search from 'hl': 'en', # language } html = requests.get('https://www.google.com/search', headers=headers, params=params) soup = BeautifulSoup(html.text, 'lxml') for mobile_result in soup.select('.xNRXGe'): title = mobile_result.select_one('.q8U8x').text link = mobile_result.select_one('a.C8nzq')['href'] snippet = mobile_result.select_one('.VwiC3b').text print(title, link, snippet, sep='\n') ----------- ''' How to Setup a Minecraft: Java Edition Server – Home https://help.minecraft.net/hc/en-us/articles/360058525452-How-to-Setup-a-Minecraft-Java-Edition-Server How to Setup a Minecraft: Java Edition Server · Go to this website and download the minecraft_server. · After you have downloaded it, make a folder on your ... Minecraft Server Download https://www.minecraft.net/en-us/download/server Download the Minecraft: Java Edition server. Want to set up a multiplayer server? · Download minecraft_server.1.17.1.jar and run it with the following command:. # other results ''' Alternatively, you can achieve the same thing by using Google Organic Results API from SerpApi. It's a paid API with a free plan. Check out the playground. The difference in your case is that you don't have to figure out things (well, you have to, but it's a much more straightforward process), don't have to maintain the parser over time, and iterate over structured JSON instead. Code to integrate: import os from serpapi import GoogleSearch params = { "api_key": os.getenv("API_KEY"), "engine": "google", "q": "how to create minecraft server", "hl": "en", "gl": "us", "device": "mobile" # mobile results } search = GoogleSearch(params) results = search.get_dict() for result in results["organic_results"]: print(result['title']) print(result['link']) ----------- ''' How to Setup a Minecraft: Java Edition Server – Home https://help.minecraft.net/hc/en-us/articles/360058525452-How-to-Setup-a-Minecraft-Java-Edition-Server How to Setup a Minecraft: Java Edition Server · Go to this website and download the minecraft_server. · After you have downloaded it, make a folder on your ... Minecraft Server Download https://www.minecraft.net/en-us/download/server Download the Minecraft: Java Edition server. Want to set up a multiplayer server? · Download minecraft_server.1.17.1.jar and run it with the following command:. # other results ''' Disclaimer, I work for SerpApi.
unknown
d19279
test
Please see this - you may have IO issues - and physical drive issues http://blogs.msdn.com/chrissk/archive/2008/06/19/i-o-requests-taking-longer-than-15-seconds-to-complete-on-file.aspx
unknown
d19280
test
First of all we have to make more typescript<6> friendly. It's not enough just to get the canvas object like another HTML element using the id. In this case we should help a little, so my first change will be: this.canvas = document.getElementById('canvas'); FOR => this.canvas = <HTMLCanvasElement>document.getElementById('canvas'); Then your function will look something like this: public markPoint(event) { var position = event.center; let ctx: CanvasRenderingContext2D = this.canvas.getContext("2d"); ctx.beginPath(); ctx.arc(position.x, position.y, 20, 0, 2 * Math.PI); ctx.fillStyle = '#00DD00'; ctx.fill(); } Hope this help.
unknown
d19281
test
Firebase Authentication was not designed to support this case. It's intended for users to be able to use a Firebase app on multiple devices. It's also expected that a user could create multiple accounts. There is no way of limiting the number of accounts a person can create.
unknown
d19282
test
If you are checkpointing then position given by setStartingPosition won't have any use. it is only used if there is no checkpoint found. Please see sample code and description here - https://github.com/Azure/azure-event-hubs-spark/blob/564267dd1287b0593f8914b1acf8ff7796b58e3b/docs/spark-streaming-eventhubs-integration.md#per-partition-configuration
unknown
d19283
test
Assuming that dataframe is named 'dat' then aggregate.formula which is one of the generics of aggregate: > aggregate( Z ~ X + Y, data=dat, FUN=sum) X Y Z 1 1 1 2435 2 2 1 534 3 1 2 91 4 2 2 97 5 1 3 1924 6 2 3 161 7 1 4 582 8 2 4 122 9 2 5 403 Could also have used xtabs which returns a table object and then turn it into a dataframe with as.data.frame: as.data.frame( xtabs( Z ~ X+Y, data=dat) )
unknown
d19284
test
Please check this JSFiddle I've modified this line: <a href="" onclick="showPages('2')">2</a> to this: <a href="#" onclick="showPages('2')">2</a>
unknown
d19285
test
It would be useful to have some versioning system (git, mercurial, svn...). Can you mount the network drive in Windows? (see here ). This would at least allow you to easily create project from existing sources (although working via network could be quite slow) One hacky way I can think of is to: * *mount the network drive as described above and map it to some letter, say Z *install local FTP server (e.g. FileZilla) *configure FileZilla FTP server to use the network drive as "ftp home" (aka the folder which FileZilla will use for saving files sent over FTP) - simply use Z:\ path to point to the mounted network drive mapped to letter Z *in NetBeans, create a new PHP project from remote server (where remote server is actually your local FileZilla server) In theory, this should work. A: Here is the fragment from NetBeans site: To set up a NetBeans project for an existing web application: Choose File > New Project (Ctrl-Shift-N on Windows/Cmd-Shift-N on OS X). Choose Java Web > Web Application with Existing Sources. Click Next. In the Name and Location page of the wizard, follow these steps: In the Location field, enter the folder that contains the web application's source root folders and web page folders. Type a project name. (Optional) Change the location of the project folder. (Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries in NetBeans IDE for more information on this option. (Optional) Select the Set as Main Project checkbox. When you select this option, keyboard shortcuts for commands such as Clean and Build Main Project (Shift-F11) apply to this project. Click Next to advance to the Server and Settings page of the wizard. (Optional) Add the project to an existing enterprise application. Select a server to which to deploy. If the server that you want does not appear, click Add to register the server in the IDE. Set the source level to the Java version on which you want the application to run. (Optional) Adjust the context path. By default, the context path is based on the project name. Click Next to advance to the Existing Sources and Libraries page of the wizard. Verify all of the fields on the page, such as the values for the Web Pages Folder and Source Package Folders. Click Finish.
unknown
d19286
test
You can disable the animation from BottomSheetDialogFragment override fun onResume() { super.onResume() // Disable dialog window animations for this instance dialog?.window?.setWindowAnimations(-1) }
unknown
d19287
test
Use lookaheads (zero-width assertion) for both patterns: (?=(foo))(?=(fooba)) RegEx Demo
unknown
d19288
test
Converting VS2010 setup project to a Wix script Please find instructions for anybody else who'd find it useful 1) Install WixToolkit and WixEdit 2) Build VS2010 setup project 3) Create new Wix project within the solution. 4) Remove the default product.wxs file from the Wix project 5) Copy the setup MSI file to the root directory of the Wix project 6) Run WixEdit application 7) Open the setup MSI file in WixEdit (This should generate files and directories) 7) Add directories and files generated by WixEdit to the Wix project 8) Compile Wix Setup Project and fix errors 9) Delete the original msi file from the wix project Re Check boxes not working "Error 5 The Control element must have a value for exactly one of the Property or CheckBoxPropertyRef attributes" Go to the error line in the script <Control Id="Checkbox1" Type="CheckBox" X="18" Y="108" Width="348" Height="12" Text="{\VSI_MS_Shell_Dlg13.0_0_0}Install Main Application" TabSkip="no"/> Change it so it reads (or appropriate changes) <Control Id="Checkbox1" Type="CheckBox" X="18" Y="108" Width="348" Height="12" Text="{\VSI_MS_Shell_Dlg13.0_0_0}Install Main Application" TabSkip="no" Property="CHECKBOXA1" CheckBoxValue="1" /> CheckBoxValue="1" was the missing attribute that caused my checkboxes to be disabled
unknown
d19289
test
You should not need to refresh the page in order to save information into the PHP Session object. PHP Session information is stored on the server, so you can do an asynchronous HTTP request to the backend, and store information the PHP Session. I would suggest using the jQuery.ajax function (http://api.jquery.com/jQuery.ajax/) to do your async HTTP requests. If you are not familiar with jQuery, I highly suggest you get familiar with it. I also suggest you look into how AJAX works. Also, if you are using the PHP session, if you are not using some kind of framework which does session management, you must make sure to call session_start() before using the $_SESSION variable.
unknown
d19290
test
You need to create the other types as database objects too: create type array1 is varray(1000) of integer; / create type array2 is varray(1000) of integer; / create or replace type object as object ( exar1 array1, exar2 array2 ); Of course, since array1 and array2 types are identical, you don't really need them both: create type array is varray(1000) of integer; / create or replace type object as object ( exar1 array, exar2 array ); A: Hey please try to create first TABLE TYPE and then reference it while creating the OBJECT Type. Let me know if this helps --Table type creation first CREATE OR REPLACE TYPE NUMBER_NTT1 IS TABLE OF NUMBER; CREATE OR REPLACE TYPE NUMBER_NTT IS TABLE OF NUMBER; --Object creation after that CREATE OR REPLACE TYPE object AS OBJECT ( exAr1 NUMBER_NTT, exAr2 NUMBER_NTT1 );
unknown
d19291
test
Your code must use backticks for all columns and not apostrophes $sql = "INSERT INTO `users` (`id`, `name`, `email`, `login_status`, `last_login`) VALUES (null, :name, :email, :login_status, :last_login)"; For your Problem with no database selected check your connection string, if there is a Databasename . But you can always send a sql query use Databasename; Or use the correct sy code instead old db= it must be dbname= class db_conn{ private $host = 'localhost'; private $db = 'webapp'; private $user = 'root'; private $pass = ''; public function connect(){ try{ $conn = new PDO('mysql:host=' . $this->host . '; dbname=' . $this->db, $this->user, $this->pass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $conn; }catch(PDOException $e){ echo 'Database Error: ' . $e->getMessage(); } } A: You have single quotes arround table name users Change this line : $sql = "INSERT INTO 'users' ('id', 'name', 'email', 'login_status', 'last_login'); To : $sql = "INSERT INTO users (id, name, email, login_status, last_login) VALUES (null, :name, :email, :login_status, :last_login)";
unknown
d19292
test
There's nothing wrong with your code, so be sure you have properly installed the plugin and enabled it, else the trigger won't work
unknown
d19293
test
Its showing this error because you are again setting the browser's page on html finished, which is wrong, to access network access manager you should first take the manager then set the manager with page and then set the browser page. let me know if you don't get this.
unknown
d19294
test
The date filter is about formatting DateTime Object, so if you pass a string this will be passed to the constructor of the DateTime object then to the format method, so in your case, you need to format the string that looks good for a DateTime constructor as example {{ "2013-3-26"|date("d/m/Y") }} From the doc: The format specifier is the same as supported by date, except when the filtered data is of type DateInterval, when the format must conform to DateInterval::format instead. And also about string format: The date filter accepts strings (it must be in a format supported by the strtotime function), DateTime instances, or DateInterval instances. For instance, to display the current date, filter the word "now": Try this in this twigfiddle A: If you use /'s as delimiter the expected format is m/d/Y, To pass the date as day, month, year you need to use a - as delimiter {{ "26-03-2017" | date('d/m/Y') }} fiddle
unknown
d19295
test
Just use the OrderBy method: Records.OrderBy(record => record.Started) or: from r in Records order by r.Started select r A: Could it be this easy? records.OrderBy(r=>r.Started)
unknown
d19296
test
There is a dynamic cast() operation you can apply to the result: return type.cast(ThreadLocalRandom.current().nextInt()); I'd be curious to know how you use your method. It seems likely there would be a cleaner way to embody and access this functionality.
unknown
d19297
test
First of all you should not modify the class generated by Qt Designer so before applying my solution you must regenerate the .py so you must use pyuic again: pyuic5 your_ui.ui -o design.py -x onsidering the above, the problem is that you have a time consuming task blocking the eventloop preventing it from doing its jobs like reacting to user events. A possible solution for this is to use threads: import sys import threading from PyQt5 import QtCore, QtGui, QtWidgets import excel2img import openpyxl as xl from design import Ui_MainWindow def task(fileName): wb = xl.load_workbook(fileName, read_only=True) ws = wb.active a, b = 2, 2 x, y = 1, 44 z, w = 1, 44 max_row = ws.max_row temp = 0 loop_num = 0 while temp < max_row: temp += 52 loop_num += 1 print(loop_num) for i in range(loop_num * 2): if i % 2 == 0: cell = "Sheet1!A{}:F{}".format(x, y) ccell = "B{}".format(a) var = ws[ccell].value a += 52 x += 52 y += 52 else: cell = "Sheet1!H{}:M{}".format(z, w) ccell = "I{}".format(b) var = ws[ccell].value b += 52 z += 52 w += 52 name = "{}.png".format(var) excel2img.export_img(fileName, name, "", cell) print("generating image {}".format(i + 1)) class MainWindow(QtWidgets.Ui_MainWindow, Ui_MainWindow): def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) # Widgets self.btn_openfile.clicked.connect(self.openfile) self.btn_exit.clicked.connect(self.exit) self.btn_convert.clicked.connect(self.convert) fileName = "" @classmethod def openfile(cls): cls.fileName, _ = QtWidgets.QFileDialog.getOpenFileName( None, "Open File", "", "Excel files (*.xlsx *xls)" ) def exit(self): quit_msg = "Are you sure you want to exit the program?" reply = QtWidgets.QMessageBox.question( None, "Prompt", quit_msg, QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, ) if reply == QtWidgets.QMessageBox.Yes: sys.exit() def convert(self): threading.Thread(target=task, args=(self.fileName,), daemon=True).start() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) A: You should call QtCore.QCoreApplication.processEvents() within your for loop to make the Qt's event loop proceed the incoming event (from keyboard or mouse) Hope i have helped
unknown
d19298
test
This is how you would do it. (Meaning almost like you did it) (https://reactjs.org/docs/react-api.html#createelement) But you have an extra semicolon inside the create argument list. const testRenderer = ReactTestRenderer.create( React.createElement('div', null, 'Text') );
unknown
d19299
test
try to use this code if (count($results) > 0) { $this->set("message", "Sorry, that data already exists. <a href=\"http://www.example.com/\">Need help?</a>"); return; } A: $this->set("message", 'Sorry, that data already exists.<a href="http://www.example.com/">'); Doing this will get the anchor in as part of the string, and if you need to echo it, it should be generated as HTML. A: it's simply: if (count($results) > 0) { $this->set("message", 'Sorry, that data already exists. <a href="http://www.example.com/">'); return; } Better use single quotes ' and you don't need to escape " in tags attributes. Or store link in variable: if (count($results) > 0) { $link = '<a href="http://www.example.com/">'; $this->set("message", "Sorry, that data already exists. $link"); return; }
unknown
d19300
test
AdDUplex is just for promote your app not for gain money :) In your case, you can't have ads in debug mode. Send your app in beta test and look if ads is available. Pub center have the best fill rate in wp8 platform. But you need to choice your app usage. If you app is a type like rss flow or news you need ads because you will have a lot of users connected for a long time and frequently. If you app is a productivity app, you will add in app purchase or send your app like a paid app or donation. Don't forget if you add ads, the possibility to remove.
unknown