grep or sed to match a block between start and end using same pattern

Uncategorized
Question: I have a file with the following info:start pattern1 line1 line2 ... end pattern1 If I know what "pattern1" is , I can do sed '/start pattern1/,/end pattern1/p' but here, I want to match pattern1 and use the same in the end. How can I do that? Answer: Using awk to print between pattern1s (inclusive):$ awk '/pattern1/{p=!p;print;next} p' file pattern1 line1 line2 ... pattern1 The regex could be defined better, like /^pattern1$/ or $0=="pattern1". Read more
Read More

Why does core data trims string values?

Uncategorized
Question: I am using Core data. One of my NSManagedObject has a string property which stores the document directory path. When I see my DB in SQLite browser, I see the full link. But when I fetch, it is trimmed. My sort descriptor is only using a time based sorting, nothing else. Here is the fetch:NSFetchRequest *fetchDrafts = [[NSFetchRequest alloc] initWithEntityName:@"DraftPost"]; NSSortDescriptor *sortViaDate = [NSSortDescriptor sortDescriptorWithKey:@"timestamp" ascending:NO]; fetchDrafts.sortDescriptors = @[sortViaDate]; NSError *fetchDraftsError = nil; [_offlinePostsArray addObjectsFromArray:[[[AppStateManager sharedInstance] applicationDBContext] executeFetchRequest:fetchDrafts error:&fetchDraftsError]]; Value in DB: /Users/rikon/Library/Developer/CoreSimulator/Devices/F2271001-04C5-46E6-9C29-DBD63E509BDF/data/Containers/Data/Application/0BF8855B-CF43-4F7C-B50C-12C907E0BEC6/Documents/tame_app_data/post_drafts/draft_1502455298.mp4 Value in the fetched object: /Users/rikon/Library/Developer/CoreSimulator/Devices/F2271001-04C5-46E6-9C29-DBD63E509BDF/data/Containers/Data/Application/0BF8855B-CF43-4F7C-B50C-12C907E0BEC6/Documents/tame_app_data/post_drafts/dra Answer: Read more
Read More

What is a NullReferenceException, and how do I fix it?

Uncategorized
Question: I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do about it? Answer: What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all. Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A". The rest of this article goes into more detail and shows mistakes that many programmers often make which can lead to a NullReferenceException. More Specifically The runtime throwing a NullReferenceException always means…
Read More

Ansible Custom login

Uncategorized
Question: I want to do automated deployment with Ansible on my custom appliances. These appliances doesn't allow direct ssh into shell/CLI and has custom options to go through. I need to know changes to make in ansible so that it first select shell option and then perform it`s desired changes. For reference please check ssh of pfense in which you have press 8 to go into shell. Custom ssh / PfSense Answer: Read more
Read More

Unable to run selenium with python using unittest

Uncategorized
Question: macOS Sierra 10.12.4 Python version 2.7 Selenium version 3.5 I'm trying to write a script in Pycharm with selenium webdriver and unittest modules. My goal is to go to a site find the element(button) and click on the button. I tried using Firefox driver and Chrome driver. I also tried to run this without the IDE but no luck. I been searching all over but can't get to work. Here is my code: import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys class HomeWorkTeam(unittest.TestCase): def setUp(self):self.driver = webdriver.Chrome(executable_path=r'/Users//HomeWork/chromedriver') def test_team_search(self):driver = self.driver driver.get("http://www.python.org/index.html") teamelem = driver.find_element_by_id("submit") teamelem.send_keys(Keys.ENTER) assert "No results found" not in driver.page_source def tearDown(self):self.driver.quit() if __name__ == '__main__':unittest.main() When I run this this is the output but the browsers does not get launched. Ran 0 tests…
Read More

Quill Blog – Responsive Minimal WordPress Blog theme

Uncategorized
Quillis a reader friendly , modern, clean, and content focus WordPress blog theme. It is 100% responsive means it will fit in various device of different size. It supports all type of post format. It is simple and it’s elegant. Using Quill you can setup a beautiful personal blog or magazine blog. Theme options are directly incorporated with WordPress customizer itself. Mino is suitable for any kind of personal or travel, hobby, tutorial blog / magazine.
Read More

How to save and load state in each scene in flash

Uncategorized
Question: I am beginner in AS3. I am currently working on Adobe AIR android app where a user can select and read visual stories. My Scene 1 is the library of stories. When I click on a certain book of a story on scene 1, it will go to another scene where that story's pages will play. I would like to do the function where each story the user had start reading can save the state or part of the story where they stop once they go back to main or exit the app, and load or go to the part where I stop reading once I go back to continue reading the story. Is there a way to do it in AS3? Thanks in advance. :) Answer: Read more
Read More

Loading tab content on click

Uncategorized
Question: I have attempted to take bits and pieces from other sources but I am unable to get the desired effect. I have multiple tabs which are currently pre-loaded, the content they are loading to be specific is a number of RSS feeds, as I have added more tabs the page has gradually taken longer to load, naturally.. I am at the point where I need to load the tabs content on click/trigger. What would be the best way to achieve this? HTML Header Some tagline here USA UK AU CA NZ - Content Here - - Content Here - - Content Here - - Content Here - - Content Here - JSFiddle https://jsfiddle.net/qvussf6t/1/ Thanks. Answer: Read more
Read More

My website is showing apache test page

Uncategorized
Question: I created website on Amazon Web Server. I route my ip to my domain using ROUTE 53 service. but now my website is showing APACHE TEST PAGE rather then content while if i enter my ip address/wordpress it's working properly. Any solution please? Answer: maybe you forgot to add a virtual host in http.conf. Apache restart is needed after this. DocumentRoot "/www/example2" ServerName www.example.org # Other directives here https://httpd.apache.org/docs/2.4/vhosts/examples.html Read more
Read More

Delegate pattern – ARC – Object not deallocated (when using managed objects)

ios
Question: I'm having trouble with the Automatic Reference Counting in swift. This is my setup: I have a UINavigationController where I pushed MyViewController (see below). This view controller uses a DataProvider object that provides data from CoreData, tracks changes and notifies the delegate (in this case MyViewController). Now, when I pop MyViewController from the navigation controller, I expect MyViewController and DataProvider to deallocate (or deinitialize, don't know which term is correct). But it's not happening (it should print "deinit ..."). After searching the internet for quite a while, I'm pretty confident to say it's caused by the ARC. I guess there is a strong reference somewhere that's blocking the deallocation. But where, and how do I fix it? First, I thought it is caused the managedObjectContext property of DataProvider (see…
Read More

Java Post request with form data

Uncategorized
Question: I want to make a simple POST call in Java, I am getting a 200 response code but, with the wrong response message, I am told there is a different way to make a Post call when using a form data. Following is my current Java code to make the post call - private String makePostCall(){ try { String url = "http://someIp/trusted"; HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); // add header List urlParameters = new ArrayList(); urlParameters.add(new BasicNameValuePair("username", "app_user")); post.setEntity(new UrlEncodedFormEntity(urlParameters)); HttpResponse response = client.execute(post); System.out.println("nSending 'POST' request to URL : " + url); System.out.println("Post parameters : " + post.getEntity()); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine())…
Read More