Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-09-23T21:24:57Z
Updated: 2 hours 5 min ago

How to append a new row on pandas dataframe with single column?

Thu, 09/21/2017 - 08:05

This question might seems easy but I could not find any solution for it.

Say I have a CSV file like this without headers.

121 334 313 930

I want to add/append new row with number 0 at the bottom like this

121 334 313 930 0

I tried with the following method but did not succeed.

import pandas as pd import os folder_path = "/home/Ling/test/" df = pd.read_fwf(folder_path + "test1.csv", usecols=[0], delimiter=",") df2 = pd.DataFrame([[0]], dtype=int) print df.append(df2, ignore_index=True)

The result

NaN 121 NaN 334 NaN 313 NaN 930 0.0 NaN

I am following this example

I even try to change from [[0]] to [[0,]] and [[,0]] but did not work. Is there anything that I miss here in the code?

Thank you for your help and suggestion.

REST API to see the file content in storage account

Thu, 09/21/2017 - 07:03

In azure via rest calls, for a particular storage account, I have files stored in Storage accounts > File service > directory > my files. But using rest API i am only able to see the directory. I am unable to see the files stored under that directory. And more specifically I want to see the content of the file.Is there ant rest API for the above?

Angular JS. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response

Thu, 09/21/2017 - 06:37

I have tried all things, use CORS plugin. disable web-security in chrome. Response is coming in POSTMAN but not able to fetch it in $http.

$http({ url: "https://interview-api-staging.bytemark.co/books", method: 'GET', headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET,OPTIONS,PUT,DELETE', 'Access-Control-Allow-Headers': 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since' } }).then(function(d) { console.log(d); });

Show a loading bar while in R shiny while sourcing a script

Thu, 09/21/2017 - 06:36

I have a shiny app, that allows user to refresh the data in the front end via a button, and shows the data. My app.R is as below:

library(shiny) file_name <- "sample.csv" bkg_color <- "red" # Define UI for application ui <- fluidPage( actionButton("refresh", "", icon("refresh") ), tableOutput("table"), uiOutput("slider") ) # Define server logic required server <- function(input, output, session) { observeEvent(input$refresh,{ source("updatedata.R") showModal(modalDialog( title = "", "Data refreshed", easyClose = TRUE, footer = NULL )) }) # observe the raw file, and refresh if there is change every 5 seconds raw <- reactivePoll(5000, session, checkFunc = function(){ if (file.exists(file_name)) file.info(file_name)$mtime[1] else "" }, valueFunc = function(){ read.csv(file_name) }) output$table <- renderTable(raw()) output$slider <- renderUI({ req(raw()) tagList( # styling slider bar tags$style(HTML(paste0(".js-irs-0 .irs-single, .js-irs-0 .irs-bar-edge, .js-irs-0 .irs-bar {background: ", bkg_color,";border-top: ",bkg_color,";border-bottom: ",bkg_color,"; border: ",bkg_color,"}"))), sliderInput("date","", min = min(raw()$v1), max = max(raw()$v1), value = max(raw()$v1)) ) }) } # Run the application shinyApp(ui = ui, server = server)

I also have another updatedata.R script that does the data update, as below:

file_name <- "sample.csv" temp <- data.frame(v1 =runif(10, min = 0, max = 100), v2 = Sys.time() ) write.csv(x =temp, file = file_name,row.names = FALSE ) Sys.sleep(10)

Whenever the user clicks the refresh button from the front end, it will performs data update. After the data finishes refreshing, there is a window prompt says that the data is refreshed. My problem is that I would also like to have 'some indication' while the data is being refreshed. I tried with shinycssloaders package, and used withSpinner(tableOutput("table")), but this does not meet my needs. Is there any option that I can explore?

Crash happening when the application is going to background

Thu, 09/21/2017 - 04:17

I dont know how to repro this crash but is is happening a lot. The stack shows that the application is going to background at #16 below.

I could not find any help regarding this crash.

