ashim

1

votes
2

answer
61

views

Implement different behavior for dismissing UIAlertController action sheet when tapping on view for cancel event

I am trying to make cancel button work and navigate to the previous screen. I am pressing outside the action sheet and the cancel event is still occurring. Here is my code: let alertController = UIAlertController(title: 'searchEvent', message: nil, preferredStyle: .actionSheet) alertController.add...
Ashim Dahal
1

votes
1

answer
53

views

How to generate dataMatrix using CIFilter?

I am getting error: Value for key inputBarcodeDescriptor of type CIDataMatrixCodeDescriptor is not yet supported let string = 'tempValue&123' let data = string.data(using: String.Encoding.ascii, allowLossyConversion: false) guard let data = data else { return nil } let descriptor = CIDataMatrixCodeD...
Ashim Dahal
1

votes
1

answer
30

views

How to get value from dynamic EditText and store the values in a integer array?

I am testing a new app on which I implemented dynamic EditText, but got stuck with a problem. I added Editexts to a List array, and I am trying to get the value from EditText and save it to an integer array, but when I click on a button I am getting empty value. My code: List all_value1 = new ArrayL...
ashim
1

votes
1

answer
92

views

sql transactions, why user can update

I am learning transactions in mysql. I cannot understand behaviour. Isolation level for my db is repeatable-read. Database schema: creade database my_db; use my_db; create table locktest( id integer, val integer, primary key (id) ); insert into locktest (id, val) values (3,6); I created two users. U...
ashim
1

votes
1

answer
925

views

How to obtain authentication token using urllib2 in python?

