w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
adding extra lines after each line in a file
My attempt: sed -n 's/^(./create.pl)s*(.*).out$/1 2.out mv complex.* 2/p' s.txt or using && between ./create.pl and mv (since mv is likely needed only when ./create.pl is correctly executed): sed -n 's/^(./create.pl)s*(.*).out$/1 2.out && mv complex.* 2/p' s.txt which gives: ./create.pl 1eaj.out && mv complex.* 1eaj ./create.pl 1ezg.out && mv complex.* 1ezg ./create.pl 1f41.out && mv complex.* 1f41

Categories : Python

How to skip the extra newline while printing lines read from a file?
the python print statement adds a newline, but the original line already had a newline on it. You can suppress it by adding a comma at the end: print line , #<--- trailing comma For python3, (where print becomes a function), this looks like: print(line,end='') #rather than the default `print(line,end=' ')`. Alternatively, you can strip the newline off the end of the line before you print it: print line.rstrip(' ') # There are other options, e.g. line[:-1], ... but I don't think that's nearly as pretty.

Categories : Python

Sub-menu creates extra space
You're pretty close, but I made a couple of changes which should help you out. nav li { background:#abcdef; border-bottom:solid 1px #9abcde; color:#000; display:block; padding:1em 0; text-align:left; text-indent:1em; text-decoration:none; width:100%; position:relative; /* need to add so nested elements are positioned relative to the current menu item */ } nav li:hover ul { display: block; top:0; width:100%; position:absolute; /*need position absolute here to take it out of the 'flow'*/ left:100%; }

Categories : HTML

Hotspot creates two coloured lines on left and right side on "mouse down"
Use outline; FIDDLE area { outline : none !important; }

Categories : CSS

Swing chat window creates extra chat windows
Just remove the static keyword from private static UDPCS1 chat = new UDPCS1(); and no more chat windows will be there... Hoping it helped... Helped in my case i was doing something too,...

Categories : Java

Django inlineformset extra lines being ignored
In your view you have a single IndicatorForm for a single Indicator instance, along with a DiseaseFormSet to bind multiple Disease instances to that single Indicator. Yet in your models.py you have a ForeignKey from Indicator to Disease, meaning that an Indicator can only be bound to one single Disease instance, while a Disease instance can have as many Indicators as you want. To fix it, change the ForeignKey from being in the Indicator model to the Disease model, to being in the Disease model to the Indicator model - or if you want it the other way around, stick with the models you've got and use an IndicatorFormSet with a single DiseaseForm.

Categories : Django

remove extra lines from anchors
To remove the spaces below the links, add vertical-align:top; to the .tb-btn-s class. To remove the spaces next to the links, remove the white space in your code. jsFiddle example

Categories : HTML

Remove Extra Lines in Excel Sheet Using VB and .cmd
You have these lines towards the end of the Sub: oXL.Quit Handler: oXL.Quit The second Quit call fails, generating the error. You need to exit the procedure just before the Handler (which will only be called in the event of an error): oXL.Quit Exit Sub Handler: oXL.Quit

Categories : Excel

How to obtain multiple lines from a input file when the file sometimes contains random empty lines in python
Add something like this import re check=re.compile("d") def hasnumbers(a): return check.search(a) Then hasnumbers(line) will return true for good lines and false for blank and "box" lines

Categories : Python

Extra blank lines in a Sphinx unordered list
From your comments it seems that the issue is with the rendering of reStructuredText on http://rst.ninjs.org and how this looks with one particular CSS theme. This is not really an issue with reStructuredText. Ignoring the styling issues, the reason you are seeing two different behaviours between the two examples is because the two examples are different: in the first the code block is part of list item Item 2; in the second example the code block is not, and therefore closes the list above it and Item 3 therefore starts a new list. We can see why from studying the reStructuredText specification on bullet lists (emphasis mine), A text block which begins with a "*", "+", "-", "•", "‣", or "⁃", followed by whitespace, is a bullet list item (a.k.a. "unordered" list item). List it

Categories : Python

Extra Ruby lines inside If statements cause problems in Haml?
The HAML reference says: Ruby blocks, like XHTML tags, don’t need to be explicitly closed in Haml. Rather, they’re automatically closed, based on indentation. A block begins whenever the indentation is increased after a Ruby evaluation command. It ends when the indentation decreases (as long as it’s not an else clause or something similar). So, when you decrease the indentation, and that line isn't an else clause (or similar, elsif for example), the if finishes – an end is added implicitly. Then of course the else line is invalid Your solution is to indent the comment, either before or after the else clause: - if @condition - # Stuff like ______ activates the if statement (Some code) - else - # Stuff like _____ activates the else statement (Some other code)