When the application is going to background, why its trying to process keyboard tasks ? Lines #1-5 shows that its trying to do some keyboard tasks.

What might be happening here ?

# 1 _dispatch_barrier_sync_f_slow + 518 (libdispatch.dylib + 0x00010c68) 0x0 # 2 __88-[UIKeyboardLayout recognizer:releaseTouchToLayoutWithId:startPoint:endPoint:whenReady:]_block_invoke + 95 (UIKit + 0x004297fd) 0x0 # 3 __88-[UIKeyboardLayout recognizer:releaseTouchToLayoutWithId:startPoint:endPoint:whenReady:]_block_invoke + 93 (UIKit + 0x004297fb) 0x74cd0c8 # 4 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 393 (UIKit + 0x0003737d) 0x74cd0f8 # 5 __39-[UIKeyboardLayout resetHRRLayoutState]_block_invoke + 625 (UIKit + 0x0042a809) 0x74cd118 # 6 _dispatch_client_callout + 21 (libdispatch.dylib + 0x00001781) 0x74cd2b0 # 7 _dispatch_barrier_sync_f_invoke + 49 (libdispatch.dylib + 0x0000da33) 0x74cd2c0 # 8 -[UIKeyboardLayout resetHRRLayoutState] + 107 (UIKit + 0x0042a56b) 0x74cd2dc # 9 +[UIKeyboardImpl applicationWillResignActive:] + 223 (UIKit + 0x0012fe35) 0x74cd304 # 10 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 9 (CoreFoundation + 0x000a6db7) 0x74cd318 # 11 _CFXRegistrationPost + 381 (CoreFoundation + 0x000a66f7) 0x74cd320 # 12 ___CFXNotificationPost_block_invoke + 39 (CoreFoundation + 0x000a64df) 0x74cd35c # 13 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1241 (CoreFoundation + 0x00101307) 0x74cd378 # 14 _CFXNotificationPost + 539 (CoreFoundation + 0x0000a033) 0x74cd6f0 # 15 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65 (Foundation + 0x000060ab) 0x74cd8bc # 16 -[UIApplication _deactivateForReason:notify:] + 815 (UIKit + 0x00073e0f) 0x74cd8d0 # 17 __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 93 (UIKit + 0x00282255) 0x74cd908 # 18 __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 165 (FrontBoardServices + 0x00020cfd) 0x74cd928 # 19 __NSIndexSetEnumerate + 437 (Foundation + 0x000af3df) 0x74cd9b8 # 20 -[NSIndexSet enumerateIndexesWithOptions:usingBlock:] + 65 (Foundation + 0x00030bcd) 0x74cda48 # 21 -[BSSettingsDiff inspectChangesWithBlock:] + 101 (BaseBoard + 0x00035a57) 0x74cda6c # 22 -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 89 (FrontBoardServices + 0x0001b025) 0x74cda98 # 23 -[FBSSettingsDiffInspector inspectDiff:withContext:] + 299 (FrontBoardServices + 0x00020b5b) 0x74cdab8 # 24 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 101 (UIKit + 0x00283427) 0x74cdb20 # 25 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 823 (UIKit + 0x00283131) 0x74cdb50 # 26 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 411 (UIKit + 0x00588aa1) 0x74cdc18 # 27 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke + 209 (FrontBoardServices + 0x0000af65) 0x74cdc7c # 28 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 17 (FrontBoardServices + 0x00035c11) 0x74cdca8 # 29 -[FBSSerialQueue _performNext] + 219 (FrontBoardServices + 0x00035acb) 0x74cdcb8 # 30 -[FBSSerialQueue _performNextFromRunLoopSource] + 43 (FrontBoardServices + 0x00035db5) 0x74cdd94 # 31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 11 (CoreFoundation + 0x000b6fdb) 0x74cdda4 # 32 __CFRunLoopDoSources0 + 423 (CoreFoundation + 0x000b6b03) 0x74cddac # 33 __CFRunLoopRun + 1159 (CoreFoundation + 0x000b4f4f) 0x74cdde8 # 34 CFRunLoopRunSpecific + 469 (CoreFoundation + 0x000080ed) 0x74cea88 # 35 CFRunLoopRunInMode + 103 (CoreFoundation + 0x00007f0f) 0x74ceb70 # 36 GSEventRunModal + 79 (GraphicsServices + 0x00009b3f) 0x74ceb98 # 37 UIApplicationMain + 149 (UIKit + 0x00071e81) 0x74cebb8 # 38 UIApplicationMain (ApplicationHooks.m:50) (MyApp + 0x0002235f) 0x74cebdc # 39 main (main.mm:18) (MyApp + 0x003a227f) 0x74cebfc # 40 0x1b33a4e9 in start + 1 (libdyld.dylib + 0x000034e9) 0x74cec18