I want to obtain authentication token using urllib2 in python. My program is (I changed credentials): import urllib2 import urllib USER_NAME = 'me' USER_PASSWORD = 'mypass' url = 'http://myurl.org/oauth/token' query_args = { 'grant_type':'password', 'username':USER_NAME, 'password':USER_PASSWORD, 'c...
ashim
1

votes
1

answer
67

views

How to reduce size of a plot, keeping numbers axis the same?

I made a histogram plot with matplotlib, but the histogram occupies all space on the plot, I would like to add more space around. How can I scale down the histogram, but keep number on the axis the same size?
ashim
1

votes
2

answer
109

views

how to make sure denormalized data insert into cassandra?

In Cassandra I have 4 tables having almost same ( duplication ) data. Pragmatically how can I make sure data inserted into 4 different table? I am using NodeJS for my application server.
Ashim
1

votes
1

answer
169

views

How to generate the nth number that consists only of even digits?

I'm novice to Programming. I can find numbers consisting of even digits but my algorithm complexity is O(n). For large n my algorithm is too slow. So I need a more efficient algorithm. Can anyone help me? For example, the first numbers with even digits are 0 , 2 , 4 , 6 , 8 , 20 , 22 , 24 , 26 , 2...
Ashim Chakraborty
1

votes
2

answer
96

views

Race condition in Meteor

How does Meteor prevent from race condition when two users update the same collection? I suspect it has to do something with Fibers. The code below is from the todo list tutorial. What if two users toggle a checkbox at the same time. How does meteor prevent race condition. Can you point me to the r...
ashim
1

votes
2

answer
498

views

PySpark minimum of a list

How to find a minimum of a list that is stored in a cell? I can do a udf, but it feels like an overkill. The min function from pyspark.sql.functions works only on groups (that is the result of groupBy). min_ = udf(lambda inarr: min(inarr), IntegerType()) myDataFrameWithMin = myDataFrame.withColumn('...
ashim
1

votes
1

answer
30

views

Populate data to UITableView inside UITableViewCell from nested data array

I am new into swift and iOS programming. I am trying to make a two layer tableview. Tableview inside tableview cell is basically what I am trying to say. Main tableview is working perfectly but the tableview inside tableview is not working at all.. I have tried everything... # Models // Main Model S...
Ashim Upadhaya
1

votes
1

answer
0

views

Tuning C++ IDE plugin for Vim

Question is about how to tune this plugin to vim. I want to change behavior of it when I push \rc, i.e. I want compile the file. I want compile with g++ with -std:c++0x option. As I understand I should change global variable g:C_CplusCompiler from defaults value 'g++' to '-std:c++0x g++'. Update:...
ashim
1

votes
1

answer
1.9k

views

python: os.system does not execute shell command

I need to execute shell command in python program (I have ubuntu). More specifically I want to create graph using graphviz in python script. My code is os.system('dot -Tpng graph.dot -o graph.png') It does not work, but if I just type 'dot -Tpng graph.dot -o graph.png' in command line then everythin...
ashim
1

votes
1

answer
417

views

python, generic functions

How to create generic stack in python? My stack implementation in python: class Node(object): def __init__(self, d): self.data = d self.nextNode = None class Stack(object): def __init__(self): self.top = None def push(self, item): newNode = Node(item) newNode.nextNode = self.top self.top = newNode d...
ashim
1

votes
1

answer
50

views

Mapping keys in Vim, unexpected behavior

In Vim, key k moves the cursor one line up. If I map key e to key k: noremap e k, then when I press e the cursor moves one line up and one position to the right. Why does it happen? Is it some Vim plugin interferes with noremap or I am missing something? How to debug it? My .vimrc file: ' Use spaces...
ashim
-1

votes
0

answer
7

views

How to setup multi user login using firebase in Android studio?

I am making an app on which I need to add three different users like below Page 1 Button admin sign-in(onclick opens sign in page) Button person 1 sign-in(sign in page) Button person 2 sign-in(sign in page) I should get the first page (page 1)on every startup of the app Page 2 After signing user wil...
ashim
1

votes
1

answer
282

views

Vimeo video is not playing when i change embedded settings in privacy

I am playing the video using Vimeo API and I am able to play the video successfully using 'anywhere settings' under privacy. But when I changed the privacy settings to 'Only on sites I choose ' the video is not playing because of privacy error. Error: Sorry Because of its privacy settings, this vide...
Ashim Kansal
1

votes
2

answer
825

views

python: convert list of strings of json type to list of dictionaries

I have file where each line is json string. I load this file to a list of strings. Is there way to convert all this strings to a list of dictionaries? json.loads() can convert only line by line. thanks I figure out one way of doing it: L = list(expression for variable in sequence)
ashim
1

votes
1

answer
156

views

php memory usage

It looks like in PHP it requires about 213 bytes to store one integer, is it true? Okay, please take a look on the next code: $N = 10000; echo memory_get_usage().'\n'; $v = array(); for($i = 0; $i < $N; $i++) { $v[] = $i; } echo memory_get_usage().'\n'; unset($v); echo memory_get_usage().'\n'; Outpu...
ashim
1

votes
1

answer
43

views

mysql, one user deletes, another updates, who will win?

Question is about mysql transactions. create table tbl1( id integer, val integer, primary key (id) ); insert into tbl1 (id, val) values (1,2); I created two users who work simultaneously. USER1 USER2 start transaction; update tbl1 set val = 3 where id = 1; de...
ashim
0

votes
0

answer
6

views

how to support all screen sizes when using more than one spinner?

I am making a new app and I am a beginner so kindly help me with this, my layout is working great if I run without any java code for layout but when I use Java code, my layout is going beyond the screen I have tried to make different layout folders such as layout-sw320dp.... public class Main2Activi...
ashim
1

votes
1

answer
254

views

web2py, How to do SELECT … FOR UPDATE?

I am learning web2py framework and Database Abstraction Level. I need to do SELECT ... FOR UPDATE statement. Is there way to it in web2py? I have not found answer in the manual
ashim
1

votes
2

answer
926

views

Push commit to 2 different remote branches?

I have two remote branches, branch A and branch B. Consider the case where I checkout branch A, made a commit and pushed. Now, I want to push the same commit to branch B. These two branches are pretty different so I cannot user rebase, can I? Because if I do git rebase then I will rebase all changes...
ashim
1

votes
3

answer
1.8k

views

python re, extract values between commas

Why next regular expression returns empty strings among 'a' and 'b'? In [48]: pat = re.compile('.*?(?=,|$)') In [49]: it = pat.findall('a,b') In [50]: it Out[50]: ['a', '', 'b', ''] How can I extract substrings between commas? EDIT: I am curious how to do it using regular expressions. EDIT: Regular...
ashim
16

votes
9

answer
40.8k

views

Modeling infinity for the largest double value

The question is about modeling infinity in C++ for the double data type. I need it in a header file, so we cannot use functions like numeric_limits. Is there a defined constant that represents the largest value?
ashim
18

votes
1

answer
9.7k

views

python: library for generalized suffix trees [closed]

I need python library that can construct suffix trees and especially generalised suffix trees. Could you suggest me some libraries. Thanks.
ashim
6

votes
2

answer
160

views

Get start and stop indexes of overlapping matches?

I need to know start and end indexes of matches from next regular expression: pat = re.compile('(?=(ATG(?:(?!TAA|TGA|TAG)\w\w\w)*))') Example string is s='GATGDTATGDTAAAA' pat.findall(s) returns desired matches ['ATGDTATGD', 'ATGDTAAAA']. How to extract start and end indexes? I tried: iters = pat.fi...
ashim
1

votes
1

answer
283

views

How to make aliases in c++ (on assembly level)?

The question sounds stupid. Surely, just type: int i = 1; int &k = i; But after I compile it with llvm ( optimization flag is -O0 ) I have next intermediate interpretation: %i = alloca i32, align 4 ; [#uses=2] %k = alloca i32*, align 8 ; [#uses=2] It me...
ashim
20

votes
2

answer
40.6k

views

Define the size of a grid on a plot using Matplotlib

I am plotting using Matplotlib in Python. I want create plot with grid, and here is an example from a plotting tutorial. In my plot range if the y axis is from 0 to 14 and if I use pylab.grid(True) then it makes a grid with the size of square of two, but I want the size to be 1. How can I force it?
ashim
20

votes
2

answer
27.3k

views

python bindings, how does it work?

I am exploring python. I curious about python bindings. Could anybody explain, how it is possible that you can have access to C libraries from Python.
ashim
2

votes
2

answer
2.6k

views

In azure datafactory how to copy data from blob to sql without duplication?

In azure datafactory how to copy data from blob to sql without duplication ie if the pipeline runs at the slice of every 15 min then how to avoid getting duplicate data
Ashim Sinha
2

votes
2

answer
183

views

What is the object owner referred to in the Google C++ Style Guide?

The Google Style Guide for C++ says, in the section about smart pointers: We prefer designs in which objects have single, fixed owners. I don't fully understand the sentence. What is the object owner? Is it just the pointer?
ashim
2

votes
4

answer
6.2k

views

c++, creating vector of vectors?

Question is about what is the best way to create vector of vectors. I have several vector coordinates; and I want pass them to function. How I should combine them, vector? Is there more elegant way?
ashim
2

votes
1

answer
808

views

graphviz, how stick nodes position on the image

I have question about how visualise trees . Now I use graphviz or dot language and have some problems. Briefly about my context. I have series of trees. Tree on step T is obtained from tree on step T-1 by adding some edges. I want to create image for each tree. Wile viewing these images in Image vi...
ashim
5

votes
3

answer
30.5k

views

How can I reduce the number of digits after decimal point when writing floats to file?

In my program I am printing float numbers to file. There is high precision of these numbers so there are many digits after decimal point, i.e number 0.0433896882981. How can I reduce number of digits that I print into file? So I would print, say, 0.043 instead of 0.0433896882981.
ashim
2

votes
3

answer
3.3k

views

R. how to make matrix which have equal rows

I have row f. I want create matrix R such that every row of it is equal f. What is the most efficient way to do it in R?
ashim
2

votes
0

answer
384

views

Camera freezes in some devices

I'm using custom camera in my app. It works fine in most of the devices but the camera freezes in some of the newer devices (Note 8, OnePlus 5). Works fine in S7 and OnePlus3(with Android O). Camera freezes but the app does not crash until the capture button is pressed. It is not the issue of wrong...
Ashim Neupane
2

votes
0

answer
27

views

android google heat maps is not showing locations more than 1000

I implemented the google heat maps in my app and heat maps is showing my locations but if my locations count crossed 1000 then heat maps is showing only 1000 points and left the remaining points. I use below code to implement heat maps. mProvider = new HeatmapTileProvider.Builder() .data(list) .radi...
Ashim Kansal
2

votes
2

answer
469

views

PySpark DataFrame: Custom Explode Function

How to implement a custom explode function using udfs, so we can have extra information on items? For example, along with items, I want to have items' indices. The part I do not know how to do is when a udf returns multiple values and we should place those values as separate rows.
ashim
2

votes
1

answer
283

views

using curl with authentication

I am running a local node.js server. I need to make a POST request with curl. It this request a user should be authenticated. So I specify user name and password in the request. The problem is that I get an error that the token cannot be found, even though login credentials are correct (I can login...
ashim

View additional