Categories : Ruby On Rails

SQL- pad results with extra rows
Try this one - DDL: SET STATISTICS IO ON; IF OBJECT_ID (N'tempdb.dbo.#temp') IS NOT NULL DROP TABLE #temp CREATE TABLE #temp ( Store CHAR(1) , Name VARCHAR(10) ) INSERT INTO #temp (Store, Name) VALUES ('A', 'John'), ('A', 'Bill'), ('B', 'Sam'), ('C', 'James'), ('C', 'Tim'), ('C', 'Chris'), ('D', 'Simon'), ('D', 'Phil') Queries: DevArt #1: ;WITH cte AS ( SELECT Store , Name , rn = ROW_NUMBER() OVER (PARTITION BY Store ORDER BY (SELECT 1)) FROM #temp ) SELECT t.Store, Name = ISNULL(t3.Name, '') FROM ( SELECT DISTINCT Store FROM cte ) t CROSS JOIN (SELECT rn = 1 UNION ALL SELECT 2 UNION ALL SELECT 3) t2 LEFT JOIN cte t3 ON t2.rn = t3.rn AND t.Store = t3.Store DevArt #2: SELECT t2.Store, Name = ISNULL(

Categories : SQL

Finding max lines in a file while printing file name and lines seperately?
This should work: #!/bin/bash file="findfiles.sh" if [ $# -ge 1 ] then file=$1 fi if [ -f $file ] then lines=`wc -l "$file" | awk '{print $1}'` echo "The file $file has $lines lines" else echo "File not found" fi See sch's answer for a shorter example that doesn't use awk.

Categories : Linux

Why do I get extra commas in my python slqlite SELECT results?
You retrieved a list of rows, and each row is a tuple of columns. As each row contains only one column the rows are tuples with one value each. In python, it is the comma that makes an expression a tuple, even if there is only one element: >>> 1, (1,) Simply select the first element of each row: result_list = [row[0] for row in cur.fetchall()]

Categories : Python

Using JavaScript to put file into blob storage results in 403 (Server failed to authenticate request)
Gaurav here's the code I use to create the empty asset (w/ locator and file): /// <summary> /// Creates an empty asset on Azure and prepares it to upload /// </summary> public FileModel Create(FileModel file) { // Update the file model with file and asset id file.FileId = Guid.NewGuid().ToString(); // Create the new asset var createdAsset = this.Context.Assets.Create(file.AssetName.ToString(), AssetCreationOptions.None); // Create the file inside the asset and set its size var createdFile = createdAsset.AssetFiles.Create(file.Filename); createdFile.ContentFileSize = file.Size; // Create a policy to allow uploading to this asset var writePolicy = this.Context.AccessPolicies.Create("Policy For Copying", TimeSpan.FromDays(365 * 10), AccessPe

Categories : Azure

Two strings evaluated by regex, but one of the scan results are being put into an extra array?
Its because you are capturing the name in name_line_1 using parentheses. This causes the scan method to return an array of arrays. If you absolutely must return a 1 dimensional array, you can use forward and backward checking like so: /(?<=*Hi ).*(?= *,)/ Or, if you find that too confusing, you could always just call .flatten on the resulting array ;-)

Categories : Ruby

