w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
how to extract file names with .csv extension from a file
String#split(String) uses a regx to split a String. However for your case there is no need of using regex: String s = "abc.csv"; String r = s.substring(0, s.lastIndexOf('.')); //=> abc

Categories : Java

Using a WebClient to save an image with the appropriate extension
Try something like this HttpWebRequest request = (HttpWebRequest)WebRequest.Create("Your URL"); request.Method = "GET"; var response = request.GetResponse(); var contenttype = response.Headers["Content-Type"]; //Get the content type and extract the extension. var stream = response.GetResponseStream(); Then save the stream

Categories : C#

in array the image extension get variables
In simple way you can do it by below way: <?php $extensions = array('.jpg', '.JPG', '.png' ,'.PNG' ,'.jpeg' ,'.JPEG'); $extension = pathinfo('$file_name'); in_array($extension,$extensions); { $image = $somepicture."*.".$extension.""); } ?>

Categories : PHP

Extract image's width, height, color and type from byte array
Use ImageIO to read as buffered image and then get relevant things which you want. See java doc at http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageIO.html. import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; public class Test { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // assuming that picture is your byte array byte[] picture = new byte[30]; InputStream in = new ByteArrayInputStream(picture); BufferedImage buf = ImageIO.read(in); ColorModel model = buf.getColorModel(); int height = buf.getHeight(); } }

Categories : Java

Successful checkbox array for image names, but now display images in email output?
Something like this, maybe: $Image_Style_Array = ""; foreach ($Image_Style as $image) { $Image_Style_Array .= '<img src="images/' . $image . '" style="border-right:1px solid #CCC;">';

Categories : PHP

how can i get image pixels and save it in int array?
Try this: int[] pixels = new int[yourBitmap.getHeight() * yourBitmap.getWidth()]; yourBitmap.getPixels(pixels, 0, myBitmap.getWidth(), 0, 0, yourBitmap.getWidth(), yourBitmap.getHeight());

Categories : Android

The word "Array" Added to every file name when trying to save an image - PHP
$_FILES['uploaded'] is an array. Array ( [name] => Array ( [1] => Array ( [0] => ) ) [type] => Array ( [1] => Array ( [0] => ) ) [tmp_name] => Array ( [1] => Array ( [0] => ) ) [error] => Array ( [1] => Array ( [0] => 4 ) ) [size] => Array ( [1] => Array ( [0] => 0 ) ) ) You're probably looking for $_FILES['uploaded'

Categories : PHP

Find out the extension of an image, if that image doesn't have any extension
There are java libraries like mime-util or jmimemagic that can detect the file type from the pure content.

Categories : Java

How to fetch an array of image URLs with node.js and save to s3 asynchronously?
There are several things you could improve with your code: HTTP Agent First of all, node.js uses an HTTP Agent, which limits the number of concurrent connections to a host. If it wasn't, you could easily accidentally hammer websites with thousands of connections. You can disable it by passing {agent: false} to request. Note that knox already disables it. I suspect this is the reason why your code runs sequentially. Async.each Async.each will run all iterations in parallel. When you are calling nextImage(), you are not telling async to start the next iteration, but rather say that you are done. Async completes when all iterations are done. The problem here is that you keep doing work after you told async that you were finished.

Categories : Node Js

PHP image upload function, save in a dir and then return save image url
for file upload try this <?php if(isset($_POST['submit'])) { $ImageName = $_FILES['photo']['name']; $fileElementName = 'photo'; $path = 'images/'; $location = $path . $_FILES['photo']['name']; move_uploaded_file($_FILES['photo']['tmp_name'], $location); } ?> <form name="form1" id="form1" method="post" action="" enctype="multipart/form-data"> <input type="file" name="photo"> <input type="submit" name="submit"> </form>

Categories : PHP

how to get the extension of a image file with known filename not extension
You can find the file extension in php like this: $file_parts = pathinfo($filename); $file_extension = $file_parts['extension']; Or if you don't know the extension, you have tot do something like this: $dirname = "./somedir/"; $filename = "myfile"; $iterator = new RegexIterator(new DirectoryIterator($dirname), '/^' . preg_quote($filename) . '.[^.]+$/iD'); // Any matching files? if (iterator_count($iterator) > 0) { echo "Matches found: "; } else { echo "No matches found. "; } // Get extensions of matching files foreach ($iterator as $fileinfo) { printf("%s -> %s ", $fileinfo, pathinfo($fileinfo, PATHINFO_EXTENSION)); } As seen on http://www.sitepoint.com/forums/showthread.php?631513-possible-check-if-file-filename-exists-w-o-knowing-its-extension

Categories : PHP

named arrays as dataframe ->col.names(df) = names(array)
> namearray evntidABCD evntidWXYZ 1 2 That is surely not looking like an 'array'. Named 'vector' perhaps. If you create a dataframe with no columns then there is nothing to to name. This will extend a "null dataframe" namevec <- c(evntidABCD=1, evntidWXYZ =2) namedf<-data.frame() namedf <- setNames( rbind(namedf,namevec), names(namevec) ) (Justin's suggestion is better.)

Categories : R

Extract numbers and names from string
Here's a regex-only solution: (?:(d+)|([^,]+))(?=,|$) The first group (d+) captures numbers, the second group ([^,]+) captures the rest. A group must be followed by a comma or the end of line (?=,|$). A quick demo: Pattern p = Pattern.compile("(?:(\d+)|([^,]+))(?=,|$)"); Matcher m = p.matcher("foo3,1234,4bar,12,12foo34"); while (m.find()) { System.out.println(m.group(1) != null ? "Number: " + m.group(1) : "Non-Number: " + m.group(2)); } Output: Non-Number: foo3 Number: 1234 Non-Number: 4bar Number: 12 Non-Number: 12foo34

Categories : Java

Regex to extract names from HTML
Match anything that is not a < character; you also cannot use a variable-width look-behind so your version doesn't work at all. Use a non-capturing pattern instead (?:;"><strong>(?:<em>)?)([^<]+?)(?=(?:</em>)?</strong>) Demo: >>> import re >>> sample = ''' ... ;"><strong>DeanSkyShadow</strong> ... ;"><strong><em>Xavier</em></strong> ... ''' >>> re.findall(r'(?:;"><strong>(?:<em>)?)([^<]+?)(?=(?:</em>)?</strong>)', sample) ['DeanSkyShadow', 'Xavier'] The better solution is to use a HTML parser instead. I can recommend BeautifulSoup: from bs4 import BeautifulSoup soup = BeautifulSoup(htmltext) for strong in soup.find_all('strong'): print strong.te

Categories : Python

extract table names from any select query using php
You can't parse SQL with simplistic regular expression matching... What happens when the tables are aliased? When there are subqueries? Cross joins? Unions? etc. The SQL grammar is quite rich. Look for an SQL parser. e.g.: https://code.google.com/p/php-sql-parser/

Categories : PHP

extract string of method names from database?
I guess that it could be made working, although I am not really sure if it is worth: you are adding a lot of complexity for almost no additional benefit. Said that, something along the lines of - if signed_in? - @current_group.navbars.each do |navbar| - if navbar.kind == "Header" - navbar.links.split(' ').each do |method| = self.send(method) Basically, take the string "profile_link community_link", split it using the space character and then send each method to the view (which is self in this context). Using send just executes the method as you would do normally, but gives you the benefit of deciding which method to execute at runtime :)

Categories : Ruby On Rails

R - extract variable names from unevaluated expression
The "left hand side" of expression(x=y+z) is actually the name of the argument you're passing to expression(), whose value is the (unevaluated) call y + z. So it's not a part of the expression, but is returned as the name of the list element (an expression is a list of calls, usually unnamed): > as.list(expression(x=y+z)) $x y + z > names(expression(x=y+z)) [1] "x" If, OTOH, you use the formula constructor ~, then you get the LHS as a part of the expression: > as.list(expression(x~y+z)) [[1]] x ~ y + z And you can get to it selecting the second element of the call: > expression(x~y+z)[[1]] x ~ y + z > expression(x~y+z)[[1]][[1]] `~` > expression(x~y+z)[[1]][[2]] x Note: in the last line, x is a symbol.

Categories : R

extract column names from sql query after where clause
My answer to this question is to not parse the user input - there is far too much that can go wrong. It would be a lot better to have a UI with drop downs and buttons for selecting equality, inequality, ranges, in statements, etc. It may seem like more work, but protecting yourself from a SQL injection attack is even more. And even if you are not concerned about malicious SQL injection, then the user still has to get every thing exactly right, or the statement fails.

Categories : Java

Bash - extract file name and extension from a string
Using awk: grep "%SWFPATH%/plugins/" filename | awk '{ match($0, /plugins/([^/[:space:]]+).([[:alnum:]]+)/,submatch); print "filename:"submatch[1]; print "extension:"submatch[2]; }' Some explanation: the match function takes every line processed by awk (indicated by $0) and looks for matches to that regex. Submatches (the parts of the string that match the parts of the regex between parentheses) are saved in the array submatch. print is as straightforward as it looks, it just prints stuff.

Categories : Bash

How to extract last 2 characters before the extension of a filename in bash?
In order to pull something out of the middle of a string, you can use a substitution. The following works in bash: filename=myfileRE.txt echo "${filename/??./.}" This is matching the pattern "??." and replacing it with ".". It is similar to a perl or sed substitution, except it uses shell pattern matching instead of regex.

Categories : Regex

Extract values of a pairwise matrix given similar samples names
example <- matrix(data=c(0,79,111,113,110,79,0,110,112,109,111,110,0,80,115,113,112,80,0,117,110,109,115,117,0),nrow=5,ncol=5,dimnames=list(c("Sample1","Sample1_r","Sample2","Sample2_r","Sample3"),c("Sample1","Sample1_r","Sample2","Sample2_r","Sample3"))) > example Sample1 Sample1_r Sample2 Sample2_r Sample3 Sample1 0 79 111 113 110 Sample1_r 79 0 110 112 109 Sample2 111 110 0 80 115 Sample2_r 113 112 80 0 117 Sample3 110 109 115 117 0 row.ind <- grep("_r",rownames(example),value=TRUE) col.ind <- match(sub("_r","",row.ind),colnames(example)) your.df <- data.frame(sample=colnames(example)[col.ind], dist=diag(exampl

Categories : R

How to extract all columns from a dataframe based upon partial column names in a vector using R
Assuming that v.names is your vector of names, you can use grepl to filter using and aggregating pattern: patt <- sub(',\s','|',(toString(v.names))) id.group <- grepl(patt,colnames(df)) df[,id.group] here an example: v.names <- c('GRP20R','GRP20KA') df <- data.frame(GRP20R.45.M=1,GRP20KA.25.8=2,hh=1) patt <- sub(',\s','|',(toString(v.names))) id.group <- grepl(patt,colnames(df)) df[,id.group] GRP20R.45.M GRP20KA.25.8 1 1 2 where df is : df GRP20R.45.M GRP20KA.25.8 hh 1 1 2 1 EDIT a liner solution (thanks @thelatemail) df[,grepl(paste0(v.names,collapse="|"),colnames(df))]

Categories : R

Extract Information from multiple workbooks into a master workbook using Define Names
You can loop over worksheet named ranges using the names collection For Each namedRange In Application.Workbooks("Vba Cost Budget").Worksheets("Costs").Names ... Next namedRange

Categories : Excel

Extract file name (without extension) while indexing using Data Import Handler in Solr
Check ScriptTransformer to replace or change the value before it is indexed. Example - Data Config - Add custom field - <script><![CDATA[ function changeFileName(row){ var fileName= row.get('fileName'); // Replace or remove the extension .. e.g. from last index of . file_name_new = file_name.replace ...... row.put(fileName, row.get('file_name_new')); return row; } ]]></script> Entity mapping - <entity name="f" transformer="script:changeFileName" ....> ...... </entity>

Categories : Solr

Save an Image generated during runtime onto the Picture library using File Save picker C# Win 8 Metro App?
var response = await HttpWebRequest.Create(url).GetResponseAsync(); List<Byte> allBytes = new List<byte>(); using (Stream imageStream = response.GetResponseStream()) { byte[] buffer = new byte[4000]; int bytesRead = 0; while ((bytesRead = await imageStream.ReadAsync(buffer, 0, 4000)) > 0) { allBytes.AddRange(buffer.Take(bytesRead)); } } StorageFolder storageFolder = awai KnownFolders.PicturesLibrary.CreateFolderAsync("QR Codes Generator",CreationCollisionOption.OpenIfExists ); //var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(

Categories : C#

Expand Variadic Template in Vardiadic Macro (how to extract arguments names from a target function)
CPP is only a copy-paste text system. Its not dessigned to do that kind of magic. In fact, it only does stupid "When you see X , put Y" operations. In your case, if you try to iterate over the variadic pack: inline void print(const std::string& name) { std::cout << name << std::endl; } #define PRINT(name) print(#name) //Base case: void extract() {} //Recursive case: template<typename HEAD , typename... TAIL> void extract(const HEAD& head , const TAIL& tail...) { PRINT(head); extract(tail...); } You only get: head head head head ... The answer is: Avoid the use of the CPP for stupid things, only use it for #ifdef #endif header guards and portable compilation. Note that GET_GREATHER(x,y) ((x) > (y) ? (x) : (y)) like macros are n

Categories : C++

How to get image from an Image Control Type in .net c#, I need to save this image in a file and then use it for later comparing
Previewing Image in ASP.NET Image Control using C# help you to get image from an Image Control Type. You can save the image in the below way. Image bitmap = Image.FromFile("C:\MyFile.bmp"); bitmap.Save("C:\MyFile2.bmp"); You should be able to use the Save Method from the Image Class and be just fine as shown above. The Save Method has 5 different options or overloads. //Saves this Image to the specified file or stream. img.Save(filePath); //Saves this image to the specified stream in the specified format. img.Save(Stream, ImageFormat); //Saves this Image to the specified file in the specified format. img.Save(String, ImageFormat); //Saves this image to the specified stream, with the specified encoder and image encoder parameters. img.Save(Stream, ImageCodecInfo, E

Categories : Dotnet

Save same file to SD Card with multiple names
Try this approach: File file = getContext().getFileStreamPath(FILE_NAME); if(file.exists()){ ... } OR File sdCardRoot = Environment.getExternalStorageDirectory(); File yourDir = new File(sdCardRoot, "yourpath"); for (File f : yourDir.listFiles()) { if (f.isFile()) String name = f.getName(); // substr the name to find the last digits } You can check if the file exists and then append the corresponding number.

Categories : Android

Save program state in chrome extension between uses
You may use local storage of the browser. However if you want to be really flexible you may use nodejs and sockets. That's how I made my extension. I used nodejs, which has an access to the user's disk and sockets to communicate with the node app. The only one problem is that the user should install the module.

Categories : Javascript

Tincr chrome extension won't save file changes
i had the same problem with Tincr But you can change in your files (css/js) using DevTool and save your changes to source file by using workspaces you need just choose project or folder which contain your files this two videos explain workspaces: http://www.youtube.com/watch?v=kVSo4buDAEE http://www.youtube.com/watch?v=x6qe_kVaBpg

Categories : CSS

How to extract image orientation information from image loaded in Canvas
Prerequisites There is of course a dependency here on the device that takes the picture that it actually has a sensor that can tell orientation. Some cameras do others don't. And even if it does have a sensor there is no guarantee EXIF will be embedded in the image. EXIF is not embedded for PNG for example and some upload JPEG images where EXIF is removed for privacy and/or size reasons (eg. GPS coordinates etc.). Photoshop will remove EXIF if saved out using its "Save for web" option. Try different EXIF components There is also the possibility that the EXIF component you are using has a bug. Try other EXIF readers out there as well to eliminate this: code.flickr.com ExifReader exif-js (and there are a ton of others). Detecting "raw" orientation In case you only have an "raw" ima

Categories : Javascript

How can I extract the first frame of a GIF and save it as a PNG using GraphicsMagick on NodeJS?
Since I couldn't get it working on the server-side, I ended up just drawing the .gif to a <canvas> element to "simulate" extracting a .gif's first frame. This gave me the paused gif that I was going for.

Categories : Javascript

Extract Info from TMDB and save to Rails DB
Looking at the documentation you can do it like this assuming you have a Movie class with the appropriate migrations for title and description. movie = TmdbMovie.find(:title => "Iron Man", :limit => 1) @movie.title = movie.title @movie.description = movie.description # Not sure if the returned data contains a description @movie.save EDIT~ In update to below comment. Let's say you have your MovieController and a user is a searching for the movie through a search field which would be in params[:search] and the movie returned would be stored in the database. If this is being done in the index action it would look like below. def index movie = TmdbMovie.find(:title => params[:search], :limit => 1) @movie = Movie.new @movie.title = movie.title @movie.description - movi

Categories : Ruby On Rails

How to save and extract session data in codeigniter
initialize the Session class in the constructor of controller using $this->load->library('session'); for example : function __construct() { parent::__construct(); $this->load->model('user','',TRUE); $this->load->model('user_activity','',TRUE); $this->load->library('session'); }

Categories : PHP

Save file names with Cyrillic letters from one textfile to other
try this: @ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION FOR /f "tokens=2 delims=:" %%a IN ('chcp') DO SET /a CurrentCodePage=%%a 2>nul CHCP 1251 >nul FOR /f "tokens=1*delims=," %%a IN ('type file.txt') DO ( SET "link=%%a" SET "channel=%%b" IF DEFINED channel (SET "fname=!channel!" ) ELSE (ECHO !link!)>"!fname!.txt" ) CHCP %currentCodePage% >nul dir output is with code page 850: 06/29/2013 08:38 AM 48 49 ?????.txt 06/29/2013 08:38 AM 47 5 ????? ??????.txt 06/29/2013 08:38 AM 46 Disney Channel.txt 06/29/2013 08:38 AM 47 ??3.txt 06/29/2013 08:38 AM 47 ???.txt dir output is with code page 1251: 06/29/2013 08:38 AM 48 49 Канал.txt 06/29/2013 08:38 AM

Categories : Windows

How to save an external page using JavaScript (in Chrome extension)?
The simple answer is no, the chrome.pageCapture.saveAsMHTML requires you to pass in the ID of the tab you wish to capture. MHTML files embed all the resources (e.g. images, css, javascript etc) associated with a HTML document into a single file. Another method you could use to capture the HTML is by using a xmlhttprequest. Although you'd need to make individual calls to capture all the associated resources. xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var responseHtml = xmlhttp.responseText; } } xmlhttp.open("GET","http://www.website.com/target.html", true); xmlhttp.send();

Categories : Javascript

Vba open files without extension from folder and save as different format
Your current code is only looking for files that already have the .xlsx extension. Try Dir('*'). If you are just renaming the files then I wouldn't attempt to open them. I would use FileCopy FileCopy source, destination where source and destination are both strings. For example, the following worked for me (on Windows XP): FileCopy "testthis", "testthis.xlsx" You could then use Kill to delete the old file Kill pathname

Categories : Excel

extract an object from image using some image processing filter
You can use object detection methods such as http://opencv.willowgarage.com/documentation/object_detection.html http://docs.opencv.org/modules/objdetect/doc/latent_svm.html to detect the object, plot a bounding box around it and extract it from the image.

Categories : Objective C

Ruby 101: How Can I Save, Read, Write, then Save the Contents of an Array?
Array#to_s does indeed have different behaviour in ruby 1.8 and 1.9. There's universal way to get the string that you want. Array has a join method that concatenates all elements of the array with a separator. Your separator would be a string ', '. @points = [1, 2, 3, 4] s = "SAVED_POINTS2 = [#{@points.join(', ')}]" s # => "SAVED_POINTS2 = [1, 2, 3, 4]"

Categories : Ruby

Extract numbers/characters from string in R and save as variable
If the string has always the same format, you can use : dist<-as.numeric(substr(text,18,21)) unit<-substr(text,22,23) way<-substr(text,25,28) But it won't work if it doesn't, for example if the number's length change (from 0.56 to 12.21 for example). You must make sure it doesn't happend !

Categories : R



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