Show More Tags:  MORE

how can I, character and words count from string to make a line break insert in android

how can I, character and words count from string to make a line break insert in androidI have a text output of words with max 150 letters and want the all 50 letters carried a line break without separating the word.how can I implement it?here is a code snippet ....ll = (TableLayout) rootview.findViewById(R.id.displayLinear);TableRow row = new TableRow(getActivity());consoleLocalStore.storeConsoleData(consolex);LayoutInflater inflater = getLayoutInflater(getArguments());View theInflatedView = inflater.inflate(R.layout.activity_consolex, null);TextView attid = (TextVie...


Permission Denied Error using Laravel & Docker

I have two docker containers: Nginx and App.The app container extends PHP-fpm and also has my Laravel Code.In my docker-compose.yml I'm doing:version: '2'services: nginx: build: context: ./nginx dockerfile: ./Dockerfile ports: - "80:80" links: - app app: build: context: ./app dockerfile: ./DockerfileIn my Nginx Dockerfile i'm doing:FROM nginx:latestWORKDIR /var/wwwADD ./nginx.conf /etc/nginx/conf.d/default.confADD . /var/wwwEXPOSE 80In my App Dockerfile I'm doing:FROM php:7-f...


Get the most used words with special characters

I want to get the most used word from an array. The only problem is that the Swedish characters (Å, Ä, and Ö) will only show as �.$string = 'This is just a test post with the Swedish characters Å, Ä, and Ö. Also as lower cased characters: å, ä, and ö.';echo '<pre>';print_r(array_count_values(str_word_count($string, 1, 'àáãâçêéíîóõôúÀÁÃÂÇÊÉÍÎÓÕÔÚ')));echo '</pre>';That code will output the following:Array( [This] => 1 [is] => 1 [just] => 1 [a] => 1 [test] => 1 [post] => 1 [with] => 1 [the] => 1 [Swedish] => 1 ...


How do i add data in dataframe under the columns and across the rows?

I have a few dataframes that are loaded previously from CSV filesb = portfolionew_df.loc [1,['x_1','x_2','x_3','x_4','x_5']]x = [stockprice_df.loc[ :, b]]print(x)This is the result for x: NYSEARCA:RYE NYSEARCA:XOP NYSEARCA:PXE NYSEARCA:VAW NYSEARCA:PYZ 0 68.37 52.00 25.37 87.94 35.00 1 60.70 48.04 22.64 83.78 32.61 2 67.04 54.48 24.70 86.61 34.44 3 65.86 53.75 24.16 84.94 34.21c = pd.DataFrame(index=(t...


How can I create a directory if it does not exist?

What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried:import osfile_path = "/my/directory/filename.txt"directory = os.path.dirname(file_path)try: os.stat(directory)except: os.mkdir(directory) f = file(filename)Somehow, I missed os.path.exists (thanks kanja, Blair, and Douglas). This is what I have now:def ensure_dir(file_path): directory = os.path.dirname(file_path) if not os.path.exists(directory): os.makedirs(directory)Is there a flag for ...


Regex with exception of particular words

I have problem with regex.I need to make regex with an exception of a set of specified words, for example: apple, orange, juice.and given these words, it will match everything except those words above. apple (should not match)applejuice (match)yummyjuice (match)yummy-apple-juice (match)orangeapplejuice (match)orange (should not match)juice (should not match)orange-apple-juice (match)apple-orange-aple (match)juice-juice-juice (match)orange-juice (match) If you really want to do this with a single regular expression, you might find lookaround helpful (especially negative l...


DRF serializer do not return a value with extra_kwargs of write_only

I'm practicaly copying the exemple code from the documentation, but the password field, with "extra_kwargs = {'password': {'write_only': True}}" is not returned as validated data.this is the code:class UserProfileSerializer(serializers.ModelSerializer):class Meta: model = models.UserProfile fields = ('email', 'first_name', 'last_name', 'birthday', 'gender', 'telephone', 'password') extra_kwargs = {'password': {'write_only': True}}def create(self, validated_data): user = models.UserProfile( email=validated_data['email'], first_name=validated_data['f...


How to swap using different data types

Ok so lets suppose I have an array of 4 ints == int[] input = new int[]{1,2,3,4};//now I some how converted these numbers into words and gets an array:-String Str = new String[]{one,two,three,four};//then I run a sort method on Str.Arrays.sort(Str);//and I got this array in the end ::: {four,one,three,two}Now i want to reconvert it into numbers(int) so that my final result should look like this:- {4,1,3,2}In Summery :-I want to sort the input int arrays through its English(words)representation Examples :-[input] [convert to words] [sorting] [Resul...


How can I fill out a Python string with spaces?

I want to fill out a string with spaces. I know that the following works for zero's:>>> print "'%06d'"%4'000004'But what should I do when I want this?:'hi 'of course I can measure string length and do str+" "*leftover, but I'd like the shortest way. You can do this with str.ljust(width[, fillchar]): Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).>>> 'hi'.ljust(10)'hi ' [XXX]Unless you need to suppo...


how to group records in days based on timestamp value from current date in oracle

I Have a table with a column as timestamp with timezone as shown below.desc log_records:id number not null,event_id number not null,event_desc varchar2(2000),log_date timestamp with time zoneHow do i suppose to group the records like older than 300 days 12 rowsolder than 250 days 12831 rowsolder than 200 days 438121 rows based on the current date in oracle Kaushik, thank you for sample data. (BTW, I think your solution is wrong, I'll leave a comment).I think that this is what you're looking for:SQL> select 2 sum(case when sysdate - trunc(log_date) > 300 then 1...


How do I convert Base58-encoded data to a Vec<u8> and then into a String?

I am trying to convert a Vec to a String for display. I have tried to use from_uf8 and from_iter with no luck.use rust_base58::{ToBase58, FromBase58};let address = String::from("1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH");let _hash160 = address.from_base58();let mut s = String::from_utf8(_hash160).unwrap();//let s = String::from_iter(_hash160);s.remove(0);s.pop();s.pop();s.pop();s.pop();println!("{}", s); .from_base58()returns Result<Vec<u8>, FromBase58Error>because the conversion can fail if the data isn't valid Base 58.Assuming you want to ignore the error like yo...


ambiguity in package references version

In a project there are several references to Ninject library which have their own version, and unit tests fails, error : Message: System.IO.FileLoadException : Could not load file or assembly 'Ninject, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---- System.IO.FileLoadException : Could not load file or assembly 'Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its depen...


Pandas assign the groupby sum value to the last row in the original table

For example, I have a table Aid price sum1 2 01 6 01 4 02 2 02 10 02 1 02 5 03 1 03 5 0What I want is like (the last row of sum should be the sum of price of a group)id price sum1 2 01 6 01 4 122 2 02 10 02 1 02 5 183 1 03 5 6What I can do is find out the sum usingA['price'].groupby(A['id']).transform('sum')However I don't know how to assign this to the sum column (last row).Thanks Use last_valid_index to locate rows to fillg = df.groupby('id')l ...


Reading Weighing Scale Tru rs232

i been using this code from How to display weight from weighing scale into a textbox via serial port RS-232 or usb converter?but unfortunately i keep receiving this data Listening on COM6... 03301B+00003301B+000033+00003301B+00003301B+001B+00003301B+00003301B03301B+00003301B+000033+00003301B+00003301B+001B+00003301B+00003301B03301B+00003301B+000033+00003301B+00003301B+001B+00003301B+00003301B03301B+00003301B+000033+00003301B+00003301B+001B+00003301B+00003301B03301B+00003301B03301B+00003301B+000033+00003301B+00003301B+001B+00003301B+00003301B03301B+00003301B+000033+0000330...


count occurrences of a word within a date range like month or quarter

I have a sheet with data organized by date for an entire year. Column "a" would be the dates in chronological order and column "b" would have a name in each cell. Many of the names are repeated throughout the year. What formula would I use to count how many times a particular name was listed in column b within a particular month, quarter or date range of my choice?I would like to create a new sheet to show this data once I have the proper formula/s.I am using excel 2016 OK, let's specify your inputs like this:E1: nameE2: start dateE3: end dateThen to do the calculation:=...





Android tint on off with java

I made a custom imagebutton.It is possible to set image src and selected tint color.I want to toggle original image and set tint color image when button clicked.I tried this.(this is not full source, just wrote point)CustomImageButton.javapublic class CustomImageButton extends LinearLayout { View v


Coping folder inside AmazonS3 Bucket (c#)

I want to copy one folder, with all existing files inside it, to another folder inside AmazonS3's same Bucket.I can copy one object but what i need is to copy folder, with all files, into another Folder. Here is the example to copy folder inside AmazonS3 Bucket Which works for me.For more d


Xamarin Android LinkAssemblies task failed

Using Visual Studio 2017 Preview 15.4.0 and the latest updates to everything as of today.Whenever I build my project I get this error, as a workaround I have been turning linking to 'none' as suggested nearly everywhere, but this isn't a fix, and I would really appreciate some useful advice on what


Switch with tons of cases vs single if

Let's say we need to go through a 128-element array of uint8 and compare neighbour elements and put the result to another array. The code below is the most simple and readable way to solve this problem.for (i = 1; i < 128; i++) if (arr[i] < arr[i-1] + 64) //don't care about overflow arr2[i


class construction must work in different php versions

One of our user groups created and has been maintaining a site on godaddy.com. The person who made it left, users asked MIS for help, and I was asked to make changes. It must remain on godaddy.com until we figure out how best to move the application to our own servers.To make a test environment I do


Any PHP Design Patterns to Handle Command Line Arguments?

So I am writing a class that needs to accept arguments, some arguments are mandatory, others are optional. For example: php test.php -a app1 -u username -p password --l --dump-dataThe last two with double dashes are optional. The -a arguments chooses an app, there are several apps such as app2, app3


reshape2 melt not producing all pairs

I have a 332 x 332 distance matrix with distances between all possible pairs of stations. I need to transform this matrix into a data.frame with three columns - start.id, end.id, and distance. I have tried the melt function from the reshape2 package but this is not giving the right resultHere is


Function and data format for doing vector-based clustering in R

I need to run clustering on the correlations of data row vectors, that is, instead of using individual variables as clustering predictor variables, I intend to use the correlations between the vector of variables between data rows. Is there a function in R that does vector-based clustering. If not a


What does an empty parameter list mean?

This question already has an answer here: Why does a function with no parameters (compared to the actual function definition) compile? 11 answers This is an obsolescent feature1 from before C was standardized, d


SQL select only rows with max value on a column

I have this table for documents (simplified version here):+------+-------+--------------------------------------+| id | rev | content |+------+-------+--------------------------------------+| 1 | 1 | ... || 2 | 1 | ...


How to use multiple concepts per text gen component in Jetbrains MPS 2017.1?

I created a simple DSL in JetBrains MPS for an automation task at hand. The DSL allows defining information objects which in turn shall be used for code generation. I am able to generate my models - but I am struggling to find a way to assign an additional text gen component to the same language con


Check if class has method in PHP

Currently my code looks like that:switch ($_POST['operation']) { case 'create': $db_manager->create(); break; case 'retrieve': $db_manager->retrieve(); break;...}What I want to do is, to check if method called $_POST['operation'] exists: if yes then call it, e


How to use MATLAB fread to read a txt file?

I try to use fread to read a text fileMy code is only 2 linesfid = fopen('1.txt', 'r');c = fread(fid,'double', skipvalue); I have tested different format like double, float32, float64 and different skipvalue from 0 to 8, but none of the combination work.The data is recorded by a c program codefprint


What could produce this bizzare behavior with two threads sleeping at the same time?

There are two threads. One is an events thread, and another does rendering. The rendering thread uses variables from the events thread. There are mutex locks but they are irrelevant since I noticed the behavior is same even if I remove them completely (for testing).If I do a sleep() in the rendering


How can 2 strings be concatenated?

How can I merge/combine two value in R?For example I have:tmp = cbind("GAD", "AB")tmp# [,1] [,2]# [1,] "GAD" "AB"My goal is to get tmp as one string tmp_new = "GAD,AB"Which Function can do this for me? paste()is the way to go. As the previous posters pointed out, paste can do two things:con