Thread 1:

# 1 0x1b40d808 in __psynch_cvwait + 24 (libsystem_kernel.dylib + 0x00015808) 0x0 # 2 0x1b4c3cb3 in _pthread_cond_wait + 561 (libsystem_pthread.dylib + 0x00002cb3) 0x0 # 3 0x1b4c5033 in pthread_cond_wait + 37 (libsystem_pthread.dylib + 0x00004033) 0x190e50a0 # 4 0x1be0ed7 in SyncCondition::Wait() (SyncSynchronization.h:592) (MyApp + 0x01ba9ed7) 0x190e50ac # 5 0x1be0f0b in SyncCondition::WaitForDuration(unsigned long) (MyAppSync.cpp:469) (MyApp + 0x01ba9f0b) 0x190e50b4 # 6 0x446ebef in invocation function for block in wlm_dispatch_create_block_wrapper(void () block_pointer) (MyAppThread_objc.mm:203) (MyApp + 0x04437bef) 0x190e5e78 # 7 0x1b30d795 in _dispatch_call_block_and_release + 9 (libdispatch.dylib + 0x00001795) 0x190e5f24 # 8 0x1b31ab1b in _dispatch_queue_override_invoke + 535 (libdispatch.dylib + 0x0000eb1b) 0x190e5f30 # 9 0x1b31c1b3 in _dispatch_root_queue_drain + 325 (libdispatch.dylib + 0x000101b3) 0x190e5f58 # 10 0x1b31c00d in _dispatch_worker_thread3 + 105 (libdispatch.dylib + 0x0001000d) 0x190e5f90 # 11 0x1b4c28eb in _pthread_wqthread + 1039 (libsystem_pthread.dylib + 0x000018eb) 0x190e5fa0 # 12 0x1b4c24ca in start_wqthread + 6 (libsystem_pthread.dylib + 0x000014ca) 0x190e5fe0

openCV imwrite writing 0 kb image frames

Thu, 09/21/2017 - 01:19

I am running the below code to convert video into frames. Problem is it is creating Image files with 0 KB size and when I open it is not showing anything.. I don't understand what is creating the problem. Do I need to install any Image codecs?

''' Using OpenCV takes a mp4 video and produces a number of images. I am using OpenCV 3.3.0 version and Python 2.7 Which will produce a folder called data with the images, There will be 2000+ images for example.mp4. ''' import cv2 import numpy as np import os # Playing video from file: cap = cv2.VideoCapture('aa.mkv') try: if not os.path.exists('data'): os.makedirs('data') except OSError: print ('Error: Creating directory of data') currentFrame = 0 while(True): # Capture frame-by-frame ret, frame = cap.read() # Saves image of the current frame in jpg file name = './data/frame' + str(currentFrame) + '.jpg' print ('Creating...' + name) cv2.imwshow(name, frame) # To stop duplicate images currentFrame += 1 # When everything done, release the capture cap.release() cv2.destroyAllWindows()

Angular Breaking Date and Time

Wed, 09/20/2017 - 21:00