Reading Lines in Batch File - How To Read Paired Distant Lines
@ECHO OFF SETLOCAL enabledelayedexpansion SET count=0 SET distance=5 :: create a temporary file with a dummy line, :: then numbered lines from the data file ECHO 0:dummy >dummy.txt TYPE acct.txt|FINDSTR /n "$">>dummy.txt :: Now pair lines ( FOR /l %%z IN (1,1,%distance%) DO ( CALL :grabline account %%z SET /a skip=%%z+%distance% CALL :grabline password !skip! SET "account=!account:*:=!" SET "password=!password:*:=!" ECHO(!account! !password! ) )>acctpass.txt del dummy.txt GOTO :eof :grabline FOR /f "skip=%2delims=" %%d IN (dummy.txt) DO SET "%1=%%d"&GOTO :eof GOTO :eof I've no idea what "32 block intervals" are, but here's a routine to pair the lines located at a defined distance. I used a distance of 5 for testing with a file account1 ... account5 password1 ...

Categories : Batch File

Android: Writing XML file creates 2 files if whitespace is present in file name
Found my problem ! I actually had two calls to create new files: if (!f.exists()) f.createNewFile(); and Result result = new StreamResult(f); transformer.transform(source, result); Without whitespace in the file name, everything went well as they both treated the same files. However, with whitespace, StreamResult encodes the file name as a URL (therefore with %20 replacing spaces) whereas createNewFile() does not. The fix was simple. I removed the f.createNewFile(); line and added: result.setSystemId(java.net.URLDecoder.decode(result.getSystemId(), "UTF-8")); therefore writing the filename correctly with spaces.

Categories : Android

Ignore lines in a file till match and process lines after that
I'd use flip-flop operator: while(<DATA>) { next if 1 .. /Important/; print $_; } __DATA__ skip skip Important Lines below this Line keep keep output: keep keep

Categories : Perl

client creates new socket object everytime the server is on
I think the problem is at the client's side you read a line and then create a new connection. I think you must keep reading the socket until it's closed or an error occurs. For example: while (true) { tabletclient = null; int loop = 0; // loop until a connection is established while (tabletclient == null) { try { tabletclient = new Socket(SERVER_IP, TAB_SERVER_PORT); } catch (Exception e) { e.printStackTrace(); // set the value to quit when no connection could be established if (loop++ > 100) return; } } try { tabletout = new PrintWriter(tabletclient.getOutputStream()); in = new Scanner(tabletclient.getInputStream());

Categories : Java

gwt getModuleBaseURL on same server creates an java.lang.UnsatisfiedLinkError
Everything client in GWT is only meant to run on the client-side: compiled to JS or in DevMode. Only shared, server and vm classes can be used on the server-side. If you want to get your server URL, use the appropriate methods from the HttpServletRequest (or whatever it is in Spring MVC as it seems from how you tagged the question that's what you're using). If you want to make HTTP requests from your server, use an HttpURLConnection, or OkHttp, Apache Http Components or similar libraries, or even Spring's own HTTP client API.

Categories : Gwt

JavaScript creates and saves a file to local file system
I've just tested it, google doesn't create a file named log.txt (but the file will be accessible via the File-API by using this name). For me (WinXP) the file is located in %LOCALAPPDATA%/Google/Chrome/User Data/Default/FileSystem/ You'll find there some folders named by numbers, inside these folders may be 2 folders named t and p . You have ro search within the t-folder(because you have used window.TEMPORARY) Inside the t-folder is one more folder named by numbers, which contains files named by numbers. These files are the stored files. For me it's e.g. %LOCALAPPDATA%/Google/Chrome/User Data/Default/FileSystem/000/t/00/00000000

Categories : Javascript

How to create a batch file that creates a batch file that creates a batch file
you will have to escape special chars like >with a caret ^ echo echo echo hello ^>t3.bat >t2.bat type t2.bat call t2.bat type t3.bat call t3.bat

Categories : Batch File

Alphabetize lines in file then remove duplicate lines
As far as the sort goes, I would probably use a natcasesort: natcasesort The rest is pretty trivial and you should be able to implement it as you see fit.

Categories : PHP

How to remove lines (or text in given lines) from file in batch?
If you can get a gnu awk to run in what looks like a Microsoft environment, awk -f hunter.awk file.txt hunter.awk: BEGIN {printing=1;} //* K2START *// { printing=0; next; } //* K2END *// { printing=1; next; } { if ( printing ) print; } May I suggest the GnuWin32 project at http://gnuwin32.sourceforge.net/.

Categories : Batch File

Replace lines by line number with lines from other file
One way with awk: $ match="second textblock" $ awk 'NR==FNR&&!p;$0~m{print p;p=1};NR>FNR&&FNR>1' m="$match" file1 file2 first text block #blank line second textblock all #blank line the other lines #blank line

Categories : Regex

Which is fastest way to get 10 lines randomly inside a file with 10.000 lines?
try: $lines = file('YOUR_TXT_FILE.txt'); $rand = array_rand($lines); echo $lines[$rand]; for 10 of them just put it in a loop: $lines = file('YOUR_TXT_FILE.txt'); for ($i = 0; $i < 10; $i++) { $rand = array_rand($lines); echo $lines[$rand]; } NOTE: ** the above code does not guarantee that **2 same lines wont be picked. In order to guarantee uniqueness you need to add extra while loop and an array that holds all randomly generated indexes, so next time it generates it and it already exists in an array, generate another one until its not in the array. The above solution might not be fastest but might fulfill your needs. Since your server does not support any type of SQL, maybe switch to a different server? Because I am wondering how you are storing User Data? Are those sto

Categories : PHP

Make a bat file that creates a txt file in a defined format
Just add start to the beginning of the line. The contents of your batch file should be like this: start for /f "tokens=2-4 delims=/ " %i in ('date /t') do echo %k/%j/%i >> e:TAG.txt

Categories : Batch File

Google App Engine: Only local server creates infinite loop when forwarding to JSP
Use Chrome devtools, network tab to see what URLs are in the infinite loop. Try creating a hosts entry in %SystemRoot%system32driversetchosts, eg.devserver.example.com 127.0.0.1 and use that in place of "localhost"

Categories : Java

PHP script to remove all lines of the file except last n lines
Simply get the number of lines, and use that to know the line numbers for the last two lines: $lines_array = file("./home/userdata/log.ini"); $lines = count($lines_array); $new_output = ""; for ($i=$lines-2; $i<$lines; $i++){ $new_output .= $lines_array[$i]; } file_put_contents("./home/userdata/log.ini");

Categories : PHP

Trying to get file with max lines to print with lines number
you can try: wc -l $1/* | grep -v total | sort -g | tail -1 actually to avoid the grep that would also remove files containing "total": for f in $1/*; do wc -l $f; done | sort -g | tail -1 or even better, as suggested in comments: wc -l $1/* | sort -rg | sed -n '2p' you can even make it a function: function get_biggest_file() { wc -l $* | sort -rg | sed -n '2p' } % ls -l ... 0 Jun 12 17:33 a ... 0 Jun 12 17:33 b ... 0 Jun 12 17:33 c ... 0 Jun 12 17:33 d ... 25 Jun 12 17:33 total % get_biggest_file ./* 5 total EDIT2: using the function I gave, you can simply output what you need as follows: get_biggest $1/* | awk '{print "The file "" $2 "" has the maximum number of lines: " $1}' EDIT: if you tried to write the function as you've written it in the question, you should

Categories : Linux

mysqldump file creates an empty sql file
As documented here you can specify the password in the command like this [...] -pPASSWORD [...]. Note that there must not be a space between the -p option flag and the actual password. Keep in mind that specifying the password this way is a security risk!

Categories : Java

File creates but cannot write in it
Try this: using(FileStream stream = File.Create(path)) { TextWriter tw = new StreamWriter(stream); tw.WriteLine("Manual Numbers="); tw.WriteLine(""); tw.WriteLine("Installation Technical Manual: "); tw.WriteLine("Performance Manual: "); tw.WriteLine("Planned Maintenance Technical Manual: "); tw.WriteLine("Service Calibration Manual: "); tw.WriteLine("System Information Manual: "); tw.WriteLine(""); } The using ensures that the filestream is closed(disposed) even when an exception occurs within writing.

Categories : C#

mkdir always creates a file instead a directory
There are many way to debug a shell-scripting. Add set -x in your beginning script Get the return value. mkdir 'the-directory' ret=$? if test $ret -eq 0; then echo 'Create success.' else echo 'Failed to create.' fi Set to verbose mode $ mkdir -v 'the-directory' Try this command $ type mkdir, to checking mkdir command.

Categories : Bash

Accessing App Config file creates an error
Try to use the Properties.Settings class to access the app.config file, check Application Settings for Windows Forms

Categories : C#

Fish function creates random file
That > isn't doing a comparison, it's output redirection. That is, it's taking the output of count $argv and writing it into a file called 0. You probably want something like: function ga if [ (count $argv) -gt 0 ] git add $argv else git add . end end

Categories : GIT

New-Item creates file instead of directory about 10% of the time
Not sure if my understanding is right: the script is running on clients. Clients run the script and do all the file/folder processing on the server (since I saw you just mentioned "server name"). So although you have several (or lots of) clients running this script but the location of file/folder processing is still on one single server. If the answer is "yes" then you might want to try chkdsk [hard drive letter] /f on the server you have problem with. Since it is a server make sure you have a good backup copy of the data of the volume you "chekdsk" on although chkdsk /f is safe - it checks and fixs the inconsistencies on disk for you. This answer is based on this article: http://answers.yahoo.com/question/index?qid=20070519001528AApeRx6

Categories : Powershell

How to match lines in one file against lines in another?
Try: if ($lineA =~ m/$lineU/sxm) Also, consider the possibility that you may have differing line endings in the file, and strip line endings prior to performing your comparison. Finally, I'm hoping that you recognize that you're ignoring the first line of each file by pulling a line prior to starting your while loops. my $lineU = <$unused>; my $lineA = <$all>; If you didn't want to do this, it would be better to initialize as such: my $lineU = q{}; my $lineA = q{};

Categories : Perl

Generate the .bat file that will copy the selected lines from the .bat file (within .bat file) to another text file
Use the lines as below Echo The land is beautiful >> %_file% echo I wanna stay here >> %_file% echo etc........ >> %_file% echo etc........ >> %_file%

Categories : Batch File

Core data creates an sqlite file with no tables
NSBundle *modelWrapper = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"StudentData" ofType:@"momd"]]; NSString *modelPath = [modelWrapper pathForResource:@"StudentData" ofType:@"mom"]; managedObjectModel = [[NSManagedObjectModel alloc]initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];

Categories : Objective C



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.