understanding python memory allocation and free up

Uncategorized
Question: I recently came across this article about python memory allocation. In this page it describes the memory usage of python and in there there is an example showing deepcopy of list of integers. I did the benchmark myself on Python 2.7 Line # Mem usage Increment Line Contents ================================================ 4 28.051 MiB 0.000 MiB @profile 5 def function():6 59.098 MiB 31.047 MiB x = list(range(1000000)) # allocate a big list 7 107.273 MiB 48.176 MiB y = copy.deepcopy(x) 8 99.641 MiB -7.633 MiB del x 9 99.641 MiB 0.000 MiB return y so delete x directly only removes x and all the references to integer to x right? Doing this could not help either (So what is the difference del x and del x[:]?):Line # Mem usage Increment Line…
Read More

Installing Bootstrap 4 Beta with Bower

Uncategorized
Question: I'm trying to install the latest version of Bootstrap 4 Beta using bower. Using this command:bower install bootstrap#v4.0.0-beta Results in:no matches found: bootstrap#v4.0.0-beta Is there anything I'm doing wrong? My bower.json looks as follows:{ "name": "bootstrap-starter", "homepage": "https://github.com/marcuschristiansen/bootstrap-starter", "authors": [ "Marcus Christiansen " ], "description": "All dependencies for the bootstrap starter theme", "main": "", "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "jquery": "~2.2.3", "normalize-scss": "git@github.com:JohnAlbin/normalizescss.git#^4.1.0", "bootstrap": "4.0", "font-awesome": "git@github.com:FortAwesome/Font-Awesome.git", "bourbon": "^4.2.7", "neat": "^1.8.0" } } Answer: I just installed Bootstrap 4 Beta with the same command: bower install bootstrap#v4.0.0-beta with npm version 5.3.0 and Bower 1.8.0. Have you tried updating npm and Bower and running the same install command? Read more
Read More

Shiny App – Paging

Uncategorized
Question: I want to build a shiny web app where:First, a page appear for the users to input selection (e.g. drop down box, text field input etc.) There is a next button for the users to click which will direct them to the next page where they can input/answer another set of questions. Then in the last page, results (visualisations/analytics) are appearing based on their input. back button is available in case the users want to modify their answers/input Are there any widgets/ways to do this ? Any recommendations will be much appreciated :-) Cheers! Answer: You could place the parts of your app in divs, and show and hide them with the shinyjs package. This also allows you to build in conditions for advancing to the next part of…
Read More

How do I switch from Python 3.5 back to 3.6 on mac terminal

Uncategorized
Question: I just dealt with the worse bug in my entire 3 years of computer programming! It turns out that because I wanted to work with the natural language toolkit I had to install python 3.5 even though I'm using python 3.6. So I downloaded 3.5 and now my terminal is using python 3.5 by default and I can't get it back to 3.6. Because I was using python 3.5 which does not automatically order dictionaries it was throwing my program off because it relies on ordered dictionaries. It took me 4 hours to figure that out. Answer: You want to use virtualenv and/or virtualenvwrapper. This is a utility that allows you to use multiple different environments, with different Python versions, different pip packages installed, etc. To find the 3.5…
Read More

Erroe using a extra project in my project

Uncategorized
Question: In my code when I add a project to my library and I want to use it, it has ERROR that says "TextReader is not public in pack4.TextReader; cannot be accessed from outside package" But here is my code in pack4:package pack4; public class TextReader { private String path; TextReader (String path) { this.path = path; } public String[] readFile() throws IOException { FileReader fr = new FileReader(path); BufferedReader bf = new BufferedReader(fr); int numberOfLines = numberOfLines(); String[] textData = new String[numberOfLines]; int counter = 0; for(counter = 0; counter < numberOfLines; counter++) { textData[counter] = bf.readLine(); } bf.close(); return textData; } public int numberOfLines() throws IOException { FileReader fr = new FileReader(path); BufferedReader bf = new BufferedReader(fr); int lineCounter = 0; while(bf.readLine() != null) { lineCounter++; } bf.close();…
Read More

Sending ArrayList to server not working with AsyncHttp

Uncategorized
Question: HttpAsyncRequest request = new HttpAsyncRequest( MapsActivity.this, Constant.BaseUrl, HttpAsyncRequest.RequestType.GET, new MarkerParser(), listener); request.addParam("array",arr); //this is not working request.execute(); I want to send arraylist of latlng to the server i am using http request but we can only send string through that . How to send arraylist of latlng ? Answer: this is how i passed my arraylist of latlng to JSONARRAY and then converted into string and then i sent to server. JSONArray pointsinjsonarray=new JSONArray(); for(int i=0;i
Read More

Xamarin Native Dependency Service

c#
Question: I am a little bit new to xamarin , i've made some project with Xamarin.forms and i used a lot the DependecyService. But now i have a project that we need to make native specefic views so we are not using xamarin.forms, but as i know our PCL code still can be the same, so if i have some methods that require specific platform implementation i can use the dependency service. As an example , i have a method that require to save in the phone path ,this method is in the PCL, but for the path i need it from Xamarin.Android and Xamarin.IOS. Can anyone explain to me how do i shall proceed ? Thanks Answer: The simplest without Dependency Injection is create an interface in your PCL.…
Read More

Call ActionResult in the Area controller from a shared view

c#
Question: From the Layout.cshtml which is inside the Views folder (outside Areas), I need to resolve the action method of a controller created inside an Area. I have a few custom routes defined, but the default route is as always:routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }); Eg: Area - Test, Controller - HomeController, Action Method - Index @Url.Action("Index", "Home", new { Area = "Test" }) returns an empty string. @Html.ActionLink("Test link", "Index", "Home") returns an empty string. @Html.RouteLink("Test Link", "default", new { controller = "Home", action = "Index" }) returns in an error A route named 'default' could not be found in the route collection. I am bummed. How can I resolve the action? Answer: Under the same namespace add following class public…
Read More