I have this code <ng-template>date:'MM/dd/yyyy h:mm:ss a Z'}}</ng-template> and it will show a long line date and time. I want to make a break in between data and time by enter <br />, but it doesn't work. Any idea? Thanks!

How to mkae a list chooser in a browser

Wed, 09/20/2017 - 20:59

I have a webpage and I need to allow the user to select or de-select from predefined keywords from a list.

Something like the tags below in stackoverflow where the user can only select or de-select predefined keywords.

Also when the user returns to the site, he must be able to see his old selections and edit them at anytime.

For example maybe can have two columns like this

UNSELECT SELECTED ------------------- A B C D E F G [ --> ] select button [ <-- ] unselect button

So there are two columns FROM and TO, then buttons allowing the user to move items back and forth between the two columns.

Doesnt have to be two columns, but any method that allows the user to only select predefined words, se-select any keyword, and can edit them later when they return to the site.

Anybody knows how to do this?

Uploading Large Files(Greater than 300 Mb) to Glassfish server gets stuck

Wed, 09/20/2017 - 20:59

I have a problem while uploading a file; it gets stuck at the point of 80% of uploading the file to the server. this server has 3 apps running in there and there was a time before were it would accept even 600 mb... i Hope you can help.

get property from object using enum value from loop

Wed, 09/20/2017 - 20:59

In one file there are enums as follows:

public enum RelativeFatLevels { Low, Medium, High }

There is a Component class in a separate file like so:

public class Component { public Enum RelativeFatLevel; public double Fat; // other properties here }

There is a FormulaOutput class in a separate file that acts like a container to hold Component objects for a formula:

public class FormulaOutput { public Component Low { get; set; } public Component Medium { get; set;} public Component High { get; set;} }

In a separate unit testing file I am trying to build a generic method to replace this logic:

private FormulaOutput GetDifferences(FormulaOutput app, FormulaOutput test) { FormulaOutput container = new FormulaOutput(); Component componentDifferencesLow = new Component(); componentDifferencesLow.RelativeFatLevel = RelativeFatLevels.Low; Component componentDifferencesMedium = new Component(); componentDifferencesMedium.RelativeFatLevel = RelativeFatLevels.Medium; Component componentDifferencesHigh = new Component(); componentDifferencesHigh.RelativeFatLevel = RelativeFatLevels.High; container.Low = componentDifferencesLow; container.Medium = componentDifferencesMedium; container.High = componentDifferencesHigh; return container; }

This is a pared down version - there are several properties in Component that need to be set which are not shown above (they were removed to make the code snippets more readable).

Below is what I've tried. The lines that are commented out are not working. I'm stuck on how to proceed from here. Note that the file does include using System.Reflection; so I don't think that's the issue. Also, the code to add the component to the container object doesn't exist yet - not sure how to write that either.

private FormulaOutput GetDifferences(FormulaOutput app, FormulaOutput test) { FormulaOutput container = new FormulaOutput(); foreach (RelativeFatLevels relativeFatLevel in Enum.GetValues(typeof(RelativeFatLevels))) { Component componentDifferences = new Component(); //componentDifferences.RelativeFatLevel = test.Low.RelativeFatLevel; //componentDifferences.RelativeFatLevel //PropertyInfo xyz = test.GetType().GetProperty(relativeFatLevel.ToString()).GetValue(test, null); //PropertyInfo abc = typeof(FormulaOutput).GetProperty(relativeFatLevel.ToString()).GetValue(test, null); //Type type = typeof(FormulaOutput); //var aaa = type.GetProperty(relativeFatLevel.ToString()).GetValue(test, null); //Component current = typeof(FormulaOutput).GetProperty(relativeFatLevel.ToString()).GetValue(test, null); } return container; }

How do I create the fiware-orion deb package?

Wed, 09/20/2017 - 20:59

My project used a Raspberry Pi3 with Debian OS and in it I execute the fiware-orion. I have compiled the Orion source code for the architecture arm64 (aarch64). Now I need to create the fiware-orion deb package.

The documentation only explains how to build the rpm package with rpm-build.

I did a search and that's all I found: Fiware Orion context Broker on Ubuntu

Is it possible to create the fiware-orion deb package?

Thank you for your help!

Kie Server - JAXB error

Wed, 09/20/2017 - 20:58

I'm working with a third-party jar for the facts, in this jar there are some interfaces so when I consume the kie server REST API, I get a JAXB error, the log is at the botom. If I try to marsahl / unmarshall the BatchExecutionCommand using kie rest api libraries I get no error. I traid to change the webapps\kieserver\WEB-INF\lib jaxb libraries to the 2.3 versions but the error persists.

Thanks

org.kie.server.api.marshalling.MarshallingException: Error while creating JAXB context from default classes! 9 counts of IllegalAnnotationExceptions org.kie.server.api.marshalling.jaxb.JaxbMarshaller.<init>(JaxbMarshaller.java:177) org.kie.server.api.marshalling.MarshallerFactory.getMarshaller(MarshallerFactory.java:39) org.kie.server.services.impl.KieContainerInstanceImpl.getMarshaller(KieContainerInstanceImpl.java:111) org.kie.server.services.impl.marshal.MarshallerHelper.marshal(MarshallerHelper.java:47) org.kie.server.remote.rest.drools.CommandResource.manageContainer(CommandResource.java:75) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:168) org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:541) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:523) org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:125) org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) javax.servlet.http.HttpServlet.service(HttpServlet.java:742) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.kie.server.services.impl.security.web.CaptureHttpRequestFilter.doFilter(CaptureHttpRequestFilter.java:42) Root Cause: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 9 counts of IllegalAnnotationExceptions uk.co.portaltech.rulesengine.wrappers.Order is an interface, and JAXB can't handle interfaces. this problem is related to the following location:

