I'd like to copy the text in ng-grid as Tab Separated Values [TSV] but right now
it has 1 item per row. For example:
| A | B | C |
| D | E | F |
becomes
A
B
C
D
E
F
rather than
A B C
D E F
Best if this worked for Ctrl-C as well as Right-Click | Copy.
Any Angular or jQuery plugins which do this or code recommendations/samples?
Currently planning to override oncontextmenu for right-clicks, but will not be able to access $scope unless there is a way to handle right clicks using ng-click.
Related
There are lots of resources for getting name, website, accreditation info, etc for higher education institutions such as the College Scorecard API or IPEDS. What I need for this project is to find a general contact information email address for my set of a few hundred colleges and universities. I plan on using Google Sheets and Apps Script to collect this data.
I have a spreadsheet such as
| Name | URL | City | State | Email |
|-----------------------|----------------------|-----------------|-------|-------|
| Prairie State College | www.prairiestate.edu | Chicago Heights | IL | |
| Langston University | www.langston.edu | Langston | OK | |
where I need to fill in the "email" column. Does anyone know any APIs that could help with that? A quick Google search tells me that ldickerson#prairiestate.edu is the contact at Prairie State College, whereas the admissions page of Langston University has luadmissions#langston.edu right on it. Does anyone have any ideas on where I can pull this data from automatically?
There is no direct API that can help you achieve that.
What you can do instead is to use UrlFetchApp from Apps Script and retrieve the page text from the admission/contact pages wanted. Afterwards you can retrieve the email address from the page text retrieved using regex.
The below code does the mentioned above but depending on the page, it may retrieve more than one email address. If you know exactly that the first email in the list is the email address you actually need, you can call email[0] instead.
function findMail() {
var url ="ADMISSION_CONTACT_PAGE_URL";
var pageText = UrlFetchApp.fetch(url).getContentText();
var email = pageText.match(/([a-zA-Z0-9._-]+#[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
Logger.log(email);
}
Reference
UrlFetchApp Class Apps Script;
Regex Tester.
As my role as tester (among all the things), I need to review log files for errors. Unfortunatly, the generated output file (file-YYYY-MM-DD.log) displays all kinds of information, not just the errors (or "things that go bad").
My question is; how do I hide the lines I don't want and generate an output file (log) containing the deviations (errors, warnings etc)?
For example, I want to hide:
| I | variable text I do not want, location: /path/to/foo/bar
| W | service X stopped
| W | service X started
The most ideal outcome with the script I want is:
-> Ask question: "Do you want to hide information and warning messages? |
-> Answer: yes --> hide all | I | message (like: no new foo's found in: /location/to/foo.
-> Answer: no --> do nothing (closes script)
The data is from an Unix environment, however the script is going to run in an Windows environment.
Thanks
I'm looking for something similar to yeoman generator for creating boilerplate. But for creating boilerplate inside a existing project. I want to automate a creation of a new view on a large project, which includes the name of the view, and it would create a directories and a javascript for the view, a template, a style for the template, and then declare stuff on some specific file.
e.g. generate MyView
would create something like this
|-app
| '--views
| '-- MyView/MyView.js
| '--templates
| '-- MyView/MyView.html
| '-- MyView/MyView.less
|
| '--styles.less <- #include templates/MyView.less
| '--loader.js <- my_view : views/MyView.js
For a project I am working on I am trying to save the contents of a WPF RichTextBox to a RTF file as the title states. I have it working for the most part. However, the file does not preserve newlines. When I save the file ( as you will see below ) it will save everything to one line in the RTF. You can see how it is saved below.
private void butSaveHistory_Click( object sender, RoutedEventArgs e ) {
Microsoft.Win32.SaveFileDialog myDlg = new Microsoft.Win32.SaveFileDialog();
myDlg.DefaultExt = "*.rtf";
myDlg.Filter = "RTF Files|*.rtf";
Nullable<bool> myResult = myDlg.ShowDialog();
if ( myResult == true ) {
/*using ( FileStream myStream = new FileStream( myDlg.FileName, FileMode.OpenOrCreate, FileAccess.Write ) ) {
TextRange myRange = new TextRange( rtbTraffic.Document.ContentStart, rtbTraffic.Document.ContentEnd );
myRange.Save( myStream, DataFormats.Rtf );
myStream.Close();
}*/
rtbTraffic.SelectAll();
rtbTraffic.Selection.Save( new FileStream( myDlg.FileName, FileMode.OpenOrCreate, FileAccess.Write ), DataFormats.Rtf );
}
}
AS you can see I tried two different ways. ( One is commented out ) Neither of these work, they both just save everything to one line when everything in the RichTextBox is on multiple lines.
So how can I get the file to save to multiple lines? Any tips or suggestions would be greatly appreciated.
Note: When saving to a .txt file it saves correctly to multiple lines. However, I cannot save to .txt because the colors and fonts of the RichTextBox need to be preserved.
Edit: This is a sample of what the RichTextBox looks like.
After saving the file it looks like this when i open the RTF in word.
This is what I want it to output.
Edit 2: Adding RTF code
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}{\f3\fcharset0 Arial;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red0\green0\blue255;\red255\green0\blue0;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\b\cf0 \cf0\ql{\f3 {\b0\cf2\highlight1\ltrch 09:10:48 | Thing | STATUS Tube_Heat_Consumer,TUBE_HEAT,3.14209:11:47 | Thing | STATUS Tube_Heat_Consumer,TUBE_HEAT,2.718}{\b0\cf3\highlight1\ltrch 09:58:49 | Thing | STOP STOP}{\b0\cf2\highlight1\ltrch 09:58:49 | Thing | STOP STOP}{\b0\highlight1\ltrch 09:58:57 | Thing | DeRegistration Successful}{\b0\cf4\highlight1\ltrch 09:58:58 | Thing | DeRegistration Failed ( Application is not currently registered ) | 81270401}{\b0\highlight1\ltrch 09:58:58 | Thing | Registration Successful}\li0\ri0\sa0\sb0\fi0\ql\par}
}
} Thing | DeRegistration Failed ( Application is not currently registered ) | 81270401}{\b0\highlight1\ltrch 08:55:21 | Thing | Registration Successful08:55:22 | Thing | DeRegistration Successful08:55:22 | Thing | Registration Successful}{\b0\cf2\highlight1\ltrch 08:55:22 | Thing | Registration Failed ( Application Thing already registered ) | 8127040008:55:22 | Thing | Registration Failed ( Application Thing already registered ) | 81270400}{\b0\highlight1\ltrch 08:55:23 | Thing | DeRegistration Successful08:55:23 | Thing | Registration Successful08:55:24 | Thing | DeRegistration Successful08:55:24 | Thing | Registration Successful08:55:25 | Thing | DeRegistration Successful}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}
From the looks of it it is not encoding \par or \lines correctly.
It will be more simple to answer if you put some example of rtf code you try to save, the result you have and what you want.
I'm not sure of what you want to be in multiple line. The rtf in a more easiest "reading" format for human? Where one line in richtextbox is on one line in rtf format like this:
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1036\fs18\f2\cf0 \cf0\ql
{\f2 {\ltrch aaaaa}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch bbbb}\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch }\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch cccc}\li0\ri0\sa0\sb0\fi0\ql\par}
}
}
in richtextbox I see this
aaaa
bbbb
cccc
I'm not sure of the interest to do that, because newline is encode by \par for end of paragraphs and \line for new line in the current paragraph then when you open the rtf file with a program (MS Word for example) newlines are respected.
And I obtain the same with this:
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1036\fs18\f2\cf0 \cf0\ql {\f2 {\ltrch aaaaa}\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch bbbb}\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch }\li0\ri0\sa0\sb0\fi0\ql\par}{\f2 {\ltrch cccc}\li0\ri0\sa0\sb0\fi0\ql\par}}}
Don't add the rtf code directly, use Wpf Paragraph and so on.
When you add your new line to RichTextBox use
YourParagraph.Inlines.Add(new LineBreak());
instead of \r\n or something like this.
As you can see in this post, if you add text as plaintext programaticaly to the RichTextBox control, you may have to add this unicode line separator \u2028. And it will normaly converted to \line in the Rtf saved file.
And I recommend you to use the method with TextRange.
I want to implment a navigate panel with buttons to control the scrollbar position of a scroll viewer. The button effect will like an ancher in html page. If click one button then the content will scroll to relative position in the scroll viewer. Is it an easy way to implement this?
--------------------------------------------
|Button0 | Button 0 relative content | |
|Button1 | ... | |
|Button2 | ... |-|
|--------- ... |||
| ||| <--the scrollbar
| ... |-|
| Button 1 relative content | |
| ... | |
| ... | |
| Button 2 relative content | |
---------------------------------------------
Thanks in advance!
It's a bit tricky because there is no build in utility function for this (as far as I know).
At the moment I can think of two feasible solutions:
First Solution: Calculate the scroll positions for your Content via UIElement.TransformToVisual Method
Something like this (not tested, not done any brainwork):
private void GotoContent3()
{
var generaltransform = m_content3.TransformToVisual( m_scrollviewer);
Point offset = generaltransform.Transform( new Point( 0, 0 ) );
m_scrollviewer.ScrollToVerticalOffset( offset.Y );
}
Second Solution (not recommended): Use a ListBox to display your Content and call ListBox.ScrollIntoView Method