My Kafka produce() method is sync instead of async by using .flush(), how should I make it async?

Wed, 09/20/2017 - 20:58

I'm using Kafka flush() after each produce to deliver all messages. When I remove flush() some of the messages are sent and some of them are not sent/delivered to destination:

from kafka import KafkaProducer from kafka.errors import KafkaError import time import ujson producer = KafkaProducer(bootstrap_servers=['localhost:9092'], value_serializer=lambda m: ujson.dumps(m).encode('ascii')) for i in range(5): future = producer.send('test2', {"json": True, "content": "Hello number %s" % i}) print vars(future) producer.flush()

This code does not work well under load as it is synchronous. When I remove flush() it just sends some messages. I don't what happen's to the other messages in Kafka cluster.

Now question is how should I make it async and deliver all messages? What should I change in code to make this code production ready?

How to print out the user input numbers and the fault and default?

Wed, 09/20/2017 - 20:58
import java.io.*; public class fifo { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int frames = 3, pointer = 0, fault = 0, reflen, def = 0; int spaces[]; int reference[]; int mem_layout[][]; System.out.println("Reference String Length: "); reflen = Integer.parseInt(br.readLine()); reference = new int[reflen]; mem_layout = new int[reflen][frames]; spaces = new int[frames]; for(int j = 0; j < frames; j++) spaces[j] = 0; System.out.println("Reference Numbers: "); for(int i = 0; i < reflen; i++) { reference[i] = Integer.parseInt(br.readLine()); } System.out.println(); for(int i = 0; i < reflen; i++) { int search = -1; for(int j = 0; j < frames; j++) { if(spaces[j] == reference[i]) { search = j; def++; break; } } if(search == -1) { spaces[pointer] = reference[i]; fault++; pointer++; if(pointer == frames) pointer = 0 ; } for(int j = 0; j < frames; j++) mem_layout[i][j] = spaces[j]; } for(int i = 0; i < frames; i++) { for(int j = 0; j < reflen; j++) //System.out.printf("%3d ", reference); System.out.printf("%3d ",mem_layout[j][i]); System.out.println(); } System.out.println("Fault: " + fault); System.out.println("Default: " + def); System.out.println("Page Fault Rate: " + fault + "/" + reflen + " = " + ((double)fault/reflen)*100 + "%" ); } }

Output:

Reference String Length: 3 Reference Numbers: 5 1 5 5 5 5 0 1 1 0 0 0 Fault: 2 Default: 1 Page Fault Rate: 2/3 = 66.66666666666666%

Question:

  1. How do I print the numbers I entered because sys.out(reference) is not working on this part because it loops already.
  2. How do I print the F and D? because the output should be like this and everytime i do something with the code i get more errors so..

******Needed Output:******

Reference String Length: 3 Reference Numbers: 5 1 5 5 1 5 // 1st question (how to print this line) 5 5 5 0 1 1 0 0 0 F F D // 2nd question Fault: 2 Default: 1 Page Fault Rate: 2/3 = 66.66666666666666%

I don't really know how to print mostly the F and D because i'm so confused about it right now.

update lable while zip file is extracted xcode ios objetve c

Wed, 09/20/2017 - 20:55

I have this code which download zip file then extracted.

I want to update label:"please wait zip file extracting" while extract the file then after finish extracting update label: the file is downloaded and extracted :

ViewController .h:

@interface ViewController : UIViewController -(void)extract_state:(NSString*) Name; @property (weak, nonatomic) IBOutlet UIProgressView *progg; @property (strong, retain) IBOutlet UILabel *dl_wait; @property (weak, nonatomic) IBOutlet UIButton *dl_but; @end

ViewController .m:

- (IBAction)download:(UIButton *)sender { //start downloading zip file _dl_wait.text = @"plz wait the file is downloading"; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://bayan-noon.com/test.zip"]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/cool"]; if(![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) { [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; } NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"cool/master.zip"]; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Successfully downloaded file to %@", path); NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString* foofile = [documentsPath stringByAppendingPathComponent:@"cool/master.zip"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:foofile]; if (fileExists) //Does file exist? { [self go:dataPath:path]; } _dl_wait.text = @"the file downloaded and extracted"; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"file downloading error : %@", [error localizedDescription]); }]; [operation start]; } -(void)extract_state:(NSString*) Name{ _dl_wait.text= Name; }

extract_zip.h

@interface UIViewController (test) -(NSString*)go:(NSString*) Name :(NSString*) Name2; @end

extract_zip.m

#import "extract_zip.h" #import "ViewController.h" @implementation UIViewController(test) -(NSString*)go:(NSString*) Name :(NSString*) Name2;{ ViewController* myScript = [[ViewController alloc] init]; //here is my issue the label is not updated when call function:extract_state... [myScript extract_state:@"extracting now"]; ZipArchive* za = [[ZipArchive alloc] init]; if( [za UnzipOpenFile:Name2] ) { if( [za UnzipFileTo:Name overWrite:YES] != NO ) { NSLog(@"Successfully extracted"); } [za UnzipCloseFile]; } [za release]; return null; }

my problem when call : [myScript extract_state:@"extracting now"];

does not update my label : _dl_waitt.. the code is messy sorry but i'm noob in coding

How to get a single image to hide website pages during maintenance period

Wed, 09/20/2017 - 20:53

I'm currently trying to get a single image (website under construction) to cover the entire Tumblr website I'm working on, temporarily, without losing any of the underlying HTML and CSS code. Additionally, I'm not sure where to put the image itself (head, body, etc) to get it to cover up the menus and other links that are above the content without changing the structure.

Javascript Font scaling code from body to div / element

Wed, 09/20/2017 - 20:51

I found some code which will scale some text when the browser window is resized and it seems to work well.

Here is the code:

document.body.setScaledFont = function (f) { var s = this.offsetWidth, fs = s * f; this.style.fontSize = fs + '%'; return this }; document.body.setScaledFont(0.35); window.onresize = function () { document.body.setScaledFont(0.35); }

My question is:

How can I modify this code so the text scales when a specified div is scaled instead?

python: extracting files based on partial title with split criteria in title

Wed, 09/20/2017 - 20:49

I have a list of files with inconsistent nomenclature:

pLst = ['CO_002_2016_Q4_Merge.loc', 'CO_002_2016_Merge.zip', 'CO_002_2016_q4_alias.loc', 'CO_002_2017_here_2017_q1_streets_alias.loc.xml', 'CO_002_2017_here_2017_q1_streets_parity.loc', 'AuburnAliasGCS_1984_1106.lox', 'CA_ORG_BCP.loc.xml', 'CA_ORG_BCP.loc', 'Co52 Alias Address Locator.lox', 'CO_002_2017_here_2017_q1_streets_parity.loc.xml', 'CentralCostaCountyStreets.lox', 'CO_002_2016_q4_alias.lox']

I want to extract files that contain the strings in this list:

exCrt = "2016_Q4", "2016_q4", or "2017"`

I would like to add all of the files with any of the elements in exCrt to an extraction list but I don't see a way to isolate the split criteria from part of the selection criteria (i.e. "_").

I tried using any:

if any(x in pLst for x in exCrt): exLst.add(x)

which resulted in an empty set.

I also tried changing exCrt to ["2016","q4","Q4","2017"] and then using an 'and' 'or' approach:

for i in pLst: if exCrt[0] and exCrt[1] or exLst[0] and exCrt[2] or exCrt[3] in i.split("_"): exLst.add(i)

But this did not exclude any of the files the unwanted files.

I would like the output to be

( 'CO_002_2016_Q4_Composite.loc', 'CO_002_2016_q4_alias.loc.xml', 'CO_002_2016_Q4_Composite.loc.xml', 'CO_002_2016_Q4_Merge.lox', 'CO_002_2016_Q4_Merge.loc.xml', 'CO_002_2016_Q4_Merge.loc', 'CO_002_2016_q4_alias.loc', 'CO_002_2016_q4_alias.lox', 'CO_002_2017_here_2017_q1_streets_alias.lox', 'CO_002_2017_here_2017_q1_streets_alias.loc', 'CO_002_2017_here_2017_q1_streets_alias.loc.xml', 'CO_002_2017_here_2017_q1_streets_parity.loc', 'CO_002_2017_here_2017_q1_streets_parity.loc.xml')

Chart JS: Ignoring x values and putting point data on first available labels

Wed, 09/20/2017 - 20:46

I am making a line chart in chart.js, and am having an issue where I am trying to plot point data on the line but it is ignoring the x values I am giving, and instead putting them on the first available label.

this.myLineChart = new Chart(this.ctx, { type: 'line', data: { labels: [0,2,4,6,8,10], datasets: [{ label: 'mylabel1', fill: false, backgroundColor: 'blue', borderColor: 'blue', data: [{ x: 2.5, y: 85 }, { x: 3.5, y: 85 }] }] }, options: { title: { display: true, text: 'mytitle1' }, scales: { yAxes: [{ display: true, ticks: { suggestedMin: 70, suggestedMax: 100 } }] } } });

The result I get is this:

But instead I would like this line to be at the x values 2.5 and 3.5, so that it lies in between the 2 and 4 labels.

What should I change in the code to make it behave as I want?

Add order by to Union Select ALL

Wed, 09/20/2017 - 20:45

I am using the following query to create an ssrs parameter and need to order by lastname

SELECT Lastname + ', ' + FirstName + ' ' + '(' + INPN + ')' as Agent FROM tblagents where agentcode in (SELECT AgentCode from AgentDetail) UNION SELECT ' ALL' AS Agent

I attempted first to use order by prior to the union.

Then i tried to wrap this all in a select * from

SELECT * from ( (SELECT Lastname, Firstname, INPN FROM tblAgents where agentcode in (SELECT AgentCode from AgentDetail) ) UNION SELECT ' ALL' AS Agent )

that did not work either. How can i order by last name in my query?

Pages