text
stringlengths
454
608k
url
stringlengths
17
896
dump
stringclasses
91 values
source
stringclasses
1 value
word_count
int64
101
114k
flesch_reading_ease
float64
50
104
I have a small encountered a zero error but I can't find it. My intention is to compare a text file which contains these words. secondly pardon woods secondly secondly, pardon secondly, woods secondly, secondly pardon, woods pardon, secondly woods, secondly from __future__ import division import gensim textfile = 'businessCleanTxtUniqueWords' model = gensim.models.Word2Vec.load("businessSG") count = 0 # keep track of counter score = 0 avgScore = 0 SentenceScore = 0 externalCount = 0 totalAverageScore = 0 with open(textfile, 'r+') as f1: words_list = f1.readlines() for each_word in words_list: word = each_word.strip() for each_word2 in words_list[words_list.index(each_word) + 1:]: count = count + 1 try: word2 = each_word2.strip() print(word, word2) # if words are the same if (word == word2): score = 1 else: score = model.similarity(word,word2) # when words are not the same # if word is not in vector model except KeyError: score = 0 # to keep track of the score SentenceScore=SentenceScore + score print("the score is: " + str(score)) print("the count is: " + str(count)) # average score avgScore = round(SentenceScore / count,5) print("the avg score: " + str(SentenceScore) + '/' + str(count) + '=' + str(avgScore)) # reset counter and sentence score count = 0 SentenceScore = 0 Traceback (most recent call last): File "C:/Users/User/Desktop/Complete2/Complete/TrainedTedModel/LatestJR.py", line 41, in <module> avgScore = round(SentenceScore / count,5) ZeroDivisionError: division by zero ('secondly', 'pardon') the score is: 0.180233083443 the count is: 1 ('secondly', 'woods') the score is: 0.181432347816 the count is: 2 ('secondly', 'secondly') the score is: 1 the count is: 3 the avg score: 1.36166543126/3=0.45389 ('pardon', 'woods') the score is: 0.405021005657 the count is: 1 ('pardon', 'secondly') the score is: 0.180233083443 the count is: 2 the avg score: 0.5852540891/2=0.29263 ('woods', 'secondly') the score is: 0.181432347816 the count is: 1 the avg score: 0.181432347816/1=0.18143 from __future__ import division It is because the first for loop has reached the last word and the second for loop will not be executed and so the count equals to zero (reset to zero in last iteration). Just change the first for loop to ignore the last word (since it is not necessary): for each_word in words_list[:-1]:
https://codedump.io/share/ilsAjeAc00aY/1/zerodivisionerror--but-i-can39t-find-the-error
CC-MAIN-2017-47
refinedweb
362
63.49
Pass. What I think you will learn In this tutorial, you will learn 2 things. First, you will understand how to “notify” other view controllers or within a single view controller. Second, you will grasp the power of NSNotification and its weaknesses. UI Component There are two view-controllers. FirstVC and SecondVC. I assume you already know how to embed UINavigationController and connect IBOutlets and IBActions and so on. SecondVC will notify FirstVC. When I say “notify”, it’s like poking. It’s not sending any data, but certainly, we can. I will explain how to send data a bit later in this article. The example below is analogous to a user making a profile update on Facebook or Instagram. I’m not using UITableView since that would be overkill for explaining the concept. Before we jump in, let’s picture how we would implement this at an extremely high level. Imagine two viewcontrollers are like a beautiful couple. They both have smartphones (NSNotification Objects) to talk to each other. Second, each smartphone has two features: receiving and sending data. Lastly, to locate each other’s device, they have a common secret key. However, it’s up to each other whether one wants to pick up the call or simply ignore. Since we have a general understanding how they communicate with each other, let’s dive into Swift ☝️ First, we are going to store the secret key. You can make a separate Swift file or just create one outside of any view-controller like this. import UIKit let myNotificationKey = "com.bobthedeveloper.notificationKey" class SecondVC: UIViewController {} myNotificationKey will be used to connect those smartphones together. Of course, just like some other couples, you can have more than one key for whatever purposes. 🙃 Now, it’s time attach a smartphone. Let’s call this an observer. The observer will have four parameters. It will ask Observer which will be self since you are attaching the smartphone to SecondVC. Second, Selector, which is a function that runs when you notify. Third, name which refers to the secret code. Lastly, object which I will explain later when dealing with FirstVC. Just put nil for now. class SecondVC: UIViewController { @IBOutlet weak var secondVCLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(doThisWhenNotify), name: NSNotification.Name(rawValue: myNotificationKey), object: nil) } func doThisWhenNotify() { print("I've sent a spark!") } } I don’t get the meaning of the default type property because there is no description in the API guideline. It says,* “No overview available” — Apple Anyway, SecondVC has a smartphone/observer, it’s time to send/notify when the button is tapped @IBAction func tabToNotifyBack(_ sender: UIButton) { NotificationCenter.default.post(name: Notification.Name(rawValue: myNotificationKey), object: self) secondVCLabel.text = "Notification Completed!😜" } In this context, object refers to the sender. Since SecondVC is notifying itself, it’s self. Since FirstVC hasn’t registered an observer yet, the spark/poking will not affect it. I mentioned earlier, the partner has the right to pick up the phone or just ignore. In iOS, we called this “loose coupling”. There is no crazy binding shit going on unlike sending data between view controllers using delegate/protocol. I know some of you guys are confused. I plan to write an article on how to pass data using delegate in the future. Also, I will discuss delegate vs NSNotification Resource Pass Data between ViewControllers in Swift 3 without Segue (YouTube) Time to Receive FirstVC is rather simple. It will add a smartphone and listen to the spark if it has the same secret key. import UIKit class FirstVC: UIViewController { @IBOutlet weak var FirstVCLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(doAfterNotified), name: NSNotification.Name(rawValue: myNotificationKey), object: nil) } func doAfterNotified() { print("I've been notified") FirstVCLabel.text = "Damn, I feel your spark" } } Now, let’s talk about object which is one of the parameters I skipped previously. If it is nil, you don’t care which/where smartphone is sending the data from as long as you have the secret key. I’ve never used anything besides nil so maybe for those who’ve used it before can help me out. In other words, I don’t know how to implement Now, it should look something like this. By the way, imagine SecondVC is like Facebook live. As long as there are many other view-controllers that contain observers which listen to the secret key, it can notify a lot of people. However, it is done synchronously. For those who don’t understand what it means, the task happens one at a time while blocking any other activities until the task is done. So, it will slow down devices if there are too many view-controllers. (not sure how many is too many). Passing Data Now you’ve learned how to notify. Let’s quickly learn how to send data while notifying. This is legit. This is where the real magic happens. In SecondVC, instead of using the good old way, // Pass Spark NotificationCenter.default.post(name: NSNotification.Name(rawValue: myNotificationKey), object: nil) Now, you can send a spark that contains a dictionary // Pass Data NotificationCenter.default.post(name: NSNotification.Name(rawValue: myNotificationKey), object: nil, userInfo: ["name":"Bob"]) In the FirstVC, under viewDidLoad, you will insert this instead NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: myNotificationKey), object: nil, queue: nil, using:catchNotification) I’m not going to talk about queue. If you put nil, the receiving task happens synchronously. In other words, if it’s not nil, FirstVC can receive data using Grand Central Dispatch. If you don’t understand GCD, don’t worry. I wrote two articles for you. Maybe I should write on how to pass data asynchronously using GCD! That would be interesting. Resources Intro to Grand Central Dispatch in Swift 3 (Medium) UI & Networking like a Boss in Swift 3 (Medium) You’ve noticed something different. That’s right catchNotification This function will consume the spark which contains userInfo! catchNotification looks something like func catchNotification(notification:Notification) -> Void { guard let name = notification.userInfo!["name"] else { return } FirstVCLabel.text = "My name, \(name) has been passed! 😄" } As soon as the button from SecondVC is pressed, catchNotification runs automatically and contains userInfo passed from SecondVC. If you don’t understand how to unwrap optionals using the guard statement, feel free to check my video below. Resource Guard Statement (YouTube) So, finally it should look something like this Resource Source Code Remove Observer/Smartphone If you want to remove any observer when the view has been dismissed, just insert the code below in FirstVC or any other view controllers. override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(true) NotificationCenter.default.removeObserver(self) } Last Remarks This article took a bit longer than I 3had expected. But, it feels so good to write and engage with a lot of people. Thank you everyone for coming all the way to the bottom. Much appreciated. 👍 Recommended Articles: Feel free to check out recommended articles: Top 10 Ground Rules for iOS Developers Intro to Grand Dispatch Central with Bob
https://www.sitepoint.com/pass-data-with-nsnotification-between-viewcontrollers-in-swift-3/
CC-MAIN-2017-43
refinedweb
1,181
50.73
1. It is different from HTTP modules not only because of their position in the request- processing pipe line but also because they must be mapped to a specific file extension. 2. HTTP handlers are the last stop for incoming HTTP Request and are ultimately the point in the request processing pipeline and as responsible to create response. 3. Generic Handlers: There is generic Handlers file type is providing. Adding this generic handlers to the project with ashx file extensions. The ashx is unique file extensions. It is provided by ASP.Net otherwise we need to add it manually; 4. Add the Generic Handler file to the project, it add the file with an .ashx extension. The .ashx file extension is the defaut HTTPHandler file extension file extension setup by ASP.Net. 5. Code snippet that implements the IHTTPHandler Interface, which require the ProcessRequest method and IsResuable property. The class stub changes the content type to plain and then writes the “Hello World” string to the output stream. The IsReusable property simply lets ASP.Net know if coming HTTP requests can reuse the sample instance of this HttpHandler. <%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } } click on the link for HTTP Pipeline Click on the link for HTTP Handler click on the link for HTTP Pipeline Click on the link for HTTP Handler
http://www.getmscode.com/2014/03/what-is-http-handler-in-aspnet.html
CC-MAIN-2017-51
refinedweb
251
57.16
Own indicator: "if function" with min max is very slow Hi everyone, I am having a hard time creating / adapting an indicator. I made it in the most slow way and I wonder whether there is a better solution. The idea is to have an if positive RoC the 1 else 0. class Momentumplus_org(bt.Indicator): lines = ('trend',) params = (('period', 190), ('rperiod', 30)) def __init__(self): self.addminperiod(self.params.period) self.roc = bt.ind.ROC(self.data, period=self.p.rperiod) def next(self): returns = np.log(self.data.get(size=self.p.period)) x = np.arange(len(returns)) slope, _, rvalue, _, _ = linregress(x, returns) annualized = (1 + slope) ** 252 test = math.ceil(self.roc[0]) rate = bt.Min(1, bt.Max(0, test)) self.lines.trend[0] = annualized * (rvalue ** 2) * rate This takes a hell of a time to get calculated. I tried to get the test and rate into the init ... I also tried to keep the original design: def momentum_func(the_array): r = np.log(the_array) slope, _, rvalue, _, _ = linregress(np.arange(len(r)), r) annualized = (1 + slope) ** 252 return annualized * (rvalue ** 2) class Momentum(bt.ind.OperationN): lines = ('trend',) params = dict(period=50) func = momentum_func But I couldn't make it work with two parameters... Are there better ways than math.ceil / min / max? Thank you very much in advance! Best - crunchypickle last edited by @Jonny8 said in Own indicator: "if function" with min max is very slow: test are you sure it is slow where you said it was? Have you profiled the code? Good call. I used cProfile to do it. There is a execution difference of 20% but it does not seem to come from min max or ceil, I assume it is due to the roc calculation in the init. Thank you chrunchypickle!
https://community.backtrader.com/topic/3294/own-indicator-if-function-with-min-max-is-very-slow/3
CC-MAIN-2021-04
refinedweb
304
60.41
How to: Use Finally Blocks When an exception occurs, execution stops and control is given to the closest exception handler. This often means that lines of code you expect to always be called are not executed. Some resource cleanup, such as closing a file, must always be executed even if an exception is thrown. To accomplish this, you can use a finally block. A finally block is always executed, regardless of whether an exception is thrown. The following code example uses a try/catch block to catch an ArgumentOutOfRangeException. The Main method creates two arrays and attempts to copy one to the other. The action generates an ArgumentOutOfRangeException and the error is written to the console. The finally block executes regardless of the outcome of the copy action. using System; class ArgumentOutOfRangeExample { public static void Main() { int[] array1 = {0, 0}; int[] array2 = {0, 0}; try { Array.Copy(array1, array2, -1); } catch (ArgumentOutOfRangeException e) { Console.WriteLine("Error: {0}", e); } finally { Console.WriteLine("This statement is always executed."); } } }
http://msdn.microsoft.com/en-us/library/ke0zf0f5.aspx
CC-MAIN-2014-15
refinedweb
166
50.63
If you are interested in web scrapers and want a solution that can extract various data from the Internet, you’ve come to the right place! In this article, we will show you how easy it is to make use of WebScrapingAPI to obtain the information you need in just a few moments and manipulate the data however you like. It is possible to create your own scraper to extract data on the web, but it would take a lot of time and effort to develop it, as there are some challenges you need to overcome along the way. And time is of the essence. Without any further ado, let us see how you can extract data from any website using WebScrapingAPI. However, we’ll first go over why web scrapers are so valuable and how can they help you or your business achieve your growth goals. How web scraping can help you Web scraping can be useful for various purposes. Companies use data extraction tools in order to grow their businesses. Researchers can use the data to create statistics or help with their thesis. Let’s see how: - Pricing Optimization: Having a better view of your competition can help your business grow. This way you know how the prices in the industry fluctuate and how can that influence your business. Even if you are searching for an item to purchase, this can help you compare prices from different suppliers and find the best deal. - Research: This is an efficient way to gather information for your research project. Statistics and data reports are an important matter for your reports’ authenticity. Using a web scraping tool speeds up the process. - Machine Learning: In order to train your AI, you need a big amount of data to work with, and extracting it by hand can take a lot of time. For example, if you want your AI to detect dogs in photos, you will need a lot of puppies. The list goes on, but what you must remember is that web scraping is a very important tool as it has many uses, just like a swiss army knife! If you are curious when can web scraping be the answer to your problems, why not have a look? Up next, you will see some features and how WebScrapingAPI can help to scrap the web and extract data like nobody’s watching! What WebScrapingAPI brings to the table You probably thought of creating your own web scraping tool rather than using a pre-made one, but there are many things you need to take into account, and these may take a lot of time and effort. Not all websites want to be scraped, so they develop countermeasures to detect and block the bot from doing your bidding. They may use different methods, such as CAPTCHAs, rate limiting, and browser fingerprinting. If they find your IP address to be a bit suspicious, well, chances are you won’t be scraping for too long. Some websites want to be scraped only in certain regions around the world, so you must use a proxy in order to access their contents. But managing a proxy pool isn’t an easy task either, as you need to constantly rotate them to remain undetected and use specific IP addresses for geo-restricted content. Despite all these problems, WebScrapingAPI takes these weights off your shoulders and solves the issues with ease, making scraping sound like a piece of cake. You can have a look and see for yourself what roadblocks may appear in one’s web scraping! Now that we know how WebScrapingAPI can help us, let’s find out how to use it, and rest assured it’s pretty easy too! How to use WebScrapingAPI API Access Key & Authentication First things first, we need an access key in order to use WebScrapingAPI. To acquire it, you need to create an account. The process is pretty straightforward, and you don’t have to pay anything, as there’s a free subscription plan too! After logging in, you will be redirected to the dashboard, where you can see your unique Access Key. Make sure you keep it a secret, and if you ever think your unique key has been compromised, you can always use the “Reset API Key” button to get a new one. After you got ahold of your key, we can move to the next step and see how we can use it. Documentation It is essential to know what features WebScrapingAPI has to help with our web scraping adventure. All this information can be found in the documentation presented in a detailed manner, with code samples in different programming languages. All this to better understand how things work and how they can be integrated within your project.The most basic request you could make to the API is setting the api_key and url parameters to your access key and the URL of the website you want to scrape, respectively. Here is a quick example in Python: import http.client conn = http.client.HTTPSConnection("api.webscrapingapi.com") conn.request("GET", "/v1?api_key=XXXXX&url=http%3A%2F%2Fhttpbin.org%2Fip") res = conn.getresponse() data = res.read() print(data.decode("utf-8")) WebScrapingAPI has other features that can be used for scraping. Some of them can be exploited just by setting a few more parameters, and others are already implemented in the API, which we talked about earlier. Let’s see a few other parameters we can set and why they are useful for our data extraction: - render_js: Some websites may render essential page elements using JavaScript, meaning that some content won’t be shown on the initial page load and won’t be scraped. Using a headless browser, WSA is able to render this content and scrape it for you to make use of. Just set render_js=1, and you are good to go! - proxy_type: You can choose what type of proxies to use. Here is why proxies are so important and how the type of proxy can have an impact on your web scraping. - country: Geolocation comes in handy when you want to scrape from different locations, as the content of a website may be different, or even exclusive, depending on the region. Here you set the 2-letter country code supported by WSA. API Playground If you want to see the WebScrapingAPI in action before integrating it within your project, you can use the playground to test some results. It has a friendly interface and it is easy to use. Just select the parameters based on the type of scraping you want to do and send the request. In the result section, you will see the output after the scraping is done and the code sample of said request in different programming languages for easier integration. API Integration How can we use WSA within our project? Let’s have a look at this quick example where we scrape Amazon’s to find the most expensive Graphics Card on a page. This example is written in JavaScript, but you can do it in any programming language you feel comfortable with. First, we need to install some packages to help us out with the HTTP request (got) and parsing the result (jsdom) using this command line in the project’s terminal: npm install got jsdom Our next step is to set the parameters necessary to make our request: const params = { api_key: "XXXXXX", url: "" } This is how we prepare the request to WebScrapingAPI to scrape the website for us: const response = await got('', {searchParams: params}) Now we need to see where each Graphics Card element is located inside the HTML. Using the Developer Tool, we found out that the class s-result-item contains all the details about the product, but we only need its price. Inside the element, we can see there is a price container with the class a-price and the subclass a-offscreen where we will extract the text representing its price. WebScrapingAPI will return the page in HTML format, so we need to parse it. JSDOM will do the trick. const {document} = new JSDOM(response.body).window After sending the request and parsing the received response from WSA, we need to filter the result and extract only what is important for us. From the previous step, we know that the details of each product are in the s-result-item class, so we iterate over them. Inside each element, we check if the price container class a-price exists, and if it does, we extract the price from the a-offscreen element inside it and push it into an array. Finding out which is the most expensive product should be child’s play now. Just iterate through the array and compare the prices between one another. Wrapping it up with an async function and the final code should look like this: const {JSDOM} = require("jsdom"); const got = require("got"); (async () => { const params = { api_key: "XXX", url: "" } const response = await got('', {searchParams: params}) const {document} = new JSDOM(response.body).window const products = document.querySelectorAll('.s-result-item') const prices = [] products.forEach(el => { if (el) { const priceContainer = el.querySelector('.a-price') if (priceContainer) prices.push(priceContainer.querySelector('.a-offscreen').innerHTML) } }) let most_expensive = 0 prices.forEach((price) => { if(most_expensive < parseFloat(price.substring(1))) most_expensive = parseFloat(price.substring(1)) }) console.log("The most expensive item is: ", most_expensive) })(); Final thoughts We hope this article has shown you how useful a ready-built web scraping tool can be and how easy it is to use it within your project. It takes care of roadblocks set by websites, helps you scrape over the Internet in a stealthy manner, and can also save you a lot of time. Why not give WebScrapingAPI a try? See for yourself how useful it is if you haven’t already. Creating an account is free and 1000 API calls can help you start your web scraping adventure. Start right now!
https://www.webscrapingapi.com/webscrapingapi-guide/
CC-MAIN-2022-05
refinedweb
1,661
69.41
No two websites’ markup are created equal. As such, it can be difficult for social media platforms like Facebook to find the correct piece of information within the content to be displayed when the page is shared on the News Feed. Open Graph: Take Control of How Social Media Shares Your Web Pages That is where the Open Graph Protocol (OGP) comes into play; an initiative developed by Facebook that allows it to recognize web content easily and display it nicely within their platform. Examine the following: This gives us a decent content preview on the Facebook Feed, with the title as well as the excerpt. If we look at the content on our demo page, however, there are a few more elements that could be utilized; such as the image and the author name. Facebook will not pick these details up without help. So let’s take a look how we can use Open Graph to improve our content presentation on Facebook. Using Open Graph Open Graph specifies a number of meta tags defining meta information of the content, similar to the meta tags that we feed to search engines in common SEO practices. Before we add these meta tags we will need to set the XML Namespace for Open Graph in the html. <!DOCTYPE html> <html xmlns: <head></head> <body></body> </html>. For instance: <!DOCTYPE html> <html prefix="og: fb:"> <head></head> <body></body> </html> Adding Open Graph Meta Tags Facebook requires a few tags to be present at all times. Content Type First, the content type, specified by the og:type property. On the homepage, we typically set the value to website. <meta property="og:type" content="website" /> And commonly set it to article for the content. <meta property="og:type" content="article" /> A number of other possible values can also be set in og:type meta tag which include product, place, video.movie, books.book, and many more in case your content is not a typical article like a blog post or news. For example: <!-- Product Type: may be used in e-commerce product sites. --> <meta property="og:type" content="product" /> <!-- Place Type: may be used in travel websites. --> <meta property="og:type" content="place" /> <!-- Movie Type: may be used in movie review websites like iMDB or movie streaming website like Netflix. --> <meta property="og:type" content="video.movie" /> Meta URL The content URL, specified with the og:url property, must contains an absolute URL of the web page without query strings or hashes, similar to the canonical link. On the homepage, the URL is the homepage URL: <meta property="og:url" content="" /> The content URL will be a little more detailed: <meta property="og:url" content="" /> Meta Title The meta title, specified with the og:title property, defines the title for the preview. The value of the title might not always match the title set in the title tag; you may choose to alter, or abbreviate the title for sharing. For example, the content of our page is about CSS and is entitled for the purposes of social media “Learn CSS: The Complete Guide”. However the document title is actually “Open Graph Protocol — Tuts+”, thus: <meta property="og:title" content="Learn CSS: The Complete Guide" /> There isn’t a defined character limit for the og:title, but Facebook is known to truncate titles on occasion, particularly for content shared in the comment thread where the space is narrow. Meta Description The meta description, specified with the og:description tag, provides the shared content excerpt. <meta property="og:description" content="A comprehensive guide to help you learn CSS online, whether you're just getting started with the basics or you want to explore more advanced CSS."> Facebook does not set a defined character or word limit to the description. Still, Facebook will truncate the description when it sees fit, so keep the description short and enticing. Meta Image The meta image is defined with og:image, enabling you to visually represent the content, and the value does not always need be an image within the content. Use the best image to entice readers to click and eventually read the content. <meta property="og:image" content="" /> In addition to the URL, you can also add in the meta tags specifying the image size and image MIME type. These meta tags are optional, but will help easing Facebook workload when it comes to parsing and caching the image. <meta property="og:image:width" content="850"> <meta property="og:image:height" content="450"> <meta property="og:image:type" content="image/png" /> The minimum image size is capped at 200×200 pixels, but Facebook recommends the image size be 1200×630 pixels for the best possible outcome. You may want to consider the aspect ratio of your image too: “Try to keep your images as close to 1.91:1 aspect ratio as possible to display the full image in News Feed without any cropping.” – Facebook Developers The Facebook App ID Within Facebook, adding the Facebook App ID with fb:app_id meta tag is highly encouraged. The App ID will allow Facebook to link your website and generate a comprehensive overview of how users interact with your website and content. <meta property="fb:app_id" content="1494084460xxxxxx"> You may ignore it, if having analytical of your website is not necessary. Subsidiary Meta Tags A few meta tags are optional, but will come in useful in certain cases. The Site Name The site name is specified with the og:site_name meta tag. It defines the website name, or more accurately your website brand. The website brand or name might not always be your domain name. Tuts+, in this case, is one good example. According to our branding guidelines this should be written as Tuts+ instead of Tutsplus, yet tutsplus.com is the domain name since a domain cannot contain the + character, hence: <meta name="og:site_name" content="Tuts+"> Facebook does not show this site name on the content shared. Instead, you will find it shown on the notification when you have installed a Facebook Social Plugin such as Facebook Comment on your website. The Type-related Meta Tags There are a number of meta tags related to the specified content type. As implied, these tags differ depending on the value specified in og:type meta tag. Here we have an article. An article may be accompanied with a few supporting meta tags such article:author, article:published_time, article:publisher, article:section, and article:tag. Before including these meta tags, we will need to add a new namespace pointing to the Open Graph Article specification. So, at this point, we have three namespaces namely og, fb, and article. <!DOCTYPE html> <html prefix="og: fb: article:"> <head></head> <body></body> </html> The Article Author According to Facebook, the article:author meta tag should contain a Facebook profile URL or the ID of the article’s author. <meta name="article:author" content=""> Adding more than one URL or ID is allowed in case multiple authors contributed to the article. <meta name="article:author" content=","> Tip: if the author does not have a Facebook account, you may replace article:author with the following author meta tag. <meta name='author' content='John Doe' /> Facebook will display the author name on the preview, as follows. Although Facebook suggest that we include article tags such as article:published_date and article:section they do not add any significance at the time of writing. That is, unless you are dealing with an Instant Article page. As mentioned, these tags largely depend on your content type. If the content type is video.movie, more appropriate tags would be video:actor, video:director, and video:duration instead of the articles:published_date. For that reason, I will leave that part of Open Graph up to you to explore. Facebook has provided comprehensive reference material on these meta tags along with a few examples of code snippets. Wrapping Up Open Graph has since been adopted by other social media platforms such as Twitter (though Twitter also has its own proprietary markup called Twitter Cards), Pinterest, LinkedIn, and Google+ in one form or another. In this tutorial we looked into a few Open Graph meta tags and leveraged them to make our content preview more compelling. Finally, if you find your content is not rendered as expected, use the Facebook Sharing Debugger to find out what’s wrong with the markup.
https://themekeeper.com/web-design/take-control
CC-MAIN-2017-22
refinedweb
1,405
60.75
Gotchas using NumPy in Apache MXNet¶ The goal of this tutorial is to explain some common misconceptions about using NumPy arrays in Apache MXNet. We are going to explain why you need to minimize or completely remove usage of NumPy from your Apache MXNet code. We also going to show how to minimize NumPy performance impact, when you have to use NumPy. Asynchronous and non-blocking nature of Apache MXNet¶ Instead of using NumPy arrays Apache MXNet offers its own array implementation named NDArray. NDArray API was intentionally designed to be similar to NumPy, but there are differences. One key difference is in the way calculations are executed. Every NDArray manipulation in Apache MXNet is done in asynchronous, non-blocking way. That means, that when we write code like c = a * b, where both a and b are NDArrays, the function is pushed to the Execution Engine, which starts the calculation. The function immediately returns back, and the user thread can continue execution, despite the fact that the calculation may not have been completed yet. Execution Engine builds the computation graph which may reorder or combine some calculations, but it honors dependency order: if there are other manipulation with c done later in the code, the Execution Engine will start doing them once the result of c is available. We don’t need to write callbacks to start execution of subsequent code - the Execution Engine is going to do it for us. To get the result of the computation we only need to access the resulting variable, and the flow of the code will be blocked until the computation results are assigned to the resulting variable. This behavior allows to increase code performance while still supporting imperative programming mode. Refer to the intro tutorial to NDArray, if you are new to Apache MXNet and would like to learn more how to manipulate NDArrays. Converting NDArray to NumPy Array blocks calculation¶ Many people are familiar with NumPy and flexible doing tensor manipulations using it. NDArray API offers a convinient .asnumpy() method to cast nd.array to np.array. However, by doing this cast and using np.array for calculation, we cannot use all the goodness of Execution Engine. All manipulations done on np.array are blocking. Moreover, the cast to np.array itself is a blocking operation (same as .asscalar(), .wait_to_read() and .waitall()). That means that if we have a long computation graph and, at some point, we want to cast the result to np.array, it may feel like the casting takes a lot of time. But what really takes this time is Execution Engine, which finishes all the async calculations we have pushed into it to get the final result, which then will be converted to np.array. Because of the blocking nature of .asnumpy() method, using it reduces the execution performance, especially if the calculations are done on GPU: Apache MXNet has to copy data from GPU to CPU to return np.array. The best solution is to make manipulations directly on NDArrays by methods provided inNDArray API. NumPy operators vs. NDArray operators¶ Despite the fact that NDArray API was specifically designed to be similar to NumPy, sometimes it is not easy to replace existing NumPy computations. The main reason is that not all operators, that are available in NumPy, are available in NDArray API. The list of currently available operators is available on NDArray class page. If a required operator is missing from NDArray API, there are few things you can do. Combine a higher level operator using a few lower level operators¶ There are a situation, when you can assemble a higher level operator using existing operators. An example for that is the np.full_like() operator. This operator doesn’t exist in NDArray API, but can be easily replaced with a combination of existing operators. from mxnet import nd import numpy as np # NumPy has full_like() operator np_y = np.full_like(a=np.arange(6, dtype=int), fill_value=10) # NDArray doesn't have it, but we can replace it with # creating an array of ones and then multiplying by fill_value nd_y = nd.ones(shape=(6,)) * 10 # To compare results we had to convert NDArray to NumPy # But this is okay for that particular case np.array_equal(np_y, nd_y.asnumpy()) True Find similar operator with different name and/or signature¶ Some operators may have slightly different name, but are similar in terms of functionality. For example nd.ravel_multi_index() is similar to np.ravel(). In other cases some operators may have similar names, but different signatures. For example np.split() and nd.split() are similar, but the former works with indices and the latter requires the number of splits to be provided. One particular example of different input requirements is nd.pad(). The trick is that it can only work with 4-dimensional tensors. If your input has less dimensions, then you need to expand its number before using nd.pad() as it is shown in the code block below: def pad_array(data, max_length): # expand dimensions to 4, because nd.pad can work only with 4 dims data_expanded = data.reshape(1, 1, 1, data.shape[0]) # pad all 4 dimensions with constant value of 0 data_padded = nd.pad(data_expanded, mode='constant', pad_width=[0, 0, 0, 0, 0, 0, 0, max_length - data.shape[0]], constant_value=0) # remove temporary dimensions data_reshaped_back = data_padded.reshape(max_length) return data_reshaped_back pad_array(nd.array([1, 2, 3]), max_length=10) [ 1. 2. 3. 0. 0. 0. 0. 0. 0. 0.] <NDArray 10 @cpu(0)> Apache MXNet community is responsive to requests, and everyone is welcomed to contribute new operators. Have in mind, that there is always a lag between new operators being merged into the codebase and release of a next stable version. For example, nd.diag() operator was recently introduced to Apache MXNet, but on the moment of writing this tutorial, it is not in any stable release. You can always get all latest implementations by installing the master version of Apache MXNet. How to minimize the impact of blocking calls¶ There are cases, when you have to use either .asnumpy() or .asscalar() methods. As it is explained before, this will force Apache MXNet to block the execution until the result can be retrieved. One common use case is printing a metric or a value of a loss function. You can minimize the impact of a blocking call by calling .asnumpy() or .asscalar() in the moment, when you think the calculation of this value is already done. In the example below, we introduce the LossBuffer class. It is used to cache the previous value of a loss function. By doing so, we delay printing by one iteration in hope that the Execution Engine would finish the previous iteration and blocking time would be minimized. from __future__ import print_function import mxnet as mx from mxnet import gluon, nd, autograd from mxnet.ndarray import NDArray from mxnet.gluon import HybridBlock import numpy as np class LossBuffer(object): """ Simple buffer for storing loss value """ def __init__(self): self._loss = None def new_loss(self, loss): ret = self._loss self._loss = loss return ret @property def loss(self): return self._loss net = gluon.nn.Dense(10) ce = gluon.loss.SoftmaxCELoss() net.initialize() data = nd.random.uniform(shape=(1024, 100)) label = nd.array(np.random.randint(0, 10, (1024,)), dtype='int32') train_dataset = gluon.data.ArrayDataset(data, label) train_data = gluon.data.DataLoader(train_dataset, batch_size=128, shuffle=True, num_workers=2) trainer = gluon.Trainer(net.collect_params(), optimizer='sgd') loss_buffer = LossBuffer() for data, label in train_data: with autograd.record(): out = net(data) # This call saves new loss and returns previous loss prev_loss = loss_buffer.new_loss(ce(out, label)) loss_buffer.loss.backward() trainer.step(data.shape[0]) if prev_loss is not None: print("Loss: {}".format(np.mean(prev_loss.asnumpy()))) Loss: 2.310760974884033 <!--notebook-skip-line--> Loss: 2.334498643875122 <!--notebook-skip-line--> Loss: 2.3244147300720215 <!--notebook-skip-line--> Loss: 2.332686424255371 <!--notebook-skip-line--> Loss: 2.321366310119629 <!--notebook-skip-line--> Loss: 2.3236165046691895 <!--notebook-skip-line--> Loss: 2.3178648948669434 <!--notebook-skip-line--> Conclusion¶ For performance reasons, it is better to use native NDArray API methods and avoid using NumPy altogether. In case when you must use NumPy, you can use convenient method .asnumpy() on NDArray to get NumPy representation. By doing so, you block the whole computational process, and force data to be synced between CPU and GPU. If it is a necessary evil to do that, try to minimize the blocking time by calling .asnumpy() in time, when you expect the value to be already computed.
https://mxnet.apache.org/versions/1.7/api/python/docs/tutorials/packages/ndarray/gotchas_numpy_in_mxnet.html
CC-MAIN-2022-33
refinedweb
1,418
50.12
Feature #8761 Binding#local_variable_get, set, defined? Description I propose new 3 methods of Binding. - Binding#local_variable_get(sym) - Binding#local_variable_set(sym) - Binding#local_variable_defined?(sym) Maybe you can imagine the behavior. These methods help the following cases: (1) Access to special keyword arguments From Ruby 2.0, we can use keyword arguments. And further more, you can use special keyword named such as if',begin' and `end', the language keyword. However, of course you can't access the local variable `if', because of syntax error. For example, def access begin: 0, end: 100 p(begin) #=> syntax error p(end) #=> syntax error end To access such a special keyword parameter, you can use Binding#local_variable_get(sym) def access begin: 0, end: 100 p(binding.local_variable_get(:begin)) #=> 0 p(binding.local_variable_get(:end)) #=> 100 end (2) Create a binding with specific local variables If you wan to make a binding which contains several local variables, you can use Binding#local_variable_set to do it. (See [Feature #8643]) Implementation note: I think Binding is good place to put these methods than Kernel. Using binding make it clear that it is need to access to a local environment. It will help optimization (don't interrupt optimization). You can try these methods on ruby 2.1dev (trunk), committed at r42464. Your comments are welcome. This proposal was discussed at dev-meeting at Japan and Matz accepted it. History #1 Updated by Koichi Sasada over 1 year ago - Category set to core - Target version set to 2.1.0 #2 Updated by Koichi Sasada over 1 year ago #3 Updated by Koichi Sasada over 1 year ago - Status changed from Open to Closed Also available in: Atom PDF
https://bugs.ruby-lang.org/issues/8761
CC-MAIN-2015-11
refinedweb
278
50.23
.) Introduction adds, modifies, or deletes list items. Clients typically call this to keep server items in sync with changes made on the client... Besides performance considerations, discussed below, this is arguably the most important sync topic: How to detect and deal with an object that was modified on both sides. .. There are some performance issues to keep in mind when you are dealing with syncing with a server.. We target high-bandwidth scenarios, but even then, it is important to try to minimize the amount of data sent across the wire. It a client is not going to require a piece of information, it should avoid requesting it.. See. Here is a listing of the GetListItemChangesSinceToken Request and Response and an explanation of the very useful queryOptions parameter.) Name listName This can be the list title, but using the list id (GUID) results in better performance. viewName Not supported. query A CAML query similar to the CAML query used in GetListItems and SPQuery. Refer to GetListItems and SPQuery in the SDK for more information. Note Not intended to be used with the contains parameter. viewFields Set of field references for each field required in the response. <ViewFields /> returns all fields in the list. A Properties='true' attribute will separate the MetaInfo field into its separate decoded properties. rowLimit The maximum number of values to return. Used for paging. queryOptions Set of options related to the query (see details below). changeToken An opaque token used to determine the changes since the last call. This token should never be parsed or constructed, as its format may change in the future. contains A CAML filter applied to the query results. This is the Where clause in a SPQuery. Note Not intended to be used with the query parameter. The queryOptions element can contain a variety of tags which modify the query. For Boolean options the default is FALSE, only a value of TRUE (must be uppercase) enables them. Available Query Option Tags Query Option Tag <Paging ListItemCollection X is an opaque token used to determine the page of items to return. Like the changeToken value, this should never be parsed or constructed. <IncludeMandatory Columns> Ensures that fields defined as required are included, even if not specified in the viewFields. This option may be misleading because Windows SharePoint Services actually has a separate set of mandatory fields that are always returned independently of this option. <RecurrenceOrderBy> This is a requirement for some calendar programs. For each recurring series, the master item is returned first and then all exceptions. This is a special internal ordering that is applied ahead of any other ordering. Note This should not be used unless your program explicitly requires it. If the view has a field of type Recurrence, the list will be ordered by fields of reference type UID, EventType and StartDate in the definition of the recurrence field. <ExpandUserField> Special rendering for the user field values that makes them include the login name, email, SipAddress, and the title when present. This causes a user field to behave as a multi lookup field. The lookup fields used in the expansion are "Name", "EMail", "SipAddress" and "Title". The values are separated by ,#. Any commas in the lookup field name are encoded as ,,. These values occur in the normal field data for each item. Examples of ExpandUserField <ExpandUserField>FALSE</ExpandUserField> looks like: ows_Author="1;#Admin AdminName" <ExpandUserField>TRUE</ExpandUserField> looks like: ows_Author="1;#Admin AdminName,#login\name,#email@address,#sip@address,#Admin AdminName " More Query Option Tags < DateInUtc> Date fields are returned in UTC format and zone. UTC is in GMT time zone an ISO6801 format: 2006-10-04T10:00:00Z Normal is in local (server) time zone and the same as above with the T and the Z replaced by spaces. <ViewAttributes foo=bar /> All attributes of this option will be used as view attributes of the view schema. The most commonly used is Scope="RecursiveAll" that defines the view as flat instead of scoped to a particular folder. <Folder> Set the root folder scope of the view. This is a server relative URL. <Folder>Shared Documents/foldername</Folder> <MeetingInstanceId> Defines which meeting instance to sync with if this list is part of a meeting workspace. -1 should be used for all instances unless the client wants to filter for a particular instance. <IncludePermissions> One way a client can request individual item permissions. <IncludeAttachmentUrls> Changes the value returned for the Attachments field from a Boolean to a list of full urls separated by ;# <IncludeAttachment Version> Used in conjunction with IncludeAttachmentUrls, IncludeAttachmentVersion also returns the GUID and version number used for conflict detection on update. <RecurrencePattern XMLVersion> v3 </RecurrencePattern Used to maintain backwards compatibility, RecurrencePatternXMLVersion changes the value of a RecurrenceData field to NOT return <V3RecurrencePattern /> when it contains elements only present on a version 3 pattern. Without this tag, recurrence patterns that were not present in Windows SharePoint Services version 2 are sent as <V3RecurrencePattern />. Including this tag means that recurrence patterns new to Windows SharePoint Services are sent correctly. <ExtraIds> 1,4,23 </ExtraIds> Request extra items to be included on the returned set regardless of whether they changed or not. The common use of ExtraIds is to specify the IDs of the folders you're syncing if you were in a doclib and chose "connect to..." on a folder rather than on the entire doclib. This way you get the folder name and can tell when it is renamed. Note This should only be used with a change token. This allows a client to sync to one or more folders and detect if any folder above the hierarchy was deleted or renamed. Folder names are not returned unless some changes are done to the list and the query to fetch changed items also uses IDs. <OptimizeFor> The two values supported are: ItemIds is the default as long as a query or recurrence order is not requested and optimizes our SQL query with an ID order. FolderUrls optimizes a sync filtered to the flat contents of one or more folders by optimizing the SQL query with a DirName, LeafName order. <OptimizeFor>ItemIds</OptimizeFor>. Any XML namespaces used below are declared here. These include configuration properties, alternate URL information, and list permissions. List and global properties table Property Definition MinTimeBetweenSyncs A server parameter that represents the minimum amount of time between user-initiated or automatic synchronization. The value represents a time in minutes. Note Clients should respect this value even if the user initiates synchronization manually. That is, if this is set to 5 minutes, clients should only send one request per 5 minutes even if the user repeatedly clicks "send/receive". RecommendedTime BetweenSyncs The recommended minimum amount of time between synchronizations. This should specifically be respected for automatic syncs. Clients should never automatically synchronize more often than this. User-initiated synchronizations can override this interval. MaxBulkDocumentSyncSize The total size of content to be synchronized to the client. The default is 500 MB. You get the URL and metadata for each document when you call GetListItemChangesSinceToken, but you then need to do an HTTP GET to retrieve the actual document contents. Setting this value to high may degrade performance. AlternateUrls Alternate URLs are listed in the following zone order, delimited by commas: Intranet,Default,Extranet,Internet,Custom EffectiveBasePermissions The permissions on the list as returned by SPList.EffectiveBasePermissions.ToString().. Change <List></List> If the list schema has changed, or if no change token was provided, we return the list here. The format is the same as returned by GetList. <Id ChangeType= "InvalidToken" /> The token is either invalid or old. You must do a full sync. <Id ChangeType="Restore" /> The list has been restored from the recycle bin or from a backup. You should do a full sync. In both of the cases above, the client should ignore other changes and do a full reconciliation of the list. Change Type "Delete">ID</Id> This item is no longer present. Note that Delete changes are sent even if the item was filtered out by the query. <Id ChangeType="MoveAway" AfterListId="ID" AfterItemId="ID">ID</Id> Treat in the same manner as a delete. <Id ChangeType="Restore"> ID </Id> This item and any items beneath it were restored. "SystemUpdate">ID</Id> Some clients may use hidden version, version history or modified time to determine whether to update an item. A SystemUpdate means Windows SharePoint Services has made changes and that you need to update all properties on that particular item. <Id ChangeType="Rename">ID</Id> Just like SystemUpdate, renamed items may retain hidden version. Attribute MetaInfo This is the property bag container, SPListItem.Properties. For more information, refer to the property bag in the SPListItem object model. Fields of type "Attachments" This is a bit column in the database, but query options modify it to return attachment data. Recurrence Data This is the XML definition of a recurrence. See for more details on this XML I would like to acknowledge the following persons for their gracious help in technical reviews for this article: Matt Swann (Microsoft Corporation), Bill Snead (Microsoft Corporation). I will be continuing this discussion in part 2.
http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2008/01.aspx?PostSortBy=MostRecent&PageIndex=1
CC-MAIN-2013-48
refinedweb
1,527
56.05
Gone are the days of useless and generic error messaging. If you're here, you're likely concerned with making your user-facing products as delightful as possible. And error messaging plays an important role in that. Having useful error messages can go a long way toward making a frustrating scenario for an end-user as pleasant as possible. This article is split into two parts. The first builds context around error messages and why they're important. This section should be useful, regardless of whether you're a JavaScript developer or not. The second part is a short follow-along to help get you started managing your own error messages. The current state of error messaging In a perfect world, error messages would be redundant and users would be able to use anything you've built a-okay, no problem-o. But errors will happen, and your end-users will run into them. These errors can stem from: - Failing validation - Server-side failures - Rate limiting - Borked code - Acts of god And when things go wrong, often the client-facing error messaging takes shape in one of two ways: - Generic errors with no meaningful information, e.g. Something went wrong, please try again later - Hyper specific messages from the stack trace sent by the server, e.g. Error 10x29183: line 26: error mapping Object -> Int32 Neither are helpful for our end-users. For our users, the generic error can create a feeling of helplessness and frustration. If they get such a message, they can't complete an action, and have no way of knowing why the error happened and how (or if) they can resolve it. This can result in loss of end-user trust, loss of customer, or an angry review. On the other hand, hyper-specific error messages are a leaky abstraction and shouldn't be seen by our end-user's eyes. For one, these kind of errors provide implementation information about our server-side logic. Is this a security concern? probably? I'm no pen-tester. Secondly, if we're in the business of crafting engaging user experiences, (and why wouldn't you be?) our error messages should feel human and be service-oriented. This is a sentiment shared in a number of resource I've come across, many of which of I've included in a further reading section at the end. Why should I create sane error messaging? To help maintain developer sanity Hunting bugs is hard, and scanning logs is tedious. Sometimes we're provided with context about why things failed, and other times we aren't. If an end-user reports a bug it's important they can present to us as much useful information as possible. A report from a user that says: Hi, I was using the app sometime last night updating my profile and all of a sudden it stopped working. The error said something about a validation error, but I don't know what that means is much less useful than: Hi, I was using the app sometime last night updating my profile and all of a sudden it stopped working. The error said "We had trouble updating your details. Your address must be located within the EU" but I live in England This saves us time and cuts down on red herrings. A clear and specific error message may also help an end-user understand what they themselves have done wrong, and can allow them to fix their mistake. To help maintain organisation sanity Sane error messages also yield benefits on an organisation level. For those working in larger companies, copy/messaging may be the responsibility of an entirely separate department. The more places in the code that require copy changes, the easier it is for the copy to get out of sync with your company's brand guidelines. Conversely, keeping all of your error messages in a single source makes it much easier for those owning copy to adhere to those brand guidelines. Other departments, like the support team, may be inundated with support tickets from users. If you're an engineer, why not reach out to your support team to see how many support tickets could be avoided with improved error messaging. Fixing the problems with your messaging when a user incorrectly fills out a form, has missing data, or doesn't have permissions for a specific action could positively impact the lives of the support team. To help maintain end-user sanity By providing sane error messaging we hope to not leave our end users feeling helpless. As described earlier, our messaging should be service-oriented. They should guide our user on how to complete their process, or at least let them know where they can go and get help if the problem is beyond their control. In Jon Yablonski's book, the Laws of UX, he describes a psychological concept called the Peak-end Rule: People judge an experience largely based on how they felt at its peak and at its end rather than the total sum or average of every moment of the experience In the context of this article, if people become so frustrated that they rage quit your site, their lasting memory of your application is of how frustrating it is to use. Error messages play a large part in preventing this, as they can act as the final gatekeeper preventing a user who is simply stuck from turning to one so frustrated they quit your app. If someone is using your product for a transactional purpose like buying an airplane ticket or shopping online, and they've been stopped dead in their tracks during a task with no way to continue, the likelihood of them leaving your site for another skyrockets. Another lost customer. While this is wholly anecdotal, I've rage quit sites often from not knowing how to complete a process – either nothing happened when I clicked a button, or I just kept getting vague error messages. Unless these sites/apps are one of those few ubiquitous platforms (like Google, Instagram, Apple), I likely haven't have used them since. I'm sure you can even remember a time this happened to you. In fact, I'll openly welcome pictures of awful error messages via Twitter Using sane error messaging can help offset this frustration if something doesn't go right. Surprisingly, creating a useful error message only requires a handful of qualities. What makes a good error message? Taken from Microcopy: A complete guide. A useful error message should satisfy these qualities: - Explain clearly that there is a problem - Explain what the problem is - If possible, provide a solution so that the user can complete the process, or - Point them to where they can go for help - Make a frustrating scenario as pleasant as possible This might sound like a lot to cover with just a couple of sentences, but here are some examples of what I deem to be good error messages: - We've limited how many times you can reset your password every hour. You can try again later. - Please log in to view this profile - We couldn't create your profile, only UK residents can use our app. It's worth noting that I'm not a UX researcher/designer, just a frontend developer with a keen interest in UX. It may be that my above examples miss the mark on what's required within your project or organisation. Saying that, if you're a frontend engineer, improving your organisation's error messaging makes for an excellent opportunity to upskill and collaborate with your UXer colleagues. How can I start writing sane error messages? I've open-sourced a simple tool called sane-error-messages. Running the tool will generate a brand new repo designed to house your default error messaging. You can tweak the default values, add or remove messages, and then publish it to consume within your client facing apps. sane-error-messages works by aggregating all of your messaging in to a single JavaScript object. The key is an error code, and the value is a corresponding message. The error codes should be the same codes you receive from your server, such as POSTS_NOT_FOUND or CONFLICTING_USER_RECORD. Your error messaging repo exposes a function to get your error message from an error code. This approach was inspired by how tools like Cypress handle their error messaging. As long as your server returns predictable error codes, the server-side implementation doesn't matter. The following sequence is just one way of implementing sane-error-messages In short: - The user "views all products" - The frontend makes a network request - The network request fails and returns an error code "USER_NOT FOUND" - The frontend requests the corresponding error message from your error-messagespackage. - The frontend applies any relevant contextual information - The frontend displays this information to the end user. If you want to try something hands on, you can play with this CodeSandbox. The CodeSandbox fires off a request to a mock server which returns 1 of 12 error codes at random. The client side will use the error code to retrieve a sane error message from the error messages repo. The client side then displays the error message to the user. If the code doesn't have a specified message, the generic fallback gets shown (and it sucks). How to set up your error messages Note: You can find the repo here. If you come across any problems during the tutorial process you can file a GitHub issue. Begin by running yarn global add sane-error-message then sane-error-messages create <dirName> to scaffold your project. Doing so will create a brand new module for you to customise with your default error messages. Your new module uses tsdx under-the-hood to handle all of the module management scripts, such as running, building, and testing. You can learn more about tsdx here. In short, the contents of your new package will look like this: /* errorCodes.ts: The file that defines each error code like */ const USER_NOT_ADMIN = '403_USER_NOT_ADMIN' /* defaultErrorMessages.ts: Maps each code to a default message */ const errorCodes { // your codes and messages go here... [USER_NOT_ADMIN]: "We're afraid only administrators have access to " } /* ErrorMessages.ts: The class you'll use to instantiate your error messages object in the consuming project */ class ErrorMessages { // You can override default messages with more specific ones constructor: (customErrorMessages: Partial<Record<string | number, string>>): ErrorMessages; // Pass through an error code to get your custom message getErrorMessage: (code: string | number, fallbackMessage?: string): string; // Checks to see if the argument is a valid error code and acts as a guard for non-ErrorCode values isErrorCode(code: string | number): boolean; // Returns the errorCodes object with your custom messages messages: Record<ErrorCode, string> } type ErrorCode = ValueOf<errorCodes> How to consume your error messages If you created a repo with the name custom-error-messages and published it to npm, you'd be able to consume it within your apps by doing the following: import { ErrorMessages } from 'custom-error-messages'; const customErrorMessages = { '400_validation': 'Please enter the fields in your form correctly', }; // Initialise your errorMessages object with your custom messages const errorMessages = new ErrorMessages(customErrorMessages); function riskyFunction() { try { // Throws an error await boom(); } catch (err) { // Get the error code our server sent over const { code } = err; // Get the code's corresponding message const message = errorMessages.getErrorMessage(code); // Display the message to the client displayNotification(message); } } You can then take all of the error codes that your server-side returns and apply corresponding messages to them. Once you're ready, you can publish your tool to NPM, and then consume it from your client-facing apps. Conclusion I hope you've enjoyed learning about an often overlooked aspect of web development. I've done a bunch of reading to learn about error messaging and I've shared some of my favourite resources below. Some are books and others are short articles, but they're all worth your time. You can also reach out if any part of the tutorial wasn't clear, or if you feel I can streamline things. Thanks for reading. FAQs Why can't the server-side just return these messages? The server shouldn't be concerned with any client-facing logic. But if you're fortunate enough to work with an API that gives useful error codes with each failed request, then you're nearly there. Will I need to create an instance of error-messages for every API consumer? Not necessarily. Because this package can take a list of default messages and codes, as long as it's in sync with the APIs, your frontends will be able to consume the same package. In each client-side instance, you can pass through additional error codes, or override existing messages to tailor your frontend messaging. I think this package should have X or do Y differently I'm dogfooding this internally at my job, and this is a problem space I'm very new to. I would love to hear of any suggestions, or improvements to the overall architecture or feature-set of sane-error-messages. Further Reading Microcopy: A Complete Guide I mentioned this book a little earlier, and it's one of my favourites when it comes to making my user-facing products a lot more personable. The book's author Kinneret Yifrah, has graciously provided a coupon for 10% off, you can purchase it here. Coupon code for the eBook: andrico-ebook Coupon code for the bundle: andrico-bundle Error messaging guidelines: NN Group A short article on the importance of sane error messaging which shares some very useful tips on how to create sane error messaging. In short: - Errors should be expressed in plain language - Indicate what the problem is - Suggest a solution Error Messages (Design basics): Microsoft An in-depth article that covers both design guidelines messaging practices Laws of UX A short book that introduces how a handful of psychology concepts can be used to improve your products UX.
https://www.freecodecamp.org/news/how-to-write-helpful-error-messages-to-improve-your-apps-ux/
CC-MAIN-2021-21
refinedweb
2,343
58.92
27 March 2008 21:38 [Source: ICIS news] HOUSTON (ICIS news)--European bulk spot monoethylene glycol (MEG) prices looked firmer into April, with fewer offers for domestic and import availability, market sources said on Thursday. “Prices have certainly moved up during March, and offers from ?xml:namespace> A trader reported the purchase of 3,000 tonnes of Turkish MEG at €730/tonne ($1,153/tonne) CIF (cost, insurance, freight) NWE (northwest Europe) on Thursday, below the majority of current price indications but still €40/tonne higher than spot business done earlier in March. Most market sources could not identify any single reason for the firmer trend, seeing it more as a combination of fewer seller offers, a stable-to-firm outlook in Bulk MEG spot levels fell around €200/tonne from the start of 2008 until early March, when the market stabilised. “I am looking to buy in the next few days and am offering around €740/tonne CIF NWE,” said another consumer. Sellers were confident that prompt demand would continue to pick up providing buyers accepted the upward price trend likely over the next month. Major European MEG producers include BASF, INEOS Oxide, Shell, and MEGlobal. ($1 = €0.63) For more
http://www.icis.com/Articles/2008/03/27/9111371/europe-bulk-meg-spot-looking-firm-into-april.html
CC-MAIN-2015-06
refinedweb
202
55.98
| Hibernate Tutorial | Spring Framework Tutorial | Struts Tutorial... Frameworks | Hibernate | Struts | JSF | JavaFX | Ajax... | JDBC Tutorial | EJB Tutorials | JSF Tutorial | WAP Tutorial | Constructor arg index Constructor Arguments Index In this example you will see how inject the arguments into your bean according to the constructor argument index...://"> <bean id plese tell -Struts or Spring - Spring /hibernate/index.shtml... about spring. which frameork i should do Struts or Spring and which version. i..., You need to study both struts and spring. Please visit the following An introduction to spring framework . Just as Hibernate attacks CMP as primitive ORM technology, Spring attacks..., including JDO, Hibernate, OJB and iBatis SQL Maps. 6. Spring Web module: The Web... 'VelocityConfigurer' bean is declared in spring configuration. The view resolver... in Spring Calling Bean using init() method Projects by combining all the three mentioned frameworks e.g. Struts, Hibernate and Spring... that can be used later in any big Struts Hibernate and Spring based.... Understanding Spring Struts Hibernate DAO Layer Spring Framework Tutorials . Spring Framework provides support for JPA, Hibernate, Web services, Schedulers..., bean, Spring MVC and much more. Here is some suggested articles that covering... Spring Framework Spring Hello World Application Inheritance in Spring Bean What is Bean lifecycle in Spring framework? What is Bean lifecycle in Spring framework? HI, What is Bean lifecycle in Spring framework? Thanks bean life cycle methods in spring? bean life cycle methods in spring? bean life cycle methods in spring ... A JUMP START the bean Spring container and JavaBeans support utilities. 4. spring-aop.jar...-hibernate.jar : It contains Hibernate 2.1 support, Hibernate 3.x support. 14. spring...; <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http DataSource in hibernate. ; Generally, in spring hibernate integration or struts hibernate integration we set data source class for integration. Here is a example of spring hibernate...; <!-- Spring Web Mapping End--> <!-- Spring Hibernate Mapping spring spring hi how can we make spring bean as prototype how can we load applicationcontext in spring what is dependency injection: NET BEAN - IDE Questions NET BEAN Thanks for your response actually i am working on struts and other window application. so if you have complete resources abt it then tell..."" then plz tell me.......or mail me at abhishek_sahu05@yahoo.com thank you Bean life cycle in spring Bean life cycle in spring This example gives you an idea on how to Initialize bean in the program and also explains the lifecycle of bean in spring. Run the given bean example Form Bean - Struts Form Bean How type of Formbean's property defined in struts config.xml? EmployeeDetailsForm is form1...:// Spring with Hibernate - Spring Spring with Hibernate When Iam Executing my Spring ORM module (Spring with Hibernate), The following messages is displaying on the browser window HTTP Status 500 struts struts <p>hi here is my code in struts i want to validate my... }//execute }//class struts-config.xml <struts-config> <form-beans> <form-bean name="regform" type spring - Spring spring what is bean java auto mail send - Struts java auto mail send Hello, im the beginner for Java Struts. i use java struts , eclipse & tomcat. i want to send mail automatically when... information on Quartz Scheduler,Mail and Struts visit to : http OGNL Index Introduction of OGNL in struts. Object Graph Navigation Language... objects. The Struts framework used a standard naming context for evaluating..., this first character at 0 index is extracted from the resulting array Spring and configuration file ---.xml is <bean id="customerService" class...; </bean> <bean id="hijackAfterMethodBean" class="com.mkyong.aop.HijackAfterMethod" /> <bean id="customerServiceProxy" 3 ;/head> <body> <h1>Spring 3 MVC and Hibernate 3... is used to declare it as service bean and its name articleService will be used...;} } ArticleController.java This is the spring controller class which handles the request Spring Bean Configuration Spring Bean Configuration The support of inheritance is present in the Spring... bean inherits the properties and configuration of the parent bean or base bean. Teacher.java package bean.configuration.inheritance; public class Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes I referred your tutorial "Spring 3 MVC and Hibernate 3 Example" and downloaded...: Error creating bean with name 'articleDao': Injection of autowired send the mail with attachment problem - Struts send the mail with attachment problem Hi friends, i am using the below code now .Here filename has given directly so i don't want that way. i need... mail server properties.setProperty("mail.smtp.host", host spring - Spring spring what is the difference between spring and hibernate and ejb3.0 Hi mamatha, Spring provides hibernate template and it has many...:// Thanks. Amarde2-spring-hibernate :// Thanks...struts2-spring-hibernate What are the files concerned with spring in a struts2-spring-hibernate web application? And what do we write in those files Send Mail Bean Send Mail Bean  ... when a new user is registered to the system. Mail Bean also used when user... ProjectConstants { public static String MAIL_BEAN="mailbean"; public
http://www.roseindia.net/tutorialhelp/comment/28551
CC-MAIN-2015-06
refinedweb
836
59.4
How do I check whether a file exists without exceptions? If the reason you're checking is so you can do something like if file_exists: open_it(), it's safer to use a try around the attempt to open it. Checking and then opening risks the file being deleted or moved or something between when you check and when you try to open it. If you're not planning to open the file immediately, you can use os.path.isfile Return Trueif path is an existing regular file. This follows symbolic links, so both islink() and isfile() can be true for the same path. import os.pathos.path.isfile(fname) if you need to be sure it's a file. Starting with Python 3.4, the pathlib module offers an object-oriented approach (backported to pathlib2 in Python 2.7): from pathlib import Pathmy_file = Path("/path/to/file")if my_file.is_file(): # file exists To check a directory, do: if my_file.is_dir(): # directory exists To check whether a Path object exists independently of whether is it a file or directory, use exists(): if my_file.exists(): # path exists You can also use resolve(strict=True) in a try block: try: my_abs_path = my_file.resolve(strict=True)except FileNotFoundError: # doesn't existelse: # exists You have the os.path.exists function: import os.pathos.path.exists(file_path) This returns True for both files and directories but you can instead use os.path.isfile(file_path) to test if it's a file specifically. It follows symlinks. Unlike isfile(), exists() will return True for directories. So depending on if you want only plain files or also directories, you'll use isfile() or exists(). Here is some simple REPL output: "/etc/password.txt")Trueos.path.isfile("/etc")Falseos.path.isfile("/does/not/exist")Falseos.path.exists("/etc/password.txt")Trueos.path.exists("/etc")Trueos.path.exists("/does/not/exist")Falseos.path.isfile(
https://codehunter.cc/a/python/how-do-i-check-whether-a-file-exists-without-exceptions
CC-MAIN-2022-21
refinedweb
313
51.24
This preview shows page 1. Sign up to view the full content. Unformatted text preview: easure of Risk Risk A measure of nondiversifiable risk Indicates how the price of a security responds to market forces Compares historical return of an investment to the market return (the S&P 500 Index) The beta for the market is 1.00 Stocks may have positive or negative betas. Nearly all are positive. Stocks with betas greater than 1.00 are more risky than the overall market. Stocks with betas less than 1.00 are less risky than the overall market. Figure 5.5 Graphical Derivation of Figure Beta for Securities C and D* Beta Monthly Holding-Period Returns of Barnes & Noble and the S&P 500 Index, December 2002 to November 2004 (The SCL for Barnes & Noble) Beta: A Popular Measure of Risk Risk Table 5.4 Selected Betas and Associated Interpretations Interpreting Beta Interpreting Higher stock betas should result in higher expected returns due to greater risk If the market is expected to increase 10%, a stock with a beta of 1.50 is expected to increase 15% If the market went down 8%, then a stock with a beta of 0.50 should only decrease by about 4% Beta values for specific stocks can be obtained from Value Line reports or online websites such as yahoo.com Interpreting Beta Interpreting Capital Asset Pricing Model (CAPM) (CAPM) Model that links the notions of risk and return Helps investors define the required return on an investment As beta increases, the required return for a given investment increases Capital Asset Pricing Model (CAPM) (cont’d) • U... View Full Document This note was uploaded on 10/31/2012 for the course ECON 435 taught by Professor Staff during the Fall '08 term at Maryland. - Fall '08 - staff Click to edit the document details
https://www.coursehero.com/file/7201204/00aremoreriskythan-theoverallmarket-Stockswithbetaslessthan100arelessriskythanthe-overallmarket/
CC-MAIN-2017-17
refinedweb
308
52.8
[ latest ] [ categories ] I’m writing this in my hotel room in downtown San Francisco, with my colleague Francesco Tisiot flying in tonight and US colleagues Jordan Meyer, Daniel Adams and Andy Rocha travelling down tomorrow and Monday for next week’s BIWA Summit 2015. The Business Intelligence, Warehousing and Analytics SIG is a part of IOUG and this year also hosts the 11th Annual Oracle Spatial Summit, giving us three days of database-centric content touching most areas of the Oracle BI+DW stack. Apart from our own sessions (more in a moment), BIWA Summit 2015 has a great-line up of speakers from the Oracle Database and also Hadoop worlds, featuring Cloudera’s Doug Cutting and Oracle’s Paul Sondereggar and with most of the key names from the Oracle BI+DW community including Christian Screen, Tim & Dan Vlamis, Tony Heljula, Kevin McGinley and Stewart Bryson, Brendan Tierney, Eric Helmer, Kyle Hailey and Rene Kuipers. From a Rittman Mead perspective we’ve delivering a number of sessions over the days, details below: Rittman Mead are also proud to be one of the media sponsors for the BIWS Summit 2015, so look out for blogs and other activity from us, and if you’re coming to the event we’ll look forward to seeing you there. For development and testing purposes, Rittman Mead run a VMWare VSphere cluster made up of a number of bare-metal servers hosting Linux, Windows and other VMs. Our setup has grown over the years from a bunch of VMs running on Mac Mini servers to where we are now, and was added-to considerably over the past twelve months as we started Hadoop development – a typical Cloudera CDH deployment we work with requires six or more nodes along with the associated LDAP server, Oracle OBIEE + ODI VMs and NAS storage for the data files. Last week we added our Exalytics server as a repurposed 1TB ESXi VM server giving us the topology shown in the diagram below. One of the purposes of setting up a development cluster like this was to mirror the types of datacenter environments our customers run, and we use VMWare VSphere and VCenter Server to manage the cluster as a whole, using technologies such as VMWare VMotion to test out alternatives to WebLogic, OBIEE and Oracle Database HA. The screenshot below shows the cluster setup in VMWare VCenter. We’re also big advocates of Oracle Enterprise Manager as a way of managing and monitoring a customer’s entire Oracle BI & data warehousing estate, using the BI Management Pack to manage OBIEE installations as whole, building alerts off of OBIEE Usage Tracking data, and creating composite systems and services to monitor a DW, ETL and BI system from end-to-end. We register the VMs on the VMWare cluster as hosts and services in a separate EM12cR4 install and use it to monitor our own development work, and show the various EM Management Packs to customers and prospective clients. Something we’ve wanted to do for a while though is bring the actual VM management into Enterprise Manager as well, and to do this we’ve also now setup the Blue Mendora VMWare Plugin for Enterprise Manager, which connects to your VMWare VCenter, ESXi, Virtual Machines and other infrastructure components and brings them into EM as monitorable and manageable components. The plugin connects to VCenter and the various ESXi hosts and gives you the ability to list out the VMs, Hosts, Clusters and so on, monitor them for resource usage and set up EM alerts as you’d do with other EM targets, and perform VCenter actions such as stopping, starting and cloning VMs. What’s particularly useful with such a virtualised environment though is being able to include the VM hypervisors, VM hosts and other VMWare infrastructure in the composite systems we define; for example, with a CDH Hadoop cluster that authenticates via LDAP and Kerberos, is used by OBIEE and ODI and is hosted on two VMWare ESXi hosts part of a VSphere cluster, we can get an overall picture of the system health that doesn’t stop at the host level. If your organization is using VMWare to host your Oracle development, test or production environments and you’re interested in how Enterprise Manager can help you monitor and manage the whole estate, including the use of Blue Mendora’s VMWare EM Plugin, drop me a line and I’d be happy to take you through what’s involved. code. In this post, I will demonstrate how to create your very own library of custom HTML tags. These tags will empower anyone to add 3rd party visualizations from libraries like D3 without a lick of JavaScript experience. Most standard HTML tags provide very simple behaviors. Complex behaviors have typically been reserved for JavaScript. While, for the most part, this is still the case, custom tags can be used to provide a more intuitive interface to the JavaScript. The term “custom tag” library refers to a developer defined library of HTML tags that are not natively supported by the HTML standard, but are instead included at run-time. For example, one might implement a <RM-MODAL> tag to produce a button that opens a modal dialog. Behind the scenes, JavaScript will be calling the shots, but the code in your narrative view or dashboard text section will look like plain old HTML tags. The first step when incorporating an external library onto your dashboard is to load it. To do so, it’s often necessary to add JavaScript libraries and css files to the <head> of a document to ensure they have been loaded prior to being called. However, in OBIEE we don’t have direct access to the <head> from the Dashboard editor. By accessing the DOM, we can create style and script src objects on the fly and append them to the <head>. The code below appends external scripts to the document’s <head> section. Figure 1. dashboard.js 01 function loadExtFiles(srcname, srctype){ 02 if (srctype=="js"){ 03 var src=document.createElement('script') 04 src.setAttribute("type","text/JavaScript") 05 src.setAttribute("src", srcname) 06 } else if (srctype=="css"){ 07 var src=document.createElement("link") 08 src.setAttribute("rel", "stylesheet") 09 src.setAttribute("type", "text/css") 10 src.setAttribute("href", srcname) 11 } 12 13 if ((typeof src!==undefined) && (src!==false)) { 14 parent.document.getElementsByTagName("head")[0].appendChild(src) 15 } 16 } 17 18 window.onload = function() { 19 loadExtFiles("/rm/js/d3.v3.min.js", "js") 20 loadExtFiles("/rm/css/visualizations.css", "css") 21 loadExtFiles("/rm/js/visualizations.js", "js") 22 } In addition to including the D3 library, we have included a CSS file and a JavaScript file, named visualizations.css and visualizations.js respectively. The visualizations.css file contains the default formatting for the visualizations and visualizations.js is our library of functions that collect parameters and render visualizations. The D3 gallery provides a plethora of useful and not so useful examples to fulfill all your visualizations needs. If you have a background in programming, these examples are simple enough to customize. If not, this is a tall order. Typically the process would go something like this: If you are writing your own visualization from scratch, these same steps are applied in the design phase. Either way, the JavaScript code that results from performing these steps should not be the interface exposed to a dashboard designer. The interface should be as simple and understandable as possible to promote re-usability and avoid implementation syntax errors. That’s where custom HTML tags come in. Using custom tags allow for a more intuitive implementation than JavaScript functions. Simple JavaScript functions do not support named arguments. What this means is JavaScript depends on order to differentiate arguments. <script>renderTreemap("@1", "@2", @3, null, null, "Y");</script> In the example above, anyone viewing this call without being familiar with the function definition would have a hard time deciphering the parameters. By using a tag library to invoke the function, the parameters are more clear. Parameters that are not applicable for the current invocation are simply left out. <rm-treemap <rm-treemap That being said, you should still familiarize yourself with the correct usage prior to using them. Now some of you may be saying that named arguments can be done using object literals, but the whole point of this exercise is to reduce complexity for front end designers, so I wouldn’t recommend this approach within the context of OBIEE. For this example, we will be providing a Treemap visualization. As could be expected, the example provided by the link is sourced by a JSON object. For our use, we will have to rewrite that code to source the data from the attributes in our custom HTML tags. The D3 code is expecting a hierarchical object made up of leaf node objects contained within grouping objects. The leaf node objects consists of a “name” field and a “size” field. The grouping object consists of a “name” field and a “children” field that contains an array of leaf node objects. By default, the size values, or measures, are not displayed and are only used to size the nodes. Additionally, the dimensions of the treemap are hard coded values. Inevitably users will want to change these settings, so for each of the settings which we want to expose for configuration we will provide attribute fields on the custom tag we build. Ultimately, that is the purpose of this design pattern. For this example we will configure behaviours for a tag called <rm-treemap>. Note: It is a good practice to add a dash to your custom tags to ensure they will not match an existing HTML tag. This tag will support the following attributes: It will be implemented within a narrative view like so: <rm-treemap <rm-treemap In order to make this tag useful, we need to bind behaviors to it that are controlled by the tag attributes. To extract the attribute values from <rm-treemap>, the javascript code in visualizations.js will use two methods from the Element Web API, Element.getElementsByTagName and Element.getAttributes. Fig 2. Lines 8-11 use these methods to identify the first <rm-treemap> tag and extract the values for width, height and showValues. It was necessary specify a single element, in this case the first one, as getElementsByTagName returns an array of all matching elements within the HTML document. There will most likely be multiple matches as the OBIEE narrative field will loop through query results and produce a <rm-treemap> tag for each row. In Fig 2. Lines 14-41, the attributes for name, measure and grouping will be extracted and bound to either leaf node objects or grouping objects. Additionally lines 11 and 49-50 configure the displayed values and the size of the treemap. The original code was further modified on line 62 to use the first <rm-treemap> element to display the output. Finally, lines 99-101 ensure that this code only executed when the <rm-treemap> is detected on the page. The last step before deployment is documentation. If you are going to go through all the trouble of building a library of custom tags, you need to set aside the time to document their usage. Otherwise, regardless of how much you simplified the usage, no one will be able to use them. Figure 2. visualizations.js 01 var renderTreemap = function () { 02 // Outer Container (Tree) 03 var input = {}; 04 input.name = "TreeMap"; 05 input.children = []; 06 07 //Collect parameters from first element 08 var treeProps = document.getElementsByTagName("rm-treemap")[0]; 09 canvasWidth = treeProps.getAttribute("width") ? treeProps.getAttribute("width") : 960; 10 canvasHeight = treeProps.getAttribute("height") ? treeProps.getAttribute("height") : 500; 11 showValues = treeProps.getAttribute("showValues").toUpperCase(); 12 13 // Populate collection of data objects with parameters 14 var mapping = document.getElementsByTagName("rm-treemap"); 15 for (var i = 0; i < mapping.length; i++) { 16 var el = mapping[i]; 17 var box = {}; 18 var found = false; 19 20 box.name = (showValues == "Y") ? el.getAttribute("name") + 21 "<br> " + 22 el.getAttribute("measure") : el.getAttribute("name"); 23 box.size = el.getAttribute("measure"); 24 curGroup = el.getAttribute("grouping"); 25 26 // Add individual items to groups 27 for (var j = 0; j < input.children.length; j++) { 28 if (input.children[j].name === curGroup) { 29 input.children[j].children.push(box); 30 found = true; 31 } 32 } 33 34 if (!found) { 35 var grouping = {}; 36 grouping.name = curGroup; 37 grouping.children = []; 38 grouping.children.push(box); 39 input.children.push(grouping); 40 } 41 } 42 43 var margin = { 44 top: 10, 45 right: 10, 46 bottom: 10, 47 left: 10 48 }, 49 width = canvasWidth - margin.left - margin.right, 50 height = canvasHeight - margin.top - margin.bottom; 51 52 // Begin D3 visualization 53 var color = d3.scale.category20c(); 54 55 var treemap = d3.layout.treemap() 56 .size([width, height]) 57 .sticky(true) 58 .value(function (d) { 59 return d.size; 60 }); 61 62 var div = d3.select("rm-treemap").append("div") 63 .style("position", "relative") 64 .style("width", (width + margin.left + margin.right) + "px") 65 .style("height", (height + margin.top + margin.bottom) + "px") 66 .style("left", margin.left + "px") 67 .style("top", margin.top + "px"); 68 69 var node = div.datum(input).selectAll(".treeMapNode") 70 .data(treemap.nodes) 71 .enter().append("div") 72 .attr("class", "treeMapNode") 73 .call(position) 74 .style("background", function (d) { 75 return d.children ? color(d.name) : null; 76 }) 77 .html(function (d) { 78 return d.children ? null : d.name; 79 }); 80 81 function position() { 82 this.style("left", function (d) { 83 return d.x + "px"; 84 }) 85 .style("top", function (d) { 86 return d.y + "px"; 87 }) 88 .style("width", function (d) { 89 return Math.max(0, d.dx - 1) + "px"; 90 }) 91 .style("height", function (d) { 92 return Math.max(0, d.dy - 1) + "px"; 93 }); 94 } 95 //End D3 visualization 96 } 97 98 // Invoke visualization code only if rm-treemap tag exists 99 var doTreemap = document.getElementsByTagName("rm-treemap"); 100 if (doTreemap !== null) { 101 renderTreemap(); 102 } Figure 3. visualizations.css 01 .treeMapNode { 02 border: solid 1px white; 03 border-radius: 5px; 04 font: 10px sans-serif; 05 line-height: 12px; 06 overflow: hidden; 07 position: absolute; 08 text-indent: 2px; 09 } The first step to implementing this code is to make is accessible. To do this, you will need to deploy your code to the weblogic server. Many years ago, Venkatakrishnan Janakiraman, detailed how to deploy code to weblogic in his blog about skinning. For this application this process still applies, however you don’t need to be concerned with the bits about modifying the instanceconfig.xml or skinning. Once that the code has been deployed to the server, there are literally only two lines of code required to implement this visualization. First the libraries need to be included. This is done by sourcing in the dashboard.js file. This can be done within the Narrative view’s prefix field, but I have chosen to add it to a text section on the dashboard. This allows multiple analyses to use the libraries without duplicating the load process in multiple places. The text section should be configured as follows. (Note: The path to Dashboard.js is relative to the root path specified in your deployment.) From the Narrative View, add the <rm-treemap> tag to the Narrative field and populate the attributes with the appropriate data bind variables and your desired settings. This should result in the following analysis. In summary: As you can see implementing custom HTML tags to serve as the interface for a D3 visualization will save your dashboard designers from having to sift through dozens if not hundreds of lines of confusing code. This will reduce implementation errors, as the syntax is much simpler than JavaScript and will promote conformity, as all visualizations will be sourced from a common library. Hopefully, this post was informative and will inspire you to consider this pattern or a similarly purposed one to make your code easier to implement.? And why we want to use it? One of the biggest problems that we face today, is the proliferation of different systems, data sources, solutions for BI, for ETL, etc in the same company. So not only for final users but also for technical people (from SysAdmin, Data Scientist, Data Steward to Developers) is quite difficult to track which data is used by which applications. In some cases is almost impossible to perform an impact analysis if someone wants to change a table or if the way that a sales measure is calculated needs to change. With more systems involved, the problem is bigger. Oracle Metadata Management (OMM) comes to provide a solution to this problem. It is a complete metadata management platform that can reverse engineer (harvest) and catalog metadata from any source: relational, Big data, ETL, BI, data modelling, etc. OMM allows us to perform interactive searching, data lineage, impact analysis, semantic definition and semantic usage analysis within the catalog. And the really important thing is the metadata from different providers (Oracle or/and third-party) can be related (stitched) so you will have the complete path of data from source to report or vice versa. In addition, it manages versioning and comparison of metadata models. The Oracle Metadata Management solution offers two products: OEMM (Oracle Enterprise Metadata Management) and OMM for OBI (Oracle Metadata Management for Oracle Business Intelligence). With the first one we can use metadata providers from Oracle and third-party technologies. Using OMM for OBI allows us to use metadata for databases, OBIEE, ODI and DAC. We will see in this series of posts how to use each of these options, the difference between them and which will be the best option depending of your environment. In this first post we will focus on the installation process and the requirements for it. Minimum Requirements for a small test environment It is important to note and it is also well explained in the Readme document, that the following are the minimum requirements for a tutorial or a small business case, not for a larger system. Browser Any of these browsers or newer versions of them with at least Adobe Flash v8 plugging can be used: Microsoft Internet Explorer (IE) v10, Mozilla Firefox v30 or newer, Google Chrome v30, Apple Safari v6. Hardware 2 GHZ or higher quad core processor 4 GB RAM (8 GB if 64bit OS using 64bits Web Application Server) 10 GB of disk space (all storage is primarily in the database server) Operating System Microsoft Windows 2008 Server, Windows 2012 Server, Windows 7, Windows 8, or Windows 8.1. Be sure that the you have full Administrator privilege when run the installer and that the Microsoft .NET Framework 3.5 or higher is installed. Other operating systems require manual install/setup, so are not supported by this version. Web Application Server The installer comes with the Apache Tomcat as Web Application Server and Oracle JRE 6 as Java Run Environment. Others web application servers (including Oracle WebLogic) require manual install/setup, and are not supported by this version. Database Server For the Database Server you can only use an Oracle Database from 10gR2 to 12 64-bit as a repository for OMM. You can create a new instance or reuse your existing Oracle database server but we need to have admin privileges in the database. A very important observation is that the character set MUST be AL32UTF8 (UTF8). This is because the Oracle Intermedia Search can only index columns of type VARCHAR or CLOB (not the national variants NVARCHAR and NCLOB respectively). Otherwise you will receive this error message when you run the OMM for the first time: To solve this, you can create a new instance of the database, or if your database has data already, there a couple of notes in My Oracle Support 260192.1 and 788156.1 to change any character set to AL32UTF8. In addition, the CTXSYS user must be exist in the database. In case it doesn’t exist, the creation and granting privileges script can be found in <ORACLE_HOME>/ctx/admin/catctx.sql. Preparing to install Step 1 - Download the software. You can download the software from the OTN site or using e-delivery.oracle.com instead. Step 2 – Create a Database Schema as Repository. Before start the installation, a database schema needs to be created as a repository for OMM to keep all its objects like models, configurations, etc (we will see all of these objects in next posts) For that reason create a user in the database: “create user MIR identified by <password> quota unlimited on users” And give to it the following grants: “grant create session to MIR; grant create procedure to MIR; grant create sequence to MIR; grant create table to MIR; grant create trigger to MIR; grant create type to MIR; grant create view to MIR” We also need to give grants to the new to user to execute a package from CTXSYS and another one from SYS. “grant execute on CTXSYS.CTX_DDL to MIR; grant execute on SYS.DBMS_LOCK TO MIR;” If you prefer (and also could be a more accurate solution) you can create specific tablespaces (user tablespace and temp tablespace) for that user. I asked to David Allan, who is always very generous with his time and knowledge, if this schema will be part of the RCU in future releases but there is no plan to incorporate the MIR schema to it. Installation and Post-Install tasks Step 3 – Install the software. We can start now to run the installation. The downloaded zip file contains an exe file, double-click on it to start the installation. In the first screen, select the type of product that you want to install: OEMM or OMM for OBI. We choose the Oracle Enterprise Metadata Management and press Next. In the next screen, you have access to the Readme document and release notes pressing the View Readme button. After the installation you can find them in the OMM_Home/Documentation folder. The next screen show you the destination location that you can change if you want. Keep the ports number suggested on the next screen. The last screen of the installation ask you to restart the computer in order to use the product. Step 4 – Start OMM Server as a service. After you restart the computer, you need to configure the OMM Server as a Service and start it. You can do this through the option that is showed in the start menu and press the Start button or going directly to the windows services screen and press the right button on the OMM service and start it. Step 5 – Initialize OEMM. Run the OEMM for the first time. We have everything ready to start using Oracle Metadata Management. Go to the URL: or execute the shortcut that was created on your desktop after the installation or use the Windows Start Menu. We need to enter the connection details using the schema that we created in the database. Enter MIR as the Database User Id, its password and the database URL, and then press the Test Connection button. After you receive the Successful message, press the Save button to run the initialization process where OEMM create the objects in the database schema to manage the repository. This process takes some minutes until you get the confirmation that the initialization process is also successful. Step 6 – Start OEMM. Close the browser tab and open again the OEMM URL (). A login page appears. User and password to login is Administrator/Administrator This is the main page of the OEMM where we are going to harvest (reverse-engineer) the metadata from different providers in the next posts. In case you want to change the password of the Administrator user go to Tools > Administration on the top right of the page. Select the Administrator user and the user will be appear below. If you prefer to create another user with Administration privileges, just press the Add User button (plus icon) in the Administration page and enter the details for the new user: We are using the Native LDAP authentication approach for this demo, but OEMM can also use an External LDAP for authentication. About the product documentation you can access it through the Help option which is on the top right of the page. In the Contents tab you have all the topics (Harvesting, Administration, etc) separated by folder and in each of them all the details about the specific topic Installation of OMM for OBI There are no differences in the installation process for OEMM and OMM for OBI. Just be sure to select the one that you want in the first screen of the installation. This is the page to login to the OMM for OBI. In the next post, we will see how is the harvest (importing metadata) process using different metadata providers like OBIEE, ODI and others. OBIEE is a well established product, having been around in various incarnations for well over a decade. The latest version, OBIEE 11g, was released 3.5 years ago, and there are mutterings of OBIEE 12c already. In all of this time however, one thing it has never quite nailed is the ability for multiple developers to work with the core metadata model – the repository, known as the RPD – concurrently and in isolation. Without this, development is doomed to be serialised – with the associated bottlenecks and inability to scale in line with the number of developers available. My former colleague Stewart Bryson wrote a series of posts back in 2013 in which he outlines the criteria for a successful OBIEE SDLC (Software Development LifeCycle) method. The key points were : Oracle’s only answer to the SDLC question for OBIEE has always been MUDE. But MUDE falls short in several respects: Whilst it wasn’t great, it wasn’t bad, and MUDE was all we had. Either that, or manual integration into source control (1, 2) tools, which was clunky to say the least. The RPD remained a single object that could not be merged or managed except through the Administration Tool itself, so any kind of automatic merge strategies that the rest of the software world were adopting with source control tools were inapplicable to OBIEE. The merge would always require the manual launching of the Administration Tool, figuring out the merge candidates, before slowly dying in despair at having to repeat such a tortuous and error-prone process on a regular basis… Then back in early 2012 Oracle introduced a new storage format for the RPD. Instead of storing it as a single binary file, closed to prying eyes, it was instead burst into a set of individual files in MDS XML format. For example, one Logical Table was now one XML files on disk, made up of entities such as LogicalColumn, ExprText, LogicalKey and so on: It even came with a set of configuration screens for integration with source control. It looked like the answer to all our SDLC prayers – now us OBIEE developers could truly join in with the big boys at their game. The reasoning went something like: But how viable is MDS XML as a storage format for the RPD used in conjunction with a source control tool such as git? As we will see, it comes down to the Good, the Bad, and the Ugly… As described here, concurrent and unrelated developments on an RPD in MDS XML format can be merged successfully by a source control tool such as git. Each logical object is an file, so git just munges (that’s the technical term) the files modified in each branch together to come up with a resulting MDS XML structure with the changes from each development in it. This is where the wheels start to come off. See, our automagic merging fairy dust is based on the idea that individually changed files can be spliced together, and that since MDS XML is not binary, we can trust a source control tool such as git to also work well with changes within the files themselves too. Unfortunately this is a fallacy, and by using MDS XML we expose ourselves to greater complications than we would if we just stuck to a simple binary RPD merged through the OBIEE toolset. The problem is that whilst MDS XML is not binary, is not unstructured either. It is structured, and it has application logic within it (mdsid, of which see below). Within the MDS XML structure, individual first-class objects such as Logical Tables are individual files, and structured within them in the XML are child-objects such as Logical Columns: Source control tools such as git cannot parse it, and therefore do not understand what is a real conflict versus an unrelated change within the same object. If you stop and think for a moment (or longer) quite what would be involved in accurately parsing XML (let alone MDS XML), you’ll realise that you basically need to reverse-engineer the Administration Tool to come up with an accurate engine. We kind of get away with merging when the file differences are within an element in the XML itself. For example, the expression for a logical column is changed in two branches, causing clashing values within ExprText and ExprTextDesc. When this happens git will throw a conflict and we can easily resolve it, because the difference is within the element(s) themselves: Easy enough, right? But taking a similarly “simple” merge conflict where two independent developers add or modify different columns within the same Logical Table we see what a problem there is when we try to merge it back together relying on source control alone. Obvious to a human, and obvious to the Administration Tool is that these two new columns are unrelated and can be merged into a single Logical Table without problem. In a paraphrased version of MDS XML the two versions of the file look something like this, and the merge resolution is obvious: But a source control tool such as git looks as the MDS XML as a plaintext file, not understanding the concept of an XML tree and sibling nodes, and throws its toys out of the pram with a big scary merge conflict: Now the developer has to roll up his or her sleeves and try to reconcile two XML files – with no GUI to support or validate the change made except loading it back into the Administration Tool each time. So if we want to use MDS XML as the basis for merging, we need to restrict our concurrent developments to completely independent objects. But, that kind of hampers the ideal of more rapid delivery through an Agile method if we’re imposing rules and restrictions like this. This is where is gets a bit grim. Above we saw that MDS XML can cause unnecessary (and painful) merge conflicts. But what about if two developers inadvertently create the same object concurrently? The behaviour we’d expect to see is a single resulting object. But what we actually get is both versions of the object, and a dodgy RPD. Uh Oh. Here are the two concurrently developed RPDs, produced in separate branches isolated from each other: And here’s what happens when you leave it to git to merge the MDS XML: The duplicated objects now cannot be edited in the Administration Tool in the resulting merged RPD – any attempt to save them throws the above error. Why does it do this? Because the MDS XML files are named after a globally unique identifier known as the mdsid, and not their corresponding RPD qualified name. And because the mdsid is unique across developments, two concurrent creations of the same object end up with different mdsid values, and thus different filenames. Two files from separate branches with different names are going to be seen by source control as being unrelated, and so both are brought through in the resulting merge. As with the unnecessary merge conflict above, we could define process around same object creation, or add in a manual equalise step. The issue really here is that the duplicates can arise without us being aware because there is no conflict seen by the source control tool. It’s not like merging an un-equalised repository in the Administration Tool where we’d get #1 suffixes on the duplicate object so that at least (a) we spot the duplication and (b) the repository remains valid and the duplicate objects available to edit. Whether a development strategy based on MDS XML is for you or not, another issue to be aware of is that for anything beyond a medium sized RPD opening times of an MDS XML repository are considerable. As in, a minute from binary RPD, and 20 minutes from MDS XML. And to be fair, after 20 minutes I gave up on the basis that no sane developer would write off that amount of their day simply waiting for the repository to open before they can even do any work on it. This rules out working with any big repositories such as that from BI Apps in MDS XML format. MDS XML does have two redeeming features : But the above screenshots both give a hint of the trouble in store. The mdsid unique identifier is used not only in filenames – causing object duplication and strange RPD behaviour- but also within the MDS XML itself, referencing other files and objects. This means that as a RPD developer, or RPD source control overseer, you need to be confident that each time you perform a merge of branches you are correctly putting Humpty Dumpty back together in a valid manner. If you want to use MDS XML with source control you need to view it as part of a larger solution, involving clear process and almost certainly a hybrid approach with the binary RPD still playing a part — and whatever you do, the Administration Tool within short reach. You need to be aware of the issues detailed above, decide on a process that will avoid them, and make sure you have dedicated resource that understands how it all fits together. Source control (e.g. git) is mandatory for any kind of SDLC, concurrent development included. But instead of storing the RPD in MDS XML, we store it as a binary RPD. Wait wait wait, don’t go yet ! … it gets better By following the git-flow method, which dictates how feature-driven development is done in source control (git), we can write a simple script that determines when merging branches what the candidates are for an OBIEE three-way RPD merge. In this simple example we have two concurrent developments – coded “RM–1” and “RM–2”. First off, we create two branches which take the code from our “mainline”. Development is done on the two separate features in each branch independently, and committed frequently per good source control practice. The circles represent commit points: The first feature to be completed is “RM–1”, so it is merged back into “develop”, the mainline. Because nothing has changed in develop since RM–1 was created from it, the binary RPD file and all other artefacts can simply ‘overwrite’ what is there in develop: Now at this point we could take “develop” and start its deployment into System Test etc, but the second feature we were working on, RM–2, is also tested and ready to go. Here comes the fancy bit! Git recognises that both RM–1 and RM–2 have made changes to the binary RPD, and as a binary RPD git cannot try to merge it. But now instead of just collapsing in a heap and leaving it for the user to figure out, it makes use of git and the git-flow method we have followed to work out the merge candidates for the OBIEE Administration Tool: Even better, it invokes the Administration Tool (which can be run from the command line, or alternatively use command line tools comparerpd/patchrpd) to automatically perform the merge. If the merge is successful, it goes ahead with the commit in git of the merge into the “develop” branch. The developer has not had to do any kind of interaction to complete the merge and commit. If the merge is not a slam-dunk, then we can launch the Administration Tool and graphically figure out the correct resolution – but using the already-identified merge candidates in order to shorten the process. This is not perfect, but there is no perfect solution. It is the closest thing that there is to perfection though, because it will handle merges of : There is no single right answer here, nor are any of the options overly appealing. If you want to work with OBIEE in an Agile method, using feature-driven development, you will have to adopt and learn specific processes for working with OBIEE. The decision you have to make is on how you store the RPD (binary or multiple MDS XML files, or maybe both) and how you handle merging it (git vs Administration Tool). My personal view is that taking advantage of git-flow logic, combined with the OBIEE toolset to perform three-way merges, is sufficiently practical to warrant leaving the RPD in binary format. The MDS XML format is a lovely idea but there are too few safeguards against dodgy/corrupt RPD (and too many unnecessary merge conflicts) for me to see it as a viable option. Whatever option you go for, make sure you are using regression testing to test the RPD after you merge changes together, and ideally automate the testing too. Here at Rittman Mead we’ve written our own suite of tools that do just this – get in touch to find out more. In a previous post I looked at using Oracle’s new Big Data SQL product with ODI12c, where I used Big Data SQL to expose two Hive tables as Oracle external tables, and then join them using the BETWEEN operator, something that’s not possible with regular HiveQL. In this post I’m going to look at using Oracle Big Data SQL with OBIEE11g, to enable reporting against Hive tables without the need to use Hive ODBC drivers and to bring in reference data without having to stage it in Hive tables in the Hadoop cluster. In this example I’ve got some webserver log activity from the Rittman Mead Blog stored as a Hive table in Hadoop, which in its raw form only has a limited amount of descriptive data and wouldn’t be all that useful to users reporting against it using OBIEE. Here’s the contents of the Hive table as displayed via SQL*Developer: When I bring this table into OBIEE, I really want to add details of the country that each user is visiting from, and also details of the category that each post referenced in the webserver logs belongs to. Tables for these reference data items can be found in an accompanying Oracle database, like this: The idea then is to create an ORACLE_HIVE external table over the Hive table containing the log activity, and then import all of these tables into the OBIEE RPD as regular Oracle tables. Back in SQL*Developer, connected to the database that has the link setup to the Hadoop cluster via Big Data SQL, I create the external table using the new ORACLE_HIVE external table access driver: And now with the Hive table exposed as the Oracle external table BDA_OUTPUT.ACCESS_PER_POST_EXTTAB, I can import all four tables into the OBIEE repository. I can now create joins across the two Oracle schemas and four tables: and then create a business model and presentation model to define a simple star schema against the combined dataset: Once the RPD is saved and made available to the Presentation layer, I can now go and create some simple reports against the Hive and Oracle tables, with the Big Data SQL feature retrieving the Hive data using SmartScan technology running directly on the Hadoop cluster – bypassing MapReduce and filtering, projecting and just returning the results dataset back to the Exadata server running the Oracle SQL query. In the previous ODI12c and Big Data SQL posting, I used the Big Data SQL feature to enable a join between the Hive table and a table containing IP address range lookups using the BETWEEN operator, so that I could return the country name for each visitor to the website. I can do a similar thing with OBIEE, by first recreating the main incoming fact table source as a view over the ORACLE_HIVE external table and adding an IP integer calculation that I can then use for the join to the IP range lookup table (and also take the opportunity to convert the log-format date string into a proper Oracle DATE datatype): and then using that to join to a new table I’ve imported from the BLOG_REFDATA Oracle schema that contains the IP range lookups: Now I can add country as a dimension, and create reports that break down site visits by country of access. Similarly, I can break the date column in the view over the Hive external table out into its own logical dimension table, and then create some reports to show site access over time. and with the final RPD looking like this: If you’re interested in reading more about Oracle Big Data SQL I also covered it earlier on the blog around the launch date, with this post introducing the feature and another looking at how it extends Oracle security over your Hadoop cluster. The Call for Papers for the Rittman Mead BI Forum 2015 is currently open, with abstract submissions open to January 18th 2015. As in previous years the BI Forum will run over consecutive weeks in Brighton, UK and Atlanta, GA, with the provisional dates and venues as below: Now on it’s seventh year, the Rittman Mead BI Forum is the only conference dedicated entirely to Oracle Business Intelligence, Oracle Business Analytics and the technologies and processes that support it – data warehousing, data analysis, data visualisation, big data and OLAP analysis. We’re looking for session around tips & techniques, project case-studies and success stories, and sessions where you’ve taken Oracle’s BI products and used them in new and innovative ways. Each year we select around eight-to-ten speakers for each event along with keynote speakers and a masterclass session, with speaker choices driven by attendee votes at the end of January, and editorial input from myself, Jon Mead and Charles Elliott and Jordan Meyer. Last year we had a big focus on cloud, and a masterclass and several sessions on bringing Hadoop and big data to the world of OBIEE. This year we’re interested in project stories and experiences around cloud and Hadoop, and we’re keen to hear about any Oracle BI Apps 11g implementations or migrations from the earlier 7.9.x releases. Getting back to basics we’re always interested in sessions around OBIEE, Essbase and data warehouse data modelling, and we’d particularly like to encourage session abstracts on data visualization, BI project methodologies and the incorporation of unstructured, semi-structured and external (public) data sources into your BI dashboards. For an idea of the types of presentations that have been selected in the past, check out the BI Forum 2014, 2013 and 2012 homepages, or feel free to get in touch via email at mark.rittman@rittmanmead.com. – just over a week from now!. It’s the afternoon of New Year’s Eve over in the UK, so to round the year off here’s the top 10 blog posts from 2014 from the Rittman Mead blog, based on Google Analytics stats (page views for 2014 in brackets, only includes articles posted in 2014) In all, the blog in one form or another has been going for 10 years now, and our most popular post of all time over the same period is Robin Moffatt’s “Upgrading OBIEE to 11.1.1.7” – well done Robin. To everyone else, have a Happy New Year and a prosperous 2015, and see you next year when it all starts again! Yes, I’m hijacking the “Data Integration Tips” series of my colleague Michael Rainey (@mRainey) and I have no shame! DISCLAIMER This tip is intended for newcomers in the ODI world and is valid with all the versions of ODI. It’s nothing new, it has been posted by other authors on different blogs. But I see so much people struggling with that on the ODI Space on OTN that I wanted to explain it in full details, with all the context and with my own words. So next time I can just post a link to this instead of explaining it from scratch. I’m loading data from a schema to another schema on the same Oracle database but it’s slower than when I write a SQL insert statement manually. The bottle neck of the execution is in the steps from the LKM SQL to SQL. What should I do? Loading Knowledge Modules (LKMs) are used to load the data from one Data Server to another. It usually connects to the source and the target Data Server to execute some steps on each of them. This is required when working with different technologies or different database instances for instance. So if we define two Data Servers to connect to our two database schemas, we will need a LKM. In this example, I will load a star schema model in HR_DW schema, using the HR schema from the same database as a source. Let’s start with the approach using two Data Servers. Note that here we use directly the database schema to connect to our Data Servers. And here are the definitions of the physical schemas : Let’s build a simple mapping using LOCATIONS, COUNTRIES and REGIONS as source to denormalize it and load it into a single flattened DIM_LOCATIONS table. We will use Left Outer joins to be sure we don’t miss any location even if there is no country or region associated. We will populate LOCATION_SK with a sequence and use an SCD2 IKM. If we check the Physical tab, we can see two different Execution Groups. This mean the Datastores are in two different Data Servers and therefore a LKM is required. Here I used LKM SQL to SQL (Built-In) which is a quite generic one, not particularly designed for Oracle databases. Performances might be better with a technology-specific KM, like LKM Oracle to Oracle Pull (DB Link). By choosing the right KM we can leverage the technology-specific concepts – here the Oracle database links – which often improve performance. But still, we shouldn’t need any database link as everything lies in the same database instance. Another issue is that temporary objects needed by the LKM and the IKM are created in the HR_DW schema. These objects are the C$_DIM_LOCATIONS table created by the LKM to bring the data in the Target Data Servers and the I$_DIM_LOCATIONS table created by the IKM to detect when a new row is needed or when a row needs to be updated according to the SCD2 rules. Even though these objects are deleted in the clean-up steps at the end of the mapping execution, it would be better to use another schema for these temporary objects instead of target schema that we want to keep clean. If the source and target Physical Schemas are located on the same Data Server – and the technology can execute code – there is no need for a LKM. So it’s a good idea to try to reuse as much as possible the same Data Server for data coming from the same place. Actually, the Oracle documentation about setting up the topology recommends to create an ODI_TEMP user/schema on any RDBMS and use it to connect. This time, let’s create only one Data Server with two Physical schemas under it and let’s map it to the existing Logical schemas. Here I will use ODI_STAGING name instead of ODI_TEMP because I’m using the excellent ODI Getting Started virtual machine and it’s already in there. As you can see in the Physical Schema definitions, there is no other password provided to connect with HR or HR_DW directly. At run-time, our agent will only use one connection to ODI_STAGING and execute code through it, even if it needs to populate HR_DW tables. It means that we need to be sure that ODI_STAGING has all the required privileges to do so. Here are the privileges I had to grant to ODI_STAGING : GRANT SELECT on HR.LOCATIONS TO ODI_STAGING; GRANT SELECT on HR.COUNTRIES TO ODI_STAGING; GRANT SELECT on HR.REGIONS TO ODI_STAGING; GRANT SELECT, INSERT, UPDATE, DELETE on HR_DW.DIM_LOCATIONS to ODI_STAGING; GRANT SELECT on HR_DW.DIM_LOCATIONS_SEQ to ODI_STAGING; Let’s now open our mapping again and go on the physical tab. We now have only one Execution Group and there is no LKM involved. The code generated is a simple INSERT AS SELECT (IAS) statement, selecting directly from the HR schema and loading into the HR_DW schema without any database link. Data is loaded faster and our first problem is addressed. Now let’s tackle the second issue we had with temporary objects being created in HR_DW schema. If you scroll upwards to the Physical Schema definitions (or click this link, if you are lazy…) you can see that I used ODI_STAGING as Work Schema in all my Physical Schemas for that Data Server. This way, all the temporary objects are created in ODI_STAGING instead of the source or target schema. Also we are sure that we won’t have any issue with missing privileges, because our agent uses directly ODI_STAGING to connect. So you can see it has a lot of advantages using a single Data Server when sources come from the same place. We get rid of the LKM and the schema used to connect can also be used as Work Schema so we keep the other schemas clean without any temporary objects. The only thing you need to remember is to give the right privileges to ODI_STAGING (or ODI_TEMP) on all the objects it needs to handle. If your IKM has a step to gather statistics, you might also want to grant ANALYZE ANY. If you need to truncate a table before loading it, you have two approaches. You can grant DROP ANY table to ODI_STAGING, but this might be a dangerous privilege to give in production. A safer way is to create a stored procedure ODI_TRUNCATE in all the target database schema. This procedure takes a table name as a parameter and truncates that table using the Execute Immediate statement. Then you can grant execute on that procedure to ODI_STAGING and edit your IKM step to execute that procedure instead of using the truncate syntax. That’s it for today, I hope this article can help some people to understand the reason of that Oracle recommendation and how to implement it. Stay tuned on this blog and on Twitter (@rittmanmead, @mRainey, @markrittman, @JeromeFr, …) for more tips about Data Integration!.: Myself, Francesco Tisiot, Jordan Meyer, Daniel Adams and Andy Rocha will be presenting on Big Data SQL, ODI & OBIEE; data science for Oracle professionals; Oracle BICS and data visualization amongst other topics Robin Moffatt and I will be speaking on OBIEE, source control and release management, and Robin will deliver his award-winning session on OBIEE performance optimization This is an evening session for the Oracle Users’ Club Holland where I’ll be talking about our project experiences delivering Big Data and BI projects on Oracle Big Data Appliance, Exadata and Exalytics I’m one of nine speakers at this event, and I’ll be speaking about OBIEE development “best practices” on the first day, and then OBIEE futures on the second Robin Moffatt, myself and others will be speaking at the OUGN Conference in March, on topics around OBIEE and Big Data That’s it for now though – have a great Christmas and New Year, and see you in 2015! TIMESTAMPS and Presentation Variables can be some of the most useful tools a report creator can use to invent robust, repeatable reports while maximizing user flexibility. I intend to transform you into an expert with these functions and by the end of this page you will certainly be able to impress your peers and managers, you may even impress Angus MacGyver. In this example we will create a report that displays a year over year analysis for any rolling number of periods, by week or month, from any date in time, all determined by the user. This entire document will only use values from a date and revenue field. The TIMESTAMP is an invaluable function that allows a user to define report limits based on a moving target. If the goal of your report is to display Month-to-Date, Year-to-Date, rolling month or truly any non-static period in time, the TIMESTAMP function will allow you to get there. Often users want to know what a report looked like at some previous point in time, to provide that level of flexibility TIMESTAMPS can be used in conjunction with Presentation Variables. To create robust TIMESTAMP functions you will first need to understand how the TIMESTAMP works. Take the following example: Here we are saying we want to include all dates greater than or equal to 7 days ago, or from the current date. So in the end we have created a functional filter making Date >= 1 week ago, using a TIMESTAMP that subtracts 7 days from today. Note: it is always a good practice to include a second filter giving an upper limit like “Time”.”Date” < CURRENT_DATE. Depending on the data that you are working with you might bring in items you don’t want or put unnecessary strain on the system. We will now start to build this basic filter into something much more robust and flexible. To start, when we subtracted 7 days in the filter above, let’s imagine that the goal of the filter was to always include dates >= the first of the month. In this scenario, we can use the DAYOFMONTH() function. This function will return the calendar day of any date. This is useful because we can subtract this amount to give us the first of the month from any date by simply subtracting it from that date and adding 1. Our new filter would look like this: For example if today is December 18th, DAYOFMONTH(CURRENT_DATE) would equal 18. Thus, we would subtract 18 days from CURRENT_DATE, which is December 18th, and add 1, giving us December 1st. (For a list of other similar functions like DAYOFYEAR, WEEKOFYEAR etc. click here.) To make this even better, instead of using CURRENT_DATE you could use a prompted value with the use of a Presentation Variable (for more on Presentation Variables, click here). If we call this presentation variable pDate, for prompted date, our filter now looks like this: A best practice is to use default values with your presentation variables so you can run the queries you are working on from within your analysis. To add a default value all you do is add the value within braces at the end of your variable. We will use CURRENT_DATE as our default, @{pDate}{CURRENT_DATE}. Will will refer to this filter later as Filter 1. {Filter 1}: As you can see, the filter is starting to take shape. Now lets say we are going to always be looking at a date range of the most recent completed 6 months. All we would need to do is create a nested TIMESTAMP function. To do this, we will “wrap” our current TIMESTAMP with another that will subtract 6 months. It will look like this: Now we have a filter that is greater than or equal to the first day of the month of any given date (default of today) 6 months ago. To take this one step further, you can even allow the users to determine the amount of months to include in this analysis by making the value of 6 a presentation variable, we will call it “n” with a default of 6, @{n}{6}. We will refer to the following filter as Filter 2: {Filter 2}: For more on how to create a prompt with a range of values by altering a current column, like we want to do to allow users to select a value for n, click here. Our TIMESTAMP appears to be pretty intimidating but if we break it into parts we can start to understand its purpose. Notice we are using the exact same filters from before (Filter 1 and Filter 2). What we have done here is filtered on two time periods, separated by the OR statement. The first date range defines the period as being the most recent complete n months from any given prompted date value, using a presentation variable with a default of today, which we created above. The second time period, after the OR statement, is the exact same as the first only it has been wrapped in another TIMESTAMP function subtracting 1 year, giving you the exact same time frame for the year prior. This allows us to create a report that can run a year over year analysis for a rolling n month time frame determined by the user. A note on nested TIMESTAMPS: You will always want to create nested TIMESTAMPS with the smallest interval first. Due to syntax, this will always be the furthest to the right. Then you will wrap intervals as necessary. In this case our smallest increment is day, wrapped by month, wrapped by year. Now we will start with some more advanced tricks: In order for our interaction between Month and Week to run smoothly we have to make one more consideration. If we are to take the date December 1st, 2014 and subtract one year we get December 1st, 2013, however, if we take the first day of this week, Sunday December 14, 2014 and subtract one year we get Saturday December 14, 2014. In our analysis this will cause an extra partial week to show up for prior years. To get around this we will add a case statement determining if ‘@{INT}{MONTH}’ = ‘Week’ THEN subtract 52 weeks from the first of the week ELSE subtract 1 year from the first of the month. Our final filter set will look like this: With the use of these filters and some creative dashboarding you can end up with a report that easily allows you to view a year over year analysis from any date in time for any number of periods either by month or by week. That really got out of hand in a hurry! Surely, this will impress someone at your work, or even Angus MacGyver, if for nothing less than he or she won’t understand it, but hopefully, now you do! Also, a colleague of mine Spencer McGhin just wrote a similar article on year over year analyses using a different approach. Feel free to review and consider your options. These are functions you can use within OBIEE and within TIMESTAMPS to extract the information you need. Back to section The only way you can create variables within the presentation side of OBIEE is with the use of presentation variables. They can only be defined by a report prompt. Any value selected by the prompt will then be sent to any references of that filter throughout the dashboard page. In the prompt: From the “Set a variable” dropdown, select “Presentation Variable”. In the textbox below the dropdown, name your variable (named “n” above). When calling this variable in your report, use the syntax @{n}{default} If your variable is a string make sure to surround the variable in single quotes: ‘@{CustomerName]{default}’ Also, when using your variable in your report, it is good practice to assign a default value so that you can work with your report before publishing it to a dashboard. For variable n, if we want a default of 6 it would look like this @{n}{6} Presentation variables can be called in filters, formulas and even text boxes. For situations where you would like users to select a numerical value for a presentation variable, like we do with @{n}{6} above, you can convert something like a date field into values up to 365 by using the function DAYOFYEAR(“Time”.”Date”). As you can see we are returning the SQL Choice List Values of DAYOFYEAR(“Time”.”Date”) <= 52. Make sure to include an ORDER BY statement to ensure your values are well sorted. Back to Section The. The wordy title is actually a simple concept that incorporates 5 key areas: While there numerous ways of implementing a security model in Oracle BI, by sticking to the key concepts above, we ensure we get it right. The largest challenge we face in BI is the different types of security required, and all three need to work in harmony:. Next is to consider the types of users we have: The types of users here are a combination of every requirement we have seen and might not be required by every client. The order they are in shows the implied inheritance, so the BI Analyst inherits permissions and privileges from the BI Consumer and so on. Depending on the size of organization determines what types of user groups are required. By default Oracle ships with: Typically we would recommend inserting the BI Analyst into the default groups:: Each of the groups will require different permissions, at a high level the permissions would be:. Assuming this is for an SME size organization where the Dashboard development (BI Author) is done by the central BI team the groups would like: The key points are:. I hope this article gives some insight into Security with Oracle BI. Remember that our Global Services products offer a flexible support model where you can harness our knowledge to deliver your projects in a cost effective manner. The.. At Rittman Mead R&D, we have the privilege of solving some of our clients’ most challenging data problems. We recently built a set of customized data products that leverage the power of Oracle and Cloudera platforms and wanted to share some of the fun we’ve had in creating unique user experiences. We’ve been thinking about how we can lean on our efforts to help make the holidays even more special for the extended Rittman Mead family. With that inspiration, we had several questions on our minds: After a discussion over drinks, the answers became clear. We decided to create a tool that uses data analytics to help you create exceptional cocktails for the holidays. Here is how we did it. First, we analyzed the cocktail recipes of three world-renowned cocktail bars: PDT, Employees Only, and Death & Co. We then turned their drink recipes into data and got to work on the Bar Optimizer, which uses analytics on top of that data to help you make the holiday season tastier than ever before. To use the Bar Optimizer, enter the liquors and other ingredients that you have on hand to see what drinks you can make. It then recommends additional ingredients that let you create the largest variety of new drinks. You can also use this feature to give great gifts based on others’ liquor cabinets. Finally, try using one of our optimized starter kits to stock your bar for a big holiday party. We’ve crunched the numbers to find the fewest bottles that can make the largest variety of cocktails. Click the annotated screenshot above for details, and contact us if you would like more information about how we build products that take your data beyond dashboards. In this mini-series of blog posts I’m taking a look at a few very useful tools that can make your life as the sysadmin of a cluster of Linux machines. This may be a Hadoop cluster, or just a plain simple set of ‘normal’ machines on which you want to run the same commands and monitoring. First we looked at using SSH keys for intra-machine authorisation, which is a pre-requisite executing the same command across multiple machines using PDSH, as well as what we look at in this article – monitoring OS metrics across a cluster with colmux. Colmux is written by Mark Seger, the same person who wrote collectl. It makes use of collectl on each target machine to report back OS metrics across a cluster to a single node. Using pdsh we can easily install collectl on each node (if it’s not already), which is a pre-requisite for colmux: pdsh -w root@rnmcluster02-node0[1-4] "yum install -y collectl && service collectl start && chkconfig collectl on" NB by enabling the collectl service on each node it will capture performance data to file locally, which colmux can replay centrally. Then install colmux itself, which you can download from Sourceforge. It only needs to be actually installed on a single host, but obviously we could push it out across the cluster with pdsh if we wanted to be able to invoke it on any node at will. Note that here I’m running it on a separate linux box (outside of the cluster) rather than on my Mac: cd /tmp # Make sure you get the latest version of collectl-utils, from # This example is hardcoded to a version and particular sourceforge mirror curl -O tar xf collectl-utils-4.8.2.src.tar.gz cd collectl-utils-4.8.2 sudo ./INSTALL # collectl-utils also includes colplot, so if you might want to use it restart # apache (assuming it's installed) sudo service httpd restart Couple of important notes: You also may encounter an issue if you have any odd networking (eg NAT on virtual machines) that causes colmux to not work because it picks the ‘wrong’ network interface of the host to tell collectl on each node to send its data to. Details and workaround here. Command colmux -addr 'rnmcluster02-node0[1-4]' -username root Output # Mon Dec 1 22:20:40 2014 Connected: 4 of 4 # <--------CPU--------><----------Disks-----------><----------Network----------> #Host cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut rnmcluster02-node01 1 1 28 36 0 0 0 0 0 2 0 2 rnmcluster02-node04 0 0 33 28 0 0 36 8 0 1 0 1 rnmcluster02-node03 0 0 15 17 0 0 0 0 0 1 0 1 rnmcluster02-node02 0 0 18 18 0 0 0 0 0 1 0 1 -cols puts the hosts across the top and time as rows. Specify one or more columns from the output without -cols. In this example it is the values for cpu value, along with the disk read/write (columns 1, 5 and 7 of the metrics as seen above): -cols cpu Command colmux -addr 'rnmcluster02-node0[1-4]' -user root -cols 1,5,7 cpu KBRead KBWrit node01 node02 node03 node04 | node01 node02 node03 node04 | node01 node02 node03 node04 0 0 0 0 | 0 0 0 0 | 12 28 0 0 0 0 0 0 | 0 0 0 0 | 12 28 0 0 1 0 1 0 | 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 | 0 20 0 0 0 0 0 0 | 0 0 0 0 | 52 4 0 0 0 0 0 2 | 0 0 0 0 | 0 0 0 0 1 0 0 0 | 0 0 0 0 | 0 0 0 0 15 16 15 15 | 0 4 4 4 | 20 40 32 48 0 0 1 1 | 0 0 0 0 | 0 0 4 0 1 0 0 0 | 0 0 0 0 | 0 0 0 0 To check the numbers of the columns that you want to reference, run the command with the --test argument: --test colmux -addr 'rnmcluster02-node0[1-4]' -user root --test >>> Headers <<< # <--------CPU--------><----------Disks-----------><----------Network----------> #Host cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut >>> Column Numbering <<< 0 #Host 1 cpu 2 sys 3 inter 4 ctxsw 5 KBRead 6 Reads 7 KBWrit 8 Writes 9 KBIn 10 PktIn 11 KBOut 12 PktOut And from there you get the numbers of the columns to reference in the -cols argument. To include the timestamp, use -oT in the -command and offset the column numbers by 1: -oT -command colmux -addr 'rnmcluster02-node0[1-4]' -user root -cols 2,6,8 -command '-oT' sys Reads Writes #Time node01 node02 node03 node04 | node01 node02 node03 node04 | node01 node02 node03 node04 22:24:50 0 0 0 0 | 0 0 0 0 | 0 0 0 0 22:24:51 1 0 0 0 | 0 0 0 0 | 0 0 0 0 22:24:52 0 0 0 0 | 0 0 0 0 | 0 16 0 16 22:24:53 1 0 0 0 | 0 0 0 0 | 36 0 16 0 22:24:54 0 0 0 1 | 0 0 0 0 | 0 0 0 0 22:24:55 0 0 0 0 | 0 0 0 0 | 0 20 32 20 NB There’s a bug with colmux 4.8.2 that prevents you accessing the first metric with -cols when you also enable timestamp -oT – details here. Collectl (which is what colmux calls to get the data) can fetch metrics from multiple subsystems on a node. You can access all of these through colmux too. By default when you run colmux you get cpu, disk and network but you can specify others using the -s argument followed by the subsystem identifier. -s To examine the available subsystems run collectl on one of the target nodes: [root@rnmcluster02-node01 ~]# collectl --showsubsys The following subsystems can be specified in any combinations with -s or --subsys in both record and playbackmode. [default=bcdfijmnstx] These generate summary, which is the total of ALL data for a particular type b - buddy info (memory fragmentation) c - cpu d - disk f - nfs i - inodes j - interrupts by CPU l - lustre m - memory n - network s - sockets t - tcp x - interconnect (currently supported: OFED/Infiniband) y - slabs From the above list we can see that if we want to also show memory detail alongside CPU we need to include m and c in the subsystem list: colmux -addr 'rnmcluster02-node0[1-4]' -user root -command '-scm' # Tue Dec 2 08:02:38 2014 Connected: 4 of 4 # <--------CPU--------><-----------Memory-----------> #Host cpu sys inter ctxsw Free Buff Cach Inac Slab Map rnmcluster02-node02 1 0 19 18 33M 15M 345M 167M 30M 56M rnmcluster02-node04 0 0 30 24 32M 15M 345M 167M 30M 56M rnmcluster02-node03 0 0 30 36 32M 15M 345M 165M 30M 56M rnmcluster02-node01 0 0 16 16 29M 15M 326M 167M 27M 81M To change the sample frequency use the -i syntax in -command: -i colmux -addr 'rnmcluster02-node0[1-4]' -user root -command '-scm -i10 -oT' -cols 2,4 Samples every 10 seconds: sys ctxsw #Time node01 node02 node03 node04 | node01 node02 node03 node04 08:06:29 -1 -1 -1 -1 | -1 -1 -1 -1 08:06:39 -1 -1 -1 -1 | -1 -1 -1 -1 08:06:49 0 0 0 0 | 14 13 15 19 08:06:59 0 0 0 0 | 13 13 17 21 08:07:09 0 0 0 0 | 19 18 15 24 08:07:19 0 0 0 0 | 13 13 15 19 08:07:29 0 0 0 0 | 13 13 14 19 08:07:39 0 0 0 0 | 12 13 13 19 Add the -colwidth argument -colwidth colmux -addr 'rnmcluster02-node0[1-4]' -user root -command '-scm' -cols 1 -colwidth 20 cpu rnmcluster02-node01 rnmcluster02-node02 rnmcluster02-node03 rnmcluster02-node04 -1 -1 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 0 As well as running interactively, collectl can run as a service and record metric samples to disk. Using colmux you can replay these from across the cluster. Within the -command, include -p and the path to the collectl log files (assumes that it is the same on each host). As with real-time mode, for different subsystems change the flags after -s -p colmux -addr 'rnmcluster02-node0[1-4]' -user root -command '-p /var/log/collectl/*20141201* -scmd -oD' [...] # 21:48:50 Reporting: 4 of 4 # <--------CPU--------><-----------Memory-----------><----------Disks-----------> #Host Date Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes rnmcluster02-node04 20141201 21:48:50 0 0 17 15 58M 10M 340M 162M 30M 39M 0 0 1 0 rnmcluster02-node03 20141201 21:48:50 0 0 11 13 58M 10M 340M 160M 30M 39M 0 0 0 0 rnmcluster02-node02 20141201 21:48:50 0 0 11 15 58M 10M 340M 163M 29M 39M 0 0 1 0 rnmcluster02-node01 20141201 21:48:50 0 0 12 14 33M 12M 342M 157M 27M 63M 0 0 1 0 # 21:49:00 Reporting: 4 of 4 # <--------CPU--------><-----------Memory-----------><----------Disks-----------> #Host Date Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes rnmcluster02-node04 20141201 21:49:00 0 0 17 15 58M 10M 340M 162M 30M 39M 0 0 4 0 rnmcluster02-node03 20141201 21:49:00 0 0 13 14 58M 10M 340M 160M 30M 39M 0 0 5 0 rnmcluster02-node02 20141201 21:49:00 0 0 12 14 58M 10M 340M 163M 29M 39M 0 0 1 0 rnmcluster02-node01 20141201 21:49:00 0 0 12 15 33M 12M 342M 157M 27M 63M 0 0 6 0 # 21:49:10 Reporting: 4 of 4 # <--------CPU--------><-----------Memory-----------><----------Disks-----------> #Host Date Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes rnmcluster02-node04 20141201 21:49:10 0 0 23 23 58M 10M 340M 162M 30M 39M 0 0 1 0 rnmcluster02-node03 20141201 21:49:10 0 0 19 24 58M 10M 340M 160M 30M 39M 0 0 2 0 rnmcluster02-node02 20141201 21:49:10 0 0 18 23 58M 10M 340M 163M 29M 39M 0 0 2 1 rnmcluster02-node01 20141201 21:49:10 0 0 18 24 33M 12M 342M 157M 27M 63M 0 0 1 0 [...] Restrict the time frame by adding to -command the arguments -from and/or -thru -from -thru [oracle@rnm-ol6-2 ~]$ colmux -addr 'rnmcluster02-node0[1-4]' -user root -command '-p /var/log/collectl/*20141201* -scmd -oD --from 21:40:00 --thru 21:40:10' # 21:40:00 Reporting: 4 of 4 # <--------CPU--------><-----------Memory-----------><----------Disks-----------> #Host Date Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes rnmcluster02-node04 20141201 21:40:00 0 0 16 14 59M 10M 340M 162M 30M 39M 0 0 0 0 rnmcluster02-node03 20141201 21:40:00 0 0 12 14 58M 10M 340M 160M 30M 39M 0 0 8 1 rnmcluster02-node02 20141201 21:40:00 0 0 12 15 59M 10M 340M 162M 30M 39M 0 0 6 1 rnmcluster02-node01 20141201 21:40:00 0 0 13 16 56M 11M 341M 156M 27M 42M 0 0 7 1 # 21:40:10 Reporting: 4 of 4 # <--------CPU--------><-----------Memory-----------><----------Disks-----------> #Host Date Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes rnmcluster02-node04 20141201 21:40:10 0 0 26 33 59M 10M 340M 162M 30M 39M 1 0 10 2 rnmcluster02-node03 20141201 21:40:10 0 0 20 31 58M 10M 340M 160M 30M 39M 0 0 4 1 rnmcluster02-node02 20141201 21:40:10 0 0 23 35 59M 10M 340M 162M 30M 39M 3 0 9 2 rnmcluster02-node01 20141201 21:40:10 0 0 23 37 56M 11M 341M 156M 27M 42M 4 1 4 1 [oracle@rnm-ol6-2 ~]$ You can find more about colmux from the website: as well as the built in man page man colmux man colmux As a little bonus to the above, colmux is part of the collectl-utils package, which also includes colplot, a gnuplot-based web tool that renders collectl data into graphs. It’s pretty easy to set up, running under Apache just fine and just needing gnuplot installed if you haven’t already. It can report metrics across a cluster if you make sure that you first make each node’s collectl data available locally to colplot. Navigating to the web page shows the interface from which you can trigger graph plots based on the collectl data available: colplot’s utilitarian graphs are a refreshing contrast to every webapp that is built nowadays promising “beautiful” visualisations (which no doubt the authors are “passionate” about making “awesome”): The graphs are functional and can be scaled as needed, but each change is a trip back to the front page to tweak options and re-render: For me, colplot is an excellent tool for point-in-time analysis and diagnostics, but for more generalised monitoring with drilldown into detail, it is too manual to be viable and I’ll be sticking with collectl -> graphite -> grafana with its interactive and flexible graph rendering: Do note however that colplot specifically does not drop data points, so if there is a spike in your data you will see it. Other tools (possibly including graphite but I’ve not validated this) will, for larger timespans average out data series so as to provide a smoother picture of a metric (eg instead of a point every second, maybe every ten seconds). If you are doing close analysis of a system’s behaviour in a particular situation this may be a problem. If you are wanting more generalised overview of a system’s health, with the option to drill into data historical as needed, it will be less of an issue.. To monitor a cluster I would always recommend collectl as the base metric collector. colmux works excellently for viewing these metrics from across the cluster in a single place from the commandline. For viewing the metrics over the longer term you can either store them in (or replay them into) Graphite/Carbon, and render them in Grafana. You have the option of colplot too since this is installed as part of colmux. So now your turn – what particular tools or tips do you have for working with a cluster of Linux machines? Leave your answers in the comments below, or tweet them to me at @rmoff. In this series of blog posts I’m taking. [1-4] -l: shutdown -h now. -f: -q -o StrictHostKeyChecking UserKnownHostsFile /dev/null @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @. You can find out more about PDSH at In the next article of this series we’ll see how the tool colmux is a powerful way to monitor OS metrics across a cluster. In this short series of blog posts I’m going to take. To start with, we’re going to use the ever-awesome ssh keys to manage security on the cluster. After that we’ll look at executing the same command across multiple machines at the same time using PDSH, and then monitoring OS metrics across a cluster with colmux. In a nutshell, ssh keys enable us to do password-less authentication in a secure way. You can find a detailed explanation of them in a previous post that I wrote, tips and tricks for OBIEE Linux sysadmin. Beyond the obvious time-saving function of not having to enter a password each time we connect to a machine, having SSH keys in place enable the use of the tools we discuss later, pdsh and colmux.). In this example I’m going to use my own client machine to connect to the cluster. You could easily use any of the cluster nodes too if a local machine would not be appropriate. As a side-note, this is another reason why I love the fact that Rittman Mead standard-issue laptop is a MacBook, and just under the covers of Mac OS is a *nix-based command-line meaning that a lot of sysadmin work can be done natively without needing additional tools that you would on Windows (e.g. PuTTY, WinSCP, Pageant, etc etc). We’ve several ways we could implement the SSH keys. Because it’s a purely sandbox cluster, I could use the same SSH key pair that I generate for the cluster on my machine too, so the same public/private key pair is distributed thus: If we wanted a bit more security, a better approach might be to distribute my personal SSH key’s public key across the cluster too, and leave the cluster’s private key to truly identify cluster nodes alone. An additional benefit of this approach is that is the client does not need to hold a copy of the cluster’s SSH private key, instead just continuing to use their own. For completeness, the extreme version of the key strategy would be for each machine to have its own ssh key pair (i.e. its own security identity), with the corresponding public keys distributed to the other nodes in the cluster: But anyway, here we’re using the second option – a unique keypair used across the cluster and the client’s public ssh key distributed across the cluster too. First, we need to generate the key. I’m going to create a folder to hold it first, because in a moment we’re going to push it and a couple of other files out to all the servers in the cluster and it’s easiest to do this from a single folder. mkdir /tmp/rnmcluster02-ssh-keys Note that in the ssh-keygen command below I’m specifying the target path for the key with the -f argument; if you don’t then watch out that you don’t accidentally overwrite your own key pair in the default path of ~/.ssh. ssh-keygen ~/.ssh The -q -N "" flags instruct the key generation to use no passphrase for the key and to not prompt for it either. This is the lowest friction approach (you don’t need to unlock the ssh key with a passphrase before use) but also the least secure. If you’re setting up access to a machine where security matters then bear in mind that without a passphrase on an ssh key anyone who obtains it can therefore access any machine to which the key has been granted access (i.e. on which its public key has been deployed). -q -N "" ssh-keygen -f /tmp/rnmcluster02-ssh-keys/id_rsa -q -N "" This generates in the tmp folder two files – the private and public (.pub) keys of the pair: tmp .pub robin@RNMMBP ~ $ ls -l /tmp/rnmcluster02-ssh-keys total 16 -rw------- 1 robin wheel 1675 30 Nov 17:28 id_rsa -rw-r--r-- 1 robin wheel 400 30 Nov 17:28 id_rsa.pub. authorized_keys ~/.ssh/ /root/.ssh/authorized_keys So we’re going to copy the public key of the unique pair that we just created for the cluster into the authorized_keys file. In addition we will copy in our own personal ssh key (and any other public key that we want to give access to all the nodes in the cluster): cp /tmp/rnmcluster02-ssh-keys/id_rsa.pub /tmp/rnmcluster02-ssh-keys/authorized_keys # [optional] Now add any other keys (such as your own) into the authorized_keys file just created cat ~/.ssh/id_rsa.pub >> /tmp/rnmcluster02-ssh-keys/authorized_keys # NB make sure the previous step is a double >> not > since the double appends to the file, a single overwrites.: .ssh id_rsa id_rsa.pub To copy the files we’ll use scp, but how you get them in place doesn’t really matter so much, so long as they get to the right place: scp -r /tmp/rnmcluster02-ssh-keys root@rnmcluster02-node01:~/.ssh At this point you’ll need to enter the password for the target user, but rejoice! This is the last time you’ll need to enter it as subsequent logins will be authenticated using the ssh keys that you’re now configuring. Run the scp for all nodes in the cluster. If you’ve four nodes in the cluster your output should look something like this: $ scp -r /tmp/rnmcluster02-ssh-keys/ root@rnmcluster02-node01:~/.ssh root@rnmcluster02-node0102:~/.ssh Warning: Permanently added the RSA host key for IP address '172.28.128.7' to the list of known hosts. root@rnmcluster02-node03:~/.ssh root@rnmcluster02-node04:~/.ssh root@rnmcluster02-node04's password: authorized_keys 100% 781 0.8KB/s 00:00 id_rsa 100% 1675 1.6KB/s 00:00 id_rsa.pub 100% 400 0.4KB/s 00:00 The moment of truth. From your client machine, try to ssh to each of the cluster nodes. If you are prompted for a password, then something is not right – see the troubleshooting section below. If you put your own public key in authorized_keys when you created it then you don’t need to specify which key to use when connecting because it’ll use your own private key by default: robin@RNMMBP ~ $ ssh root@rnmcluster02-node01 Last login: Fri Nov 28 17:13:23 2014 from 172.28.128.1 [root@localhost ~]# There we go – logged in automagically with no password prompt. If we’re using the cluster’s private key (rather than our own) you need to specify it with -i when you connect. robin@RNMMBP ~ $ ssh -i /tmp/rnmcluster02-ssh-keys/id_rsa root@rnmcluster02-node01 Last login: Fri Nov 28 17:13:23 2014 from 172.28.128.1 [root@localhost ~]# SSH keys are one of the best things in a sysadmin’s toolkit, but when they don’t work can be a bit tricky to sort out. The first thing to check is that on the target machine the authorized_keys file that does all the magic (by listing the ssh keys that are permitted to connect inbound on a host to the given user) is in place: [root@localhost .ssh]# ls -l ~/.ssh/authorized_keys -rw-r--r-- 1 root root 775 Nov 30 18:55 /root/.ssh/authorized_keys If you get this: [root@localhost .ssh]# ls -l ~/.ssh/authorized_keys ls: cannot access /root/.ssh/authorized_keys: No such file or directory then you have a problem. One possible issue in this specific instance could be that the above pre-canned scp assumes that the user’s .ssh folder doesn’t already exist (since it doesn’t, on brand new servers) and so specifies it as the target name for the whole rnmcluster02-ssh-keys folder. However if it does already exist then it ends up copying the rnmcluster02-ssh-keys folder into the .ssh folder: scp rnmcluster02-ssh-keys [root@localhost .ssh]# ls -lR .: total 12 -rw------- 1 root root 1675 Nov 22 2013 id_rsa -rw-r--r-- 1 root root 394 Nov 22 2013 id_rsa.pub drwxr-xr-x 2 root root 4096 Nov 30 18:49 rnmcluster02-ssh-keys ./rnmcluster02-ssh-keys: total 12 -rw-r--r-- 1 root root 775 Nov 30 18:49 authorized_keys -rw------- 1 root root 1675 Nov 30 18:49 id_rsa -rw-r--r-- 1 root root 394 Nov 30 18:49 id_rsa.pub [root@localhost .ssh]# To fix this simply move the authorized_keys from rnmcluster02-ssh-keys back into .ssh: [root@localhost .ssh]# mv ~/.ssh/rnmcluster02-ssh-keys/authorized_keys ~/.ssh/ Other frequent causes of problems are file/folder permissions that are too lax on the target user’s .ssh folder (which can be fixed with chmod -R 700 ~/.ssh) or the connecting user’s ssh private key (fix: chmod 600 id_rsa). The latter will show on connection attempts very clearly: chmod -R 700 ~/.ssh chmod 600 id_rsa robin@RNMMBP ~ $ ssh -i /tmp/rnmcluster02-ssh-keys/id_rsa root@rnmcluster02-node01 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0777 for '/tmp/rnmcluster02-ssh-keys/id_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /tmp/rnmcluster02-ssh-keys/id_rsa Another one that has bitten me twice over time – and that eludes the troubleshooting I’ll demonstrate in a moment – is that SELinux gets stroppy about root access using ssh keys. I always just take this as a handy reminder to disable selinux (in /etc/selinux/config, set SELINUX=disabled), having never had cause to leave it enabled. But, if you do need it enabled you’ll need to hit the interwebs to check the exact cause/solution for this problem. /etc/selinux/config SELINUX=disabled So to troubleshoot ssh key problems in general do two things. Firstly from the client side, specify verbosity (-v for a bit of verbosity, -vvv for most) -v -vvv ssh -v -i /tmp/rnmcluster02-ssh-keys/id_rsa root@rnmcluster02-node01 You should observe ssh trying to use the private key, and if the server rejects it it’ll fall back to any other ssh private keys it can find, and then password authentication: [...] debug1: Offering RSA public key: /tmp/rnmcluster02-ssh-keys/id_rsa debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: password Quite often the problem will be on the server side, so assuming that you can still connect to the server (eg through the physical console, or using password authentication) then go and check /var/log/secure where you’ll see all logs relating to attempted connections. Here’s the log file corresponding to the above client log, where ssh key authentication is attempted but fails, and then password authentication is used to successfully connect: /var/log/secure Nov 30 18:15:05 localhost sshd[13156]: Authentication refused: bad ownership or modes for file /root/.ssh/authorized_keys Nov 30 18:15:15 localhost sshd[13156]: Accepted password for root from 172.28.128.1 port 59305 ssh2 Nov 30 18:15:15 localhost sshd[13156]: pam_unix(sshd:session): session opened for user root by (uid=0) Now we can see clearly what the problem is – “bad ownership or modes for file /root/.ssh/authorized_keys”. The last roll of the troubleshooting dice is to get sshd (the ssh daemon that runs on the host we’re trying to connect to) to issue more verbose logs. You can either set LogLevel DEBUG1 (or DEBUG2, or DEBUG3) in /etc/ssh/sshd_config and restart the ssh daemon (service sshd restart), or you can actually run a (second) ssh daemon from the host with specific logging. This would be appropriate on a multi-user server where you can’t just go changing sshd configuration. To run a second instance of sshd you’d use: LogLevel DEBUG1 /etc/ssh/sshd_config service sshd restart /usr/sbin/sshd -D -d -p 2222 You have to run sshd from an absolute path (you’ll get told this if you try not to). The -D flag stops it running as a daemon and instead runs interactively, so we can see easily all the output from it. -d specifies the debug logging (-dd or -ddd for greater levels of verbosity), and -p 2222 tells sshd to listen on port 2222. Since we’re doing this on top of the existing sshd, we obviously can’t use the default ssh port (22) so pick another port that is available (and not blocked by a firewall). sshd -D -d -dd -ddd -p 2222 Now on the client retry the connection, but pointing to the port of the interactive sshd instance: ssh -v -p 2222 -i /tmp/rnmcluster02-ssh-keys/id_rsa root@rnmcluster02-node01 When you run the command on the client you should get both the client and host machine debug output go crackers for a second, giving you plenty of diagnostics to pore through and analyse the ssh handshake etc to get to the root of the issue. Hopefully you’ve now sorted your SSH keys, because in the next article we’re going to see how we can use them to run commands against multiple servers at once using pdsh. We’ll see in the next couple of articles some other tools that are useful when working on a cluster: I’m interested in what you think – what particular tools or tips do you have for working with a cluster of Linux machines? Leave your answers in the comments below, or tweet them to me at @rmoff.: package com.cloudera.analyzeblog import org.apache.spark.SparkConf import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark.sql.SQLContext case class accessLogRow(host: String, identity: String, user: String, time: String, request: String, status: String, size: String, referer: String, agent: String) case class pageRow(host: String, request_page: String, status: String, agent: String) case class postRow(post_id: String, title: String, post_date: String, post_type: String, author: String, url: String, generated_url: String) object analyzeBlog { def getRequestUrl(s: String): String = { try { s.split(' ')(1) } catch { case e: ArrayIndexOutOfBoundsException => { "N/A" } } } def main(args: Array[String]) { val sc = new SparkContext(new SparkConf().setAppName("analyzeBlog")) val sqlContext = new SQLContext(sc) import sqlContext._ val raw_logs = "/user/mrittman/rm_logs" //val rowRegex = """^([0-9.]+)\s([\w.-]+)\s([\w.-]+)\s(\[[^\[\]]+\])\s"((?:[^"]|\")+)"\s(\d{3})\s(\d+|-)\s"((?:[^"]|\")+)"\s"((?:[^"]|\")+)"$""".r val rowRegex = """^([\d.]+) (\S+) (\S+) \[([\w\d:/]+\s[+\-]\d{4})\] "(.+?)" (\d{3}) ([\d\-]+) "([^"]+)" "([^"]+)".*""".r val logs_base = sc.textFile(raw_logs) flatMap { case rowRegex(host, identity, user, time, request, status, size, referer, agent) => Seq(accessLogRow(host, identity, user, time, request, status, size, referer, agent)) case _ => Nil } val logs_base_nobots = logs_base.filter( r => ! r.request.matches(".*(spider|robot|bot|slurp|bot|monitis|Baiduspider|AhrefsBot|EasouSpider|HTTrack|Uptime|FeedFetcher|dummy).*")) val logs_base_page = logs_base_nobots.map { r => val request = getRequestUrl(r.request) val request_formatted = if (request.charAt(request.length-1).toString == "/") request else request.concat("/") (r.host, request_formatted, r.status, r.agent) } val logs_base_page_schemaRDD = logs_base_page.map(p => pageRow(p._1, p._2, p._3, p._4)) logs_base_page_schemaRDD.registerAsTable("logs_base_page") val page_count = sql("SELECT request_page, count(*) as hits FROM logs_base_page GROUP BY request_page").registerAsTable("page_count") val postsLocation = "/user/mrittman/posts.psv" val posts = sc.textFile(postsLocation).map{ line => val cols=line.split('|') postRow(cols(0),cols(1),cols(2),cols(3),cols(4),cols(5),cols(6).concat("/")) } posts.registerAsTable("posts") val pages_and_posts_details = sql("SELECT p.request_page, p.hits, ps.title, ps.author FROM page_count p JOIN posts ps ON p.request_page = ps.generated_url ORDER BY hits DESC LIMIT 10") pages_and_posts_details.saveAsTextFile("/user/mrittman/top_10_pages_and_author4") } }: [mrittman@bdanode1 analyzeBlog]$ spark-submit --class com.cloudera.analyzeblog.analyzeBlog --master yarn target/analyzeblog-0.0.1-SNAPSHOT.jar SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.2.0-1.cdh5.2.0.p0.36/jars/spark-assembly-1.1.0-cdh5.2.0-hadoop2.5.0-cdh5.2.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.2.0-1.cdh5.2.0.p0.36/jars] 14/12/06 19:18:25 INFO SecurityManager: Changing view acls to: mrittman 14/12/06 19:18:25 INFO SecurityManager: Changing modify acls to: mrittman ... 14/12/06 19:19:41 INFO DAGScheduler: Stage 0 (takeOrdered at basicOperators.scala:171) finished in 3.585 s 14/12/06 19:19:41 INFO SparkContext: Job finished: takeOrdered at basicOperators.scala:171, took 53.591560036 s 14/12/06 19:19:41 INFO SparkContext: Starting job: saveAsTextFile at analyzeBlog.scala:56 14/12/06 19:19:41 INFO DAGScheduler: Got job 1 (saveAsTextFile at analyzeBlog.scala:56) with 1 output partitions (allowLocal=false) 14/12/06 19:19:41 INFO DAGScheduler: Final stage: Stage 3(saveAsTextFile at analyzeBlog.scala:56) 14/12/06 19:19:41 INFO DAGScheduler: Parents of final stage: List() 14/12/06 19:19:41 INFO DAGScheduler: Missing parents: List() 14/12/06 19:19:41 INFO DAGScheduler: Submitting Stage 3 (MappedRDD[15] at saveAsTextFile at analyzeBlog.scala:56), which has no missing parents 14/12/06 19:19:42 INFO MemoryStore: ensureFreeSpace(64080) called with curMem=407084, maxMem=278302556 14/12/06 19:19:42 INFO MemoryStore: Block broadcast_5 stored as values in memory (estimated size 62.6 KB, free 265.0 MB) 14/12/06 19:19:42 INFO MemoryStore: ensureFreeSpace(22386) called with curMem=471164, maxMem=278302556 14/12/06 19:19:42 INFO MemoryStore: Block broadcast_5_piece0 stored as bytes in memory (estimated size 21.9 KB, free 264.9 MB) 14/12/06 19:19:42 INFO BlockManagerInfo: Added broadcast_5_piece0 in memory on bdanode1.rittmandev.com:44486 (size: 21.9 KB, free: 265.3 MB) 14/12/06 19:19:42 INFO BlockManagerMaster: Updated info of block broadcast_5_piece0 14/12/06 19:19:42 INFO DAGScheduler: Submitting 1 missing tasks from Stage 3 (MappedRDD[15] at saveAsTextFile at analyzeBlog.scala:56) 14/12/06 19:19:42 INFO YarnClientClusterScheduler: Adding task set 3.0 with 1 tasks 14/12/06 19:19:42 INFO TaskSetManager: Starting task 0.0 in stage 3.0 (TID 215, bdanode5.rittmandev.com, PROCESS_LOCAL, 3331 bytes) 14/12/06 19:19:42 INFO BlockManagerInfo: Added broadcast_5_piece0 in memory on bdanode5.rittmandev.com:13962 (size: 21.9 KB, free: 530.2 MB) 14/12/06 19:19:42 INFO TaskSetManager: Finished task 0.0 in stage 3.0 (TID 215) in 311 ms on bdanode5.rittmandev.com (1/1) 14/12/06 19:19:42 INFO YarnClientClusterScheduler: Removed TaskSet 3.0, whose tasks have all completed, from pool 14/12/06 19:19:42 INFO DAGScheduler: Stage 3 (saveAsTextFile at analyzeBlog.scala:56) finished in 0.312 s 14/12/06 19:19:42 INFO SparkContext: Job finished: saveAsTextFile at analyzeBlog.scala:56, took 0.373096676 s.
http://www.orafaq.com/aggregator/sources/14?page=1
CC-MAIN-2015-14
refinedweb
16,402
57.1
C Programming Odd and even program in C We will discuss about C programming to check odd and even numbers in this article. We know that even numbers are divisible by two and odd number is not divisible by two. We can implement this idea to determine that a number is odd or even. Modulus operator (%) is used to determine the reminder. So we can tell that if we get zero as reminder when we divide a number by 2 then the number will be even. Otherwise it will be odd. So, lets implement this idea to make an odd and even C program. Program to determine odd and even // c program for odd and even #include <stdio.h> int main(){ int num; printf("Enter an integer to check : "); scanf("%d", &num); if (num % 2 == 0){ printf("%d is even.\n", num); }else{ printf("%d is odd.\n", num); } return 0; } Output of this odd even program Odd and even program using conditional operator Conditional operator is a special type of operator and if you don’t know about various operators then it is time to see our another article about operators in C which will let you know all about operators. // odd and even using condition #include <stdio.h> int main(){ int number; printf("Input an integer here : "); scanf("%d", &number); number % 2 == 0? printf("Even\n"):printf("Odd\n"); // conditional operator return 0; } Output: Finding odd or even using bitwise operator If you don’t know about bitwise operator then we will highly recommended you to visit our bitwise operator article in C then try to understand the code bellow. // odd and even by bitwise operators #include <stdio.h> int main(){ int num; printf("Input an integer to check : "); scanf("%d", &num); if (num & 1 == 1){ printf("The number is odd.\n"); }else{ printf("The number is even.\n"); } return 0; } See the output Odd or even program in other way in C If we divide an even number by 2 and again multiply the result by 2 then we will get the original number. Suppose, 8 / 2 = 4 and 4 * 2 = 8 Now, 8 ==8 But in case of odd number, when we divide it by 2 will get a fraction number and as we have taken the integer data type, the fraction part will be ignored. Then we will multiply the result by 2 which will give the result not equal to original number. Suppose, 7 / 2 = 3 and 3 * 2 = 6 Now 7 != 6 #include <stdio.h> int main(){ int num; printf("Enter an integer to check : "); scanf("%d", &num); if ((num / 2) * 2 == num){ printf("Even\n"); }else{ printf("Odd\n"); } return 0; } See the output of this odd even program Enter an integer to check : 15 Odd Process returned 0 (0x0) execution time : 5.706 s Press any key to continue.
https://worldtechjournal.com/c-programming/odd-and-even-program-in-c/
CC-MAIN-2022-40
refinedweb
478
69.52
In order for customers to successfully distribute forms, they require predictability. Predictability is more important than bug-free software (if there were such a thing). Predictability means the form you originally developed continues to work the same when opened in a new version of Adobe Reader. "the same" means it has the same set of features and the same set of bugs as in the previous version. Same features, same bugs. If you want the new features and bug fixes you need to bring your form into Designer and target it for a newer release of Reader. But even so, for complex forms you probably prefer to get the new features without necessarily getting the new bug fixes. Bug fixes can change form appearance and/or script behaviour. What users most often want is to use that cool new feature, but not to tweak their layout due to the fixes in form rendering. To accommodate these needs, there are two dials that control the form: the target version and the original version. Target version field.setItems() was an enhancement to the XFA object model for Reader 9. Suppose Adobe Reader 9 opens a form Designed for Reader 8. What should it do if this Reader 8 form happens to have a script calling field.setItems() ? It should do the same thing that Reader 8 does: throw an error. Each form is stamped with a target version. The stamp is expressed as the XFA version. Reader 8 uses XFA version 2.6. Reader 9 uses XFA version 2.8. Whenever Reader is asked to execute a script function, it first checks whether that script function is valid for that version of XFA. This applies to more than just script functions. It applies to XFA markup as well. e.g. Hyphenation was added in XFA 2.8. If Reader encounters a 2.6 form that has the markup commands to turn on hyphenation, the hyphenation will not be enabled. The XFA version is defined by the XML namespace of the template: e.g. <template xmlns=""> The target version is controlled in the Designer UI under form properties/defaults. Note that by default, Designer will set the target version one version back from the current shipping version of Adobe Reader. Original Version Form behaviour is determined by more than just new features, it is also determined by bug fixes. In some cases fixing a bug in Reader can actually break existing forms that inadvertently relied on the buggy behaviour. Therefore by default we preserve old behaviours when migrating a form forward. We preserve the old behaviour by storing the original version of the form in a processing instruction in the template. When you modify your form in Designer to take it from Reader 8.1 to Reader 9.0, we embed the original version inside the form so that you end up with the version 9 features, but the version 8.1 behaviours. The processing instruction looks like this: <?originalXFAVersion?> When Reader 9 opens a form with an original version of 2.6, it makes sure that the behaviours are consistent with Reader 8.1. This is all well and good, but there are times where you really, really need the latest bug fixes. Unfortunately there’s no UI to move the original version forward. If you need the latest and greatest bug fixes, the go into the XML source tab, find the originalXFAVersion processing instruction and delete it. Now your form will get all the behaviours and features of XFA 2.8 and Reader 9. Sample I have attached a sample form that demonstrates changing the target and original versions. There are three interesting part to the form. 1. The form has both target version and original version set to 2.6 (Reader 8.1). There is a button on the form that extracts these values from the template and populates a couple of fields with the result. 2. When you open the form in Designer, you will see a field displaying current date and time in ISO8601 format. This field has a calculation that looks like this: this.rawValue = "20090205T163000"; xfa.host.currentDateTime(); When you preview this form, the first line executes fine, but the second line encounters the currentDateTime() function that was added to XFA version 2.8. As a result, the script fails on the second line, and the value of the field remains "20090205T163000". If you open the script console in Acrobat (control+J) you’ll see the error. 3. The bottom part of the form illustrates a bug fix that was made in Reader 9. Hidden fields are not supposed to affect layout. The hidden property has always behaved properly in flowed subforms, but we discovered a bug in positioned containers. Prior to Reader 9 a hidden field would expand the extent of a growable, positioned subform. In this form, the subform is taller than it should be. Update The Target Version Change the target version (in the form properties/defaults tab) from "Acrobat and Adobe Reader 8.1 or later" to "Acrobat and Adobe Reader 9.0 and later". Now when you preview the form you will see: 1. The target version is now 2.8, but the original version remains 2.6. 2. The calculation now works without error. The field displays the current date and time. 3. The growable subform renders at the same height as it did in Reader 8.1 Update the Original Version Go into XML source mode and remove the originalXFAVersion processing instruction. Now when you preview the form you will see: 1. Both target and original versions are 2.8 2. The calculation continues to work 3. The growable subform has collapsed to an extent that does not include the hidden field The Deep End Discovering Processing Instructions at Runtime I was able to get at the processing instructions by loading an E4X XML object with the results of xfa.template.saveXML(). I don’t recommend doing this in a production form, since the result of calling saveXML() on the template can be a very, very large string — especially if there are images embedded in the template. If you wanted just the target version (the xml namespace), there is an easy way to get it with the ns property: xfa.template.ns. FormTargetVersion I simplified a couple of details in order to make this easier to explain. The full story is a little more complicated. When Designer opens a form that has markup that is newer than the target version, it will automatically update the namespace of the XFA template. So for example: Designer opens a 2.6 template with a target version of Reader 8.1. It discovers syntax for turning on letter spacing, so it will automatically update the template to 2.8. But the target version remains Reader 8.1. This is because the UI for target version is actually driven by another processing instruction: <?templateDesigner FormTargetVersion 26?> Under most circumstances, Designer will keep the FormTargetVersion and the XFA template version synchronized. If the template version is newer, then you will undoubtedly find a bunch of messages in your warnings tab. This is Designer’s way of telling you that you’re using features that do not work in your target version. Until you clean those up, your form will not work correctly in your target version. Choosing Selected Changes Changing the original version is pretty high level switch. You either get all the bug fixes for a new release, or you get none. In reality, there are qualifiers that allow you to preserve selected behaviours. Suppose that in my sample form I wanted the bug fixes that came with Reader 9/XFA 2.8 except for the fix for hidden fields in positioned subforms. In that case I can specify the processing instruction as: <?originalXFAVersion v2.6-hiddenPositioned:1?> The qualifier: v2.6-hiddenPositioned:1 tells Reader 9 to preserve the XFA 2.6 behaviour for hidden fields in positioned subforms. Scripting bug fixes Most of the time, I am happy with the default behaviour where original version behaviour is enforced by default. However there is one exception. My previous post described how the behaviour of strict scoping changed from 8.1 to 9.0. The difference is that with strict scoping on in 8.1 we release JavaScript variables declared in script objects. In 9.0 we preserve these variables. If you are targeting 9.0 and make extensive use of script objects, make sure that you set your original version to 9.0 as well. Changing Default Behaviours There have been a couple of times where we have changed behaviour and made the new behaviour the default without protecting it with the original version mechanism. The most infamous was when we added "direct rendering" for dynamic forms. In this case we had developed a way to dramatically improve the performance of dynamic forms. We had to choose between turning the new behaviour (and the performance boost) on for all forms or just for those forms designed for 8.1 and later. We chose to make the new behaviour the default. If this caused problems, the form author could "opt out" by inserting an originalXFAVersion processing instruction. This is described in the knowledge base article:
http://blogs.adobe.com/formfeed/2009/02/form_compatibility.html
CC-MAIN-2014-41
refinedweb
1,551
66.74
Can There Be a Non-US Internet? 406. (Score:5, Funny) Re:Oblig. (Score:5, Insightful) Non-US Internet (Score. Re:Non-US Internet (Score. .... 6. Control the ideas/speech of all websites within Iran. Technically yes; practically unlikely (Score:5, Insightful) Re:Technically yes; practically unlikely (Score:5, Interesting) )). Amazon.*** namespaces (Score): (Score:2): (Score:2) Why ironic? Re: (Score:2, Interesting) Re: (Score:2) Re: (Score:3) WTF is the point? (Score:5, Insightful): ): (Score:2) Also, and not to sound like an apologist, pretty much every other country has just as crappy government reputations for things like privacy. Re: (Score:2) No. Re:Yes, but it won't make any difference. (Score:4, Insightful): ). (Score:5, Informative) Re: (Score:2) Re: (Score:3): (Score:2) They just follow the old doctrine of communism: There's no need to conquer by force. Nothing to do with communism. That's Sun Tzu [wikipedia.org] 25 centuries ago. Re: (Score) wi Re: (Score:2) politic Why do we keep discussing this... (Score:5, Insightful) ..: (Score:3) dea Re:Why do we keep discussing this... (Score:5, Insightful) ..: ) (Score:3) anoth (Score:2, Insightful) That is not what they declared (Score:5, Informative).) t Re:WWW (Score:5, Informative): (Score:2) By the way, the actual invention was done not by a programmer but by the an engineer who was doing the real work. Re: (Score:2) Re: (Score:3, Interesting)) Re: (Score:2) *word Re: (Score.
https://tech.slashdot.org/story/13/09/25/231220/can-there-be-a-non-us-internet?sdsrc=nextbtmnext
CC-MAIN-2017-43
refinedweb
246
69.58
I am new to this website, and coding as well, so please bear with me. I have a program that i'm trying to fortmat the output into a single line. The output should read : HHHHHTTTTT Number of Heads: 5 Number of Tails : 5 where the values change per the result of the coin flips. here is the code: #include <cstdlib> #include <ctime> #include <iostream> #include <iomanip> using namespace std; void flips(); // Function Prototype int count; //initializing the counters int countH=0; int countT=0; int flip; int main() { srand((unsigned)time(0)); for(count=0; count<10; count++) flips(); // Calling function flip() cout <<"\n\n\n\t\tNumber of Heads: "<<countH<<endl; cout <<"\t\tNumber of Tails: "<<countT<<endl<<endl<<endl; return 0; } void flips() // Defination of flip() funtion { flip = (rand()%2)+1; if (flip < 2) { cout <<"H"; countH++; } else { cout<<"T"; countT++; } } this is what i get for output: HHHHTHHHTH Number of Heads: 8 Number of Tails: 2 Press any key to continue . . . so my question is how do i center the first line ? thanks.
https://www.daniweb.com/programming/software-development/threads/233996/help-formatting-data
CC-MAIN-2018-43
refinedweb
177
56.73
Design is difficult as you have to come up with a set of rules to describe it – a system. You don't always have to devise one yourself, and Material Design by Google is one starting point. To understand the topic better, I'm interviewing Olivier Tassinari, one of the authors of Material UI. It's a collection of React components which implement the system.. Sometime later I worked at Doctolib, the leading booking platform, and management software provider for doctors in France. Besides coding I love sports, swimming, running and from time to time climbing. I'm training to beat my 10k record next year. Material-UI provides user interface components which can be reused in different contexts. That's our core mission - we are a UI library. The React, Angular, Vue, Ember and Polymer ecosystems all have the concept of components. We have chosen to implement the Material Design Specification in React components. Let's say you want to display a nice button, all you need to do is the following (example for Material-UI v1): import Button from 'material-ui/Button'; const MyApp = () => <Button>I Will Survive</Button>; export default MyApp; Editor's note: This would be a good chance to use babel-plugin-transform-imports as it can rewrite import { Button } from 'material-ui';to above while still pulling the same amount of code to the project. Most of the heavy lifting in Material-UI is done by React and JSS. While we bet on React early in 2014 and have stuck with it, we are already at our third iteration on our choice of a styling solution. We started with Less, tried inline styles, and now are switching to CSS in JS thanks to JSS. One of the first things people ask when they find out about the library is how to customize the style of it. In the past our answer to that question was not ideal, but it's improving now. Through the evolution of components in different contexts, we have identified and addressed four types of customization going (ordered from most specific to most generic): To learn more about JSS, see the interview of Oleg Slobodskoi, the author of the tool. It helps to understand the tradeoffs we have made. At some point when building a UI library or even a presentational component, one aspect will need to be prioritized over another. So let's see what we have prioritized and what we have not. I believe that most of the value of using a UI library comes from the API contract it provides. But at the same time, API design is one of the hardest things to do when building a UI library. However, sometimes we have to trade consistency and level of abstraction to have a good enough implementation. Finally, we would rather support fewer use-cases well and allow people to build on top of the library than supporting more use-cases poorly. You can read further in our vision for the project. The credit for creating Material-UI goes to Hai Nguyen. I have been contributing since six months after the first release. Ironically, my original motivation for choosing Material-UI for a fun-side project (to save time by using an existing React implementation of Material Design) is at odds with the effort I put in as a maintainer now. I have spent a lot of time improving the library. But I don't regret it as I have learned a lot in the process, ranging from how to conduct social interactions in a community to the ins and outs of the web stack, API design, visual testing and more. We are going to try to follow this plan: At that point, some features and components from v0.x will be missing in v1. So, what about them? All of the plans above are in our roadmap. Material-UI is popular in the React ecosystem, but Google recently changed their strategy with material-components-web. Depending on how well material-components-web solves the problem, Material-UI might use it internally. But at the same time, Material-UI's goal goes further than just providing an elegant implementation of the Material Design guidelines. The Material Design specification sets the bar quite high, and developers should be able to benefit from that while easily customizing it for their needs. This customization work is what I have been collaborating on lately at work. We have been taking advantage of Material-UI's customization power to implement a brand-specific UI far from the Material Design specification. You can think of it as a Bootstrap theme. I believe this can be a useful strategy for other developers too. Arunoda Susiripala for the awesome work he has been doing with the ZEIT team on Next.js. React was the last JavaScript project that I was as excited about as I am about Next.js. The user experience and developer experience is way beyond anything I have used before. Special thanks to the core Material-UI team: Thank you Oleg Slobodskoi for open sourcing JSS. And thanks for having me on the blog! Thanks for the interview Olivier! It's great to see solid UI libraries for React as that has been traditionally a little weak point but looks like the situation is improving. See Material UI site and Material UI GitHub to learn more about the project.
https://survivejs.com/blog/material-ui-interview/index.html
CC-MAIN-2018-34
refinedweb
906
62.78
How To Use Symfony2 To Perform CRUD Operations on a VPS (Part 1) About Symfony Symfony is an open source PHP web development framework - a set of tools and methodology to help you build great applications. Some of the traits of this framework are its speed, flexibility, scalability, and stability. You can use it for a full blown web application but also for smaller functionalities needed for your project. In the previous tutorial, we have seen how to install the Symfony2 Standard Distribution and configure it to work on your VPS. In this and the next tutorial, we will create a small Symfony application that performs some basic CRUD (create, read, update, delete) operations on our data model. This tutorial assumes you have followed the steps from the previous article and you are able to continue where it left off. The data we will work with are news pages. We will be creating an entity (servings as our data model for the news pages) and learn how to read and display it. In the next one, we will learn how to perform the other operations, namely to add, update and delete the news pages. But first, we’ll need to create a bundle. Bundles A bundle in Symfony is a directory where you keep all the files necessary for a specific functionality in your application. This includes PHP files, stylesheets, javascript files, etc. In our application we will create only one bundle that is responsible for everything that has to do with the news pages. If we wanted to also have a blog, we could create a specific bundle responsible for that. The cool thing about bundles is that they also act like plugins (even core Symfony functionality is arranged in bundles). This means you can create new bundles yourself that will hold all the code for a specific feature or you can register an external bundle created by someone else. So before starting to play with our data, let’s generate an empty bundle in the command line since the Symfony Standard Distribution provides this neat facility. This means you don’t need to create all the folders and manually register the bundle with Symfony - all this will be done automatically. So to generate automatically a bundle, navigate to the main folder of your application, in our case, Symfony: cd /var/www/Symfony Run the following command to generate a new bundle by the name, NewsBundle: php app/console generate:bundle --namespace=Foo/NewsBundle --format=yml Follow the instructions on the screen and accept the default options. This command will generate a bundle by the name NewsBundle that belongs to the vendor Foo. You can choose whatever vendor naming you want (this represents you basically) but you need to make sure the bundle name ends with the word Bundle. In addition, the command specifies the configuration format for the bundle to be in YAML files. In the background, the folder structure for your bundle is created (at src/Foo/NewsBundle) and the bundle is registered with the rest of the application. Entities If you followed all the steps in the previous tutorial, your database connection should already be configured. If not, you can edit the parameters.yml file: nano /var/www/Symfony/app/config/ parameters.yml And there, you can specify your database information. If you already have a database created, you can skip the next step. However, you can let Symfony automatically create the database that matches the information in this file with the following command: php app/console doctrine:database:create Now, in order to work with our data model (news page) we will need to create something called an Entity. This is basically a PHP class that defines all the information about our news pages. Symfony has a nifty command line tool for this that we will use and another nice one for creating the actual database tables that match this data model. So run the following command from the command line for generating the entity called News: php app/console doctrine:generate:entity Follow the instructions on the screen. The first thing you’ll need to specify is the name, albeit the shortcut name. For us it will be FooNewsBundle:News (the entity name is the one following the colon but you need to specify also the bundle it belongs to). Next, for the configuration management go ahead and select yml. Following this, you’ll add the class properties (that will match the table columns) for our data model. Let’s add a title (string, 255), body (text) and created_date (datetime). Next, there is no need for a repository so select no and then confirm the generation. The entity is now created. If you are curious to see how it looks, you can explore the newly created entity class file: nano /var/www/Symfony/src/Foo/ NewsBundle/Entity/News.php Next, let’s have Symfony generate the database table that will store our news pages based on this newly created entity. Run the following command: php app/console doctrine:schema:update --force This command will take the information from the entity and generate the table based on this. You should get a simple confirmation: "Database schema updated successfully! "1" queries were executed." Now if you look in the database, you should see a table called News with 4 columns (id, title, body and created_date) all of which matching a property in the News entity class. Reading Data Since our database is empty, let’s use phpmyadmin or the command line to insert 2 test rows that we can read using our new Symfony application. Later, we will see how to use the application to add new content but for now, you can run the following commands in the mysql terminal to add 2 rows: use symfony; INSERT INTO News (title,body,created_date) VALUES ('News title 1', 'Some body text', NOW()); INSERT INTO News (title,body,created_date) VALUES ('News title 2', 'Another body text', NOW()); Now that we have some dummy content, let’s create a route to map the user request for a particular news page to a Symfony Controller. The main route file in your application is found in the app/config folder but you can also define specific routing rules for your bundle in the routing.yml file located in the bundle folder structure: nano /var/www/Symfony/src/Foo/ NewsBundle/Resources/config/ routing.yml Let’s delete the rule that’s already there and add another one instead: foo_news_show: pattern: /news/{id} defaults: { _controller: FooNewsBundle:Default:show } The name of this rule is foo_news_show and it will be triggered when the browser requests We specified here the DefaultController because its file is already there, automatically generated by Symfony when we created the bundle. So we might as well use it. What we have to do now is create the method that will use the News entity class and the Doctrine database library to request the news page and then pass it in a variable to a Twig template file. So let's edit the DefaultController.php file: nano /var/www/Symfony/src/Foo/ NewsBundle/Controller/ DefaultController.php In this file, you’ll see already the indexAction() method defined. Below it, let’s declare the showAction() method: public function showAction($id) { $news = $this->getDoctrine() ->getRepository(' FooNewsBundle:News') ->find($id); if (!$news) { throw $this-> createNotFoundException('No news found by id ' . $id); } $build['news_item'] = $news; return $this->render('FooNewsBundle: Default:news_show.html.twig', $build); } This function uses Doctrine to retrieve the news entity with the ID passed (throws an exception if no news is found) and passes the news object along to the news_show.html.twig template file that we have to create next. The code is pretty straightforward. So let’s do just that. Views are found in the bundle under the Resources/views folder inside another folder named after the Controller that uses them - in our case Default. So create there a new file called news_show.html.twig: nano /var/www/Symfony/src/Foo/ NewsBundle/Resources/views/ Default/news_show.html.twig And paste in the following template code: {{ news_item.Title }} {{ news_item.Body }} <h1>{{ news_item.Title }}</h1> {{ news_item.Body }} This is an html file with Twig templating language. We will not go into detail here about Twig in Symfony so feel free to read more about it here. Now if you point your browser to Let’s now create a listing of all the news pages by creating another routing rule and Controller method. Open the same routing.yml file you edited earlier: nano /var/www/Symfony/src/Foo/ NewsBundle/Resources/config/ routing.yml And add the following: foo_news_home: pattern: /news/ defaults: { _controller: FooNewsBundle:Default:index } This route will trigger the indexAction() method of the DefaultController so let’s go edit it (if you remember it is already in the Controller file so we just need to modify it): nano /var/www/Symfony/src/Foo/ NewsBundle/Controller/ DefaultController.php Remove the argument specified there by default ($name) and the code inside the method itself. Instead, paste the following: $news = $this->getDoctrine() ->getRepository(' FooNewsBundle:News') ->findAll(); if (!$news) { throw $this-> createNotFoundException('No news found'); } $build['news'] = $news; return $this->render('FooNewsBundle: Default:news_show_all.html. twig', $build); Similar to the method we created before, this one will find all the news in the table and pass them to the news_show_all.html.twig template file. So let’s create this file in the same folder as the one we created earlier: nano /var/www/Symfony/src/Foo/ NewsBundle/Resources/views/ Default/news_show_all.html. twig And iterate through the $news object array to display all the news titles: {% for new in news %} <h3>{{ new.Title }}</h3> {% endfor %} Now if you go to <h3>{{ new.Title }}</h3> with this: <h3><a href="{{ path('foo_news_show', {'id': new.Id }) }}">{{ new.Title }}</a></h3> This is a handy way to generate links inside the Twig template. You basically specify which route to use and what should be the value of the wildcard the route is expecting - in this case the ID found in the news object. Now if you refresh the page, the titles turn into links to their respective pages. Conclusion In this tutorial, we’ve seen what Symfony bundles are and how to create them. We’ve also begun our small application that needs to interact with our news pages in the database. For this, we’ve defined an Entity class that matches the table structure and we've used Doctrine to access the information and populate the entity objects. In addition, we’ve also used the Symfony routing system to connect a browser request with PHP Controller methods that then request the data and present it back to the browser in a Twig template. In the next and last tutorial we will look at creating, updating and deleting news pages. 5 Comments
https://www.digitalocean.com/community/tutorials/how-to-use-symfony2-to-perform-crud-operations-on-a-vps-part-1
CC-MAIN-2019-26
refinedweb
1,813
52.9
C - Questions 1. What does static variable mean? 2. What is a pointer? 3. What is a structure? 4. What are the differences between structures and arrays? 5. In header files whether functions are declared or defined? 6. What are the differences between ma lloc() and calloc()? 7. What are macros? what are its advantages and disadvantages? 8. Difference between pass by reference and pass by value? 9. What is static identifier? 10. Where are the auto variables stored? 11. Where does global, static, local, regi ster variables, free memory and C Program instructions get stored? 12. Difference between arrays and linked list? 13. What are enumerations? 14. Describe about storage allocation and scope of global, extern, static, local and register variables? 15. What a s ame as an uninitialized pointer? 32. What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro? 33. What does the error 'Null d characte rs whe ther a particular bit is on or off? 56. which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1? 57. Write a program to compare two strings without using the strcmp() function. 58. Write a progr am to concatenate two strings. 59. Write a program to interchange 2 variables without using the third one. 60. Write programs for String Reversal & Palindrome check 61. Write a program to find the Factorial of a number 62. Write a program to generate the F ib ot her pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically? 71. Which function should be used to free the memory allocated by calloc()? 72. How much maximum can you allocate in a si ngle call to malloc()? 73. Can you dynamically allocate arrays in expanded memory? 74. What is object file? How can you access object file? 75. Which header file should you include if you are to develop a function which can accept variable number of argume nts? 76. Can you write a function similar to printf()? 77. How can a called function determine the number of arguments that have been passed to it? 78. Can there be at least some solution to determine the number of arguments passed to a variable argument l ist function? 79. funct ions sin(), pow(), sqrt()? 86. How would you use the functions memcpy(), memset(), memmove()? 87. How would you use the functions fseek(), freed(), fwrite() and ftell()? 88. How would you obtain the current time and difference between two times? 89. How wo uld? C++ - Questions 1. What is a class? 2. What is an object? 3. What is the d ifference? Di fferentiate between them. 20. Difference between realloc() and free? 21. What is a template? 22. What are the main differences between procedure oriented languages and object oriented languages? 23. What is R T T I ? 24. What are generic functions and gene ric classes? 25. What is namespace? 26. What is the difference between pass by reference and pass by value? 27. Why do we use virtual functions? 28. What do you mean by pure virtual functions? 29. What are virtual classes? 30. Does c++ support multilevel a nd multiple inheritance? 31. What are the advantages of inheritance? 32. When is a memory allocated to a class? 33. What is the difference between declaration and definition? 34. What is virtual constructors/destructors? 35. In c++ there is only virtual de struct t o post fix notation ((a+2)*(b+4)) - 1 (Similar types can be asked) 5. How is it possible to insert different type of elements in stack? 6. Stack can be described as a pointer. Explain. 7. Write a Binary Search program 8. Write programs for Bubble Sort, Quic k sort 9. Explain about the types of linked lists 10. How would you sort a linked list? 11. Write the programs for Linked List (Insertion and Deletion) operations 12. What data structure would you mostly likely see in a non recursive implementation of a re cursive algorithm? 13. What do you mean by Base case, Recursive case, Binding Time, Run - Time Stack and Tail Recursion? 14. Explain quick sort and merge sort algorithms and derive the time - constraint relation for these. 15. Explain binary searching, Fibinoc ci li st e lement is not there, if the elements are completely unordered? 22. What is the average number of comparisons needed in a sequential search to determine the position of an element in an array of 100 elements, if the elements are ordered from largest to smal lest? 23. Which sort show the best average behavior? 24. What is the average number of comparisons in a sequential search? 25. Which data structure is needed to convert infix notations to post fix notations? 26. What do you mean by: * Syntax Error * Logica l Error * Runtime Error How can you correct these errors? 27. In which data structure, elements can be added or removed at either end, but not in the middle? 28. How will inorder, preorder and postorder traversals print the elements of a tree? 29. Parenthe sis are never needed in prefix or postfix expressions. Why? 30. Which one is faster? A binary search of an orderd set of elements in an array or a sequential search of the elements.. Wha t is the difference between process and threads? 7. What is update method called? 8. Have you ever used HashTable and Directory? 9. What are statements in Java? 10. What is a JAR file? 11. What is JNI? 12. What is the base class for all swing components? 1 3. t hread synchronization occur in a monitor? 17. Is there any tag in htm to upload and download files? 18. Why do you canvas? 19. How can you know about drivers and database information ? 20. What is serialization? 21. Can you load the server object dynamical ly? la yout for card in swing? 27. What is light weight component? 28. Can you run the product development on all operating systems? 29. What are the benefits if Swing over AWT? 30. How can two threads be made to communicate with each other? 31. What are the file s generated after using IDL to java compiler? 32. What is the protocol used by server and client? 33. What is the functionability stubs and skeletons? 34. What is the mapping mechanism used by java to identify IDL language? 35. What is serializable interfa ce? 36. What is the use of interface? 37. Why is java not fully objective oriented? 38. Why does java not support multiple inheritance? 39. What is the root class for all java classes? 40. What is polymorphism? 41. Suppose if we have a variable 'I' pro gram for recursive traverse? 46. What are session variable in servlets? 47. What is client server computing? 48. What is constructor and virtual function? Can we call a virtual function in a constructor? 49. Why do we use oops concepts? What is its advanta ge? S tatement? 58. What is meant by Static query and Dynamic query? 59. What are Normalization Rules? Define Normalization? 60. What is meant by Servelet? What are the parameters of service method? 61. What is meant by Session? Explain something about HTTP Sess ion th e stub? 69. Explain about version control? 70. Explain 2 - tier and 3 - tier architecture? 71. What is the role of Web Server? 72. How can we do validation of the fields in a project? 73. What is meant by cookies? Explain the main features? 74. Why java is con sidered as platform independent? 75. What are the advantages of java over C++? 76. How java can be connected to a database? 77. What is thread? 78. What is difference between Process and Thread? 79. Does java support multiple inheritance? if not, what is tre ading?. Expla in betwe en t betwee n fu nctions executed by them. 3. What are the difference phases of software development? Explain briefly? 4. Differentiate between RAM and ROM? 5. What is DRAM? In which form does it store data? 6. What is cache memory? 7. What is hard disk and what is its pur pose?in g? 29. Difference between multi threading and multi tasking? 30. What is software life cycle? 31. Demand paging, page faults, replacement algorithms, thrashing, etc. 32. Explain about paged segmentation and segment paging 33. While running DOS on a PC, whi ch command would be used to duplicate the entire diskette? MICROPROCESSOR QUESTIONS 1. Which type of architecture 8085 has? 2. How many memory locations can be addressed by a microprocessor with 14 address lines? 3. 8085 is how many bit microprocessor? 4. Why is data bus bi - directional? 5. What is the function of accumulator? 6. What is flag, bus? 7. What are tri - state devices and why they are essential in a bus oriented system? 8. Why are program counter and stack pointer 16 - bit registers? 9. What does it mean by embedded system? 10. What are the different addressing modes in 8085? 11. What is the difference between MOV and MVI? 12. What are the functions of RIM, SIM, IN? 13. What is the immediate addressing mode? 14. What are the different flags in 808 5? 15. What happens during DMA transfer? 16. What do you mean by wait state? What is its need? 17. What is PSW? 18. What is ALE? Explain the functions of ALE in 8085. 19. What is a program counter? What is its use? 20. What is an interrupt? 21. Which line will be activated when an output device require attention from CPU? yo u mean by zener breakdown and avalanche breakdown? 10. What are the different types of filters? 11. What is the need of filtering ideal response of filters and actual response of filters? 12. What is sampling theorem? 13. What is impulse response? 14. Expl ain the advantages and disadvantages of FIR filters compared to IIR counterparts. 15. What is CMRR? Explain briefly. 16. What do you mean by half - duplex and full - duplex communication? Explain briefly. 17. Which range of signals are used for terrestrial tra nsmission?. Wh at is meant by pre - emphasis and de - emphasis? 25. What do you mean by 3 dB cutoff frequency? Why is it 3 dB, not 1 dB? 26. What do you mean by ASCII, EBCDIC? Log in to post a comment
https://www.techylib.com/en/view/prettybadelynge/c-_questions_1._what_does_static_variable_mean_2._what_is_a_point
CC-MAIN-2017-30
refinedweb
1,751
78.96
Many of you are aware of indexers and its properties. For those unaware of it want to know that indexers are used to represent objects using indexes or even using keys. i.e. we can represent an object of a class by the way an array is using. But this is the default behavior of an indexer i.e. its return type is an integer and indexed objects are representing using integer type indexes. But we can override theses default items, as return type may be an object and representing indexed objects using string type keys rather than integer type indexes. I tried to explain here with some sort of coding. Start a new C# web project in VS.NET and add a class Nations to it. Click the ClassView button, as any thing you want to add in a class type is very easy in VS.NET by making the class view of the project and just right click on that particular class. So after right click the class select add -> add indexer menu and your default indexer will added to the class. But change the definition of that indexer like below. /// <summary> /// Overrides the default indexer prototype /// </summary> public Nations this[string nationName] { get { return (Nations)nationsObjects[nationName]; } set if (nationsObjects.Contains(nationName)) { nationsObjects.Remove(nationName); } nationsObjects.Add(nationName,(Nations) value); } Basically I changed the return type of the indexer to "Nation" type and changed the default integer type indexes to a string type key. So now indexer will active by the statement <object>[<key>] compare to the previous status of <object>[<index>]. Each indexed objects want to be stored and will use later and more over this storing want to be performed using a string type key value. For that we want a ListDictionary in to which all indexed objects will keep. The statement nationsObjects.Add(nationName,(Nations) value); is used for this stored precess and the (Nations)nationsObjects[nationName]; statement in side the get will return a particular indexed object on the basis of a key value. Ok this is the main activities in the class. In the front end I first create a normal object using the statement Nations n = new Nations(); and then the real thing happens. Look this statement n["india"] = new Nations(); got it? Nothing here I indexed the object "n" using a key "india" and assign it to a type of Nations. Now you can use n ["india"] like any other object to access the resources of the type Nations. The difference is that we can represent this particular object with a key ("india"). In this way you can create more objects with different keys and perform various operations. Look at the sample code along with this article, as you may get clearer picture on customized indexers. Use Customized Indexers Access a Form Control in Code Behind
http://www.c-sharpcorner.com/UploadFile/jaishmathews/UsageofCustomizedIndexers03122006041654AM/UsageofCustomizedIndexers.aspx
crawl-003
refinedweb
476
55.54
On Wed, 13 Jul 2011 17:49:48 -0400 Arnaud Lacombe wrote:> Hi,> > On Sun, Jul 10, 2011 at 3:51 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:> >".> >> Actually, I used to have a patch to make hex value have a mandatory> "0x" prefix, in the Kconfig. I even fixed all the issue in the tree,> it never make it to the tree (not sure why). Here's the relevant> thread:> >>>> I prefer that this be fixed in kconfig, so long as it won't causeany other issues. That's why I mentioned it.> > >)> > +> that seems hackish...It's a common idiom for concatenating strings in the kernel.How would you do it without (instead of) a kconfig fix/patch?> > #endif /* !__LINUX_STRINGIFY
https://lkml.org/lkml/2011/7/13/308
CC-MAIN-2016-30
refinedweb
122
82.85
Hello Everyone, i can see that this question has been asked a lot but i tried them and it didn't work. I am using Unity 5.3.5. I have a trigger in my animator Attack1Trigger which should trigger my attack1 animation. I set the trigger to true using GetKeyDown(KeyCode.Space), i also tried GetKey() to be sure as well. The animations are triggered twice for some weird reason that i can't figure it out. And similarly my other animations (attack2,3 and 4) also play twice. I am able to stop that by checking the "Can transition to self" box but that is not the effect i want because then i can keep pressing the key and it will never complete the animation. Could anyone please tell me any possible solution to this problem?? GetKeyDown(KeyCode.Space) GetKey() Are these animations legacy? Thanks for the response. I dont know how to check the legacy thing. They are character animations that came with the character pack. Please find the images of how it looks Is this pack an Official unity asset? or did you get this from the asset store. Answer by YellowUromastyx · Jul 08, 2016 at 09:57 AM @Abhiroop Tandom (Note i am not a professional with animations but i have worked with them) This could be caused be a few reasons) 1: The animation is being called twice. This could be because the script that calls this animation is attached to more then 1 object, or the script itself calls the animation more then once. Try fixing this by putting a Debug.Log("Animation called"); where you are calling the animation from. 2: The animation could (By accident) loop the animation 2 times, its impossible to tell because they are made in an animating software outside of unity. if these don't work try setting the animation to Legacy, you can do this by selecting the animation, then look for the icon in the inspector, in the top left there should be a small triangle pointing down with 4 horizontal lines to the right of it. When you click this a list should appear from the bottom of the icon, at the very top of the list should be an option titled "Normal" and it should have a check mark next to it. You need to select "Debug". when you open the Debug version of the animation there will be a lot of options, just 3 options down there should be a check box and to the left of it it should say "Legacy", select this check box then go back to Normal by following the same steps you did to get to Debug. Legacy animation can NOT be called in the animator and must be called via script. I am using C# in this example but i can convert it to Java as well. Use this script to call the animation. using UnityEngine; using System.Collections; public class CallAnimation : MonoBehaviour { public Animation attackAnimation; // We will set this to the desired animation in the inspector void Update () { // you can use Input.GetKeyDown also if (Input.GetButtonDown ("Fire1")) { attackAnimation.Play (); Debug.Log ("Attack animation has played!"); } } } Put this script on an object, you will see a bar that has "None (Animation)" written on it. Click the dot to the right of the bar and select the animation that you set to legacy. (If the animation is NOT legacy it will not work) make sure a game object has the Animation Component attached to it and the Animation is assigned in the Animation Component. when you play your game and hit the Left Mouse Button the animation should trigger and text should appear in the console saying "Attack animation played!". If you receive an error saying "UnassignedReferenceException: The variable attackAnimation of CallAnimation has not been assigned. You probably need to assign the attackAnimation variable of the CallAnimation script in the inspector." then that means you did NOT assign the animation to the script, you must do this via the inspector. I hope this helps and i am very sorry if it does not. This is a image of the icon with he upside down triangle with the 4 lines. (its a bit blurry) I hope this helps @YellowUromastyx I really appreciate your elaborate answer. I followed as you said and for some reason i cannot make the animation legacy Then i tried the debug thing and figured out that my debug statement executes only once but the animation is played twice. Would you know how to fix that?? The thing to note here is if in my animator i select those arrows and check "Can transition to self" it then plays the animation only once. But then obviously i can keep pressing the key and it will restart the animation before its finished and will never finish the animation(which is not the desired effect). Could you please help ? I don't know how to help with this, this is likely a problem with the animation itself. Sorry for the inconvenience. No problem @YellowUromastyx. Thanks for your time though :) !! Thanks, YellowUromastyx, your first suggestion was very helpful. I was having the same problem and added the Debug.Log() as you suggested to find that, even though the script wasn't calling the animation twice, it was being called twice. Turned out I was holding space down for a fraction of a second and my script didn't take that into account, so triggered the jump animation twice. Answer by SteenPetersen · Apr 21, 2017 at 11:10 PM @Abhiroop-Tandon If im not mistaken what you've done is make a very short animation clip. and as you ask it to start with a trigger you have left the "transition duration" on it in your animator from the "any state" to the desired animation. try setting the transition duration to 0 on the line leading to your animation and see if that works. with short animations it gives itself time to play it twice. hope this helps someone, tis at least how I fixed this issue. I come back to this answer whenever this happens because I forget how to fix it every time. This is what fixes double animation every time. Thanks @SteenPetersen Even though this is very late Anytime :) Logged in just to upvote this :) So simple solution but such annoying behaviour. Unity should give transitions priority, so that if an animation has no exit condition and therefore needs to go to the next state, it shouldn't be allowed to play twice, and just abort whatever transition it is in. Answer by GameDevSA · May 08, 2017 at 08:00 AM I think most likely you are accidentally triggering the animation twice. A useful test would be to put in a debug message to confirm. if (Input.GetKeyDown(KeyCode.Space)) { print("Playing Attack Animation"); anim.SetTrigger("Attack"); } You could also try adding in a second condition to be sure, by only setting the trigger if the right animation is playing. For example, if you want to trigger an attack animation from an idle state, make sure the trigger is only set to true if the animation is currently in Idle state. if(other.gameObject.tag == "Player" && anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) { print("Attacking hero"); anim.SetTrigger("Attack"); } Also you might want to double check the actual transition itself. For the transition into, I had 'Exit Time' off, because I wanted it to happen immediately, but left transition duration at 0.1 under Settings. If the settings aren't correct in the actual Animator itself it may accidentally cause looping. To be safe, I reset mine, and then just turned off Exit Time, and that fixed it. Because I was originally getting weird errors even when my script looked like it should have worked, but someone else set the transition up. So I reset it and did the above, and it worked perfectly. Hope that helps anyone else having this issue. I had to wrack my head around it for a bit. Thank you very much. Answer by atcjavad · May 07 at 07:59 AM Hi U need to connect all of your states to Exit State,Hi U need to connect all of your statments to Exit State. Answer by onur84 · Sep 18 at 01:50 AM I encountered the same problem. I solved this issue with just a line of code. Just put that code into your triggering state's behaviour's OnStateEnter : //TriggerName: Put your own trigger's name here animator.ResetTrigger("TriggerName"); OR instead put the same line into triggered state's OnStateExit. Animator Override Controller changed at runtime doesn't always play the animations correctly 1 Answer Animations not showing for Animator 0 Answers smoothly Animate clips simultaneously 0 Answers Dynamically create states and transition using Animator Controller 1 Answer How to get reference to a specific Animation Clip in Animator. 0 Answers
https://answers.unity.com/questions/1212066/animation-trigger-playing-twice.html?sort=oldest
CC-MAIN-2019-47
refinedweb
1,492
63.19
New exercises added to: Ruby, Java, PHP, Python, C Programming, Matplotlib, Python NumPy, Python Pandas, PL/SQL, Swift php.js Tutorial Introduction to php.js php.js is a JavaScript library, enables you perform high-level operations like converting a string to time or retrieving a specific date format, in JavaScript. Using php.js, you can write high-level PHP functions for low-level JavaScript platforms (for example browsers, V8 JavaScript Engine etc). In this comprehensive php.js tutorial, you will learn about hundreds of php.js functions with examples. History php.js was started in the early 2009 by Kevin van Zonneveld and Brett Zamir. It is an Open Source Project, licensed under MIT License. Till then, many developers have contributed to the project and the project is 81.4% complete as of this writing. Many other projects like Ext for Yii, node.js, ShaniaTwain.com, KillBugs, XSoftware Corporation, TwiPho, mediacode, Sprink, Harmony Framework used php.js someway or other successfully. Advantages of learning php.js You will save a lot of time, since using php.js you can perform high-level operations on Browsers and or Client side. You can use your concepts learned from PHP functions in another language (JavaScript). Obtain php.js You can download it from Github (). You can download it from. In fact they provide you with a very nice option of compiling and downloading various js files according your requirement. Step 1 : Click on compile and you will get this : Step 2 : select the functions you want to : Step 3 : select whether you want to (i)include namespace (default is no) (ii)You want a compressed function (iii)give a name of your js file (iv)click on compile. If your selection of functions matches a previously created one, you will directed to download that file, else your selection of functions will be compiled to a new js package file and will be downloaded. w3resource provided you with downloading options of php.js files. After you have downloaded the file, include that file in an webpage like this : <script src="filename.js"></script> And write you JavaScript code like : <script src="filename.js"></script> <script type="text/javascript"> .....your code </script> Amazon promo codes to get huge discounts for limited period (USA only).
https://www.w3resource.com/phpjs/use-php-functions-in-javascript.php
CC-MAIN-2018-26
refinedweb
380
58.89
This document outlines the process by which Android runs in a Linux container in Chrome OS. This document explains how the container for Android master works unless otherwise noted. The container for N may work in a slightly different way. config.json is used by run_oci, to describe how the container is set up. This file describes the mount structure, namespaces, device nodes that are to be created, cgroups configuration, and capabilities that are inherited. Android is running using all of the available Linux namespaces(7) to increase isolation from the rest of the system: cgroup_namespaces(7) mount_namespaces(7) network_namespaces(7) pid_namespaces(7) user_namespaces(7) Running all of Android's userspace in namespaces also increases compatibility since we can provide it with an environment that is closer to what it expects to find under normal circumstances. run_oci starts in the init namespace (which is shared with most of Chrome OS), running as real root with all capabilities. The mount namespace associated with that is referred to as the init mount namespace. Any mount performed in the init mount namespace will span user sessions and are performed before run_oci starts, so they do not figure in config.json. First, run_oci creates a mount namespace (while still being associated with init‘s user namespace) that is known as the intermediate mount namespace. Due to the fact that when it is running in this namespace it still has all of root’s capabilities in the init namespace, it can perform privileged operations, such as performing remounts (e.g. calling mount(2) with MS_REMOUNT and without MS_BIND), and requesting to mount a tmpfs(5) into Android‘s /dev with the dev and exec flags. This intermediate mount namespace is also used to avoid leaking mounts into the init mount namespace, and will be automatically cleaned up when the last process in the namespace exits. This process is typically Android’s init, but if the container fails to start, it can also be run_oci itself. Still within the intermediate mount namespace, the container process is created by calling the clone(2) system call with the CLONE_NEWPID and CLONE_NEWUSER flags. Given that mount namespaces have an owner user namespace, the only way that we can transition into both is to perform both simultaneously. Since Linux 3.9, CLONE_NEWUSER implies CLONE_FS, so this also has the side effect of making this new process no longer share its root directory ( chroot(2)) with any other process. Once in the container user namespace, the container process enters the rest of the namespaces using unshare(2) system call with the appropriate flag for each namespace. After it performs this with the CLONE_NEWNS flag, it enters the a mount namespace which is referred to as the container mount namespace. This is where the vast majority of the mounts happen. Since this is associated with the container user namespace and the processes here no longer run as root in the init user namespace, some operations are no longer allowed by the kernel, even though the capabilities might be set. Some examples are remounts that modify the exec, suid, dev flags. Once run_oci finishes setting up the container process and calls exit(2) to daemonize the container process tree, there are no longer any processes in the system that have a direct reference to the intermediate mount namespace, so it is no longer accessible from anywhere. This means that there is no way to obtain a file descriptor that can be passed to setns(2) in order to enter it. The namespace itself is still alive since it is the parent of the container mount namespace. The user namespace is assigned 2,000,000 uids distributed in the following way: The second range maps Chrome OS daemon uids (600-649), into one of Android's OEM-specific AIDs ranges. Similarly, gid is assigned in the same way as uids assignment, except the special gid 20119 is allocated for container gid 1065, which is Android's reserved gid. This exception is because ext4 resgid only accepts 16-bit gid, and hence the originally mapped gid 1065 + 655360 does not fit the ext4 resgid. TODO There are several ways in which resources are mounted inside the container: system.raw.img, and another one for vendor.raw.img. chroot(2)and pivot_root(2). MS_SHAREDflags for mount(2)in the init mount namespace and MS_SLAVEin the container mount namespace, which causes any mount changes under that mount point to propagate to other shared subtrees. All mounts are performed in the /opt/google/container/android/rootfs/root subtree. Given that run_oci does not modify the init mount namespace, any mounts that span user sessions (such as the system.raw.img loop mount) should have already been performed before run_oci starts. This is typically handled by arc-setup. The flags to the mounts section are the ones understood by mount(8). Note that one mount entry might become more than one call to mount(2), since some flags combinations are ignored by the kernel (e.g. changes to mount propagation flags ignore all other flags). /: This is /opt/google/containers/android/system.raw.imgloop-mounted by arc-setup(called from /etc/init/arc-system-mount.conf) in the init namespace. This spans container invocations since it is stateless. The exec/ suidflags are added in the intermediate mount namespace, as well as recursively changing its propagation flags to be MS_SLAVE. /config/sdcardfs: Bind-mount of /sys/kernel/config/sdcardfssubdirectory of a normal configfscreated by esdfs. /dev: This is a tmpfsmounted in the intermediate mount namespace with android-rootas owner. This is needed to get the dev/ execmount flags. /dev/pts: Pseudo TTS devpts file system with namespace support so that it is in a different namespace than the parent namespace even though the device node ids look identical. Required for bionic CTS tests. The device is mounted with nosuid and noexec mount options for better security although stock Android does not use them. /dev/ptmx: The kernel documentation for devpts indicates that there are two ways to support /dev/ptmx: creating a symlink that points to /dev/pts/ptmx, or bind-mounting /dev/pts/ptmx. The bind-mount was chosen to mark it u:object_r:ptmx_device:s0. /dev/kmsg: This is a bind-mount of the host‘s /run/arc/android.kmsg.fifo, which is just a FIFO file. Logs written to the fake device are read by a job called arc-kmsg-loggerand stored in host’s /var/log/android.kmsg. /dev/socket: This is a normal tmpfs, used by Android's initto store socket files. /dev/usb-ffs/adb: This is a bind-mount of the hosts's /run/arc/adbdand is a slave mount, which contains a FIFO that acts as the ADB gadget configured through ConfigFS/FunctionFS. This file is only present in Developer Mode. Once the /dev/usb-ffs/adb/ep0file is written to, the bulk-in and bulk-out endpoints will be bind-mounted into this same directory. /dataand /data/cache: config.jsonbind-mounts one of host's read-only directories to /data. This read-only and near-empty /datais only for “mini” container for login screen, and is used until the user signs into Chrome OS. Once the user signs in, arc_setup.cc‘s OnBootContinue()function unmounts the read-only /data, and then bind-mounts /home/root/${HASH}/android-data/{data,cache}to /dataand /data/cache, respectively. These source directories are writable and in Chrome OS user’s encrypted directory managed by cryptohome. /var/run/arc: A tmpfsthat holds several mount points from other containers for Chrome <=> Android file system communication, such as dlfs, OBB, and external storage. /var/run/arc/sdcard: A FUSE file system provided by sdcarddaemon running outside the container. /var/run/chrome: Holds the ARC bridge and Wayland UNIX domain sockets. /var/run/cras: Holds the CRAS UNIX domain socket. /var/run/inputbridge: Holds a FIFO for doing IPC within the container. surfaceflinger uses the FIFO to propage input events from host to the container. /sys: A normal sysfs. /sys/fs/selinux: This is bind-mounted from /sys/fs/selinuxoutside the container. /sys/kernel/debug: Since this directory is owned by real root with very restrictive permissions (so the container would not be able to access any resource in that directory), a tmpfsis mounted in its place. /sys/kernel/debug/sync: The permissions of this directory in the host are relaxed so that android-rootcan access it, and bind-mounted in the container. /sys/kernel/debug/tracing: This is bind-mounted from the host's /run/arc/debugfs/tracing, only in dev mode. Note that the group id is mapped into the container to allow access from inside by DAC. /proc: A normal procfs. This is mounted in the container mount namespace, which is associated with the container user+pid namespaces to display the correct PID mappings. /proc/cmdline: A regular file with the runtime-generated kernel commandline is bind-mounted instead of the Chrome OS kernel commandline. /proc/sys/vm/mmap_rnd_compat_bits, /proc/sys/vm/mmap_rnd_bits: Two regular files are bind-mounted since the original files are owned by real root with very restrictive permissions. Android's initmodified the contents of these files to increase the mmap(2)entropy, and will crash if this operation is not allowed. Mounting these two files reduces the number of mods to init. /proc/sys/kernel/kptr_restrict: Same as with /proc/sys/vm/mmap_rnd_bits. /oem/etc: This is bind-mounted from host's /run/arc/oem/etcand holds platform.xmlfile. /var/run/arc/bugreport: This is bind-mounted from host‘s /run/arc/bugreport. The container creates a pipe file in the directory to allow host’s debugdto read it. When it is read, Android's bugreportoutput is sent to the host side. /var/run/arc/apkcache: This is bind-mounted from host‘s `/mnt/stateful_partition/unencrypted/apkcache. The host directory is for storing APK files specified by the device’s policy and downloaded on the host side. /var/run/arc/dalvik-cache: This is bind-mounted from host's /mnt/stateful_partition/unencrypted/art-data/dalvik-cache. The host directory is for storing boot*.art files compiled on the host side. This allows the container to load the files right away without building them. /var/run/camera: Holds the arc-camera UNIX domain socket. /var/run/arc/obb: This is bind-mounted from host's /run/arc/obb. A daemon running outside the container called /usr/bin/arc-obb-mountermounts an OBB image file as a FUSE file system to the directory when requested. /var/run/arc/media: This is bind-mounted from host's /run/arc/media. A daemon running outside the container called /usr/bin/mount-passthroughmounts an external storage as a FUSE file system to the directory when needed. /vendor: This is loop-mounted from host's /opt/google/containers/android/vendor.raw.img. The directory may have graphic drivers, Houdini, board-specific APKs, and so on. Android is running in a user namespace, and the root user in the namespace has all possible capabilities in that namespace. Nevertheless, there are some operations in the kernel where the capability check is performed against the user in the init namespace. All the capabilities where all the checks are done in this way (such as CAP_SYS_MODULE) are removed because no user within the container would be able to use it. Additionally, the following capabilities were removed (by dropping them from the list of permitted, inheritable, effective, and ambient capability sets) to signal the container that it cannot perform certain operations: CAP_SYS_BOOT: This signals Android's initprocess that it should not use reboot(2), but instead call exit(2). It is also used to decide whether or not to block the SIGTERMsignal, which can be used to request the container to terminate itself from the outside. CAP_SYSLOG: This signals Android that it will not be able to access kernel pointers found in /proc/kallsyms. By default, processes running inside the container are not allowed to access any device files. They can only access the ones that are explcitly allowed in the config.json's linux > resources > devices section. TODO The hooks used by run_oci follow the Open Container Initiative spec for POSIX-platform Hooks, with a Chrome OS-specific extension that allows a hook to be installed after all the mounts have been processed, but prior to calling chroot(2). All the hooks are run by calling fork(2)+ execve(2) from the run_oci process (which is the parent of the container process), and within the intermediate mount namespace. In order to avoid paying the price of creating several processes and switching back and forth between namespaces (which added several milliseconds to the boot time when done naïvely), we have consolidated all of the hook execution to two hooks: pre-create and pre-chroot. The pre-create hook invokes arc-setup with the --setup flag via its wrapper script, /usr/sbin/arc_setup_wrapper.sh and creates host-side files and directories that will be bind-mounted to the container via config.json. The pre-chroot hook invokes arc-setup with the --pre-chroot flag and performs several operations: binfmt_miscto perform ARM binary translation on Intel devices. run_oci, since these are not handled by either the build system, or the first invocation of arc-setupthat occurs before run_ociis invoked. /dev/.coldboot_done, which is used by Android as a signal that it has reached a certain point during the boot sequence. This is normally done by Android's initduring its first stage, but we do not use it and boot Android directly into init's second stage.
https://chromium.googlesource.com/chromiumos/platform2/+/master/arc/container-bundle/
CC-MAIN-2018-34
refinedweb
2,271
54.52
The CDATA class shown in Example 15.13 is a subclass of Text with almost no functionality of its own. The only difference between CDATA and Text is that when an XMLOutputter serializes a CDATA object, it places its contents in a CDATA section rather than escaping reserved characters such as the less-than symbol with character or entity references. package org.jdom; public class CDATA extends Text { protected CDATA() { } public CDATA(String s) throws IllegalDataException; public Text setText(String s) throws IllegalDataException; public void append(String s) throws IllegalDataException; public String toString(); } In my opinion, you really shouldn't use this class at all. The builder may (or may not) create CDATA objects when it parses a document that contains CDATA sections, but you should not create them yourself. CDATA sections are purely a convenience for human authors. They are not part of the document's Infoset. They should not be exposed as a separate item in the logical model of a document, and indeed not all parsers and APIs will report them to the client program. Even APIs like JDOM and DOM that support them do not necessarily guarantee that they'll be used where possible. Chapter 11 already warned against using CDATA sections as a sort of pseudo-element to hide HTML in your XML documents. That warning bears repeating now. CDATA sections let you add non-well- formed text to a document, but their contents are just text like any other text. They are not a special kind of element, and a parser likely won't distinguish between the contents of the CDATA section and the surrounding text. If you have a legitimate reason for doing this, you still need to enclose the CDATA section in an actual element to provide structure that programs can detect. For example, an HTML tutorial might enclose HTML code fragments or complete documents in example elements, like this: <example> <![CDATA[<html> <body> <h1>My First Web Page</h1> HTML is cool!<P> <hr> © 2002 John Smith </body> </html>]]> </example> This is much more flexible and much more robust than relying on CDATA sections to distinguish the examples from the main body text.
https://flylib.com/books/en/1.131.1.155/1/
CC-MAIN-2021-21
refinedweb
362
50.77
Sometimes we require to redirect request to old or deprecated pages in our sites to new versions of that page or to a totaly different site. For instance, lets suppose that we decided to redirect the page to. In that case, because the new page is in a different domain, we need an external redirect which is basically a Sling mapping. Understanding sling mappings The sling mappings expose properties that allow us to modify the way a resource is resolved. Said properties are: - sling:match. Defines a partial regular expresion which be used to macth the incoming request instead of the resource name. - sling:redirect. The value of this property is sent back in the Location header in the response, which causes a redirection. - sling:status. The value of this property is sent back as the HTTP status to the client when we use the sling:redirect property. It defaults to 302, but you can use 300 (Multiple Choices), 301 (Moved Permanently), 303 (See Other), and 307 (Temporary Redirect). - sling:internalRedirect. Multi-value property. It modifies the path internally so the path specifed in sling:match can resolve to a given resource. - sling:alias. Adds an alias for a page, e.g content/myoldpageto content/mynewpage. Creating an external redirect First we should create the mapping under the /etc/map/http node. We have two options to create the node, we could use the namespace as the name e.g. “localhost.4502” or we can use another custom name e.g. “localhost_any” in conjunction with the “sling:match” property. For this example, we will use the first approach. - Create a folder under /etc/map/http with the name “localhost.4502”. - Create a node inside that folder with any name you want e.g. “togoogle”, the type will be “sling:Mapping” - Add the following properties: - “sling:match” with the URL you want to be redirected, e.g. “content/oldcontent.html” - “sling:internalRedirect” with the URL of the page you want to redirect to, e.g. “” - “sling:status” choose any of the suported statuses, in thi case we will choose 301 What if the page I want to redirect to is in the same server and domain? In that case it’s not necessary to create an external redirect. Instead you can: - Use a vanity url - Specify and alias with a Sling mapping (sling:alias) so content/myoldpagecan be considered an alias of content/mynewpage - Use an internal redirect to transparently redirect content/mynewpageto content/myoldpage. Please check my previous post and its second part for more information about internal redirects. Well, that was it for today! thanks for reading.
http://blog.magmalabs.io/2017/09/05/use-external-redirects-adobe-experience-manager.html
CC-MAIN-2018-17
refinedweb
438
56.35
Description 题意 给出一个n*n的矩阵,和可以走的距离,每个位置都有奶酪数量,第二次走的位置奶酪数量只能比第一次的位置奶酪数量多,求出最大可以获得的奶酪数量。 思路 简单的搜索题,如果直接搜索就会超时 就像这个样子,必须要进行记忆化处理才可以过。 代码如下: #include<stdio.h> #include<iostream> #include<string.h> using namespace std; int n,k; int c[110][110],dp[110][110]; int f[4][2]={1,0,0,1,-1,0,0,-1};//上下左右走的方向 int slove(int a,int b) { if(dp[a][b]!=0) return dp[a][b];//进行记忆化处理。 int maxn=0; for(int i=1;i<=k;i++) { for(int j=0;j<4;j++) { int l1=f[j][0]*i+a; int l2=f[j][1]*i+b;//四个走的方向 if(l1>=0&&l1<n&&l2>=0&&l2<n&&c[l1][l2]>c[a][b])//不出界并且当前获得最大值比以前的大 { if(slove(l1,l2)>maxn) maxn=slove(l1,l2); } } } dp[a][b]=maxn+c[a][b]; return dp[a][b]; } int main() { while(~scanf("%d %d",&n,&k)&&!(n==-1&&k==-1)) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&c[i][j]); memset(dp,0,sizeof(dp)); printf("%d\n",slove(0,0)); } return 0; }
https://blog.csdn.net/qq_43627087/article/details/88898916
CC-MAIN-2021-04
refinedweb
176
60.31
#include <AppDef_ResConstraintOfMyGradientOfCompute.hxx> Given a MultiLine SSP with constraints points, this algorithm finds the best curve solution to approximate it. The poles from SCurv issued for example from the least squares are used as a guess solution for the uzawa algorithm. The tolerance used in the Uzawa algorithms is Tolerance. A is the Bernstein matrix associated to the MultiLine and DA is the derivative bernstein matrix.(They can come from an approximation with ParLeastSquare.) The MultiCurve is modified. New MultiPoles are given. Returns the derivative of the constraint matrix. returns the duale variables of the system. returns the maximum difference value between the curve and the given points. returns the Inverse of Cont*Transposed(Cont), where Cont is the constraint matrix for the algorithm. returns True if all has been correctly done. is internally used for the fields creation. is used internally to create the fields.
https://dev.opencascade.org/doc/occt-7.1.0/refman/html/class_app_def___res_constraint_of_my_gradient_of_compute.html
CC-MAIN-2022-33
refinedweb
146
52.76
Home -> Community -> Mailing Lists -> Oracle-L -> Re: PL/SQL question Below is the code. the cursor has about 300000 recs. The details tables have large volume of data and some have about 30 recs for each ref_num in cursor. This script has to be run .Can performance be increased. I've tested this for 3000 recs in cursor and with lesser volume of data in detail table. time taken is 25 min. Note :index is not present in all detail tables on column used in filter. set timing on set serverout on size 1000000 declare l_commit_interval number := 5000; l_where_clause varchar2(2000); l_cnt number := 0; l_owner varchar2(25) := 'OWNER1'; l_index_cnt number := 4; and a.table_name = b.table_name and b.column_name in ('REF_NUM','BILL_REF_NUM','FLDR_T2_ID','TXN_REF_NUM') and a.owner = l_owner and b.owner = l_owner; begin for curs1 in c1 loop l_cnt := l_cnt + 1; l_index_cnt := 4; for curs2 in c2 loop l_where_clause := ' where '||curs2.column_name || ' = :col1'; execute immediate 'update '||curs2.table_name||' set ctry_cd = ''KK'''|| l_where_clause using curs1.ref_num; txn_tab_cnt(l_index_cnt).tab_name := curs2.table_name; txn_tab_cnt(l_index_cnt).tab_aff_rows:= txn_tab_cnt(l_index_cnt).tab_aff_rows+sql%rowcount;l_index_cnt := l_index_cnt + 1; rjamya <rjamya_at_gmail.com> To: manoj.gurnani_at_polaris.co.in Sent by: cc: oracle-l_at_freelists.org oracle-l-bounce_at_fr Subject: Re: PL/SQL question eelists.org 09/28/2005 06:42 PM Please respond to rjamya You don't show us the code, you don't tell us what version,platform, you don't tell us how much time it takes and you don't tell us how much time ti should take. Sorry, the crystal ball is broken, come back in 3 weeks. ps: 1 lakh is one hundred thousand. Raj -- on Wed Sep 28 2005 - 08:30:30 CDT Original text of this message
http://www.orafaq.com/maillist/oracle-l/2005/09/28/1333.htm
CC-MAIN-2014-41
refinedweb
285
60.92
How to: Create LINQ to SQL Classes in a Web Project When you want to use Language-Integrated Query (LINQ) to access data in a database, you do not connect directly to the database. Instead, you create classes that represent the database and its tables, and use those classes to interact with data. You can generate the classes through the Object Relational Designer or by running the SqlMetal.exe utility. For more information, see Object Relational Designer (O/R Designer) and Code Generation Tool (SqlMetal.exe). This topic shows how to use the O/R Designer in a Web application to create data classes that represent a SQL Server database. In a Web site project, you must put the data classes in the project's App_Code folder or in a subfolder of App_Code. If you include the data classes in a subfolder of App_Code, the name of the subfolder will be used as the namespace for the classes. In that case, you must provide that namespace when you connect to the data classes. For a Web application project, you do not have to use the App_Code folder. You can put the data classes in the project folder. For information about the difference between Web site projects and Web application projects, see Web Application Projects versus Web Site Projects. When you use the O/R Designer, the connection string for accessing the database is automatically added to the Web.config file. After you create the classes, you can connect to the classes by using the LinqDataSource control, the ObjectDataSource control, or a LINQ query. To create a class from a database, type a name for the .dbml file, and then click Add. The Object Relational Designer window is displayed. In Server Explorer, drag the database table into the Object Relational Designer window. The table and its columns are represented as an entity in the designer window. Save the .dbml file. This creates .designer.cs or .designer.vb file that is located under the .dbml file. The file contains a class that represents the database and a class that represents the table. The parameterless constructor for the database class reads the connection string from the Web.config file.
https://msdn.microsoft.com/en-us/library/bb907587(v=vs.90)
CC-MAIN-2018-05
refinedweb
366
54.32
Lab Exercise 8: Classes The purpose of this lab is to give you practice in creating your own classes. In particular, we will convert both the lsystem and the. Tasks Most of the exercises in lab will involve building up an L-system class. This week it will be important for you to use the method names provided. The next several labs will expect the L-system and Interpreter (function), function declaration. For example, the following function has two arguments, the second of which is optional with a default value of 5. def boo( a, b = 5 ): print a, " ", b The Lsystem init function should have two arguments: self, and an optional filename. If the function = '' - Create mutator and accessor methods for the base string: setBase(self, bstr), getBase(self). The setBase function should assign bstr to the base field of self. The getBase function should return the base field of self. - Create an accessor method getRule(self, index) that returns the specified single rule from the rules field of self. Then create the method addRule(self, newrule), which should add a copy of newrule to the rules field of self. Look at the version 1 lsystem if you need to remember how to write the method. - Create a read(self, filename) method that opens the file, reads in the Lsystem information, resets the base and rules fields of self, and then store the information from the file in the appropriate fields (you can use the accessors self.setBase and self.addRule to do that). You can copy and paste the function code from the version 1 lsystem.py file, but it will require some modification. For examle, you don't need to create a new Lsystem (self already exists) and you'll need to use the new accessor methods. - In order to handle multiple rules, we need to write our own replace method for an L-system. The indented algorithm is below. We scan through the string, and for each character we test if there is a rule. If so, we add the replacement to a new string, otherwise we add the character itself to the new string. # add to tstring the replacement from the rule # set found to True # if not found # add to tstring the character c # return tstring - Create a buildString(self, iterations) function.. python lsystem.py systemA 3 stra ) print lsys lstr = lsys.buildString( iterations ) fp = file( outfile, 'w' ) fp.write(lstr) fp.close() return if __name__ == "__main__": main(sys.argv) You can download and run the file on any of the following examples. SystemE is a little more complex than the others as it uses the characters f, L, and !. Let f be forward by distance*1.7; let L be a leaf; and let ! reduce the width by 1. In order for the shape to draw properly, you'll need to start the turtle with a width greater than 1 (e.g. 5), and you'll need to save and restore the turtle width along with the position and heading for [ and ]. When you run it, use an angle of 15. Getting systemE to run properly is a good extension. - Create a new file called interpeter.py. Label it as version 2. You'll want to import the turtle package, and probably the random and sys packages as well. Begin the class definition for an Interpreter class. class Interpreter: - Create an __init__ method with the definition below. The init should call turtle.setup(width = dx, height = dy ) and then set the tracer to False (if you wish). def __init__(self, dx = 800, dy = 800): - Create a drawString method for the Interpreter class. Except for the actual function definition, you can copy and paste it from the version 1 interpreter.py. The new method definition just needs self as the first argument. def drawString(self, dstring, distance, angle): - Copy over the hold and saveCanvas functions. Again, you just need to add self as the first argument to each function definition. - Add the test function below, which is almost identical to last week, and test your interpreter.py file just like we did last week. def main(argv): if len(argv) < 4: print 'Usage: interpreter.py <string file> <distance> <angle>' exit() filename = argv[1] distance = int(argv[2]) angle = float(argv[3]) dev = Interpreter( 800, 800 ) fp = file( filename, 'r' ) lstring = fp.readline() fp.close() dev.drawString( lstring, distance, angle ) dev.hold() if __name__ == "__main__": main(sys.argv) If you run the file as below, it should draw the rectangular shape corresponding to SystemA. python interpreter.py stra 10 90 Once you have finished the lab, go ahead and get started on project 8.
http://cs.colby.edu/courses/S10/cs151-labs/labs/lab08/
CC-MAIN-2018-34
refinedweb
779
75.2
Have you found that Sony Vegas Pro can not read MXF files in a P2 card or a hard drive? It is necessary to find an effective way to import P2 MXF to Sony Vegas Pro if you are shooting with Panasonic's AG-HVX200, since it features 3 wide aspect CCDs for true 16:9 recordings and the capability of shooting 1080/60i videos to a P2 card. For editing with Sony Vegas Pro, the advantage becomes the disadvantage. Actually, it is easy to solve the importing problem of P2 MXF and Sony Vegas Pro. You just need to convert Panasonic AG-HVX200 MXF footage to MPEG, the compatible video format for editing in Sony Vegas Pro. Besides, if you don't have so much spare space, WMV is also a great choice for you. In order to preserve the HD quality of your MXF files, a top MXF to MPEG Converter becomes the most important part in the problem-solving process. Here recommened the best MXF Converter as well as the four-step guide for you to get your P2 MXF converted to MPEG for importing to Sony Vegas Pro. Guide: Transcode P2 MXF files to MPEG-2/WMV for Sony Vegas Pro. Things to be noted: The MXF Converter is compatible with Windows 2000/XP/2003/Vista/Windows 7/Windows 8 and always free updated. 1) Import your 1080i MXF files from P2 card to the free-downloaded P2 MXF to Sony Vegas Converter; 2) Hit the Format box and get the drop-down list. Select Adobe Premiere/Sony Vegas --> MPEG-2 (*.mpg) as output format. Besides, you can also choose WMV (VC-1) (*.wmv) if you want to get the MXF files converted with smaller size. 3) Adjust video and audio parameters, including the Bitrate of Video and Audio, the Codec of Video and Audio, Video Size, Sample Rate, Frame Rate, Audio Channels, etc., in the Profile Settings. Tip: For MXF to MPEG-2 conversion, if you want to keep you 5.1 Channels as original, please set ac3 as audio codec. 4) Click the button for "Convert" to start converting Panasonic AG-HVX200 MXF footage for Sony Vegas Pro immediately. Usefull Functions of MXF. Deinterlace 1080i files: Click Edit --> Effect --> Deinterlacing. 6. Crop: Edit --> Crop and you can get the imported videos cropped as you want. After the MXF to MPEG conversion, you can now easily transfer your Panasonic AG-HVX200 recordings to Sony Vegas Pro, including Sony Vegas Pro 8/9/10/11, for editing without any problem. Besides, if you have other editing software or want to switch to another editing software, like Adobe Premiere Pro, Avid Media Composer, Adobe Premiere Elements, Windows Movie Maker, Magix Movie Edit Pro, etc., you needn't worry about the incompatibility problem with the versatile MXF Converter. If you want to get more info, please link to Brorsoft MXF Converter. Related Guide: Panasonic P2 MXF to MPEG-2- Import P2 MXF form Panasonic P2 Camera into Sony Vegas Transfer/Import Canon EOS C300 1080i MXF to Sony Vegas Pro Fast convert Canon MXF to MPEG-2 for Sony Vegas further editing Convert Panasonic AG-HPX370 DVCPRO HD P2 MXF to Sony Vegas Pro Import/Transcode Panasonic AG-HVX200 P2 MXF files to HD MPEG-2 for CyberLink PowerDirector 10 import P2 MXF to Sony Vegas Pro, converting Panasonic AG-HVX200 MXF footage for Sony Vegas Pro, transfer P2 MXF to Sony Vegas Pro, importing MXF from Panasonic AG-HVX200 to Sony Vegas Pro, transcode P2 MXF to WMV for Sony Vegas, convert P2 MXF to MPEG-2 for Sony Vegas, copy P2 MXF to Sony Vegas, put 1080i MXF to Sony Vegas, add P2 MXF to Sony Vegas Pro, convert Panasonic AG-HVX200 MXF footage to MPEG, P2 MXF to WMV conversion, P2 MXF to MPEG-2 conversion, MXF Converter for Sony Vegas Pro, MXF to Sony Vegas conversion, P2 MXF Sony Vegas importing problem, P2 MXF to Sony Vegas Converter
http://www.brorsoft.com/how-to/import-p2-mxf-to-sony-vegas-pro.html
CC-MAIN-2014-49
refinedweb
664
65.76
The previous article introduced the OpenAI Gym environment for Atari Breakout, together with some code for training an agent to solve it using reinforcement learning. Now we are going to take a closer look at the details of this environment, and use a more sophisticated algorithm to train an agent on it much quicker. You can use the following simple Python code to play the game interactively (and, it has to be said, more slowly than usual). The keys you need are A for left, D for right, and Space to launch the ball. This will only work if you’re in an environment with a real graphical display; otherwise, you can just read this bit. import gym from gym.utils.play import play, PlayPlot def callback(obs_t, obs_tp1, action, rew, done, info): return [rew] plotter = PlayPlot(callback, 30 * 5, ["reward"]) env = gym.make("Breakout-ramNoFrameskip-v4") play(env, callback=plotter.callback, zoom=4) We use a callback function to show the reward received over time. As you can see, we get no reward except when the ball hits and removes a brick. There is no negative reward for losing a life. Several things aren’t apparent from this screenshot: So, a few challenges for an agent to overcome! Since we are inspecting things, this is a good opportunity to have a brief overview of Ray’s architecture and, in particular, the things we might like to tweak to change its performance. In the previous article, we ran on a single CPU; this time we are going to make use of more cores and a GPU. The architecture of Ray consists of one trainer and zero or more external worker processes, which feed back batches of observations. Each worker can run one or more environments, based on what you have configured. Here are some of the common parameters you can change to affect performance and scaling: num_cpus_per_worker num_envs_per_worker num_gpus num_gpus_per_worker num_workers rollout_fragment_length train_batch_size The following code sets up seven Ray workers, each running five Breakout environments. We are also switching to use the IMPALA algorithm instead of DQN. import ray from ray import tune from ray.rllib.agents.impala import ImpalaTrainer ray.shutdown() ray.init(include_webui=False, ignore_reinit_error=True) ENV = "BreakoutNoFrameskip-v4" TARGET_REWARD = 200 TRAINER = ImpalaTrainer tune.run( TRAINER, stop={"episode_reward_mean": TARGET_REWARD}, config={ "env": ENV, "monitor": True, "evaluation_num_episodes": 25, # from "rollout_fragment_length": 50, "train_batch_size": 500, "num_workers": 7, "num_envs_per_worker": 5, "clip_rewards": True, "lr_schedule": [ [0, 0.0005], [20_000_000, 0.000000000001], ] } ) Using eight CPU cores and a GPU, this took about 0.6 hours to train to the score of 200. Much quicker than the DQN model we used in the previous article. Progress wasn’t exactly linear. In particular, it had a very wobbly moment towards the end, where the mean score dropped right back. width="602px" alt="Image 2" data-src="/KB/AI/5271948/image002.png" class="lazyload" data-sizes="auto" data-> Having learned to solve the Breakout environment in half the time, you might think we are done with it. But no, this is only half the battle. Learning Breakout from RAM, instead of from pixels, throws up some interesting challenges, as we will discover in the next article. This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
https://www.codeproject.com/Articles/5271948/Learning-Breakout-More-Quickly
CC-MAIN-2021-39
refinedweb
547
55.95
desk checking The process of walking through a program's logic on paper before you actually write the program conversion the entire set of actions an organization must take to switch over to using a new program or set of programs The ____ used in the pseudocode reflects the logic you can see laid out graphically in the flowchart indentation The statements that execute when a tested condition in a selection is false are called the ____. else clause True or False In a flowchart, one structure can attach to another at any point in the structure. False With a selection structure or ____ structure you ask a question, and, depending on the answer, you take one of two courses of action. decision With a(n) ____, you perform an action or task, and then you perform the next action, in order. sequence structure True or False Machine language is represented as a series of 0s and 1s, also called decimal form. False True or False Instructions after an endif statement are not dependent on the if statement at all. True True or False Software developers say that spaghetti code has a longer life than structured code. False True or False A sequence can contain any number of tasks, but there is no chance to branch off and skip any of the tasks. True The process of walking through a program's logic on paper before you actually write the program is called ____. desk-checking True or False It is more common for uninitialized variables to have an a valid default value assigned to them then for them to contain an unknown or garbage value. False If you use an otherwise correct word that does not make any sense in the current context, you commit a ____ error. semantic True or False Whether you are drawing a flowchart or writing pseudocode, you must only use Yes and No to represent decision outcomes. False Every operator follows ____ that dictate the order in which operations in the same statement are carried out. rules of precedence every operator follows this which dictate the order in which operations in the same statement are carried out. Rules of Precedence
https://quizlet.com/3261067/midtermm-chapters-1-4-flash-cards/
CC-MAIN-2016-22
refinedweb
366
63.93
I am new to C++ and tried the following code on LINUX using g++. #include <stdio.h> #include <iostream> #include <string> using namespace std; class mom { public: void display() {cout<<"MOM is here..."; } }; class son: private mom { public: void display(){mom::display();} friend void g2(mom*); }; void g2(mom* s) { s->display(); } int main() { son s1; g2(&s1); cout<<"\n"; return 0; } It gives me an error which says mom is an inaccessible base class of son. But according to me if the base class is declared private then its public and protected members are accessible to members and friends of the derived class and only members and friends have the premission( or can change) D* to B*. So dows it means i have a bugged version of g++ but the same message is printed on VC++ and Dev C++ also. Pls help me. First, declare display() as virtual. Secondly. post the exact error. Kuphryn You cannot convert a derived class to a pointer to a base class (as you try to do in son s1;g2(&s1) when you have declared the inheritance private or protected. try public inheritance instead Code: class son: public mom class son: public mom Further, you don't need to create another Display method in Son if all it does is call Mom's Display. If you want Son to do something different, declare Mom's Display as virtual and have Son do something different. As it is, the code is redundant and therefore potentially confusing. [Moved thread] Ciao, Andreas "Software is like sex, it's better when it's free." - Linus Torvalds Article(s): Allocators (STL) Function Objects (STL) GCDEF: son does need a display() function in order to make it visible. All the members of mom are private to son, so virtualising display still wouldn't work, and is unnecessary. Private inheritance means that you can't pass a son object to a mom* argument. But according to me if the base class is declared private then its public and protected members are accessible to members and friends of the derived class and only members and friends have the premission( or can change) D* to B*. Not really. Private inheritance means that public and protected members of the base class have their access specifier changed to private in the derived class. Friends of a derived class have the same access rights to memebrs of a base class as do the members of the derived class. There is no defined conversion between D* and B* for private (or protected) inheritance (which is why you can't call g2() with a son object - only public inheritance gives you the IS-A relationship).
http://forums.codeguru.com/showthread.php?267643-std-string-amp-debugging&goto=nextnewest
CC-MAIN-2015-06
refinedweb
448
66.67
Mobile Page Class Definition Warning This API is now obsolete. Serves as the base class for all ASP.NET mobile Web Forms pages. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. public ref class MobilePage : System::Web::UI::Page public class MobilePage : System.Web.UI.Page [System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see.")] public class MobilePage : System.Web.UI.Page type MobilePage = class inherit Page Public Class MobilePage Inherits Page - Inheritance - MobilePage - Derived - - Attributes - Remarks The MobilePage class inherits from the ASP.NET Page class. To specify a mobile page and use ASP.NET mobile controls, an ASP.NET mobile Web Forms page must contain the following page directive. <%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="c#" %> The Inherits attribute is required. The Language attribute is set to the language that is used on the page, if it is needed. Note ASP.NET mobile pages allow for multiple mobile forms on each page, whereas ASP.NET Web pages allow for only one form per page.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.mobilecontrols.mobilepage?redirectedfrom=MSDN&view=netframework-4.8
CC-MAIN-2020-16
refinedweb
196
54.08
Difference between revisions of "BeagleBoard Community" Latest revision as of 09:01, 2 May 2019. Note that all of CircuitCo's Beagle specific support wiki pages can be found within elinux.org's Beagleboard:Main_Page namespace. This content is only editable by CircuitCo employees. Contents - 1 Hardware - 2 Availability - 3 I/O Interfaces - 4 BootRom - 5 Code - 6 Compiler - 7 Cortex A8 ARM features - 8 Board recovery - 9 Development environments - 10 Software hints - 11 Graphics accelerator - 12 Beginners guide - 13 FAQ - 14 Links - 15 Other OMAP boards - 16 Subpages Hardware The BeagleBoard M g - Currently six-layer PCB; target: four layer PCB Bottom of rev B: See jadonk's photostream for some more detailed BeagleBoard pictures. Manual See the links below. Schematic Schematic of BeagleBoard Rev. C3 is available as part of the BeagleBoard System Reference Manual. EBVBeagle was a rev C2 board with green PCB boxed with some useful accessories: AC adapter, USB-to-Ethernet adapter, MMC card, USB hub and some cables. - ICETEK-OMAP3530-Mini (Mini Board), a Chinese BeagleBoard clone. - Embest DevKit8000, a compact development board based on TI OMAP3530. - Embest DevKit8500D, a high-performance development board based on TI DM3730. - Embest SBC8530, a compact single board computer based on TI DM3730 and features UART, 4 USB Host, USB OTG, Ethernet, Audio, TF, WiFi/Bluetooth, LCD/VGA, DVI-D and S-Video. - Tianyeit CIP312, a Chinese clone with WLAN, Bluetooth, dual 10/100M Ethernet Contoller-LAN9221I/MCP2512, CAN, touch screen controller, USB hub, USB host, USB OTG based on the DM3730/OMAP3530. 40x40x3.5 mm package - IGEPv2 Platform, a Spanish BeagleBoard clone, with Ethernet, Wi-Fi and Bluetooth - SOM3530, a tiny Chinese System-on-Module BeagleBoard clone with Ethernet. 40x40x4 mm BeagleBoard-based products - Always Innovating Touch Book, see [2] - ViFFF-024 camera board, an extremely sensitive camera for Beagleboard XM, very easy to program and use. I/O Interfaces This section contains notes on some of the BeagleBoard's I/O interfaces. For detailed information about all integrated interfaces and peripherals see the BeagleBoard System Reference Manual. See the peripherals page for external devices like TI's DLP Pico Projector and compatible USB devices. RS-232 The 10-pin RS-232 header is useful for debugging the early boot process, and may be used as a traditional serial console in lieu of HDMI. The pinout on the BeagleBoard is "AT/Everex" or "IDC10". You can buy IDC10 to DB9M adapters in many places as they are commonly used for old PCs, or build one based on this schematic. You may also be able to also need a 9-Pin NullModem cable to connect BeagleBoard to serial port of your PC. Since many systems no longer come with an actual serial port, you may need to purchase a USB-to-serial converter to connect to your BeagleBoard. Be warned that some of them simply do not work. Many of them are based on the Prolific chip, and under Linux require pl2303 module to be loaded. But even when two converters appear to have exactly the same characteristics as listed in /var/log/messages, one simply may not work. Adapters based on the FTDI chipset are generally more reliable. USB There are two USB ports on the BeagleBoard, one with an EHCI (host) controller and another with an OTG (on-the-go, client) controller. EHCI Note that prior to Rev C, the EHCI controller did not work properly due to a hardware defect. The OMAP3 USB ECHI controller on the BeagleBoard only supports high-speed (HS) signaling. This simplifies the logic on the device. FS/LS (full speed/low speed) devices, such as keyboards and mice, must be connected via B and lower — The EHCI controller did not work properly due to a hardware defect, and was removed in rev B4. may get [3] for more information. OTG The HS USB OTG (OnTheGo) controller on OMAP3 on the BeagleBoard supports: [4]. JTAG For IC debugging the BeagleBoard sports a 14-pin TI JTAG connector, which is supported by a large number of JTAG emulation products such as OpenOCD. See BeagleBoardJTAG and OMAP3530_ICEPICK for more information. Expansion Boards Many have created expansion boards for the BeagleBoard, typically to add peripherals like LCD controllers (via the LCD header, SRM 5.11) or to break out functions of the OMAP3 like GPIO pins, I2C, SPI, and PWM drivers (via the expansion header, SRM 5.19). External hardware is usually necessary to support these functions because BeagleBoard's 1.8 V pins require level-shifting to interface with other devices. Expansion boards may also power the BeagleBoard itself through the expansion header. The most complete list of expansion boards can be found on the pin mux page, which also documents how different OMAP3 functions may be selected for expansion header pins. The BeagleBoard Expansion Boards category lists more expansion boards.. Update: 2019 the above x-loader link is "not found" Barebox can be used as an alternative bootloader (rather than U-Boot). You will have to generate it two times: - As a x-loader via defconfig: omap3530_beagle_xload_defconfig - As the real boot loader: omap3530_beagle_defconfig e17 as window manager, the AbiWord word processor, the gnumeric spreadsheet application, a NEON accelerated mplayer and the popular NEON accelerated omapfbplay which gives you fullscreen 720p decoding. The directory should contain all the files you need: See the beagle wiki on how to setup your SD card to use all this goodness. KB sized u-boot.bin in the main directory. Note: Due to (patch and binary) size, the: For beagleboard revision C4, above sources will not work. USB EHCI does not get powered, hence devices are not detected... Get a patched version of u-boot from (Update on April 23 - 2010: This repository has been superseded by the U-Boot version found at) Note: If you want to activate I²Board the main OMAP Git repository with additional patches, mainly display & framebuffer related. (Link to Unknown Project) - Tomi's kernel tree, a clone of the main OMAP Git repository: An pld c6000 Linux compiler is available on the TI FTP site. It does NOT support c64x+ core in OMAP3 devices. Not recommended. You can also use introduction' since ANSI C can only describe scalar floating point, where there is only one operation at a time. 2) NEON NEON vectorized single precision operations (two values in a D-register, or four one cycle/instruction throughput (processing two single-precision values at once) for consumer multimedia.>, float32x2_t datatype and vmul_f32() etc) - Use NEON assembly language directly On Cortex-A9, there is a much higher performance floating point unit which can sustain one cycle/instruction throughput, with low result latencies. OMAP4 uses dual-core Cortex-A9+NEON which gives excellent floating-point performance for both FPU and NEON instructions. Board recovery If you played, for example, with the contents of the NAND, it might happen that the BeagleBoard doesn't boot any more (without pressing user button) due to broken NAND content. See BeagleBoard recovery article how to fix this. Do not panic and think you somehow 'bricked' the board unless you did apply 12 V. So you likely will have to upgrade the X-Loader. Here's what to do: - Make an SD card with the Angstrom Demo files. See the Beagleboard Wiki Page for more information on making the SD card. - Put the SD card in the BeagleBoard, and boot up to the U-Boot prompt. - Do the first six instructions in the Flashing Commands with U-Boot section. - Reboot the BeagleBoard to see that the new X-Loader is properly loaded. This will update the X-Loader to a newer version that will automatically load uImage. Information on how RSE is used for, for example, Gumstix development is described in this post. See also Using Eclipse with Beagle (for JTAG debugging)..Board, are available here. Current release supports input devices (keyboard/mouse), network and sound. You can watch Android booting on BeagleBoard. the 0xdroid demo video on the BeagleBoard: *Board.. Arch Linux ARM See [5] how to install Arch Linux introduction, too. Software hints This section collects hints, tips & tricks for various software components running on BeagleBoard.Board. Mediaplayer (FFmpeg) There is a thread how to get a mediaplayer with NEON optimization (FFmpeg) to run on BeagleBoard. Includes compiler hints and patches. Java Open source. Oracle Java As of August 2012, there is a binary version of Oracle JDK 7 available for Linux/ARM under a free (but not open source) license. More information: - Download on java.oracle.com - Release notes for JDK 7 Update 6 - Original announcement - Oracle blog with FAQ - Oracle Binary Code License Supported features: - Java SE 7 compliant - Almost all development tools from the Linux/x86 JDK - Client and server JIT compilers - Swing/AWT support (requires X11R6) - Softfloat ABI only Oracle states in the FAQ that they are working on hard float support, as well as a JavaFX 2 port to Linux/ARM. Booting Android (TI_Android_DevKit) from a USB stick Please note - This procedure was tested on BeagleBoard-xM revision B(A3) - An SD card will be still needed to load the kernel. - An SD card will contain boot parameters for the kernel to use a USB stick as the root filesystem Procedure - Download Android Froyo for BeagleBoard-xM from TI - Follow the installation procedure for an SD card card. - Test if Froyo is working with your BeagleBoard-xM with an SD card. - You will notice that Android has a slow performance. That is why we will install root filesystem on the BeagleBoard. - Mount your SD card to your computer. - Now we need to tell the BeagleBoard to use the root filesystem from the /dev/sda1 partition instead of the SD card partition. That is done by overwriting boot.scr on the SD card with this one - Unmount the SD card and insert it into the BeagleBoard and test.. Tutorial: Some videos: - SGX on BeagleBoardBoard home) - Using Google you can search beagleboard.org (including IRC logs) using site:beagleboard.org <search term> Manuals and resources - BeagleBoard System Reference Manual (rev. C4) - BeagleBoard System Reference Manual (rev. C3) - BeagleBoard System Reference Manual (rev. B7) - BeagleBoard System Reference Manual (rev. B6) - BeagleBoard System Reference Manual (rev. B5) - BeagleBoard System Reference Manual (rev. B4) - BeagleBoard System Reference Manual (rev. A5) - OMAP3530 processor description and manuals - BeagleBoard at code.google.com - OMAP3530/25 CBB BSDL Model - Micron's multi chip packages (MCPs) for BeagleBoard - BeagleBoard resources page with hardware documentation - Some performance comparison of BeagleBoard Rev. B with some other ARM/PC systems. - OMAP3 pinmux setup - OMAP3 eLinux pinmux page Contact and communication - BeagleBoard discussion list - BeagleBoard open point list and issue tracker - BeagleBoard blog - BeagleBoard chat: #beagle channel on irc.freenode.net (archives)Board - LinuxDevices article about Digi-Key launch - LinuxDevices article about BeagleBoard Rev C, Beagle MID from HY Research, Touch Book and Sponsored Projects Contest - Linuxjournal article on the BeagleBoard Books BeagleBoard based training materials BeagleBoard wiki pages -BoardBoard -Board from Make:Online - Robert's private BeagleBoard wiki (please don't add anything there, do it here. It will help to avoid splittering. Thanks!) - Felipe's blog about D1 MPEG-4 decoding using less than 15% of CPU with help of DSP - Embedded Mediacenter based on BeagleBoard (German) - Floating Point Optimization with VFP-lite and NEON introduction - BeagleBoard setting date via GPS - Complete embedded Linux training labs on the BeageBoard - BeagleBoardPWM Details about PWM on the BeagleBoard - Compatible peripherals and other hardware BeagleBoard photos - BeagleBoard pictures at flickr - BeagleBoard and USRP - Modify SDP3430 QUART cable for BeagleBoard - MythTV on BeagleBoard BeagleBoard videos - BeagleBoard Beginnings - BeagleBoard in the Living Room - BeagleBoard 3D, Angstrom, and Ubuntu - testsprite with BeagleBoard - BeagleBoard LED demo - LCD2USB attached to a BeagleBoard - Video blending in hardware - BeagleBoard Running Angstrom (VGA) on DLP Pico Projector - SGX on BeagleBoard working with Linux 2.6.27 - Not on Beagle OMAP3530: Ubuntu 7.04 on on OMAP3430 SDP - BeagleBoard booting Android - BeagleBoard, SGX, and libfreespace demo BeagleBoard manufacturing - BeagleBoard Solder Paste Screening - BeagleBoard Assembly Inspection - BeagleBoard Functional Test - BeagleBoard Reflow - BeagleBoard Assembly at Circuitco Other OMAP boards - OMAP 4430 Based 40X40 mm, Wi-Fi and mm) OMAP35XX-based system on module in the world! (It is not-Gumstix Overo is smaller at 17 mm*58 mm) - OMAP35x based CM-T3530 from CompuLab Subpages <splist parent= showparent=no sort=asc sortby=title liststyle=ordered showpath=no kidsonly=no debug=0 />
https://elinux.org/index.php?title=BeagleBoard_Community&diff=491381&oldid=10079
CC-MAIN-2019-51
refinedweb
2,063
53.61
One more time, I've a problem with accents One more time, I've a problem with accents I use Pythonista 3, in Python 3 I compare a file name (got with ftplib nlst) to a file name built with alert.dialog text field. The file name is Xxxé. When I print on comsole or display in a ui.label, each variable shows Xxxé, but when I compare both variables, they are different. When I loop on each character to print it, I get Xxxe ́ for the ftp file name Xxxé for the other I really need help to understand and to solve my problem Thanks in advance You could try normalizing both strings before comparing them, using unicodedata.normalize, e.g. import unicodedata # ... filename = unicodedata.normalize('NFC', filename) dlg_text = unicodedata.normalize('NFC', dlg_text) if filename == dlg_text: #... Thanks a lot, that solves my problem, but I don't understand the kind /encoding a of a string which contains/prints/displays é but prints e' when I loop on each character! @cvp Unicode has multiple ways of representing accented characters. Most accented characters have their own code point, for example é is U+00E9 (LATIN SMALL LETTER E WITH ACUTE). But almost all accents also exist as separate "combining" characters, which you can place after another character to add an accent to it. This means that you can also write é as U+0065 (LATIN SMALL LETTER E) followed by U+0301 (COMBINING ACUTE ACCENT). Both variants of é look the same when you display them, and most systems even treat "split up" characters as one character in text fields and such, so if you delete a "split up" character it removes the entire character and not just the accent. But if you look at the string character by character, you'll notice that they are actually different. That's why Unicode defines four forms of "normalization" for strings. Form "NFC" combines all letters and their accents into a single character if possible ("composition"), and form "NFD" splits them into separate letter and combining accents if possible ("decomposition"). There are also the "compatibility" forms "NFKC" and "NFKD", which do a few additional conversions. (Look up "Unicode equivalence" on Wikipedia if you want more details.) In most cases NFC is all you need, sometimes NFKC can be useful, and NFD and NFKD are almost never useful. But Apple's HFS+ file system (also called Mac OS Extended) uses the NFD form for file names, which means that if your FTP server is a Mac, it will give you decomposed characters, instead of normal composed characters like most other programs and services. Thanks for your clear explanation. Coming from IBM world, I had always used the EBCDIC code, where all machines "speak" the same language. Thus, I'm still afraid that I could use a code to send a file to my Mac or NAS and that the file name or folder name would be unreadable by another system. Thanks, I'll have a look You're right. Just checked and seems strange. Thanks
https://forum.omz-software.com/topic/3490/one-more-time-i-ve-a-problem-with-accents/5
CC-MAIN-2021-04
refinedweb
511
69.31
Problem Distutils standard install_data doesn't automatically store resource-files in the same location as Python source-code files. This tends to break the assumptions of packages which expect to find their resource files in the same relative location to their source-code files. Since most data-files being packaged with a Python package really are resources on which code depends (not mere data-files) this can be a pain. To see the effect, try installing a library that specifies data-files while specifying --install_lib=somewhere. The data-files will still be installed to site-packages while the Python files show up in "somewhere". Solution for Python 2.3 Sub-class install_data and tell it to use the install_lib directory as its root install directory. from distutils.command.install_data import install_data class smart_install_data(install_data): def run(self): #need to change self.install_dir to the library dir install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') return install_data.run(self) then specify that the command class for 'install_data' is to be smart_install_data: setup ( name = "pytable", version = "0.7.7a", ... cmdclass = {'install_data':smart_install_data}, **extraArguments ) This code was created by Pete Shinners (of PyGame fame). You can see a real-world usage example in the PyTable setup script Note that in Python 2.4 and newer, you'll be able to use the 'package_data' keyword to the 'setup' function to install data in packages without having to clobber the normal install_data command. Solution for Python 2.1 and 2.2 For some obscure reason, the solution above does not work with Python 2.2 (or 2.1), even if the distutils code of Python 2.3 is used with Python 2.2. To make things worse, Python 2.1 and 2.2 will install data_files to /usr/package instead of /usr/lib/python2.x/package. See this posting for a solution that will work with every Python version. Discussion If you want to be able to use resources reliably even in the presence of Py2exe or similar packaging schemes (which aren't helped by this recipe), you might want to try ResourcePackage. ResourcePackage automatically embeds resources in Python packages/modules so that they are treated as Python code by the various packaging mechanisms. CategoryDistutilsCookbook
http://wiki.python.org/moin/Distutils/Cookbook/InstallDataScattered?highlight=(CategoryDistutilsCookbook)
CC-MAIN-2013-20
refinedweb
371
50.23
When Canonical released Ubuntu 9.10 in October, the Linux distributor also officially launched Ubuntu One, a cloud storage solution that is designed to synchronize files and application data between multiple computers over the Internet. The service has considerable potential, but only a handful of applications—including Evolution and Tomboy—take advantage of its capabilities. Fortunately, the underlying components that Canonical has adopted for Ubuntu One make it surprisingly easy for third-party software developers to integrate support for cloud synchronization in their own applications. In this article, we will show you how to do it and give you some sample code so that you can get started right away. Ubuntu One architecture There are a few aspects of Ubuntu One's architecture that you should understand before we begin. The service's file and application synchronization features are largely separate and operate on different principles. In this article, we will be looking solely at the framework for synchronizing application data. This facet of Ubuntu One is powered by CouchDB, an open source database system. One of the most noteworthy advantages of CouchDB is that it is highly conducive to replication. It has built-in support for propagating data between CouchDB instances that are running on different servers. Ubuntu One is engineered to take advantage of this characteristic of CouchDB. When a user runs the Ubuntu One client application that is shipped with Ubuntu 9.10, it will attempt to establish a pairing with Canonical's servers in the cloud. This pairing enables replication between the local instance of CouchDB that is running on the user's own computer and a remote instance of CouchDB that is hosted on Canonical's infrastructure. When the user has the Ubuntu One client enabled, data that applications put in CouchDB will automatically be propagated to and from other computers that the user has authorized to access their Ubuntu One account. As we explained at length in our review of Ubuntu 9.10, one of the challenges posed by adopting CouchDB on the desktop is that it isn't really intended to be used with a variable number of instances in multiuser environments. To work around this limitation, Canonical has created a simple framework of scripts called Desktop CouchDB that make it possible to dynamically spawn per-session instances of CouchDB on randomly selected ports. Desktop CouchDB uses D-Bus activation to automatically launch the database server when it is needed. It will also use D-Bus to expose the port number so that applications can connect without having to know the port ahead of time. In order to improve security and prevent other users from accessing the data, Desktop CouchDB requires that applications supply OAuth credentials before accessing the database. It's worth noting that users who don't want to rely on Ubuntu One can still use Desktop CouchDB and take advantage of CouchDB's native replication capabilities to achieve seamless cloud synchronization with their own self-hosted infrastructure. Ubuntu One provides free hosted storage and largely automates the configuration, but it's not entirely necessary. The code examples in this article are intended to work with Desktop CouchDB regardless of whether you have an Ubuntu One account. Accessing Desktop CouchDB with Python The Ubuntu One developers have created a simple Python library that wraps the Desktop CouchDB service. It transparently handles authentication and completely hides the other idiosyncrasies of Desktop Couch. A GObject-based library is also available for C programmers who want to use the service. The examples in this tutorial will primarily focus on the Python library. CouchDB is very different from conventional relational databases. It is designed to store its content as JSON documents with nested key/value pairs. To retrieve data from CouchDB, you create special view documents with JavaScript functions that operate on the JSON content. Although this query model seems very alien to developers who are accustomed to working with SQL, it has its own unique beauty that becomes evident over time. It's very flexible because you aren't constrained by a schema and can structure the individual items any way that you want. The Python library allows you to use dictionary objects to describe your database items. To create a new CouchDB document, you instantiate a new Record and provide it with the data. You should also specify the record type by providing a URL that points to human-readable documentation of the record's structure. from desktopcouch.records.server import CouchDatabase from desktopcouch.records.record import Record as CouchRecord # Connect to CouchDB and create the database database = CouchDatabase("people", create=True) # Create a new record with some data record = CouchRecord({ "email": "segphault@arstechnica.com", "nickname": "segphault", "name": "Ryan Paul" }, "") # Put the record into the database database.put_record(record) In the example above, we accessed a database called "people" by instantiating the CouchDatabase class. The create parameter tells CouchDB to automatically create a new database with that name if one doesn't already exist. We instantiated Record with two arguments. The first one is a dictionary with the data that we want to store in the record. The second one is the record type URL. Finally, we pushed the record into the database by calling the put_record method. After you run this code, you can see the newly added data in CouchDB by using Futon, a nifty CouchDB debugging tool that lets you inspect and manage databases. You can access Futon by opening ~/.local/share/desktop-couch/couchdb.html in your Web browser. If you have Ubuntu One enabled, the data will automatically appear on other connected computers during the next replication cycle (Ubuntu One data replication occurs every ten minutes). The concept of record type URLs might seem a bit confusing and warrants further clarification. One of the goals of the Desktop CouchDB project is to encourage interoperability between applications. The record types, which are not a standard part of CouchDB, are a convention that was introduced by Canonical's developers to make it easier for multiple applications to share the same data with each other in CouchDB. The URL is supposed to point to a wiki page that describes the fields that are used with the associated record type. Ideally, these fields should not be implementation-specific. Information that is intended to be used only by a single application should be stored in a subdocument for application annotations. It's important to understand that record type documentation is not the same thing as a schema. The goal is to provide guidance that will help other developers make their software work with the data. Conformance with the documented structure is not enforced in any way and you are not obligated to use a valid URL. Additionally, it's important to keep in mind that CouchDB data is supposed to be amorphous and you don't necessarily need to have the same fields in every record within a database. You must login or create an account to comment.
http://arstechnica.com/information-technology/2009/12/code-tutorial-make-your-application-sync-with-ubuntu-one/
CC-MAIN-2014-23
refinedweb
1,165
52.9
I think performance optimization should not be the principle determining factor in deciding which technique to use. Unless your application is running unacceptably slowly and you've identified the multi-branch if/else section as a bottleneck, it's ridiculous to change that to something else just for a performance gain. Maintainability, and design — as in consistency of — those are of primary importance. I like dispatch tables. They're clever. But at the same time, they raise a red flag for me — the same one I see whenever hashes are used to store a static set of entities in an application: It completely undermines the safety of strict. (There are steps you can take to regain some of this safety, such as using Tie::StrictHash.) The solution is to make the subs named class methods. I recently did this on a project at work. I had two dispatch tables, one for the "real" functions and one for a set of stubs, to be used when debugging. Old way: my %real_functions = ( wipe_system => sub { system "rm -rf /" }, ); my %debug_stubs = ( wipe_system => sub { warn "wiping system (no, not really)\n" }, ); my $funcs = $debug ? \%debug_stubs : \%real_functions; $funcs->{'wipe_system'}->(); [download] New way: { package SystemFunctions::Real; sub wipe_system { shift; # will be the class name system "rm -rf"; } } { package SystemFunctions::Debug; sub wipe_system { shift; # will be the class name warn "wiping system (no, not really)\n"; } } my $funcs = $debug ? 'SystemFunctions::Real' : 'SystemFunctions::Debug'; $funcs->wipe_system(); [download] Now, it sometimes won't be convenient to do this, due to the complication of packages. In my case, it was; in fact, it was a significant improvement, since it gave me a convenient place to encapsulate all my "system functions", which hitherto had lived in the main namespace. In the very simplest cases, you don't need to worry about packages at all:OAD. In reply to Re: When should I use a dispatch table? by jdporter in thread When should I use a dispatch table?
http://www.perlmonks.org/index.pl?parent=587246;node_id=3333
CC-MAIN-2015-22
refinedweb
325
60.35
11], [XML-NS], [XSCHEMA]. This part of the SMIL 2.1 specification describes the framework on which SMIL modularization and profiling is based, and specifies the SMIL 2.1 Modules, their identifiers, and the requirements for conformance within this framework. This section is informative. This section is unchanged from SMIL Modules section [SMIL20-modules]. SMIL 2.1 reuses the modularization approach as used in SMIL. Also refer to SMIL Modules section [SMIL20-modules] for host language conformance, integration set conformance and modules notions. This section is informative. SMIL 2.1 specification provides three classes of changes to the SMIL Recommendation, among the ten functional areas; The following functional areas are affected by SMIL2.1. Timing Layout Media Object Transitions This section is normative. SMIL functionality is partitioned into ten functional areas. Within each functional area a further partitioning is applied into modules. All of these modules, and only these modules, are associated with the SMIL namespace. The functional areas and their corresponding modules are: Note: Modules marked with (**) are new Modules added in SMIL2.1. Modules marked with (*) are revised modules from SM 2.1 modules and the modules they depend on. This section is informative. This section is unchanged from SMIL Recommendation [SMIL20-modules] This section is informative. This section specifies the identifiers for the SMIL 2.1 namespace and the SMIL 2.1.1 modules, elements and attributes, are contained within the following namespace:.1 module is necessary. Table 2 summarizes the identifiers for SMIL 2.1 modules. This section is normative. four language profiles using SMIL 2.1 Modules. They are the SMIL 2.1 Language Profile, the SMIL 2.1 Extended Mobile Profile, the SMIL 2.1 Mobile Profile and the SMIL 2.1 Basic Language Profile. All four profiles are SMIL host language conformant. This section is normative. The following two tables list names used to collectively reference certain sets of SMIL 2.1.1 host language conformant if it includes the following modules: In addition, the following requirements must be satisfied: Support of deprecated elements and attributes is no longer required for SMIL 2.1 host language conformance but it is highly recommended for all modules the given language supports. Support of deprecated elements and attributes can only be left out in cases where interoperability with SMIL 1.0 implementations is not an issue. For example, if a SMIL 2.1 host language supports the MultiArcTiming module, it is highly recommended that it support the deprecated syntax defined in the MultiArcTiming module. Since the SMIL 2.1 Structure module may only be used in a profile that is SMIL host language conformant, this implies that the SMIL 2.1.1 integration set conformant if it includes the following modules: In addition, the following requirements must be satisfied: Support of deprecated elements and attributes is not required for SMIL 2.1 integration set conformance. However, when included, the above requirements also apply to these elements and attributes. Also, when supported, it is required that all the deprecated elements and attributes from all the included modules are supported as a whole. This section is informative. This section is unchanged from SMIL 2.0 Recommendation [SMIL20-modules] This section is normative. For the purpose of identifying the version and the language profile used, SMIL host language conformant documents must satisfy the following requirements: This section is normative. This section is unchanged from SMIL Recommendation [SMIL20-modules]. This section is normative. This section is unchanged from SMIL Recommendation [SMIL20-modules] This section is informative. This section describes how language profiles could be defined using the SMIL 2.1 modular DTDs. The reader is assumed to be familiar with the mechanisms defined in "Modularization of XHTML" [XMOD], in particular Appendix D [XMOD-APPD] and Appendix E [XMOD-APPE]. In general, the SMIL 2.1 modular DTDs use the same mechanisms as the XHTML modular DTDs use. Exceptions to this are: Below, we give a short description of the files that are used to define the SMIL 2.1 modular DTDs. See the table and the end of the section for a complete list of the filenames involved. Following the same mechanisms as the XHTML modular DTDs, the SMIL 2.1 specification places the XML element declarations (e.g. <!ELEMENT...>) and attribute list declarations (e.g. <!ATTLIST...>) of all SMIL 2.1 elements in separate files, the SMIL module files. A SMIL module file is provided for each functional area in the SMIL 2.1 specification (that is, there is a SMIL module file for animation, layout, timing, etc). The SMIL module files are used in the normative definitions of the specification of the SMIL 2.1 Language Profile. Usage of the same module files for defining other SMIL profiles is recommended, but not required. The requirements that SMIL language profiles must follow are stated in the SMIL 2.1.1.1 elements. For the same reasons, the SMIL module files only define a default attribute list for their elements. This default list only contains the SMIL 2.1.
http://www.w3.org/TR/2005/CR-SMIL2-20050513/smil-modules.html
CC-MAIN-2013-48
refinedweb
839
52.15
Anne O’Brien’s WEDNESDAY BIBLE STUDY The Minor Prophets This study notes provide the core content of a group of bible studies on. 1 THE MINOR PROPHETS There. I have put them in chronological order, rather than the order that you find them in the Bible. Most of them can be dated by the events mentioned in the text. However, the dates of Obadiah and Jonah are uncertain, so I have arbitrarily placed them at the beginning. Most of the Books, with the exception of Obadiah pick up the theme of the rebellion, repentance and restoration of Israel ; but of course they apply just as much to the reader today; and whilst much of the text reveals the sin in man and God’s pronounced judgment, the mercy and grace of God shines through. Israel were God’s chosen people and He loved them with an everlasting love. But we, also, are God’s people of the New Covenant, so that these prophecies are applicable and appropriate for us too in these Last Days. For a better understanding of how the prophets relate to the historical context please see Appendix 1. 1 JONAH It is thought that Jonah was one of the earlier minor prophets in around the 7th- 8th century BC. He is also mentioned in 2 Kings 14v25, and his story is referred to by Jesus which gives proof to the fact that it actually happened. Jonah chapter 1 Read verses 1-3: Jonah’s commission was to go to Nineveh and preach against their wickedness – not a very attractive proposition! Nineveh was 700 miles east of Israel and it was not a very nice place. In fact it was Israel’s enemy. Jonah must have been very certain of God’s call because you do not act on an imaginary thought. But Jonah chose to take himself out of God’s will, he ran away – 2000 miles in the opposite direction! Q. Can we ever really escape from God’s presence? Was it the physical or spiritual barrier that kept Jonah from God? Read Psalm 139 Read verses 4-7: The Lord sent a storm – not out of anger but in order to bring Jonah to the place where he wanted him. Q. Can you think of any times when God has used a storm to shape your life? Everyone’s life was in danger, and hiding didn’t work for Jonah! The pagan captain, who seemed to have more faith in God than Jonah at that moment, drew lots and Jonah drew the short straw – he was to be thrown overboard. Read verses 8-12: The sailors recognized that a greater power was responsible for the storm, and in response to their questions Jonah replied that he was a Hebrew worshipper of creator God and that he was running away from God – he took the blame. Jonah had become a curse and the sailors were terrified. Q. Would God have answered Jonah while he was unrepentant? Read verses 13-16: Jonah’s sacrifice in leaving the ship brought them deliverance. The actions of the sailors (v15) resulted in a calm sea, and they acknowledged God’s sovereignty. God still used Jonah, even when he was rebellious and in the storm. God’s covenant was with Israel, but part of the purpose of that covenant was that they might bring God’s blessing to others. God loves the whole world. Jonah learnt this lesson and he also learnt (v17) that he was not in control of the events in his life, God was. Jonah chapter 2 Read verses 1-6: Jonah find that his actions led, not to escape but, to distress. And finally when he was at “rock bottom” he talked to God. Q. Why did God have to use such drastic measures? Jonah had had a near-death experience, but eventually he acknowledged God’s sovereignty. This was a real experience but the description is also a metaphor for the way people feel when they cannot go on – when life feels too hard for them. 2 Read verses 6-10: When Jonah acknowledged that God was the One in control and threw himself on God’s mercy he found he was able to praise God – and God delivered him. Praise brings the victory. Q. Why does praise make a difference to our situation? Jonah chapter 3 Read verses 1-3: Jonah’s experience brought him from rebellion to obedience. This time God said “Go” and Jonah obeyed. God calls us all to different ministries but the principle of obedience is the same. Obedience always brings blessing. Read verses 4-10: The people of Nineveh had hearts that were ready to hear the Word of God through Jonah. Although wicked, they repented and believed (even the King!). This miracle (which nearly didn’t happen because of Jonah’s disobedience) probably held back the Assyrians from attacking Israel for a generation or two. Q. Is there someone who God has prepared to hear his message through you, maybe? Jonah chapter 4 Read verses 1-4: Who has the right to judge? It seemed wrong to Jonah that wicked people (despite their repentance) escaped God’s judgment. It was ironic that God had turned away his anger, but Jonah’s was building up inside him. Q. How does anger stop us from seeing things as God sees them? Jonah knew that God was gracious, loving and compassionate. He had received mercy from God – and yet he did not want the Ninevites to have it! He was stuck in the mindset that evildoers must be punished, he didn’t want to acknowledge God’s grace. Rather like a petulant child (for the second time in his story!) he wanted to die. Q. What does the Bible say? Should we be judged according to what we have done or according to our repentance and faith in God? What does “grace” mean? Read verses 5-9: Once again Jonah runs away to sulk – this time to the east of Nineveh. God could have punished Jonah but he showed him kindness and grace by providing shelter from the heat. In a wqay, God turned the tables on Jonah. If Jonah didn’t think grace was right for the Ninevites then God would take away the grace he had shown him, so he caused the shady plant to die. And yet again Jonah wants to die! – even though he had put himself in that hot place. Q. We can see that Jonah was being irrational – but can we be the same? Read verses 10&11: The phrase “those who don’t know their right hand from their left” is telling us that the Ninevites were ignorant of the things of God and shouldn’t be judged without being given the chance to repent. It’s the same message today. We are not to judge those who have never heard, but rather to show them the gospel of God’s grace and mercy. 3 2. Edom/Esau’s sin was pride in their land – but it was God who created it thus. (v3&4) 3. When Moses was leading the Israelites out of the wilderness he asked for permission to cross the land of Edom, but was denied. In fact they!” 4. 5 JOEL Theme: It is never too late to repent. God can restore. Key verses: Joel 2v12&13 Locusts: In chapter 1 Joel wrote about a locust swarm, about great locusts, young locusts and other locusts. And he used many different descriptive names for them including shearer, swarmer, leaper and destroyer. They conjure up a picture of frightening destruction. Billions of locusts can sweep through a dry country eating all the vegetation as they go. This is an eye witness account: We beat and burned to death heaps upon heaps, but the effort was utterly useless. Wave after wave of locusts rolled up the mountains, and poured down upon us, over rocks, walls, ditches and hedges: those behind covering up and bridging over the masses already killed. Such a plague results in starvation and death and destitution. Israel had suffered a locust plague. God said it was a visual aid – a warning to the people of Israel, describing his judgment if they did not repent of their wicked ways. Read: Joel 2v1-11 (Notice the locust imagery.) In fact, we know from the Bible that because of their unrepentance God ultimately allowed armies from Assyria and Babylon to enter Israel with their invading armies and take the majority of people away as captives. But it was not a final judgment. Q. How can we apply this to our own busy .. hurting .. unfulfilled ..confused lives where sometimes we feel swarmed and swamped by events beyond our control? What do we need to do to find peace and restoration? Often, God allows the locusts (literally and metaphorically) – not as a punishment – but as a way of bringing his people into a place of repentance and restoration; to bring them back into that right relationship with him. Read Joel 2v12-17. God says (v12), “Return to me for I am gracious and compassionate”. When he says, “Rend your heart and not your garments” it means that repentance shouldn’t just be an outward gesture, it has to be real. Joel doesn’t spell out just what the people should repent of, although generally it was because they put other people and other things before God and they took God for granted. And it resulted in them going under (swarmed by locusts). 6 Q. What is the result when we (God’s people) truly repent by changing our lifestyle and our attitudes and desires? Read Joel 2v18-27 Especially look at verses 25&26. This is the result of repenting and putting God first: RESTORATION including absence of enemies, new grain, new wine, green fruitful trees, abundant showers (imagery for showers of blessing/the Holy Spirit) and vats overflowing with oil. The word restoration in Joel has a legal connotation meaning recompense. There was to be abundant blessing making up for lost years. In our lives the years the locusts have taken from us will not be lost or wasted or negative. God doesn’t want us to be resigned to the tough times. He wants us to stay close and he wants to bless us and restore us. He promised abundant showers and to fill us to overflowing with the Holy Spirit (v23,24). Read Joel 2v28-32 Joel now prophesies about the End Days (the time between Jesus’ First and Second Coming). There is the promise of the outpouring of the Holy Spirit on all his people. As the Jews believe in Jesus they will also experience this promise (v32). WE know this prophecy came true in Acts 2, and we still see it coming true today. We see the Holy Spirit as guide and comforter, as the giver of power and here as the way that God will speak through his people. Chapter 3 is about the final reckoning on the Day of Judgment. 7 AMOS Theme: Amos was called to highlight social injustice in Israel and to tell them that God expected them to act differently to the way the ungodly nations around them were acting. Amos – Who was he? Amos was from Jerusalem but God called him to go north to Israel to prophesy. This was around the year 750BC. Amos was an ordinary person (Read chapter 7v14) who looked after sheep and fig trees, but was obedient to God’s calling; he had to declare that God was angry with the people. Read Amos 1v2. Israel at that time: Jeroboam 11 was king. The country was rich and traded with many nations. Traditional Jewish religion was observed but the cult of Baal still persisted. The people only paid God lipservice, but their hearts were cold because they had taken Him and everything he had done for them for granted. And worse than that, they were exploiting those worse off. Amos chapter 1: Amos begins his prophecy with words of judgment for the surrounding countries whose sins had rubbed off on the Israelites: Verse 3: Damascus; Verse 6: Gaza; Verse 9: Tyre; Verse 11: Edom; Verse 13: Ammon; Chapter 2v1: Moab These countries had all been given more than one chance by God to repent. What were their sins? Read the verses again: they had stolen Israel’s crops; sold some Israelites into slavery; destroyed others with the sword; killed pregnant women and gone against treaties that they had made in the past. Amos should encourage us because it shows us that God is aware of what is happening in the world. He sees the injustices and he hears the cries. And ultimately his patience will wear out and judgment will come. 8 A modern-day parable: Now, I want you to imagine you are a teenager ... and part of a group of football fans going to a match. You are on a coach trip to a match somewhere, and this group of fans is made up of all sorts of people. Now, your dad is the leader of the group – so maybe, in some ways you are privileged – you occasionally get perks and discounts, but actually you take it all for granted, as teenagers often do. Now the thing is – on nearly every occasion when the group is away, there is trouble. Most of the fans don’t respect the leader, your father, and they don’t treat others very well either. They drink too much, they steal, they fight, they don’t turn up on time, and so on. And you’ve actually gone along with them sometimes – you are not as bad as them of course – but on the other hand you’ve never spoken out against them. You think you are an o.k person; you don’t generally break the law, after all. Then - one day ... your father decides enough is enough. He has given everyone of the problem fans three, if not four, chances to redeem themselves, but they haven’t listened. And this time when they get on the coach your dad shows them his anger. Right you lot! I’ve done this voluntarily for years and you’ve not shown me any respect. Steve, you can get off my coach – you’re always getting into fights. Bob – you can go too. I’ve seen you stealing tickets and selling them on. Andy – you can get off. You are always drunk - before we start off sometimes. Bill – you can get off. You keep us waiting half an hour every trip. And so on – until everyone is off the coach, apart from you and your brother, who are both sitting there feeling quite smug and pleased with yourself. Until ... you realise your father hasn’t finished – and he now starts talking to you and your brother! He says. “You can both get off too. You’ve spent too much time with that lot and you’ve become like them. You and your brother have never given me respect as the coach driver, but more importantly you don’t show me love or respect as your father either. You’ve always gone along with the boys and never stuck up for me, you’ve just taken everything I’ve done for you for granted.” Well! This has come as a shock. The feeling of smugness disappears. You no longer feel selfrighteous. Although in your mind your father has punished the good with the bad. The thing is, if you are honest you had become complacent. You had taken for granted the comfort and privileges of your position as sons of the driver. And you actually needed to be jolted into the awareness that everything you had – and everyone had – was down to the kindness and goodwill of your father. But you had taken it all for granted and abused your privilege – that special relationship - and in the end, became the same as everyone else. In effect, pleasing your friends became more important than pleasing your father... But, now you have heard the truth. You are ashamed and ask your father to forgive you, which – because of your special relationship – he does. 9 To Consider: In this parable ... Who is the father? Who are the sons? Who are the other fans? What is the message? Why are the sons different? The answers might help you understand why God acts as he does. Amos chapters 3-6: God’s judgment is not just for the other countries - He summons witnesses against Israel, too. God’s aim was to make them see themselves as they really were so that they could be brought to repentance and back into right relationship with Him. The words “to get you to return to me” are repeated and show us God’s love. Read chapter 4v6; 7; 9; and 10. Chapters 5 and 6 show us Israel’s sins: Read chapter 5v11; v12; v21; 6v1; 6v2; 6v6. The rich were drinking wine by the bowlful and yet many of the ordinary Israelites were going without food and drink and being used as slaves. Many countries around the world are experiencing this even as we study today – nothing changes! But, God sees. Such was the luxury of the rich that Amos talks about their houses adorned with ivory. They loved their ivory palaces more than they cared about their own people. Read Amos 4v3 Consequently God rejected their worship – Read chapter 5v21 Chapters 7-8 Amos had four visions: 1. Locusts (7v1): similar to Joel’s prophecy 2. Fire (7v4): the land would be burnt 3. A plumb line (7v7-9): Used to measure against God’s standard 4. A basket of ripe fruit (8v1-7): Israel was like beautiful ripe fruit that was actually rotting & displeasing and ripe for judgment. Chapter 9: BUT ... By God’s grace that was not the end. He promises restoration to the repentant. Read 9 v 13&14 Q. The challenge is: Are we different; are we kind to others? And how can we make a difference to the injustices in the world today? How can we help those in slavery, those who work for a pittance, those who are persecuted? God doesn’t just want lip-service; he wants action too. 10 HOSEA Key Verse: I desire mercy/love, not sacrifices. Hosea 6v6 Israel had become a country that had substituted the 10 Commandments for 2 new ones which were: “Every man for himself.” and “You can do what you like as long as it doesn’t hurt anyone else.” Does that sound familiar? Idols, blasphemy, murder, adultery, theft, covetousness – this was the way of life in Israel when Hosea was called by God to prophesy. When they got rid of the rules, they also got rid of their God. This was all happening 7-800 years BC. God’s charges against Israel: (There are so many, so I’ve just picked out one from nearly every chapter): Chapter 2v8: They were taking God’s blessings for granted. Chapter 4v1 and 2v12: Replacing God with an inanimate idol and the lies – could that be the TV in the corner of our living room? Chapter 5v4: The “spirit of prostitution” is placing your dependence onto people or things other than God. God told the Israelites that making alliances with other nations was adultery against Him. Chapter 6v4: Israel was fickle, not faithful. Chapter 7v2: They had abandoned God, & abandoned their morals. Chapter 8v1: Israel’s blessing was always dependent on them keeping the covenant of Law that they had made with God through Moses – but they had broken this. Chapter 9v1: Israel was called God’s Bride, but she had been unfaithful, like an adulterous prostitute. Chapter 10v4: Litigation is not a new thing! When a nation’s relationship with God is not right it is reflected in their relationship with one another. Chapter 11v12: They were guilty of lies and deceit. Chapter 12v1: Israel were making unholy alliances. Chapter 13v6: Here is the sadness of God’s heart. Like a loving husband he had provided for Israel, but they had left Him. Such was Israel’s sin. But the parable that follows shows us just how much God loves his people and what he will do to get them back into right relationship with him. Hosea’s story was a living parable: Read chapter 1v2-9 Hosea was a spiritual man and God’s prophet and yet God asked him to marry a prostitute, to rescue her from the gutter. His life was to become the parable, in which: 11 Hosea represents God, Gomer represents God’s people and their children represent the message from God. The message was that friendship had been broken, love had gone and they were being disowned. Why was the relationship broken? Well, you would think Gomer would be eternally indebted to Hosea and be a faithful wife but ... Read chapter 2v5-8 Gomer went back to prostitution, abandoning Hosea and her own children. She thought she would profit materially by selling her favours. She went with other men for what she could get out of them. What she hadn’t appreciated was that all that she was and had for a time was in fact all down to Hosea in the first place. She suffered the results of her lifestyle, but would not go back to Hosea who was devastated because of what had happened. Remember this is really portraying the relationship between God and the people he loves. Read chapter 3v1-3: God said “Go again. Give her another chance”. Hosea went out and bought his wife back (redeemed her) – for a price! What an incredible story of love and grace and forgiveness. Gomer deserved punishment, but Hosea showed her unconditional love and her children too. Read chapter 2v23 & 3v5. They would be loved and belong again. Israel’s story and Hosea’s story is our story too. Read Romans 5v8 and Romans chapter 9v22-25. Discuss. What a faithful God!! 12 MICAH Key verses: Chapter 6v6: Micah 1v7: idols, temple bribes, icons and political prostitution Micah 2v2: covet and steal Micah 6v6-8: God did not want their sacrifices (including child sacrifices – v7?). He wanted them to show love and mercy. Read Micah 6v5: Micah asks the people to remember two things. Balaam: (Numbers chapter 22-24) Balaam was a prophet who cursed military enemies for money. Using a donkey and an angel God spoke to him so that he could only say the words God gave him, which were, that he (Balaam) could not curse Israel because God had promised to bless them.The apostle Peter uses Balaam as an example of a false teacher. So Micah says: Remember not to listen to false prophets. God has determined blessing for Israel if they keep covenant with him.. Q. How often do we take time out to remember what God has done for us and the promises he has given us? 13 THE PRESENT Read Micah 6v10-16 and 7v2: Judgment was imminent because the people would not repent. Judgment ultimately came on Israel (within 20 years of Micahâ&#x20AC;&#x2122;s prophecy) when the Assyrian army took Samaria and carried the people of Israel away as exiles. Read Micah 7v7: But Israel was not without hope. Micah, Isaiah and those who were upright were the remnant who knew God would hear them and bring them through. Q. When things around are bad, is our response the same as Micahâ&#x20AC;&#x2122;s? Verse 7 is a good verse to learn! THE FUTURE Read Read Read Read Micah Micah Micah Micah 4v10: The Judean exiles to Babylon will return 7v11: There would be rebuilding and restoration 5v2: A Saviour is promised, will be born in Bethlehem 4v1-5: In the Last Days God will establish his reign Read Micah 7v18-20: Although God in his infinite justice would bring judgment, he would also forgive and restore the remnant that trust in him. God is faithful throughout the ages to those who are in covenant relationship with him (Abraham, Jacob, US!). We can learn and remember from the past, we can trust God in the present, and we can know we have a secure future in God. 14 NAHUM Key verse: Nahum 1v3 Whereas the last six books were written before the capture of Israel by the Assyrians, this prophecy by Nahum was written a couple of generations (approx. 70 years) after that event, when all the previous prophecies had come true. He prophesies to Nineveh, the capital of Assyria. Assyria was the first of the world empires referred to by the prophet Daniel, and Nahum’s prophecy foretells the fall of Nineveh to the Babylonians (the second world empire) which history tells us occurred in 612BC. THE PROPHECIES OF DANIEL foretold 5 world empires which were: Assyria, Babylon, Persian, Greek and Roman. They have never been replaced by another world power. Daniel’s prophecies came true over the centuries. “Kingdoms may rise, kingdoms may fall, but the Word of the Lord endures forever”. Nahum is a book for the Israelites about Assyria. It’s about 2 things: Bad news – Judgment on Nineveh Good news – Blessing for Israel Read Genesis 10v6-11: One of the oldest cities in the world, built to show what man could do, was a kingdom set against God’s kingdom. The present-day city of Mosul (a strategic place in the Iraq War) is now built on the same site. When Assyria had control of Nineveh they invented door locks, time keeping, navigational charts, paved roads, a postal system, iron weapons, glass for magnification, writing on clay tablets and they had universities and libraries. They had done some seemingly good things, so what was the problem with Nineveh? Read Nahum 3v19: Their leaders were unbearably cruel. Example: Asshur-banipal: put a dog chain through the jaw of a defeated king and made him live in a dog kennel like an animal, and he had his defeated foes hanging from the city walls. Chapter 3 is full of Assyria’s crimes: lies, theft, piles of dead, enslaver of nations, exploitation and leaders who didn’t care. Added to this the northern tribes of Israel were already subject to Assyria’s power since the capture of Samaria, and they were being abused. God had already shown compassion to Nineveh during Jonah’s time. They had had their chance, and they no longer had the excuse of ignorance! Read Nahum 1v2&3: In mercy and compassion God is slow to show anger, but when the time is right he is swift to bring his powerful and righteous judgments. Just as Israel was scattered throughout the Assyrian kingdom and suffered greatly, so today many Christians scattered around the world are being persecuted and suffer because they proclaim that Jesus is King. 15 Discuss Romans 11v22 – the kindness and severity of God (Isaiah 10v5-18: Isaiah tells how Assyria was God’s tool to chasten the Israelites.) Read Nahum 1v7: The secret of knowing God’s care is trusting in him. We have those things which cause us to stumble, which pull us down; those things which make us feel bound in different ways. Father God wants us to be free. He will come to our rescue, but it will always be in his timing and so that he can work out his purpose in us. Meanwhile “we have a refuge in him”. Read Nahum 1v8: Nahum predicted a flood would be the end of Nineveh. The Bad news for Nineveh was that God defeated Assyria, Israel’s enemy – once and for all The Good news was and still is (!!) that God always defeats sin and brings freedom to enjoy the blessings of salvation to those who put their trust in him. Read Nahum 1v15: This promise has yet to be fulfilled at the second coming of Christ. 16 ZEPHANIAH The name Zephaniah means “The Lord hides – or protects”. Zephaniah prophesied after the Fall of Samaria (Israel) and before the Fall of Judah in the south. But although Zephaniah’s message is for Judah and the surrounding nations, like most prophecy it also speaks to us. Key verse: Chapter 2v3 – Seek the Lord ... Who would be the channel of God’s judgment? The Babylonians were expanding their empire. God would use them to bring judgment, both on Judah and also on the surrounding countries who had helped in Judah’s downfall. Why Judgment? What was Judah guilty of? Read chapter 1 verses 4-6: There is quite a list:Baal worship, idolatrous priests, astrology, worship of Molek (the Philistine god), superstitious (v9), rejection of God, no communion with God. Read chapter 1v12: They were complacent. Like most people in our country today they thought the Lord would do nothing, either good or bad. They didn’t believe that judgment would come. Q. Why is it easy to become complacent?. JERUSALEM – Read chapter 3v1-5: Even in the place where God’s presence filled the Holy of Holies in the Temple the people were guilty and the unrighteous “knew no shame”. Q. Do these verses make us feel uncomfortable? Do foreign gods infiltrate today’s church? 17 Where was there hope for Judah, and ultimately for us? Our hope is in being humble and not proud. (Zephaniah 2v3) Even when we question God we are challenging his authority and therefore not giving him the rightful place in our thoughts. Our hope is in God’s covenant-based promises. For Judah these were based in the covenant that God made with Abraham to bless his seed. God would always save a remnant so that he would keep his promise. Read chapter 2v7 and chapter 3v12. God’s desire is to bless, because he delights in those who trust in him. Read chapter 3v17-20? 18 HABAKKUK God showed Habakkuk that He was about to raise up the Babylonians - so that they would be his instrument of judgment on the people of Judah. God’s people had not heeded the many prophetic warnings - that if they did not repent, then God would allow them to be punished by becoming exiles in Babylon. And so, prior to the judgment Habakkuk has some big questions for God. He voices them in the form of two complaints. First Complaint – Read chapter 1v2-4 Here Habakkuk is crying out to God for his people, who have allowed their society to become violent and unjust; and his question/complaint is, “How long before you do something, Lord?”. 19). Read Chapter 2v14 God’s Answer – Read chapter 2v3&4 God has the answer to our prayer already determined for a set time. So we are to wait for it with a sense of trust and assurance, by faith. For it will surely come. Read chapter 3v2 Habakkuk’s Response – And Ours? Habakkuk determined to trust God. It is an effort of our will. Read chapter 3v17-19. 20 HAGGAI The prophecies of Habakkuk and Zephaniah had come true. Just as they had predicted; the Babylonians had taken Judah and exiled its people – and it was a time of great sorrow. Read Psalm 137v1-4 o They no longer had a king (The signet ring was God’s seal of authority on the king’s leadership) Read Jeremiah 22v24-27 o They no longer had their land and o They no longer had the Temple where they could offer worship and sacrifice (it had been sacked by the Babylonians). They had been in exile for 70 years when, once again, God used another world power to work out his purpose. King Cyrus, the King of Persia (for the Persian Empire had now superseded the Babylonian Empire) gave them permission to return to their homeland. Read Ezra 1v1 (The Bible is factual - You can still see the actual clay cylinder today; it is on display in the British Museum) And so the Jews returned to their homeland. But Jerusalem was now under a Persian governor. The Jews would no longer have their own king. The amazing thing was that, under the Persians, they not only had permission to return but King Cyrus gave them all the Temple goods that had been confiscated 70 years before. Ezra 1v7-11. Read Haggai 1v1&2 When reading Haggai we must remember that the same prophecy can be for the immediate future (historically); it can be about the coming of Jesus as Messiah; and it can be about the End Days, in which we find ourselves. Haggai’s first sermon Read verses 3-6 The people lived in “paneled houses” (i.e. luxury homes) while God’s House was still unbuilt. They had done the foundations and built a temporary altar, but that was all. Their priorities were wrong – they were putting themselves first. Yet, they were never satisfied (v6). Read verses 7-11 God said that the drought was a result of their failure to put God first. Read verses 12-15 The people heard God (really listened to what he had to say); they determined to obey God; and then God stirred them up spiritually; so that, within 3 weeks they were rebuilding the Temple. 21 Q. If this is a parable where the Temple is God’s church today, how can we apply this to ourselves? Haggai’s second sermon could be in our hearts and not just in one place. Read Hebrews 3v6 Haggai’s Third Sermon. Q. Do you agree with this statement: True consecration to God must come before commitment to do something for him.? Haggai’s Fourth Sermon. Are we the like the people who started building and gave up – or are we those who commit ourselves to God’s work because we understand the bigger picture? 22 ZECHARIAH The book of Zechariah is the longest of the Minor Prophets and is worth looking at over two studies. It centres mainly around 8 visions which came to the prophet in the space of one night and which speak to the newly returned exiles from Babylon; but as with much of prophecy, the message is also directed at the first and second coming of Jesus, the Messiah. THE FIRST VISION Read chapter 1v8-16 What did Zechariah see? A man on a red horse, with other horses too; in a steep valley with myrtle trees; an angel was the mediator. What did it mean? The Jews had returned home but were not free (trapped as in a ravine) because they were under Persian governors. God was promising to be with them symbolized by the myrtle tree (with its aromatic aroma it is representative of the presence of God in the Bible). The horsemen probably symbolize God’s angelic messengers – God’s eyes on the earth. God wanted to reassure the people that he would be with them at the rebuilding of the Temple (see verse 16). They were not out of the valley yet, but God would be with them. What does it mean for us? We can remember that when we are in difficult situations God is with us, his angels are watching over us. We can know the fragrance of his presence and be assured that he will bring us through. THE SECOND VISION Read chapter 1v18-21 What did Zechariah see? He saw four horns and four craftsmen. What did it mean? In the Bible the number four usually signifies north, east, south and west and horns are world powers (horn signifies strength). So the four horns are Israel’s enemies. God was angry with Israel’s enemies (1v15). These horns were to be cut off and reshaped by the four craftsmen. God is the one who is powerful above all others. He is in control. What does it mean for us? Jesus was the ultimate “craftsman”; he alone can take a sinful, damaged life and reshape it into something beautiful for God. And today God is still the one who is in control of world powers. THIRD VISION Read chapter 2v1-5 What did Zechariah see? He saw a man with a tape measure and a city without walls. What did it mean? 23 The people had built their own homes but had not rebuilt the Temple. The measure was a symbol of building. They were to rebuild both the Temple and the city, and the people would grow and prosper. The city with “no walls” was symbolic because God had told Nehemiah to build walls. God was telling his people to put their trust in him and not in the stone walls. This was an indication of the day when God’s kingdom would have no boundaries. What does it mean for us? We are also asked to build God’s kingdom – without walls, all must be invited in. We don’t need tangible walls to protect us. God said (verse 5), “I will be a wall of fire around it” (represents the Holy Spirit). The Lord is our security and we are part of his city without walls. being burned by the fire. And then he reclothed Joshua in clean garments. Israel hadn’t been able to atone for their sin for over 70 years in exile. Now, they were being given a new chance, a fresh start, restoration and renewal. What does it mean for us? Joshua was a “type” of Jesus – both names mean Saviour. Jesus, our great High Priest, put on our dirty garments when he was made sin for us on the cross. He made himself unclean so that he deserved the punishment of hell. But God rescued him and raised him up and exalted him to the highest place, so that he is above all things. Just as the work of Joshua brought atonement for Israel, so the work of Jesus brings atonement for us. FIFTH VISION Read chapter 4v2-4 What did Zechariah see? He saw a seven-branched lampstand – the kind used in the Tabernacle – a reservoir of oil and two olive trees. What did it mean? Light always characterizes the Godhead. When God is present there is Light. The reservoir of oil speaks of the Holy Spirit perpetually sustaining the light. Zerubbabel and Joshua were symbolized by the two olive trees, assisting in the work. The promise was that they would succeed in their rebuilding because the Spirit of the Lord was with them. What does it mean for us? God will help us build his church BY HIS SPIRIT. We as Christians, like the Israelites, are few. But the promises in verses 6 and 10 are true for us as well. 24 SIXTH VISION Read chapter 5v1-4 What did Zechariah see? He saw a flying scroll, 30’x 15’ – the exact dimensions of the Holy Place in the Tabernacle. On one side was written “theft” and on the other side was “lies”. What did it mean? The measure of the Holy Place is the standard (of absolute purity) against which God measures sin. The sin of the people was represented by the two words theft and lies. These two words can summarise the Ten Commandments. What does it mean for us? God’s Word must be our standard – not the world’s view. How do we measure up to God’s purity? SEVENTH VISION Read chapter 5v5-11 What did Zechariah see? He saw a woman (under a heavy lead cover) in a measuring basket, which was carried in the sky by two women with stork’s wings (therefore not to be confused with angels!). What did it mean? The measuring basket implied that the people had been weighed and found wanting. The woman in the basket was the personification of sin which was so bad it had to be kept down by a heavy lead weight. The destination of the basket was Babylon (Babel – a place synonymous with rebellion against God). Israel’s sin would be taken away (as in sixth vision), and removed to where sin belonged. What does it mean for us? When we ask God to forgive us he will literally take away our sin. Jesus Christ will ultimately deal with sin and the wickedness of Babylon (covered in Rev. chapters 17 and 18). Note: Babylon is mentioned over 350 times in the Bible and it nearly always represents opposition to God, beginning with Babel in Genesis, and ending with the woman Babylon in Revelation. EIGHTH VISION Read chapter 6v1-5 What did Zechariah see? He saw 4 chariots drawn by different coloured horses coming between two mountains of bronze. What does it mean? This may be apocalyptic. The valley could be Armageddon. In the Bible bronze symbolizes judgment and the four horsemen could represent angelic instruments of judgment. Seen as a sequel to the previous visions, it implies that all men and women will ultimately face God’s judgment (between two bronze mountains/ no way out of it) – because he alone is Sovereign over all; on that final day of judgment every knee will bow and confess that He is Lord. He will have the last word and He will make the final judgments. 25 The messages that God gives Zechariah from chapter 7 onwards are spoken after the rebuilding of the Temple. Chapter 7 In this chapter the people ask about mourning and fasting (v3) but God replies that he is not looking for outward show but for love and justice which come from the heart. Read verses 8-10 Chapter 8 This chapter deals with the restoration of Jerusalem. God would again be with his people. Read verse 3. Those who were scattered by their enemies would return (and be known as the remnant). Read verse 8.And the land and its crops would also know revival. Read verse 12. Chapter 9 This chapter looks to the future for Israel. Read verses 9 and 10. This is a prophecy of how Jesus did in fact enter Jerusalem on a foal of a donkey and Matthew made a point of recording it in his gospel – as if to say, “Look, this is the prophecy coming true.” Read Matthew 21v5. So that when Jesus rode into the city in that way some of the Jews recognized him as the promised Messiah. And by doing the impossible (riding on an unbroken colt) Jesus was also demonstrating his Lordship over all creation. Zechariah foresaw this wonder and recorded it so that we could know Jesus was all that he claimed to be. Q. In v.9 what 3 words stand out that show the qualities of Jesus? Chapter 10 The Messianic prophecy continues. Read verse 4, 6&7. Jesus is The Cornerstone, from Judah, from David’s line. The cornerstone speaks of three things. 1) A foundation stone that provides a standard for the building 2) A stone which joins walls going off at two different angles 3) It is a large solid rock which holds the building together. 4) Discuss how these apply to Jesus. Chapter 11 Read verses 7-14 The prophet speaks of the Good Shepherd who got rid of three bad shepherds, which may represent errant prophets, priests and kings (although that is only a suggestion). This Good shepherd had two staffs, called “Favour” and “Union”. The breaking of these staves became symbolic. 1) The staff called favour was broken because Israel’s favoured position was to come to an end when the Messiah came. The veil in the Temple was split/broken in two when Jesus died. The act of Judas (verse 12) was representative of the value that the Jews put on Jesus’ life and therefore it is not surprising that they lost favour with God. 26 2) The staff called Union was broken signifying that when Jesus came the Jews would no longer automatically be in union with God. They, along with everyone else, must come to him for salvation through Jesus Christ. Chapter 12 In this chapter Zechariah’s prophecy begins to talk about The Last Days when all the nations will gather against Jerusalem, ultimately in the Battle of Armageddon. We can already see the possibility of this. And God will make Jerusalem “an immovable rock” (v3). But God’s ultimate purpose is to restore Israel to himself. They had rejected him, he broke favour with them, but his desire is to renew relationship with him. Read verses 10&11. The Jews will realize the responsibility they bear for “the one they pierced” and they will devastated and grieve bitterly ... But ... Chapter 13 Read verse 1. They will not find judgment, but forgiveness and cleansing. They will understand the full meaning of the blood sacrifices. Read verse 9. They will also be sanctified. Chapter 14 Read verses 4,8,9,11 things in the Temple, but all things and all people in this new Living Temple. Every aspect of life will be holy and consecrated to the Lord. 27 MALACHI This prophecy was God’s final revelation to the Jews, some 400 years before the coming of Christ. This was a time when knowledge and learning were growing at a tremendous rate. The Greeks were beginning to rise in power and men like Socrates and Pythagoras and Hippocrates were soon to lay down the philosophy of scientific reasoning. The world was changing – but the people were the same. Malachi’s book reveals that, sadly, 100 years after the fresh start for the Jews and the rebuilding of the Temple, the people had once again lost their love and commitment to the Lord. In this book God makes 5 accusations, the people respond with questions and then God answers. FIRST ACCUSATION – God said, “You do not appreciate my love”. Read chapter 1v2&3 The answer of the people was unkind, “How have you loved us?” But we all know people today who might say that. God's answer to them seems a little strange at first, until you realize what it signifies. Jacob represented the Covenant that God made with Israel (God renamed him Israel. Read Genesis 35v9-12). Esau had rejected his birthright (his inheritance as the eldest) but Jacob had fought for it by ‘fair means and foul’. God’s love for them was a part of his covenant with them and an essential attribute of his character. The New Testament Covenant is the same for us, when we enter into it by accepting Jesus and what he accomplished on the Cross. In his love he has given everything to us. May we never be guilty of saying, “God doesn’t love me”. SECOND ACCUSATION – God said, “You do not respect my name”. Read chapter 1v6-9 The people were contemptuous in the very way they questioned to God (v6), showing their disrespect! “How have we shown contempt for your name?” God’s answer to them was to challenge their attitude to sacrifice and worship. Was their worship pure? Was it a sacrifice or were they only giving what they didn’t need for themselves? Was it a duty or a pleasure? Were they just taking God for granted? How is our church worship defined today? Do we give God the respect due to him? Do we “rob God” of part of ourselves? Read Romans 12v1&2 God held the priests responsible in Malachi’s day. Are the leaders of our churches to take responsibility for the quality of worship in our churches – or are we, as individuals? THIRD ACCUSATION – God said, “You are unfaithful in your relationships”. Read chapter 2v10-16 Basically – as is also true today in many cases – the people couldn’t see what their attitude to sex and marriage had to do with their relationship with God. “Why do we profane the 28 covenant by being unfaithful?” The people were still living under Persian rule and they had inherited many of their ways and things that were legal in Persian society. Today, in our country, deviant sexual relationships have become lawful, but they remain un-Biblical; things like homosexuality, one-night stands, divorce, voluntary single parenting etc. But God created us to be in a threefold relationship with him – man, wife and the Lord. And so it follows that marital and extramarital relationships have a direct influence on our relationship with God. God calls the breaking of marriage vows a ‘violent’ act. This is because it is breaking asunder that which God has put together, and is damaging to the threefold unity. Realistically, in this 21st century all this seems very out of date and many people, including a large proportion of Christians, will have made wrong choices in this area – or will have been wronged themselves. But it is still God’s ideal. Is it possible to make things right with God again? Read 1 John 1v9&10 FOURTH ACCUSATION – God said, “You weary me with your complaining”. Read chapter 2v17 – 3v4 This passage looks forward to the time when 1 John 1v9&10 would become possible. The people said, “How have we wearied him?” We shouldn’t complain about our lot. We should be examining ourselves, being honest about our shortcomings and we should repent and ask for God’s forgiveness and a fresh new start. If we have made a drastically wrong choice (e.g abortion or immoral lifestyle or drugs or violence etc) we often suffer for years afterwards. But we needn’t, because if we are honest and repentant, God will forgive us and wipe the slate clean. The same goes for less obvious “sins” of the heart (wrong attitude, jealousy, hatred, vindictiveness, pride etc). If we are not honest and repentant we must be prepared to take the consequences. Read 3v5. FIFTH ACCUSATION – God said, “You rob me of offerings and time”. Read Malachi 3v6-10 “How do we rob you?” they asked – and perhaps we might ask the same question. God is saying “when you repent and return to me I don’t want you to come with penance and selfpunishment, but by bringing me all that is rightfully mine”. The tithe (meaning a tenth of their produce or income) was a worship offering given to God in fellowship with one another and for the work of the Temple (church). Tithing is significant of obedience, sacrifice and communion. By neglecting to tithe, the people were not only robbing God, but themselves too. Is tithing only for Old Testament times or is it also for today? Read 2 Corinthians 8v7-12 and Philippians 4v16-19 God’s promise to us regarding tithing is in Malachi 3v10 When we honour God he always honours us. 29 Appendix 1 Place of the Prophets in Israel’s History King David (Wars fought and won) s King Solomon (40 years of peace) s Civil War (Division of the Land) s 10 Northern Tribes Israel (Capital Samaria) s Bad Kings s Prophets (Isaiah, Amos, Joel Hosea, Micah, Nahum) s Assyria (Captures Samaria and Disperses the people) Date: 722BC s 2 Southern Tribes Judah (Capital Jerusalem) s Good and bad Kings s Prophets (Habakkuk, Zephaniah Haggai, Zechariah etc) s Babylon (Judah destroyed and the people exiled to Babylon) Date: 587BC s Prophets to the exiles (Daniel, Ezekiel, Haggai Zechariah, Malachi) The Remnant (from those exiled) return to Jerusalem after 70 years. There followed a period of 400 years where there was no further prophecy until John the Baptist came. 30
https://issuu.com/ashingdonelim/docs/minor_prophets_july2014
CC-MAIN-2021-49
refinedweb
8,595
81.43
Hi, I want to make a program that opens a url, finds the data I need, and returns it to me. The problem is I have to login to the website, and I don't know how to do this. I've looked at some examples, and this is what I have so far. import urllib import urllib2 # Build opener with HTTPCookieProcessor o = urllib2.build_opener( urllib2.HTTPCookieProcessor() ) urllib2.install_opener( o ) # Parameters to submit p = urllib.urlencode( { 'stuident': 'stuid', 'stupassword': 'password' } ) # Login with params f = o.open( '', p ) data = f.read() print data f.close() It doesn't give any errors but it doesn't login either.
https://www.daniweb.com/programming/software-development/threads/198560/logging-in-to-a-website
CC-MAIN-2017-34
refinedweb
106
69.18
21 October 2013 18:00 [Source: ICIS news] HOUSTON (ICIS)--Here is Monday’s midday ?xml:namespace> CRUDE: Nov WTI: $99.80/bbl, down $1.01; Dec Brent: $109.65bbl, down 29 cents NYMEX WTI crude futures fell in response to the weekly supply statistics from the Energy Information Administration (EIA) showing a much greater-than-forecast build in crude stocks. The statistics for the week ended 11 October should have been released on 16 October but were delayed by the government shutdown. The delayed data also revealed a crude build at the NYMEX delivery hub in Cushing, Oklahoma. WTI bottomed out at $99.45/bbl before rebounding. RBOB: Nov $2.6658/gal, down 0.74 cents Reformulated blendstock for oxygen blending (RBOB) gasoline futures traded higher during early morning hours, but prices slipped by midday, levelling off around the $2.66/gal mark. The decline came despite the delayed EIA report, which showed a build in consumption and a decline in inventories. NATURAL GAS: Nov: $3.736/MMBtu, down 2.8 cents NYMEX natural gas futures began the week sliding several cents, losing value on changing weather forecasts, which now show warmer-than-anticipated temperatures across the Midwest and east coast for early November and concerns surrounding strong production levels. ETHANE: wider at 25.50-25.75 cents/gal The ethane spot price range widened as demand from crackers remained steady. A drop in natural gas prices midday kept ethane from rising further. AROMATICS: benzene down at $3.90-4.05/gal Prompt benzene spot prices were discussed at $3.90-4.05/gal early in the day, sources said. The range was down from $4.04-4.09/gal FOB (free on board) the previous session. OLEFINS: ethylene lower at 44.00-48.75 cents/lb, PGP bid lower at 62 cents/lb US October ethylene bid/offer levels fell to 44.00-48.75 cents/lb to start Monday from 46.00-50.00 cents/lb at the close of the previous week. US polymer-grade propylene (PGP) bid levels fell slightly to 62.00 cents/lb from 62.25 cents/lb against no fresh
http://www.icis.com/Articles/2013/10/21/9717292/NOON-SNAPSHOT---Americas-Markets-Summary.html
CC-MAIN-2015-22
refinedweb
358
70.09
"Daniel Wallin" <dalwan01 at student.umu.se> writes: I wrote: >> >>. > > I meant composing typelist's with '+' opposed to composing > the typelist manually like in BPL. I think we agree that's probably minor. >> >> >> > [ ... ]. > > Right, we don't have nested classes. We have thought about a > few solutions: > > class_<A>("A") > .def(..) > [ > class_<inner>("inner") > .def(..) > ] > .def(..) > ; Looks pretty! > Or reusing namespace_: > > class_<A>("A"), > namespace_("A") > [ class_<inner>(..) ] > > We thought that nested classes is less common than nested > namespaces. Either one works; I like the former, but I think you ought to be able to do both. >> >>. > > Right. We have a general conversion function for all > user-defined types. We actually have something similar, plus dynamic lookup **as a fallback in case the usual method doesn't work** > More on this later. OK >> There is still an issue of to-python conversions for wrapped >> classes; different ones get generated depending on how the class is >> "held". I'm not convinced that dynamically generating the smart >> pointer conversions is needed, but conversions for virtual function >> dispatching subclass may be. > > I don't understand how this has anything to do with ordering. Unless > you mean that you need to register the types before executing > python/lua code that uses them, which seems pretty obvious. :) It has nothing to do with ordering; I'm just thinking out loud about how much dynamic lookup is actually buying in Boost.Python. >> >> >>. > > Right. We didn't really intend for luabind to be used in this way, > but rather for binding closed modules. I think I'm saying that on some systems (not many), there's no such thing as a "closed module". If they're loaded in the same process, they share a link namespace :( >> >. > > Your converter implementation with static ref's to the > registry entry is really clever. Thanks! > Instead of doing this we have general converters which is used to > convert all user-defined types. I have the same thing for most from_python conversions; the registry is only used as a fallback in that case. >. > As mentioned before, lua can have multiple states, so it would be > cool if the converters would be bound to the state somehow. Why? It doesn't seem like it would be very useful to have different states doing different conversions. > This would probably mean we would need to store a hash table in the > registry entries and hash the lua state pointer (or something > associated with the state) though, and I don't know if there is > sufficient need for the feature to introduce this overhead. > > I don't know if I understand the issues with multiple extension > modules. You register the converters in a map with the typeinfo as > key, but I don't understand how this could ever work between > dll's. Do you compare the typenames? Depends on the platform. See my other message and boost/python/type_id.hpp. > If so, this could never work between modules compiled with different > compilers. If they don't have compatible ABIs you don't want them to match anyway, but this is currently an area of weakness in the system. > So it seems to me like this feature can't be that useful, > what am I missing? Well, it's terribly useful for teams who are developing large systems. Each individual can produce wrappers just for just her part of it, and they all interact correctly. >. > For clarification: > > void dispatcher(..) > { > *storage here* > try all overloads > call best overload > } I've already figured out how to solve this problem; if we can figure out how to share best-conversion technology I'll happily code it up ;-) -- Dave Abrahams Boost Consulting
https://mail.python.org/pipermail/cplusplus-sig/2003-June/004156.html
CC-MAIN-2016-36
refinedweb
611
64.3
0 I know how the ++ operator and -- operator works.This is my code to count the no of digit in an integer and it works perfectly. import java.util.Scanner; public class modified_sepadigit { public static void main(String args[]) { Scanner input=new Scanner(System.in); System.out.println("Enter a number"); int no=input.nextInt(); int noOfDigit=0; int tempNo=no; while(tempNo>=1) { tempNo=tempNo/10; noOfDigit++; } System.out.println("No of digits:"+ noOfDigit); } } But if i change noOfDigit++ in the while loop to noOfDigit=noOfDigit++, then i always get ouput as 0. Now i know that it is meaningless to write noOfDigit=noOfDigit++ when i can simply write noOfDigit++ What i think is that If that statement worked then i should get input as the (total no of digits in an number) -1 beacause of the way post increment works. Can anybody tell me why i am getting output as 0 always if i change noOfDigit++ in the while loop to noOfDigit=noOfDigit++ ?
https://www.daniweb.com/programming/software-development/threads/426719/doubt-regarding-operator
CC-MAIN-2016-50
refinedweb
165
53.61
> Anyone know if something changed in xalan that requires a new chage. I > noticed this in the BUGS section of the xalan 0.19.4 distro : > >Namespace axes is not implemented. > > but I don't know what that means :-) This has nothing to do with your problem, it referes to the namespace axes, as in select="namespace::foo". It has since been implemented. Your error seems strange, and I've not seen it before. We just did some work on the namespace handling in stylesheets (namely for performance reasons), so perhaps this is fixed. -scott |------------------------+------------------------+------------------------| | | Mike Engelhart | | | | <mengelhart@earthtrip| To: | | | .com> | Cocoon Dev | | | | <cocoon-dev@xml.apach| | | 02/24/00 10:23 AM | e.org> | | | Please respond to | cc: | | | cocoon-dev | (bcc: Scott | | | | Boag/CAM/Lotus) | | | | Subject: | | | | xalan namespace not | | | | found | |------------------------+------------------------+------------------------| I just dropped in Cocoon 1.7 with the included xalan and am getting this error for my XSL java extension. org.apache.xalan.xslt.XSLProcessorException: ElemTemplateElement error: Can not resolve namespace prefix: java This is my stylesheet header; <xsl:stylesheet xmlns: Anyone know if something changed in xalan that requires a new chage. I noticed this in the BUGS section of the xalan 0.19.4 distro : >Namespace axes is not implemented. but I don't know what that means :-)
http://mail-archives.apache.org/mod_mbox/cocoon-dev/200002.mbox/%3COFF37406FB.AB062B2F-ON8525688F.007AA3A2@lotus.com%3E
CC-MAIN-2014-49
refinedweb
212
68.16
Hello friends in this tutorial we are going to learn what is Object Oriented Programming in C#. Introduction: As we know there are three commonly used programming paradigms: - Procedural programming. - Functional programming - Object-oriented programming. C# has the support for both procedural and object-oriented programming. Object Oriented Programming uses objects and their interaction to design Program application. In Object Oriented Programming there are four main pillars: - Abstraction - Polymorphism - Encapsulation - Inheritance Why we need Object Oriented Programming? Before OOPs concepts were introduced, there was “Procedural” programming, that uses a bunch of functions and procedures while designing a software system. This makes the Software System more complex and hard to understand to maintain the software system. What is Object Oriented Programming? The OOP came with the new concepts of designing Software System. In Object Oriented Programming the software system is divided into small units called object and then builds data and function around these objects, which rise up decoupling and increases code re-usability. A most common use of decoupling in OOP is to polymorphically decouple the encapsulation. For code reusability, it is introduced by Inheritance and Generics concepts. Object-oriented programming (OOP) tries to lighten the problem by creating networks of objects, each like a small software “machine”. These objects are naturally smaller entities, simplifying the development task of each unit. However, when the objects co-operate in a system, they become the building blocks of the much more complex solution. Features of Object Oriented Programming: Class: A class is the blueprint of the object that uses variable for storing data and functions to perform operations on that data. It acts as a template for other classes. Since a Class is a logical representation of data so it does not occupy any space in the memory. We can simply create a class by using the Class keyword. Here is the example for creating a Class in C#. Class MyClass { //Functionality goes here } Object: Object Oriented Programming is all around Object, which means that it is the basic building block of C# Program. An object is anything in that exists in real world and can perform set of related operations that describe a behaviour of the object. For example, an Employee can have Employee ID and Name. An Object contains the data and methods called the member of the object. Memory is not allocated for the class until we do not create an object of the class using the new operator. When we create an object of the class without using new operator the memory will not be allocated in the heap. Suppose there is a class called Employee. class Employee { //Functionality Goes here } Here is the syntax for creating an object of the class. Employee objEmployee=new Employee(); You can see we have used “new” keyword to create an object of Employee class. Abstraction: Abstraction is the process of showing essential data and without showing the implementation. This means that Abstraction describes what an object does not how it does. We can achieve Abstraction using one of the features provided by C# like Interfaces, Abstract Classes, Inheritance and Encapsulation. Example: No need to go far way from programming. You can find a good example of abstraction in .Net framework, for example, List and collection. You use List and collection in most of the scenario in C#. These are the most abstract classes provided by .Net framework. Let’s make it more clearly by a real world example: In today’s life, all of us have a cell phone. Some people have a cell phone with facilities like calling and sending messages and some people have a cell phone with facilities like calling, sending messages, FM radio, Camera and some have a cell phone with calling, sending messages, FM radio, camera, Video Recording and Sending and Receiving Emails. Let’s understand above example into Programming Language. class ModelA01 { Calling(); SendingAndReceivingMessages(); } class ModelA02: ModelA01 { Calling(); SendingAndReceivingMessages(); FMRadio(); Camera(); } class ModelA03: ModelA01 { Calling(); SendingAndReceivingMessages(); FMRadio(); Camera(); VideoRecording(); SendingAndReceivingEmails } You can see ModelA01 shares common functionalities with other two model ModelA02 and ModelA03. So Abstraction is the common thing. Encapsulation: As now you can understand Abstraction is the process of showing the essential details. On the other hand, Encapsulation is the process of hiding essential detail outside the class and interface. Encapsulation is used to wrapping up data member and member function into a single unit such as class. Encapsulation is like your wallet in which you carry your money, Debit card, Credit card and Visiting card. class wallet { Money; DebitCard; CreditCard; VistingCard; WithdrawlMoneyUsingDebitCard(); } This means that encapsulation is the processing hiding confidential details from outside the world. Real World Example: Suppose when you will go to purchase a refrigerator from a shop, the sales person explains you about the capacity of the refrigerator, colour and how to use refrigerator now how it works. This process of hiding internal details is called Encapsulation. Let’s take a look at another example: Suppose a company don’t want to expose contact details of Employee by exposing only the necessary information. We can achieve this scenario using Encapsulation. class Employee { public string FirstName; public string LastName; protected string MobileNo; protected string Address; public string GetEmployeeName() { Return FirstName+” “+LastName; } } In the above example, we only expose Name of the Employee. We have declared MobileNo and Address as protected because we do not want to expose these details. Inheritance: Inheritance is the property through which a child class can access members of the parent class. Using inheritance we can extend the functionality of one class to other class. In this way, a class can act as a template for other classes. Inheritance provides us feature such as code reusability. Let’s take a look at below code: public class Shape { public Shape() { Console.WriteLine("Parent Class Constructor."); } public void printMessage() { Console.WriteLine("I'm a method of Shape Class."); } } public class Triangle: Shape { public Triangle() { Console.WriteLine("Triangle Class Constructor."); } public static void Main() { Triangle objTriangle= new Triangle(); objTriangle.printMessage (); } } Note: C# does not support multiple inheritances but it does support multi-level inheritance. Polymorphism: Polymorphism means many forms of one function. In polymorphism, the same function can behave in different forms. A good example of polymorphism is your mobile phone one name many forms. It can behave: - As a Phone. - As a Camera. - As an MP3 Player. - As an FM radio. Another example of polymorphism is a CAB which can be A.C. or Non A.C. Let’s take a look at a C# Program. class PolymorphismExample { Public int Sum(int Number1,int Number2) { Return Number1+Number2; } Public int Sum(int Number1,int Number2,int Number2) { Return Number1+Number2+Number3; } } You can see in the above program many forms of Sum functions. The first form takes two parameters, the Second form takes three parameters. Hope, this is a useful post for you. Thank You best drugstore foundation pharmacy rx one reviews online pharmacy drugstore approved canadian online pharmacies 24 hr pharmacy near me online pharmacy professional pharmacy pharmacy orlando mexican pharmacy online rx best drugstore bb cream india pharmacy pharmacy rx one reviews 24 hour drug store ed Wonderful article! We are linking to this great post on our site. Keep up the great writing.| Great post.| prescription drug neurontin neurontin 800 mg tablets best!. where can i buy generic methotrexate without prescription mexican pharmacies shipping to usa canadian rx canadia online pharmacy prednisone 20 mg tablets canada drugs pharmacy viagra light switch plate prescription pricing trusted overseas pharmacies prescription drugs online without doctor safe canadian online pharmacies australia cheap viagra free viagra and cialis samples viagra onlnine Cialis Oral Jelly (Orange) mexican pharmacies pharmacy intern gastro health canadian pharmacies without an rx canada pharmaceutical online ordering motion sickness best canadian mail order pharmacies trusted overseas pharmacies buy brand cialis discount cialis 20mg cialis black is it safe i need a payday loan bad credit no fee direct lender payday loans business loans based on cash flow canada pharmacy generic viagra thru paypal cheaper viagra pills cialis lilly kaufen cialis a leki na nadciЕ›nienie can cialis cause joint pain cash loan places in maryland roseville ca payday loans does consumer credit counseling help with payday loans cialis tanio cialis y arritmia cialis generika online apotheke fha loan cash deposits shareholder loaning money to corporation how to get a cash advance on a discover card how to buy viagra in usa viagra for female online india where can i buy viagra online in canada why is viagra so expensive natural viagra for men get viagra prescription Wonderful blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Cheers| I have noticed that in digital camera models, special receptors help to target automatically. Those kind of sensors connected with some camcorders change in contrast, while others start using a beam with infra-red (IR) light, specially in low lighting. Higher specification cameras occasionally use a mixture of both devices and may have Face Priority AF where the digital camera can ‘See’ any face while focusing only on that. Thanks for sharing your opinions on this blog site. Thanks in favor of sharing such a pleasant thinking, paragraph is nice, thats why i have read it completely| A motivating discussion is worth comment. There’s no doubt that that you need to write more about this subject, it may not be a taboo matter but generally folks don’t speak about these topics. To the next! Many thanks!!| Good day! I could have sworn I’ve been to this site before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely happy I found it and I’ll be book-marking and checking back often!| 275494 552799You need to have to join in a contest initial with the finest blogs on the internet. I most surely will suggest this internet site! 205193 Thanks so much for the article post.Much thanks again. Really Great. Why visitors still make use of to read news papers when in this technological globe all is accessible on web?| I know this website presents quality based articles and extra data, is there any other site which gives such things in quality?| Very informative post.Really looking forward to read more. Cool. Say, you got a nice blog post. Great. Im obliged for the blog.Thanks Again. Fantastic. Thanks a lot for the article post.Thanks Again. Great. I loved your article post.Really thank you! Really Great. Very neat article post. Keep writing. Im grateful for the article post.Really looking forward to read more. Much obliged. Im obliged for the blog article.Thanks Again. Great. I used to be able to find good advice from your articles.|
http://debugonweb.com/2017/05/object-oriented-programming/
CC-MAIN-2021-25
refinedweb
1,820
55.74
Borislav Hadzhiev Last updated: Apr 17, 2022 The error "Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render." occurs for 2 common reasons: <Route path="/about" element={About} />instead of <Route path="/about" element={<About />} />. Here is a simple example of how the error occurs. /** * ⛔️ Functions are not valid as a React child. * This may happen if you return a Component instead of <Component /> from render. * Or maybe you meant to call this function rather than return it. */ const App = () => { const getButton = () => { return <button>Click</button>; }; // 👇️ returning function not JSX element from render return <div>{getButton}</div>; }; export default App; The issue in the code snippet is that we are returning the getButton function from our render method instead of returning an actual JSX element. To solve the error in this scenario, we can call the function. const App = () => { const getButton = () => { return <button>Click</button>; }; // ✅ now returning the actual button // added parentheses () to call the function return <div>{getButton()}</div>; }; export default App; By calling the getButton function, we return the button element which solves the error. If you are trying to render an actual component, make sure to use it as <Component /> and not Component. const App = () => { const Button = () => { return <button>Click</button>; }; // ✅ Using component as <Button />, not Button return ( <div> <Button /> </div> ); }; export default App; Another common cause of the "Functions are not valid as a React child" error is when we pass an element to a react router route like <Route path="/about" element={About} />. // ⛔️ wrong syntax <Route path="/about" element={About} /> // ✅ right syntax <Route path="/about" element={<About />} /> In react router v6, instead of passing a children prop to the Route components, we use the element prop, e.g. <Route path="/about" element={<About />} />. When using react router, make sure to pass the component that should be rendered for the specific route as <Component /> and not Component.
https://bobbyhadz.com/blog/react-functions-are-not-valid-as-react-child
CC-MAIN-2022-40
refinedweb
323
51.18
14 December 2010 04:45 [Source: ICIS news] By ?xml:namespace> SINGAPORE “The prospect of rising oil prices, with the supply overhang - it’s going to squeeze market next year,” Standard and Poor’s corporate and infrastructure ratings analyst Andrew Wong told ICIS. Oil prices were hovering close to $90/bbl (€68/bbl), largely on account of the US dollar weakness that makes investments in dollar-denominated commodities more attractive. At noon, light sweet crude for January delivery was trading at $88.47/bbl, up by more than 8% from the start of the year. Among petrochemical products, ethylene gained 2.2% in value in northeast Asia from the start of the year, while toluene was up 1.1% while benzene fell 5.72% over the same period, according to ICIS data. “The improvement in demand is going to be quite important to support product prices. Otherwise, oil prices are creeping up ... increasing at a pace faster than product prices,” he said. Ethylene capacity additions in But demand has remained lacklustre as economic recovery had been, at best, tentative in the western economies. Debt problems in the eurozone, along with the continued fragility in the “A lot of petrochemical companies have been very thankful that “But I think they also realise that you can’t keep on telling investors or lenders that Given current market fundamentals, product prices may be a couple of years away from hitting pre-crisis levels, the S&P analyst said. “There’s going to be a fairly gradual improvement in the economics of the industry,” Wong said, adding that petrochemical companies may have to perform a “delicate balancing act” should crude prices continue to spike. “For some existing players, it might be good for a while - it [higher oil prices] might get product prices high once demand is coming back,” Wong said. “But there’s going to be a point when all these new capacities are going to … start producing and then that’s going to put a cap on product prices,” he said. S&P categorises the chemical, commodity and specialty chemical industries as "slightly higher risk" given their cyclical and capital-intensive nature, as well as due to volatility in product prices, said Wong. Meanwhile, a positive spin to the recently strong capacity additions was that capital expenditures would be less in the coming year, Wong said. Companies would be more focused on trying to mitigate the “challenging operating environment” and not overspend, he said. (.
http://www.icis.com/Articles/2010/12/14/9418727/rising-crude-may-squeeze-asia-petchem-margins-s.html
CC-MAIN-2013-20
refinedweb
412
51.58
How to use an image from a file as a background for a canvas - michael_recchione I've been trying the following: import canvas from PIL import Image im = Image.open("./myfile.jpg") image = im.tobitmap() canvas.draw_image(image,0,0,600,600) I keep getting the error on the line calling tobitmp: "ValueError: Not a bitmap" What am I doing wrong? Thanks! import canvas, clipboard, Image pil_image = Image.open('my_photo.png') clipboard.set_image(pil_image, format='png') canvas.set_size(*pil_image.size) canvas.draw_clipboard(0,0,*pil_image.size) There must be a way to do this without the clipboard but it was beyond me. - michael_recchione Thanks, this worked! I tried used one of the online converters to convert an image from jpg to bmp, but when I tried to use it with canvas.draw_image, it claimed that the bitmap compression wasn't supported. So, bottom line, I haven't yet been successful in getting draw_image() to work.
https://forum.omz-software.com/topic/1519/how-to-use-an-image-from-a-file-as-a-background-for-a-canvas
CC-MAIN-2022-27
refinedweb
155
50.12
Flutter is Google's UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. In this codelab, you'll finish an app that reports the number of stars on a GitHub repository. You'll use Dart DevTools to do some simple debugging. You'll learn how to host your app on Firebase. Finally, you'll use a Flutter plugin to launch the app and open the hosted privacy policy. What you'll learn - How to use a Flutter plugin in a web app - The difference between a package and a plugin - How to debug a web app using Dart DevTools - How to host an app on Firebase Prerequisites: This codelab assumes that you have some basic Flutter knowledge. If you are new to Flutter, you might want to first start with Write your first Flutter app on the web. What would you like to learn from this codelab? A plugin (also called a plugin package) is a specialized Dart package that contains an API written in Dart code combined with one or more platform-specific implementations. Plugin packages can be written for Android (using Kotlin or Java), iOS (using Swift or Objective-C), web (using Dart), macOS (using Dart), or any combination thereof. (In fact, Flutter supports federated plugins, which allow support for different platforms to be split across packages.) A package is a Dart library that you can use to extend or simplify your app's functionality. As previously mentioned, a plugin is a type of a package. For more information about packages and plugins, see Flutter Plugin or Dart Package? You need three pieces of software to complete this lab:. Enable web support Web support is in beta, so you must opt in. To manually enable web support, use the following instructions. In a terminal, run these commands: $ flutter channel beta $ flutter upgrade $ flutter config --enable-web You only need to run the config command once. After enabling web support, every Flutter app you create also compiles for the web. In your IDE (under the devices pulldown), or at the command line using flutter devices, you should now see Chrome and Web server listed. Selecting Chrome automatically starts Chrome when you launch your app. Selecting Web server starts a server that hosts the app so that you can load it from any browser. Use Chrome during development so that you can use Dart DevTools, and use the web server when you want to test your app on other browsers. For this codelab, we provide much of the starting code so that you can quickly get to the interesting bits. Create a simple, templated Flutter app. Use the instructions in Create your first Flutter app. Name the project star_counter (instead of myapp). Update the pubspec.yaml file. Update the pubspec.yaml file at the top of the project: name: star_counter description: A GitHub Star Counter app version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter flutter_markdown: ^0.3.0 github: ^6.1.0 intl: ^0.16.0 flutter: uses-material-design: true Fetch the updated dependencies. Click the Pub get button in your IDE or, at the command line, run flutter pub get from the top of the project. Replace the contents of lib/main.dart. Delete all of the code from lib/main.dart, which creates a Material-themed, count-the-number-of-button-presses app. Add the following code, which sets up a not-yet-complete, count-the-number-of-stars-on-a-GitHub-repo app: import 'package:flutter/material.dart'; void main() { runApp(StarCounterApp()); } class StarCounterApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( brightness: Brightness.light, ), routes: { '/': (context) => HomePage(), }, ); } } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { String _repositoryName = ""; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ConstrainedBox( constraints: BoxConstraints(maxWidth: 400), child: Card( child: Padding( padding: EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'GitHub Star Counter', style: Theme.of(context).textTheme.headline4, ), TextField( decoration: InputDecoration( labelText: 'Enter a GitHub repository', hintText: 'flutter/flutter', ), onSubmitted: (text) { setState(() { _repositoryName = text; }); }, ), Padding( padding: const EdgeInsets.only(top: 32.0), child: Text( _repositoryName, ), ), ], ), ), ), ), ), ); } } Run the app. Run the app on Chrome. If you're using an IDE, then first select Chrome from the device pulldown. If you're using the command line, then from the top of the package, run flutter run -d chrome. (If flutter devices shows that you have web configured but no other connected devices, then the flutter run command defaults to Chrome.) Chrome launches, and you should see something like the following: Enter some text into the text field followed by pressing Return. The text you typed is displayed at the bottom of the window. Next, instead of displaying the text that was entered in the form, " google/flutter.widgets", you modify the app to show the number of stars for that repo. Create a new file in lib called star_counter.dart: import 'package:flutter/material.dart'; import 'package:github/github.dart'; import 'package:intl/intl.dart' as intl; class GitHubStarCounter extends StatefulWidget { /// The full repository name, e.g. torvalds/linux final String repositoryName; GitHubStarCounter({ @required this.repositoryName, }); @override _GitHubStarCounterState createState() => _GitHubStarCounterState(); } class _GitHubStarCounterState extends State<GitHubStarCounter> { // The GitHub API client GitHub github; // The repository information Repository repository; // A human-readable error when the repository isn't found. String errorMessage; void initState() { super.initState(); github = GitHub(); fetchRepository(); } void didUpdateWidget(GitHubStarCounter oldWidget) { super.didUpdateWidget(oldWidget); // When this widget's [repositoryName] changes, // load the Repository information. if (widget.repositoryName == oldWidget.repositoryName) { return; } fetchRepository(); } Future<void> fetchRepository() async { setState(() { repository = null; errorMessage = null; }); var repo = await github.repositories .getRepository(RepositorySlug.full(widget.repositoryName)); setState(() { repository = repo; }); } @override Widget build(BuildContext context) { final textTheme = Theme.of(context).textTheme; final textStyle = textTheme.headline4.apply(color: Colors.green); final errorStyle = textTheme.bodyText1.apply(color: Colors.red); final numberFormat = intl.NumberFormat.decimalPattern(); if (errorMessage != null) { return Text(errorMessage, style: errorStyle); } if (widget.repositoryName != null && widget.repositoryName.isNotEmpty && repository == null) { return Text('loading...'); } if (repository == null) { // If no repository is entered, return an empty widget. return SizedBox(); } return Text( '${numberFormat.format(repository.stargazersCount)}', style: textStyle, ); } } Observations - The star counter uses the github Dart package to query GitHub for the number of stars a repo earned. - You can find packages and plugins on pub.dev. - You can also browse and search packages for a particular platform. If you select FLUTTER from the landing page, then on the next page, select WEB. This brings up all of the packages that run on the web. Either browse through the pages of packages, or use the search bar to narrow your results. - The Flutter community contributes packages and plugins to pub.dev. If you look at the page for the github package, you'll see that it works for pretty much any Dart or Flutter app, including WEB. - You might pay particular attention to packages that are marked as Flutter Favorites. The Flutter Favorites program identifies packages that meet specific criteria, such as feature completeness and good runtime behavior. - Later, you add a plugin from pub.dev to this example. Add the following import to main.dart: import 'star_counter.dart'; Use the new GitHubStarCounter widget. In main.dart, replace the Text widget (lines 60-62) with the 3 new lines that define the GitHubStarCounterWidget: Padding( padding: const EdgeInsets.only(top: 32.0), child: GitHubStarCounter( // New repositoryName: _repositoryName, // New ), // New ), Run the app. Hot restart the app by clicking the Run button again in the IDE (without first stopping the app), clicking the hot restart button in the IDE , or by typing r in the console. This updates the app without refreshing the browser. The window looks the same as before. Enter an existing repo, such as the one suggested: flutter/flutter. The number of stars is reported below the text field, for example: Are you ready for a debugging exercise? In the running app, enter a non-existent repo, such as foo/bar. The widget is stuck saying "Loading...". You fix that now. Launch Dart DevTools. You may be familiar with Chrome DevTools, but to debug a Flutter app, you'll want to use Dart DevTools. Dart DevTools was designed to debug and profile Dart and Flutter apps. There are a number of ways to launch Dart DevTools, depending on your workflow. The following pages have instructions about how to install and launch DevTools: - Launch DevTools from Android Studio or IntelliJ. - Launch DevTools from VS Code. - Launch DevTools from the command line. Bring up the debugger. The initial browser page you see when Dart DevTools launches can be different, depending on how it was launched. Click the Debugger tab , to bring up the debugger. Bring up the star_counter.dart source code. In the Libraries text field, in the lower left, enter star_counter" Double-click the package:star_counter/star_counter.dart entry from the results list, to open it in the File view. Set a breakpoint. Find the following line in the source: var repo = await github.repositories. It should be on line 52. Click to the left of the line number, and a circle appears, indicating that you set a breakpoint. The breakpoint also appears in the Breakpoints list on the left. On the upper right, select the Break on exceptions checkbox. The UI should look like the following: Run the app. Enter a non-existent repository and press Return. In the error pane, below the code pane, you'll see that the github package threw a "repository not found" exception: Error: GitHub Error: Repository Not Found: / at Object.throw_ [as throw] () at at github.GitHub.new.request () at request.next (<anonymous>) at at _RootZone.runUnary () at _FutureListener.thenAwait.handleValue () at handleValueCallback () at Function._propagateToListeners () at _Future.new.[_completeWithValue] () at async._AsyncCallbackEntry.new.callback () at Object._microtaskLoop () at _startMicrotaskLoop () at Catch the error. In star_counter.dart, find the following code (lines 52-56): var repo = await github.repositories .getRepository(RepositorySlug.full(widget.repositoryName)); setState(() { repository = repo; }); Replace that code with code that uses a try-catch block, to behave more gracefully by catching the error and printing a message: try { var repo = await github.repositories .getRepository(RepositorySlug.full(widget.repositoryName)); setState(() { repository = repo; }); } on RepositoryNotFound { setState(() { repository = null; errorMessage = '${widget.repositoryName} not found.'; }); } Hot restart the app. In DevTools, the source code is updated to reflect the changes. Once again, enter a non-existent repo. You should see the following: You've found something special! In this step you'll add a privacy policy page to your app. At first, you will embed the privacy policy text in your Dart code. Add a lib/privacy_policy.dart file. In the lib directory, add a import 'package:flutter/widgets.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; class PrivacyPolicy extends StatelessWidget { @override Widget build(BuildContext context) { return Markdown( data: _privacyPolicyText, ); } } // The source for this privacy policy was generated by // var _privacyPolicyText = ''' ## Privacy Policy Flutter Example Company built the Star Counter app as an Open Source app. This SERVICE is provided by Flutter Example Star Counter unless otherwise defined in this Privacy Policy. '''; Add the following import to main.dart: import 'privacy_policy.dart'; Add a new route (page) for the privacy policy. After line 17, add the route for the privacy policy page: routes: { '/': (context) => HomePage(), '/privacypolicy': (context) => PrivacyPolicy(), // NEW }, Add a button to display the privacy policy. In the _HomePageState's build() method, add a FlatButton to the bottom of the Column, after line 65: FlatButton( color: Colors.transparent, textColor: Colors.blue, onPressed: () => Navigator.of(context).pushNamed('/privacypolicy'), child: Text('Privacy Policy'), ), Run the app. Hot restart the app. It now has a Privacy Policy link at the bottom of the screen: Click the Privacy Policy button. Note that the privacy policy displays, and the URL changes to Go back. Use the browser's Back button to return to the first page. You get this behavior for free. The advantage of a hosted page is that you can change that page, without releasing a new version of your app. From the command line, at the root of the project, use the following instructions: Install the Firebase CLI. Log in to Firebase to authenticate using firebase login. Initialize a Firebase project using firebase init. Use the following values: - Which Firebase features? Hosting - Project setup: Create a new project - What project name? my-flutter-app (for example) - What to call your project? Press Return to accept the default (which is the same as the name used in the previous question). - What public directory? build/web (This is important.) - Configure as a single page app? y At the command line, you'll see something like the following after you finish running firebase init: At the completion of the init command, the following files are added to your project: firebase.json, the configuration file .firebaserc, containing your project data Make sure that the public field in your firebase.json specifies build/web, for example: { "hosting": { "public": "build/web", # This is important! "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } } Build a release version of your app. Configure your IDE to build a release version of your app using one of the following approaches: - In Android Studio or IntelliJ, specify --releasein the Additional arguments field of the Run > Edit Configuration dialog. Then, run your app. - At the command line, run flutter build web --release. Confirm that this step worked by examining the build/web directory of your project. The directory should contain a number of files, including index.html. Deploy your app. At the command line, run firebase deploy from the top of the project to deploy the contents of the public build/web directory. This shows the URL where it's hosted,>.web.app. In the browser, go to https://<project-id>.web.app or https://<project-id>.web.app/#/privacypolicy to see the running version of your privacy policy. Next, instead of embedding the privacy policy in the Dart code, you'll host it as an HTML page using Firebase. Remove the file from the lib directory of your project. Update main.dart. In lib/main.dart, remove the import statement import privacy_policy.dart and the Add Place this file in the web directory of your project. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Privacy Policy</title> </head> <body> <h2 id="privacy-policy">Privacy Policy</h2> <p>Flutter Example Company built the Star Counter app as an Open Source app. This SERVICE is provided by Flutter Example Company at no cost Star Counter unless otherwise defined in this Privacy Policy.</p> </body> </html> Next, you use the url_launcher plugin to open the privacy policy in a new tab. Flutter web apps are Single Page Apps (SPAs). This is why using the standard routing mechanism in our web example opens the privacy policy in the same web page. The URL launcher plugin, on the other hand, opens a new tab in the browser, launches another copy of the app, and routes the app to the hosted page. Add a dependency. In the pubspec.yaml file, add the following dependency (and remember, white space matters in a YAML file, so make sure that the line starts with two blank spaces): url_launcher: ^5.4.0 Fetch the new dependency. Stop the app, because adding a dependency requires a full restart of the app. Click the Pub get button in your IDE or, at the command line, run flutter pub get from the top of the project. Add the following import to main.dart: import 'package:url_launcher/url_launcher.dart'; Update the FlatButton's handler. Also in main.dart, replace the code that is called when the user presses the Privacy Policy button. The original code (on line 70) uses Flutter's normal routing mechanism: onPressed: () => Navigator.of(context).pushNamed('/privacypolicy'), The new code for onPressed calls the url_launcher package: onPressed: () => launch( '/#/privacypolicy', enableJavaScript: true, enableDomStorage: true, ), Run the app. Click the Privacy Policy button to open the file in a new tab. The primary advantage of using the url_launcher package is that (after the privacy policy page is hosted), it works on web and mobile platforms. An additional benefit is that you can modify the hosted privacy policy page without recompiling your app. For fun, you might want to launch an Android emulator, the iOS simulator, or a connected mobile device to test whether your app (and the device policy) works there too. After your finish with your project, remember to clean up: Delete your firebase project. Congratulations, you successfully completed the GitHub Star Counter app! You also got a small taste of Dart DevTools, which you can use to debug and profile all Dart and Flutter apps, not just web apps. What's next? - Try one of the other Flutter codelabs. - Learn more about the power of Dart Devtools. Continue learning about Flutter: - flutter.dev: The documentation site for the Flutter project - The Flutter Cookbook - The Flutter API reference documentation - Additional Flutter sample apps, with source code
https://codelabs.developers.google.com/codelabs/web-url-launcher
CC-MAIN-2020-50
refinedweb
2,837
51.24
Return-cmd Immediately exit from a script or a macro without generating any error. return [value] This command is particularly useful in an object script or in a script file script. The optional return value can only be used when returning from run.section( ), run.file( ), or run.dialog( ) calls. Note: Macros do not return values. Also, only integer return values from 0 to 255 are supported. Example 1 The following script defines a macro that takes an argument and types OK if the argument is greater than 2. Otherwise, it types Not OK. def test { if (%1 > 2) { type "OK"; return; } type "Not OK"; } In this case, test 1.876; would respond with Not OK. Example 2 If an object named Test contains the following script: if (var1 + 3 * var3 > 1) return 0; else return 1; A script that accesses the object can use the return value as follows: if (test.run()==0) type "Result OK"; else type "Result too small";
http://cloud.originlab.com/doc/LabTalk/ref/Return-cmd
CC-MAIN-2020-16
refinedweb
162
66.84
The. Thank you very much. 😉 I wrote some C# sample code to get an ISymbolReader from a managed PDB (Program Database) file and then… I hear IronPython is a great managed scripting language to embed in other managed apps, so I thought… Previously, I added IronPython scripting support to a real existing application, MDbg (a managed debugger… I hear IronPython is a great managed scripting language to embed in other managed apps, so I thought… Hi Mike, The link for downloading the updated Mdbg sample is broken. Can you please update? Thanks, Notre Okay, I think I’ve found it at. I’ve downloaded it and attempted to build the solution file, but I am getting many errors with most of them related to not being able to find the namespace Microsoft.Samples.Debugging.CorDebug.NativeApi. Are there any prerequisites to building the Mdbg sample? I’m using VS 2005 August CTP (along with August VS 2005 SDK). Thanks, Notre Notre – I’ve updated the link. I guess it got moved underneath us. The build issue is a known error. We have a fix and are working to publish it. More details here: Sorry about that. Here is a template for playing around with an extension for the MDbg sample (Mdbg is the managed debuggeer… I often publish little samples in this blog based off MDbg (which generally show off the debugging services…
https://blogs.msdn.microsoft.com/jmstall/2005/08/10/mdbg-sample-is-updated-for-beta-2-and-rtm/
CC-MAIN-2016-44
refinedweb
233
62.38
For literally years now the Roslyn team has been considering whether or not to release the C# and VB analyzers as open source projects, and so I was very happy but not particularly surprised to watch on Channel 9 a few minutes ago Anders announce that Roslyn is now available on CodePlex. What astonished me was that its not just a “reference” license, but a full on liberal Apache 2.0 license. And then to have Miguel announce that Xamarin had already got Roslyn working on linux was gobsmacking. Believe me, we cloned that repo immediately. I’m still mulling over the consequences of this awesome announcement; I’m watching Soma discuss Roslyn on Channel 9 right now, and Anders is coming up again soon for a Q&A session. (At 12:10 Pacific Daylight Time, here.) I am also on a personal level very excited and a little nervous to finally have a product that I spent years of my life working on widely available in source code form. Since I always knew that open sourcing was a possibility I tried to write my portions of it as cleanly and clearly as possible; hopefully I succeeded. Congratulations to the whole Roslyn team, and thanks for taking this big bold step into the open source world. Congratulations! C# has a great future ahead. I think this is very true. For libraries or products intended for developers to use, having the source encourages trust, maintains interest, and does more to keep the code flexible in the direction that its users want than any amount of focus groups or market research can hope to achieve. It promotes the organic growth that is crucial for any large piece of software to be great. How far has Microsoft come in the last 10 year…. This is amazing! Vive la Satya That is very cool; congratulations. If you’re so inclined, I’d love to see you pick a few parts of Roslyn that you found especially interesting or enjoyable and review them on your blog (or, perhaps, revisit some of your previous articles with code-in-hand). With the source being open, you can include extracts and references without worry of some kind of legal violation. Great idea! Excellent idea ! I also expect a lot of exciting questions on Stack Overflow about that ! It takes a long time for a battleship to turn. Man, but when it does. No doubt. One of the Build speakers said that in DevDiv the attitude is now “we need a good reason to NOT open source a library”. That is a complete 180 from how things were even a few years ago. To what extent does open-sourcing constitute documentation of (and commitment to) implementation details and associated quirky corner-cases, and to what extent can code still say “Even though this code will have predictable effects in various cases whose behavior is not defined by specification, programmers should not assume that future versions of the code will continue to have such effects.” On the one hand, if a method has various tricky but potentially-useful corner cases, specifying the behavior by specifying the code may be easier and more accurate than trying to list all the corner cases. On the other hand, such specification may preclude a more efficient implementation. How does one decide not just what a method should do, but the extent to which its behavior should be specified, and–if the code is published–what aspects of behavior should be explicitly disclaimed as unspecified? Source never specifies … that’s the worst possible idea in software engineering. With the NSA revelations in mind, I would argue this also increases confidence in the framework’s benevolent behavior, which may have been a factor of at least slight issue before. Is it too much to ask which parts you wrote, or contributed the most to? I’m personally interested in seeing and learning from your coding and design style. Everyone works on a little bit of everything, but most of my work was in the semantic analyzer. That is, anything that happens after lexing and parsing, and before code generation. Having not looked at the code for over a year, it’s undoubtedly been reorganized and rewritten. I’ve cloned it but haven’t read it yet; I’ll look over the code next week and see if there’s anything I want particularly to call out. In BUILD 2014 they mentioned .NET Native where IL code is passed to the VC++ backend compiler and getting highly optimised code. Anders said that this was “cool” and it was on their “wish list” for a long time. I recall in one of Charles “expert-to-expert” talk with you (and Erik Meijer) that its getting harder to maintain the “old technology” used behind the C# and VB compilers at the time of the interview and that the Roslyn project was suppose to take the place of the “old” technology of C# and VB compilers. Does this mean a 180 degree turn-around from the use of VC++ based compilers (based on the preview of .NET Native) and that VC++-based compilers still have a use and Roslyn will be meant for other uses? The C# compiler, including the reimplementation codenamed Roslyn, is in the business of consuming source code and producing MSIL. @Antonio, why do you think that competes with, replaces, or inhibits the use of a better optimizing compiler for the MSIL->machine code step? In SemanticModel.cs there’s a commented block as : Consider the following example: public class Base { protected void M() { } } public class Derived : Base { void Test(Base b) { b.M(); // Error – cannot access protected member base.M(); } } I wonder where I’ve seen that before. (-: Oops replied to the wrong comment. Apologies This is interesting. M() can be accessed either inside Base class or in Derived class by Derived_Object.M(). Since I always knew that open sourcing was a possibility I tried to write my portions of it as cleanly and clearly as possible. Whereas, for closed-source products, you do what exactly? :) Well, consider the following choice: (1) take an idiomatically-written-in-C, messy but efficient and correct algorithm from the original compiler. Port it over line-for-line to C#; do not bother to make it idiomatic C#. (2) Refactor the algorithm into idiomatic C#, but go no further. (3) Rewrite the algorithm from scratch to match the style and conventions of the Roslyn codebase. These are in order of both increasing cost and increasing likelihood of introducing a subtle bug — particularly a subtle incompatibility between the original compiler and the Roslyn compiler. My personal “sweet spot” preference was (2), but the guidance I got from the architects and managers of the Roslyn team was consistently to go for (3), even if it meant taking more time, writing more tests, spending more money and running higher risks. Had the project been closed source, if the only people who would bear the penalty of doing a merely “good enough” job were insiders, then (1) or (2) might have been the wiser choice. I think that’s great, personally. I love it when management support keeping the codebase clean and modern. Bugs in a clean codebase can be fixed, but a messy codebase is very hard to tidy up piecemeal. You never get it as good. The original C# compiler code is kinda of open-sourced via the SSCLI project. Was the only way Microsoft could get you to carry on contributing to Roslyn. Expect them to start assigning you issues on codeplex imminently. They’ve already started encouraging me to submit pull requests. I think they’re joking. I hope they’re joking! I guess they’ll be prompting Jon Skeet also for his pull requests Joking? How else can we get you to work for us for free? Isn’t it funny that code quality suddenly rises when you expect that important people, or large amounts of people, will scrutinize your work? This forces the last bit of laziness out of a developers working process. I must say that the code is of *very* high quality. And I did not realize that the compiler contains a non-trivial XML parser to parse XML comments :) Pingback: It’s a great day to be a .Net developer | Caffeinated Geek.ca How does one read such a large codebase? Where should one start? Does that mean your default answer to “Why doesn’t C# do X?” will now be followed by “… but feel free to implement it yourself”? I’m wondering, have you run the codebase through the Coverity engine? Yes!!! I’ve got a few mates who are big Java fans, and I’ve been fighting this uphill battle: they admit that C# is a more powerful language *but*! It’s not free, not open source, and made by Microsoft (the Enemy, the Evil Empire of the Software Universe, etc.) :-) Now my time has come! C# *is* now free and open soucre, it *is* multi-platform, and it’s still more powerful than Java! Hooray! Victory!!! When confronted with this, I tend to point out that Java is very much owned by Oracle, and that there are ISO standards for earlier versions of both C# and the CLI. Now you don’t have to work at Microsoft to contribute to C#. Looking forward to new features made by Lippert! Pingback: C# – Я свободен! | klnhomealone Great news! Thank you. Fortunately Apache 2.0 does not protect integrators of Roslyn from infringing Microsoft patents. So the implementation is freed from copyright hassles, but if you create your next .NET based set-top-box that competes with Xbox, you might be screwed by MS if you grew too big. Apache 2.0 does protect against patents that are used in the licensed work, I believe. Just not against any and all MS’s patents (that would be crazy). The patent issue was one of the reasons Linux distributions were hesitant to include Mono, but it seems to me now that that would no longer be a valid reason. Oh, sorry. My bad. I was still not up-to-date with Apache 1.0 and Apache 1.1. Of course, neither of us are lawyers, but Apache 2.0 is a GPL v3 compatible license blessed by Free Software Foundation. Wow. I must admit that Microsoft is changing. Pingback: Dew Drop – April 4, 2014 (#1758) | Morning Dew This, and .NET native, and (finally!) SIMD via RyuJIT…I’m quite excited to be a C# developer right now :) What makes you “a little nervous”? The fact that the code you wrote will be analyzed, reviewed and scrutinized by thousands of experienced developers that will blame you for any minor or major mistake? Not considering the crowds of black hat hackers that will exploit any single security vulnerability you caused… :-) Would making Classic Visual Basic 6 open source be considered a step back or a step forward? “Yes.” Pingback: Top 10 | Links of the Week #10 | 04/11/2014 | The SoftFluent Blog “Xamarin had already got Roslyn working on linux was gobsmacking.” What does this mean for Mono? Should we expect Mono to revive and replace code with Roslyn? Pingback: C# and VB are open sourced | Fabulous Adventures In Coding « The Wiert Corner – irregular stream of stuff Visual Studio 2013 Professional required for compilation ? Could that be a bit of a barrier to entry ? Visual Studio Community 2013 with Update 4 is a free (as in no cost) download that Scott Hanselman described as “… This is not Express. This is basically Pro. …”. While it has some minimal usage restrictions, I think this lowers the “barrier to entry” quite a bit. Pingback: Comment commentary | Fabulous adventures in coding
http://ericlippert.com/2014/04/03/c-and-vb-are-open-sourced/
CC-MAIN-2014-52
refinedweb
1,969
63.19
This chapter describes the schema objects that you use in Oracle Database Java environment: Overview of Schema Objects Resolution of Schema Objects Compilation of Schema Objects Unlike conventional Java virtual machine (JVM), which compiles and loads Java files, Oracle JVM, you must use the loadjava tool to create a Java class schema object from the class file or the source file and load it into a schema. To make a resource file accessible to Oracle JVM, you must use the loadjava tool to create and load a Java resource schema object from the resource file. The dropjava tool deletes schema objects that correspond to Java files. You should always use the dropjava tool to delete a Java schema object that was created with the loadjava tool. Dropping schema objects using SQL data definition language (DDL) commands will not update auxiliary data maintained by the loadjava tool and the dropjava tool. 10g,, it opens the archive and loads its members individually. There are no JAR or ZIP schema objects. Note:When you load the contents of a JAR into the database, you have the option of creating a database object representing the JAR itself. For more information, refer to "Database Resident JARs"... A developer can direct the loadjava tool to resolve classes or can defer resolution until run time. The resolver runs automatically when a class tries to load a class that is marked invalid. It is best to resolve before run time to learn of missing classes early. Unsuccessful resolution at run time produces a ClassNot, the loadjavatool resolves references to classes but not to resources. Ensure that you correctly load the resource files that your classes need. If you can, defer resolution until all classes have been loaded. This avoids a situation in which the resolver marks a class invalid because a class it uses has not yet been loaded. The schema object digest table is an optimization that is usually invisible to developers. The digest table enables the loadjava tool to skip files that have not changed since they were last loaded. This feature improves the performance of makefiles and scripts that call the loadjava tool for collections of files, some of which must, the loadjava tool computes a digest of the content of the file and then looks up the file name in the digest table. If the digest table contains an entry for the file name that has an identical digest, then the loadjava tool does not load the file, because a corresponding schema object exists and is up to date. If you call the loadjava tool with the -verbose option, then it will show you the results of its digest table lookups. Normally, the digest table is invisible to developers, because the loadjava tool and the dropjava tool keep the table synchronized with schema object additions, changes, and deletions. For this reason, always use the dropjava tool to delete a schema object that was created with the loadjava tool, even if you know how to drop a schema object using DDL.. Loading a source file creates or updates a Java source schema object and invalidates the class schema objects previously derived from the source. If the class schema objects do not exist, then the loadjava tool the loadjava -resolve option. The compiler writes error messages to the predefined USER_ERRORS view. The loadjava tool retrieves and displays the messages produced by its compiler invocations. The compiler recognizes some options. There are two ways to specify options to the compiler. If you run the loadjava tool with the -resolve option, then you can specify compiler options on the command line. You can additionally specify persistent compiler options in a per-schema database table, JAVA$OPTIONS. You can use the JAVA$OPTIONS table for default compiler options, which you can override selectively using a loadjava tool ojvmtc tool enables you to resolve all external references, prior to running the loadjava tool. The ojvmtc tool allows the specification of a classpath that specifies the JARs, classes, or directories to be used to resolve class references. When an external reference cannot be resolved, this tool either produces a list of unresolved references or generated stub classes to allow resolution of the references, depending on the options specified. Generated stub classes throw a java.lang.ClassNotfoundException, if it is referenced at runtime. The syntax is: ojvmtc [-help ] [-bootclasspath] [-server connect_string] [-jar jar_name] [-list] -classpath jar1:path2:jar2 jars,...,classes For example: ojvmtc -bootclasspath $JAVA_HOME/jre/lib/rt.jar -classpath classdir/lib1.jar:classdir/lib2.jar -jar set.jar app.jar The preceding example uses rt.jar, classdir/lib1.jar, and classdir/lib2.jar to resolve references in app.jar. All the classes examined are added to set.jar, except for those found in rt.jar. Another example is: ojvmtc -server thin@scott:localhost:5521:orcl -classpath jar1:jar2 -list app2.jar Password:password The preceding example uses classes found in the server specified by the connection string as well as jar1 and jar2 to resolve app2.jar. Any missing references are displayed to stdout. Table 11-1 summarizes the arguments of this command. The loadjava tool creates schema objects from files and loads them into a schema. Schema objects can be created from Java source, class, and data files. The loadjava tool the loadjava tool to terminate prematurely. These errors are displayed with the following syntax: exiting: error_reason This section covers the following: The syntax of the loadjava tool command is as follows: loadjava {-user | -u} user/[password][@database] [options] file.java | file.class | file.jar | file.zip | file.sqlj | resourcefile | URL... [-casesensitivepub] [-cleargrants] [-debug] [-d | -definer] [-dirprefix prefix] [-e | -encoding encoding_scheme] [-fileout file] [-f | -force] [-genmissing] [-genmissingjar jar_file] [-g | -grant user [, user]...] [-help] [-jarasresource] [-noaction] [-norecursivejars] [-nosynonym] [-nousage] [-noverify] [-o | -oci | oci8] [-optiontable table_name] [-publish package] [-pubmain number] [-recursivejars] [-r | -resolve] [-R | -resolver "resolver_spec"] [-resolveonly] [-S | -schema schema] [-stdout] [-stoponerror] [-s | -synonym] [-tableschema schema] [-t | -thin] [-unresolvedok] [-v | -verbose] [-jarsasdbobjects] [-prependjarnames] [-nativecompile] Table 11-2 summarizes the loadjava tool command arguments. If you run the loadjava tool multiple times specifying the same files and different options, then the options specified in the most recent invocation hold. However, there are two exceptions to this, as follows: If the loadjava tool does not load a file because it matches a digest table entry, then most options on the command line have no effect on the schema object. The exceptions are -grant and -resolve, which always take effect. You must use the -force option to direct the loadjava tool to skip the digest table lookup. The -grant option is cumulative. Every user specified in every invocation of the loadjava tool for a given class in a given schema has the EXECUTE privilege. This section describes the details of some of the loadjava tool arguments whose behavior is more complex than the summary descriptions contained in Table 11-2. You can specify as many .class, .java, .sqlj, .jar, .zip, and resource files as you want and in any order. If you specify a JAR or ZIP file, then the loadjava tool processes the files in the JAR or ZIP. There is no JAR or ZIP schema object. If a JAR or ZIP contains another JAR or ZIP, the loadjava tool the loadjava tool will also work, without having to learn anything about resource schema object naming. Schema object names are different from file names, and the loadjava tool names different types of schema objects differently. Because class files are self-identifying, the mapping of class file names to schema object names done by the loadjava tool is invisible to developers. Source file name mapping is also invisible to developers. The loadjava tool gives the schema object the fully qualified name of the first class defined in the file. JAR and ZIP files also contain the names of their files. However, resource files are not self identifying. The loadjava tool generates Java resource schema object names from the literal names you supply as arguments. Because classes use resource schema objects and the correct specification of resources is not always intuitive, it is important that you specify resource file names correctly on the command line. The perfect way to load individual resource files correctly is to run the loadjava tool, the loadjava tool, the loadjava tool creates two schema objects, alpha/beta/x.properties and ROOT/home/scott/javastuff/alpha/beta/x.properties. The name of the resource schema object is generated from the file name as entered. Classes can refer to resource files relatively or absolutely. To ensure that the loadjava tool and the class loader use the same name for a schema object, enter the name on the command line, which To simplify the process further, place both the class and resource files in a JAR, which makes the following invocations equivalent: % loadjava options alpha.jar % loadjava options /home/scott/javastuff/alpha.jar The preceding loadjava tool commands imply that you can use any path name to load the contents of a JAR file. Even if you run the redundant commands, the loadjava tool would realize from the digest table that it need not load the files twice. This implies that reloading JAR files is not as time-consuming as it might seem, even when few files have changed between the different invocations of the loadjava tool. { process associated with the loadjava tool. Some Oracle Database-specific optimizations for interpreted performance are put in place during the verification process. Therefore, the interpreted performance of your application may be adversely affected by using this option. [-optionfile <file>] This option enables you to specify a file with different options that you can specify with the loadjava tool. This file is read and processed by the loadjava tool before any other loadjava tool options are processed. The file can contain one or more lines, each of which contains a pattern and a sequence of options. Each line must be terminated by a newline character ( \n). For each file or JAR entry that is processed by the loadjava tool, the long name of the schema object that is going to be created is checked against the patterns. Patterns can end in a wildcard ( *) to indicate an arbitrary sequence of characters, or, the loadjava tool options are not cumulative. Rather, later options override earlier ones. This means that an option specified on a line with a longer pattern will override a line with a shorter pattern. This file is parsed by a java.io.StreamTokenizer. You can use Java comments in this file. A line comment begins with a #. Empty lines are ignored. The quote character is a double quote ( "). That is, options containing spaces should be surrounded by double quotes. Certain options, such as -user and -verbose, affect the overall processing of the loadjava tool and not the actions performed for individual Java schema objects. Such options are ignored if they appear in an option file. To help package applications, the loadjava tool looks for the META-INF/loadjava-options entry in each JAR it processes. If it finds such an entry, then it treats it as an options file that is applied for all other entries in the option file. However, the loadjava tool does some processing on entries in the order in which they occur in the JAR. If the loadjava tool has partially processed entities before it processes META-INF/loadjava-options, then it attempts to patch up the schema object to conform to the applicable options. For example, the loadjava tool alters classes that were created with invoker rights when they should have been created with definer rights. The fix for -noaction is to drop the created schema object. This yields the correct effect, except that if a schema object existed before the loadjava tool started, then it would have been dropped. [-publish <package>] [-pubmain <number>] The publishing options cause the loadjava tool: the loadjava tool to compile and resolve a class that has previously been loaded. It is not necessary to specify -force, because resolution is performed after, and independent of, loading. {-resolver | -R} resolver_specification This option associates an explicit resolver specification with the class schema objects that the loadjava tool, the loadjava tool the loadjava tool uses the user's default database. If specified, loadjava tool commands: Connect to the default database with the default OCI driver, load the files in a JAR into the TEST schema, and then resolve them: loadjava -u joe -resolve -schema TEST ServerObjects.jar Password: password Connect with the JDBC Thin driver, load a class and a resource file, and resolve each class: loadjava -thin -u SCOTT@dbhost:5521:orcl \ -resolve alpha.class beta.props Password: password Add Betty and Bob to the users who can run alpha.class: loadjava -thin -schema test -u SCOTT@localhost:5521:orcl \ -grant BETTY,BOB alpha.class Password: password This option indicates that JARs processed by the current loadjava tool are to be stored in the database along with the classes they contain, and knowledge of the association between the classes and the JAR is to be retained in the database. In other words, this argument indicates that the JARs processed by the current loadjava tool are to be stored in the database as database resident JARs. This option is used with the -jarsasdbobjects option. This option enables classes with the same names coming from different JARs to coexist in the same schema. The dropjava tool is the converse of the loadjava tool. the dropjava tool. the dropjavatool on the same source file. If you translate on a client and load classes and resources directly, then run the dropjavatool on the same classes and resources. You can run the dropjava tool either from the command line or by using the dropjava method in the DBMS_JAVA class. To run the dropjava tool the loadjava tool. The output is directed to stderr. Set serveroutput on and call dbms_java.set_output, as appropriate. This section covers the following topics: The syntax of the dropjava tool command is: dropjava [options] {file.java | file.class | file.sqlj | file.jar | file.zip | resourcefile} ... -u | -user user/[password][@database] [-genmissingjar JARfile] [-jarasresource] [-o | -oci | -oci8] [-optionfile file] [-S | -schema schema] [-stdout] [-s | -synonym] [-t | -thin] [-v | -verbose] Table 11-3 summarizes the dropjava tool arguments. This section describes a few of the dropjava tool arguments, which are complex. The dropjava tool interprets most file names as the loadjava tool the dropjava tool interprets the file name as a schema object name and drops all source, class, and resource objects that match the name. If the dropjava tool the dropjava tool uses the user's default database. If specified, then database can be a TNS name or an Oracle Net Services name-value list. -thin:@ database dropjava tool command: Drop all schema objects in the TEST schema in the default database that were loaded from ServerObjects.jar: dropjava -u SCOTT -schema TEST ServerObjects.jar Password: password Connect with the JDBC Thin driver, then drop a class and a resource file from the user's schema: dropjava -thin -u SCOTT@dbhost:5521:orcl alpha.class beta.props Password: password Earlier versions of the dropjava tool required that the classes, JARs, source, and resources be present on the machine, where the client or server side utility is running. The current version of dropjava has an option that enables you to drop classes, resources, or sources based on a list of classes, which may not exist on the client machine or the server machine. This list can be either on the command line or in a text file. For example: dropjava –list –u scott –v this.is.my.class this.is.your.class Password: password The preceding command drops the classes this.is.my.class and this.is.your.class listed on the command line without them being present on the client machine or server machine. dropjava –listfile my.list –u scott –s –v Password: password The preceding command drops classes, resources, or sources and their synonyms based on a list of classes listed in my.list and displays verbosely. the dropjava tool to remove the resources. The ojvmjava tool is an interactive interface to the session namespace of a database instance. You specify database connection arguments when you start the ojvmjava tool. It then presents you with a prompt to indicate that it is ready for commands. The shell can launch an executable, that is, a class with a static main() method. This is done either by using the command-line interface or by calling a database resident class. If you call a database resident class, the executable must be loaded with the loadjava tool. This section covers the following topics: The syntax of the ojvmjava tool command is: ojvmjava {-user user[/password@database ] [options] [@filename] [-batch] [-c | -command command args] [-debug] [-d | -database conn_string] [-fileout filename] [-o | -oci | -oci8] [-oschema schema] [-t | -thin] [-version | -v] -runjava [server_file_system] -jdwp port [host] -verbose Table 11-4 summarizes the ojvmjava tool arguments. Open a shell on the session namespace of the database orcl on listener port 2481 on the host dbserver, as follows: ojvmjava -thin -user SCOTT@dbserver:2481:orcl Password: password The ojvmjava tool commands span several different types of functionality, which are grouped as follows: ojvmjava Tool Command-Line Options This section describes the options for the ojvmjava tool command. the ojvmjava Tool Commands in the @filename Option This @ filename option designates a script file that contains one or more ojvmjava tool the ojvmjava tool to run another script file, then this file must exist in $ORACLE_HOME on the server. Enter the ojvmjava tool command followed by any options and any expected input arguments. The script file contains the ojvmjava tool command followed by options and input parameters. The input parameters can be passed to the ojvmjava tool on the command line. The ojvmjava tool processes all known options and passes on any other options and arguments to the script file. To access arguments within the commands in the script file, use &1...& n to denote the arguments. If all input parameters are passed to a single command, then you can type &* to denote that all input parameters are to be passed to this command. The following shows the contents of the script file, execShell: chmod +x SCOTT nancy /alpha/beta/gamma chown SCOTT /alpha/beta/gamma java hello.World &* Because only two input arguments are expected, you can implement the Java command input parameters, as follows: java hello.World &1 &2 Note:You can also supply arguments to the -commandoption in the same manner. The following shows an example: ojvmjava ... -command "cd &1" contexts After processing all other options, the ojvmjava tool passes contexts as argument to the cd command. To run this file, do the following: ojvmjava -user SCOTT -thin -database dbserver:2481:orcl \ @execShell alpha beta Password: password The ojvmjava tool hello.World alpha beta You can add any comments in your script file using hash ( ojvmjava tool. For example: #this whole line is ignored by ojvmjava This option controls whether or not the ojvmjava tool shell command Java runs executable classes using the command-line interface or database resident classes. When the -runjava option is present the command-line interface is used. Otherwise, the executable must be a database resident class that was previously loaded with the loadjava tool. Using the optional argument server_file_system means that the -classpath terms are on the file system of the machine running Oracle server. Otherwise, they are interpreted as being on the file system of the machine running the ojvmjava tool. This option specifies a debugger connection to listen for when the shell command java is used to run an executable. This allows for debugging the executable. The arguments specify the port and host. The default value of the host argument is localhost. These are used to execute a call to DBMS_DEBUG_JDWP.CONNECT_TCP from the RDBMS session, in which the executable is run. Running sess_sh Within Applications You can run sess_sh commands from within a Java or PL/SQL application using the following commands: This section describes the following commands available within the ojvmjava shell: Note:An error is reported if you enter an unsupported command. Table 11-5 summarizes the commands that share one or more common options, which are summarized in Table 11-5: This command displays displays a class. It does this either by using the command-line interface or using a database resident class, depending on the setting of the runjava mode. In the latter case, the class must have been previously loaded with the loadjava tool. the command with runjava mode off is: java [-schema schema] class [arg1 ... argn] The syntax of the command with runjava mode on is: java [command-line options] class [arg1 ... argn] where, command-line options can be any of those mentioned in Table 3-1. Table 11-6 summarizes the arguments of this command. Consider the following Java file, World.java: package hello; public class World { public World() { super(); } public static void main(String[] argv) { System.out.println("Hello@localhost:2481:orcl hello/World.class Password: password % ojvmjava -user SCOTT -database localhost:2481:orcl Password: password $ java hello.World alpha beta Hello displays the user name of the user who logged in to the current session. The syntax of the command is: whoami This command enables the client to drop the current connection and connect to different databases without having to reinvoke the ojvmjava tool with a different connection description. The syntax of this command is: connect [-service service] [-user user][-password password] You can use this command as shown in the following examples: connect -s thin@locahost:5521:orcl -u scott/tiger connect -s oci@locahost:5521:orcl -u scott -p tiger Table 11-7 summarizes the arguments of this command. This command queries or modifies the runjava mode. The runjava mode determines whether or not the java command uses the command-line interface to run executables. The java command: Uses the command-like interface when runjava mode is on Uses database resident executables when runjava mode is off Using the runjava command with no arguments displays the current setting of runjava mode. Table 11-8 summarizes the arguments of this command. This command queries or modifies whether and how a debugger connection is listened for when an executable is run by the Java command. Note:The RDBMS session, prior to starting the executable, executes a DBMS_DEBUG_JDWP.CONNECT_TCPcall with the specified port and host. This is called Listening. Using this command with no arguments displays the current setting. Table 11-9 summarizes the arguments of this command.
http://docs.oracle.com/cd/B28359_01/java.111/b31225/cheleven.htm
CC-MAIN-2015-48
refinedweb
3,766
54.02
1 //. 27 state1 [12]byte 28 sema uint32 29 } 30 31 func (wg *WaitGroup) state() *uint64 { 32 if uintptr(unsafe.Pointer(&wg.state1))%8 == 0 { 33 return (*uint64)(unsafe.Pointer(&wg.state1)) 34 } else { 35 return (*uint64)(unsafe.Pointer(&wg.state1[4])) 36 } 37 } 38 39 // Add adds delta, which may be negative, to the WaitGroup counter. 40 // If the counter becomes zero, all goroutines blocked on Wait are released. 41 // If the counter goes negative, Add panics. 42 // 43 // Note that calls with a positive delta that occur when the counter is zero 44 // must happen before a Wait. Calls with a negative delta, or calls with a 45 // positive delta that start when the counter is greater than zero, may happen 46 // at any time. 47 // Typically this means the calls to Add should execute before the statement 48 // creating the goroutine or other event to be waited for. 49 // If a WaitGroup is reused to wait for several independent sets of events, 50 // new Add calls must happen after all previous Wait calls have returned. 51 // See the WaitGroup example. 52 func (wg *WaitGroup) Add(delta int) { 53 statep := wg.state() 54 if race.Enabled { 55 _ = *statep // trigger nil deref early 56 if delta < 0 { 57 // Synchronize decrements with Wait. 58 race.ReleaseMerge(unsafe.Pointer(wg)) 59 } 60 race.Disable() 61 defer race.Enable() 62 } 63 state := atomic.AddUint64(statep, uint64(delta)<<32) 64 v := int32(state >> 32) 65 w := uint32(state) 66 if race.Enabled && delta > 0 && v == int32(delta) { 67 // The first increment must be synchronized with Wait. 68 // Need to model this as a read, because there can be 69 // several concurrent wg.counter transitions from 0. 70 race.Read(unsafe.Pointer(&wg.sema)) 71 } 72 if v < 0 { 73 panic("sync: negative WaitGroup counter") 74 } 75 if w != 0 && delta > 0 && v == int32(delta) { 76 panic("sync: WaitGroup misuse: Add called concurrently with Wait") 77 } 78 if v > 0 || w == 0 { 79 return 80 } 81 // This goroutine has set counter to 0 when waiters > 0. 82 // Now there can't be concurrent mutations of state: 83 // - Adds must not happen concurrently with Wait, 84 // - Wait does not increment waiters if it sees counter == 0. 85 // Still do a cheap sanity check to detect WaitGroup misuse. 86 if *statep != state { 87 panic("sync: WaitGroup misuse: Add called concurrently with Wait") 88 } 89 // Reset waiters count to 0. 90 *statep = 0 91 for ; w != 0; w-- { 92 runtime_Semrelease(&wg.sema, false) 93 } 94 } 95 96 // Done decrements the WaitGroup counter by one. 97 func (wg *WaitGroup) Done() { 98 wg.Add(-1) 99 } 100 101 // Wait blocks until the WaitGroup counter is zero. 102 func (wg *WaitGroup) Wait() { 103 statep := wg.state() 104 if race.Enabled { 105 _ = *statep // trigger nil deref early 106 race.Disable() 107 } 108 for { 109 state := atomic.LoadUint64(statep) 110 v := int32(state >> 32) 111 w := uint32(state) 112 if v == 0 { 113 // Counter is 0, no need to wait. 114 if race.Enabled { 115 race.Enable() 116 race.Acquire(unsafe.Pointer(wg)) 117 } 118 return 119 } 120 // Increment waiters count. 121 if atomic.CompareAndSwapUint64(statep, state, state+1) { 122 if race.Enabled && w == 0 { 123 // Wait must be synchronized with the first Add. 124 // Need to model this is as a write to race with the read in Add. 125 // As a consequence, can do the write only for the first waiter, 126 // otherwise concurrent Waits will race with each other. 127 race.Write(unsafe.Pointer(&wg.sema)) 128 } 129 runtime_Semacquire(&wg.sema) 130 if *statep != 0 { 131 panic("sync: WaitGroup is reused before previous Wait has returned") 132 } 133 if race.Enabled { 134 race.Enable() 135 race.Acquire(unsafe.Pointer(wg)) 136 } 137 return 138 } 139 } 140 } 141
https://golang.org/src/sync/waitgroup.go?s=3246:3273
CC-MAIN-2018-09
refinedweb
630
77.64
This article demonstrates how to use WMI (Windows Management Instrumentation) in C#, to retrieve several types of information about the processor, such as the CPU clock speed, Voltage, Manufacturer, and other properties. Included in the first .zip is the executable polls your system for all the implemented properties. The bench-marker looks like this: It seems that WMI is an unknown concept to many beginners and maybe it intimidates the somewhat more advanced ones. On the MSDN forums there are several questions on how to get CPU/Harddrive information. In this article I will demonstrate how to get a handful of CPU related properties, beginning on what hopefully will become a series of WMI articles/wrappers in the near future. To use the wrapper, download the .cs file and place it in your application's solution folder: WMI_ProcessorInformationWrapper.zip - 901 B. Next add a using reference to the namespace: using WMI_ProcessorInformation; the last step is to call one of the static methods like this: WMI_Processor_Information.GetCpuManufacturer(); That's really all that there is to using the wrapper, so now lets take a tiny peek at some of what goes on behind the scenes. Most of the methods look like this one conveinient way of getting CPU information through the wrapper. To learn more about WMI check out some the great article here on codeproject: CodeProject Search for WMI WMI is very powerfull and can be used to get the properties of many different system components such as: P.S. As this is my first article please cut me at least a little slack, but I am NOT opposed to constructive critisism and we'll have an article version at 2.5 before you know it. V 0.9 ~Initial release. General News Question Answer Joke Rant Admin
http://www.codeproject.com/KB/system/Wmi_Processor_infoWrapper.aspx
crawl-002
refinedweb
297
62.88
When a ceylon module imports "java.base" "8" it doesn't see the original java.lang classes, but it gets something else. So when I want a parsing from a java string to a java integer I have to cast java string to ceylon string and then parse it into java integer. module.ceylon: native("jvm") module mod "1.0.0" { import java.base "8"; } import java.lang{ JI = Integer, JS = String, } // strange: // java String constructor expects ceylon strings // in pseudo dotted ceylon : java.lang.String(ceylon.language.String s) JS t = JS("fdsf" of String); // very strange: // javas base library expects ceylon base types: // java.lang.Integer.valueOf(ceylon.language.String s) JI ji = JI.valueOf(t.string); // Where t is a java String. // strange like an elephant: // JI.valueOf(t.string) returns a java type. // for some purposes it's ok, // but where can I buy the complete documentation ??? JI ji = JI.valueOf(t.string); I’m not sure how to answer your question, because you’re saying a lot that isn’t really a question, and then you’re asking several questions too. But here goes: So please show how to achieve a direct conversion between java type (primitive and wrapped). I'm not talking about arrays and other stuff contained in ceylon.interop.java. import ceylon.language { CInteger=Integer } import java.lang { JInteger=Integer } shared void run() { CInteger ci1 = 1; JInteger ji1 = JInteger(ci1); JInteger ji2 = JInteger.valueOf(ci1); CInteger ci2 = ji1.intValue(); } You can use the Java wrapper class’ constructor or the static valueOf method. To convert back, use intValue(). type mapping rules are applied incompletly: They are not. The rules are: j.l.String and the primitive types ( int, double etc.) are mapped to their Ceylon equivalents. All other types – including, as stated in There is no mapping between Java's wrapper classes like java.lang.Integer or java.lang.Boolean and Ceylon basic types, the wrapper classes – are not mapped. (Except for "ceylon.language.Integer?" which is mapped to "ceylon.language.Integer" or the like ...) The Java signature java.lang.Integer valueOf(java.lang.String) is therefore mapped to the Ceylon signature java.lang::Integer valueOf(ceylon.language::String), because java.lang.String is mapped and java.lang.Integer isn’t. The Integer constructor is mapped from java.lang.Integer Integer(int) to java.lang::Integer Integer(ceylon.language::Integer), because the primitive type int is mapped, but the wrapper class java.lang.Integer isn’t. This is exactly what the documentation tells you. Could you please give a full documentation of the differences between the original java.lang and the java.lang as seen from ceylon? How can I get the complete documentation of java.base as seen from ceylon (when not working in eclipse), generating one from reflection... ? I don’t think this is available, though it would probably be useful…
https://codedump.io/share/GLQauPxmh0h1/1/mapping-between-java39s-wrapper-classes-and-ceylon-basic-types-quotguessing-typesquot
CC-MAIN-2017-47
refinedweb
480
54.49
2.7.1 threadprivate Directive The threadprivate directive makes the named file-scope, namespace-scope, or static block-scope variables specified in the variable-list private to a thread. variable-list is a comma-separated list of variables that do not have an incomplete type. The syntax of the threadprivate directive is as follows: Each copy of a threadprivate variable is initialized once, at an unspecified point in the program prior to the first reference to that copy, and in the usual manner (i.e., as the master copy would be initialized in a serial execution of the program). Note that if an object is referenced in an explicit initializer of a threadprivate variable, and the value of the object is modified prior to the first reference to a copy of the variable, then the behavior is unspecified. As with any private variable, a thread must not reference another thread's copy of a threadprivate object. During serial regions and master regions of the program, references will be to the master thread's copy of the object. After the first parallel region executes, the data in the threadprivate objects is guaranteed to persist only if the dynamic threads mechanism has been disabled and if the number of threads remains unchanged for all parallel regions. The restrictions to the threadprivate directive are as follows: A threadprivate directive for file-scope or namespace-scope variables must appear outside any definition or declaration, and must lexically precede all references to any of the variables in its list. Each variable in the variable-list of a threadprivate directive at file or namespace scope must refer to a variable declaration at file or namespace scope that lexically precedes the directive. A threadprivate directive for static block-scope variables must appear in the scope of the variable and not in a nested scope. The directive must lexically precede all references to any of the variables in its list. Each variable in the variable-list of a threadprivate directive in block scope must refer to a variable declaration in the same scope that lexically precedes the directive. The variable declaration must use the static storage-class specifier. If a variable is specified in a threadprivate directive in one translation unit, it must be specified in a threadprivate directive in every translation unit in which it is declared. A threadprivate variable must not appear in any clause except the copyin, copyprivate, schedule, num_threads, or the if clause. The address of a threadprivate variable is not an address constant. A threadprivate variable must not have an incomplete type or a reference type. A threadprivate variable with non-POD class type must have an accessible, unambiguous copy constructor if it is declared with an explicit initializer. The following example illustrates how modifying a variable that appears in an initializer can cause unspecified behavior, and also how to avoid this problem by using an auxiliary object and a copy-constructor. int x = 1; T a(x); const T b_aux(x); /* Capture value of x = 1 */ T b(b_aux); #pragma omp threadprivate(a, b) void f(int n) { x++; #pragma omp parallel for /* In each thread: * Object a is constructed from x (with value 1 or 2?) * Object b is copy-constructed from b_aux */ for (int i=0; i<n; i++) { g(a, b); /* Value of a is unspecified. */ } } Dynamic threads, see Section 3.1.7 on page 39. OMP_DYNAMIC environment variable, see Section 4.3 on page 49.
https://msdn.microsoft.com/en-us/library/ch691419(v=vs.100).aspx
CC-MAIN-2018-17
refinedweb
577
50.16
Setting Up Cucumber for your Rails Projects Stay connected This is the 15th Testing Tuesday episode. Every week we will share our insights and opinions on the software testing space. Drop by every Tuesday to learn more! Last week we showed you how to set up RSpec with standalone Ruby applications and Rails web applications. Set up Cucumber for Ruby applications For all Ruby applications you can use the cucumber gem. In the screencast we walk you through creating a basic Ruby project and installing cucumber using bundler. We implement one passing scenario and make Cucumber use RSpec expectations instead of Minitest that ships with Ruby. Set up Cucumber for Rails web applications There is a special cucumber-rails gem that makes setting up Cucumber with Ruby on Rails web applications even easier. It contains a generator that prepares your app by adding preconfigured cucumber profiles, rake tasks and a Cucumber script. We'll look into the advantages in more detail in the screencast. Up next Testing Tuesday: JavaScript Testing with Jasmine Next week we'll show you how to test your Javascript with Jasmine. In the meantime check out our other episodes on Cucumber. You can find a list of them below in the "Further info" section. Further info: Testing Tuesday #8: Behavior-Driven Integration and Unit Testing Testing Tuesday #6: Top 5 Cucumber best practices Testing Tuesday #5: Test your web apps with Selenium Testing Tuesday #4: Continuous Integration and Deployment with Cucumber Testing Tuesday #3: Behavior-Driven Development with Cucumber Transcript Setting up Cucumber Ahoy and welcome! My name is Clemens Helm and this is Codeship Testing Tuesday #15. Last week I showed you how to set up RSpec for Ruby and Rails projects. This week we're gonna do the same thing for Cucumber. Thanks to Rafael who left me a comment and showed me an even faster way of setting up RSpec for a new project. I'll use your technique in this episode. We're gonna set up one standalone Ruby application and one Rails application, because there are a few differences in the setup. Let's get started with the standalone application first: Let's create an empty directory cucumber-app for our application. cd cucumber-app In the directory we initiate bundler by calling bundle init. This will create a Gemfile for us. Let's add the Cucumber gem gem "cucumber" and install it by running bundle. When we run cucumber now, it tells us "No such file or directory - features". Cucumber will look for our features in the "features" directory, so let's create it mkdir features and run cucumber again. It ran successfully without executing any features. Let's add a simple feature: mate ., create features/warm_welcome.feature Feature: Warm welcome In order to make my users feel comfortable on my website As the website owner I want to greet them appropriately Scenario: Greeting a sailor Given I am a sailor Then I want to be greeted "Ahoy and welcome!" Running cucumber lists the missing step definitions. Let's copy these snippets into a file "sailor_steps.rb" features/step_definitions/sailor_steps.rb: Given(/^I am a sailor$/) do @user = User.new type: :sailor end Then(/^I want to be greeted "(.*?)"$/) do |greeting| @user.greeting.should == greeting end Now cucumber tells us that it doesn't know the constant User. Let's add a user class in lib/user.rb. Cucumber still complains, because we need to require user.rb somewhere. Let's do that in the "sailor_steps.rb" file require "user" We get a different error message now, because the user's constructor doesn't accept any arguments yet. But how did Cucumber know where to look for the User class? We didn't eplicitly tell it to look in the lib directory. Like I already showed you in last week's episode, there's a global variable that contains the load paths of source files. When we print this variable in our Cucumber steps puts $: it will list our "lib" directory as first entry of the load paths. Cucumber added this directory, because there's a convention to put your Ruby classes there. Ok, let's remove the puts statement again. Cucumber complained about our constructor, so let's make it accept a "type" argument: def initialize type: type end Now Cucumber still misses the "greeting" method. def greeting end And now Cucumber complains that it doesn't know the method "should". The reason is that Cucumber doesn't contain the RSpec matchers. By default, you can use "Minitest" which is included in the Ruby standard library. We could rewrite our step definition as: Then(/^I want to be greeted "(.*?)"$/) do |greeting| assert_equal @user.greeting, greeting end This will give us the expected result. But how can we stick with our RSpec syntax? (undo change) We have to install "rspec-expectations". Let's add them to our Gemfile. gem "rspec-expectations" bundle cucumber And now our feature runs on RSpec. Great! Let's fix the error by greeting our sailor correctly: def greeting "Ahoy and welcome!" end Now our feature works! But what if we want to greet sailors on our Rails web application as well? Let's create a new Rails application for this. rails new rails-greeter We could use the cucumber gem here as well, but there is a special cucumber-rails gem that comes with additional goodies for Rails. Let's add it to the test-environment in our Gemfile: cd rails-greeter mate . group :test do gem 'cucumber-rails', require: false end We added require: false so Cucumber isn't loaded when we run other testing tools like RSpec. The cucumber command will require the cucumber gem anyway. It's also recommended to add the "database_cleaner" gem to your Gemfile. Database cleaner makes sure that your database is cleaned after every scenario. group :test do gem 'cucumber-rails', require: false gem 'database_cleaner' end Let's install these gems with Bundler. bundle install Cucumber-Rails provides us with a generator script to set up cucumber. We only need to run rails generate cucumber:install. This will do a few things: It creates a cucumber.yml file. This defines 3 cucumber profiles: default, work in progress and rerun. You can run cucumber with each of these profiles by passing the --profileoption. For example, if we run the "wip" profile, it will run scenarios tagged with "@wip" and complain, if there are more than 3 of them. You can customize the options for these profiles or add your own profiles in this file. It also creates a cucumber script. In Rails 4 this actually belongs in the "bin" directory, so let's move the file and delete the "script" directory. This script makes sure that the right cucumber distribution is required. The install script also adds directories for features, step definitions and support files and already creates the first support file "env.rb" which contains the Cucumber configuration. And it creates a rake file to run cucumber as a rake task. rake -T | grep cucumberThere are several tasks to run only subsets of your features. In general I recommend against using them though, because rake increases the load time for cucumber. It modifies the database.yml and creates an own cucumber enviroment which inherits from the test environment by default. I won't go into detail about how to write your features again, because it works the same way as for other Ruby applications. So the main advantage of the cucumber-rails gem is that it hooks directly into our rails application by creating everything that's necessary with the installation script. Outro If you haven't already, I highly recommend you to try Cucumber. The setup is very easy and I personally love working with it. In the next few days we'll review the book "Cucumber Recipes" which offers a Cucumber solution for almost every problem. Don't miss out on that! See you next Testing Tuesday when we'll take a look at Javascript testing with Jasmine. And please remember: Always stay shipping! Stay up to date We'll never share your email address and you can opt out at any time, we promise.
https://www.cloudbees.com/blog/cucumber-rails-setup/
CC-MAIN-2021-17
refinedweb
1,369
65.83
Your Account by Rick Jelliffe Country Vote Really No? Probably No? Probably Yes? Indie Parrot Off-topic material Radical Australia Abstain - X Austria Yes (X) Brazil No Bulgaria Canada No Use DrawingML rather than VML Chile - Field formatting. Use MathML, Use SMIL, Use SVG, Use ODF China Review time (Document 13) ? X? Remove VML Colombia OPC to separate standard Czech Republic Denmark Finland Dates before 1900. Remove VML. Use MathML France Date prior 1900, remove math pending mathml3 Germany Dates prior to 1900 Ghana Dates prior to 1900. (replace VML with DrawingML, adopt MathML) Great Britain Add ODF-isms, (replace VML with DrawingML, adopt MathML) Greece Dates prior to 1900, (replace VML with DrawingML, adopt MathML) India Use MathML, pre 1900 dates Iran Dates before 1900. Add ODF-isms Ireland Dates before 1900 Israel Italy Reference implementation, test suite Japan Publish OPC as separate standard Kenya Dates before 1900. Remove DrawingML Korea Needs interoperability with ODF. Remove VML and DrawingML Malta Mexico Dates before 1900 New Zealand Rename elements, vague Norway Split out DrawingML. Split out OPC Peru Philippines Poland Portugal Singapore South Africa Rewrite based on ODF. Make OPC a separate standard. Remove DrawingML and MathML Switzerland Thailand Time for review Tunisia Turkey US X remove VML, Drawing ML, OPC, compatibility, dates before 1900 Uruguay (replace VML with DrawingML, adopt MathML) Venezuela The other aspect to this is that MS itself is removing VML from Office: they just didn't around to doing it everywhere yet. So this is a good chance for MS to cooperate with Ecma and for Ecma to cooperate with the NBs to get something that would be win/win. (At a certain point it becomes more valuable PR for MS to say "We changed OOXML in response: it really is open" rather than the PR benefit of saying "Office 2007 follows the Ecma standard": the later would tend to retard their happiness for progress.) It is a big mistake to think that many of the NB changes are things that MS might not itself see as good things! For example, where there are fixed lists in the schema, these tend to tie the schema to a particular version of the product and therefore create a maintenance problem: undoubtedly MS will be having extra ideas for OOXML coming in from the Mac port and from ports by other vendors, and undoubtedly from localization too. Changing fixed lists to open lists (e.g. less enumerations, more simple tokens) reduces the validation power of the schema (which can be addressed by using derived schemas for a product) but increases the flexibility where MS can evolve Office. I expect the realistic resolution would be to move VML to a non-normative annex, and generalize where it is used so that multiple formats are possible, with DrawingML and VML being the ones that MS chooses to implement. So that nominally SVG could be used, but anyone who wanted actual interoperability would choose DrawingML. Or VML could be complete removed from DIS 29500 but still allowed by a conforming implementation. That solution doesn't invalidate any existing Office 2007 documents, doesn't make a deprecated language part of the normative standard, still documents VML, allows MS to retire VML from future versions of Office, and would allow other graphics formats to be used if there is some market requirement (e.g. if governments say "Drawings in SVG must be allowed"). Those are the kinds of trade-off that I expect would be well considered by NBs in advance of the BRM and at the BRM. Other possibilities and ideas should come up too of course. But I have said it a million times already, the idea will be win/win: NBs happy, Ecma happy. The BRM is there to try to negotiate making as many people happy, and even to make grumpy NBs less grumpy, so that they will think "We still cannot support this because of reasons A, B and C but it is good that D, E amd F have been fixed." I think it is always good for standards to have open lists: plurality has lots of evolution and growth benefits at the expense of the advantage of fixed lists where interopability can be "guaranteed". You can find the link on Alex Brown's blog. I am giving his page rather the link directly, because he has a different perspective. The big thing, of course, is to read the countries vote before reading the comments. Sometimes NBs just send on all the comments they think are relevant even if they were not convincing to the NB: so a country can vote yes, but have quite ranty or radical comments that don't actually have consensus at the NB. I think this is really slack myself, but the level of heat is causing it: the BRM will be very aware that the radical issues that yes-voting NBs raise are not being presented by the NB as must-haves. At this point, they seem to be moving away from that kind of component, however, and moving into Silverlight/XAML. Again, one has to stop looking exclusively at office documents which are fast becoming dodos, and look at the interactive apps where information is rendered into dashboard widgets and eventually these become map layers in a higher dimensional display system such as the virtual earth systems emerging. Now the namespace dominance implodes and the text/data portions are wrapped in the graphics portion as a map layer. The hard trick for standards building is to precisely target their effective time of governance before they should be retired. It seems strange that an ISO national body would recommend using a non-ISO standard that is more limited than a proposed format which could be part of ISO standards. On the issue of MathML, I think originally it actually contains two languages: one is a presentation-based language and the other is a semantic based one (think Mathematica). And within formulae there are lots of sub-domains (specialist mathematics and so on) that make it quite tricky to capture things adequately for everyone. And the needs of laymen and students may be different from the needs of professional mathematicians and quality typesetters. Plus it is a notoriously conservative trade, so people who start off in TeX don't see any value in changing. It is not an area of typesetting I would take sides on without a lot more study. What I would say is that I think we can adopt a four-layer view of documents: the bottom layer is field notations, such as ISO 8601, which are usually in attribute values; the second layer is in utility namespaces, such as XLink and Dublin Core, which provide very simple capabilities for all sorts of applications; the third is in topical namespaces, which provide information from a certain angle, such as MathML does for mathematics; and the top level are the application formats. I think the underlying challenge of the BRM is to come to grips with what the preferred practice should be for each layer: I see three choices, each with pros and cons: * One open standard option for each layer: I think this is the view that Tim Bray has pretty consistently articulated in many instances over the years: so you don't need JSON when you have XML; * A couple of standard families, where each family may be tightly coupled but no interbreeding between the races is tolerated: I think this is the position that both ODF and MS have taken in the past. * Systematic plurality, where each layer allows choice in the successive layers: this is what I have been calling for over most of the last decade. So the question is not XML or JSON, but whether the infrastructure supports them both well to allow developers to choose the appropriate one. Applying these three views to MathML, I think the single-standards people would say "It is a no-brainer: of course OOXML should drop its own maths and adopt the standard MathML"; the keep-it-in-the-family mob would say "They should do what they do best and we should do what we do best, and they should not be forced to support how we think and we should not be forced to support how they think, and the consumer has nice clear choice between Pepsi and Coke"; the pluralist would say, "what matters is that the framework allows both MathML and the OOXML Math to be provided, perhaps even both at the same time!" None of these three positions is intrinsically (and certainly not morally) wrong, but I don't think there will ever be agreement on which is best because I think they come from fairly deep things hard-wired into people's brains. If you look at the comments on my blog over the last year, you will regularly people saying "It goes without saying that the point of standards is to have only one" or "I don't see the need for standards, everyone can do their own thing" or "Let the market decide and don't get in the way of innovation": the three tendencies! So, naturally as a plurality, my POV is that it would be a great result if OOXML was checked to make sure that it could handle a switch to, say, the future MathML 3 without change. And indeed to handle specialist Math languages from other vendors alongside Office's native one or MathML as well. That is one reason I am keen on OPC: I think it is a good step in the right direction for supporting plurality. If you look at the way that email handles HTML mail, as a multipart message with a plain text part and an HTML part, so that the client mail reader can choose the one, that is exactly the pluralist kind of solution. Once you are aware of this aesthetic-psychological preference that people have, it becomes easier to figure what they think about standards. As a pluralist, when I think of standards, I think about things like MIME content types and the TCP/IP tree and even XML extensibility as the main game, while particular content types or protocols or schemas are just the decorations on the Christmas tree. A single-standard person would look at them and say "there is only one syntax for content types, only one syntax for XML WF, and in fact TCP/IP are tightly coupled" and feel that the sharp end of the sword was the fixity not the extensibility. Of course, I am stereotyping! I applaud your suggestion for the removal of any drawing specification from the OOXML document with an eye towards maintaining it as a distinct module. While it is possible that Microsoft may actually implement SVG, it is, as you point out, unlikely, and I feel that DrawingML adoption is similarly a non-start for Microsoft. One of my contentions against OOXML as a standard in the first place was the fact that it represented not one standard but a number of them, including a drawing module, a math module and so forth, each of which has its own inherent taxonomy. Perhaps one approach that I think would placate those of us on the other side of the OOXML divide would be for Microsoft to recognize where the natural modularization points within their proposed specification are and 1) provide separate modular specifications for each of these subschemas, 2) provide a reasonable extension mechanism such that other OOXML implementations could integrate their own modules into the larger OOXML framework. I see that as a potential win for both sides, as it gives Microsoft an excuse for providing a good faith effort on making the standard "open" while at the same time not significantly compromising upon their already significant investment in the proposed standard (or its underlying technology), while from the standpoint of competitors and the open source market such an effort makes it possible to implement non-MS OOXML systems that nonetheless take advantage of native open standards components such as SVG, XForms, and so on. For example, in the case of maths modules, it seems that there is a high degree of dispute which suggests that the pluralist approach is appropriate. But Math models (like tables and graphics) may have generic text in them, in which case you probably have to tightly couple the implementation of the equations with the typesetting system, which favours the multiple-independent traditions viewpoint. But text is highly generic and has many commonalities, which favours the single standard viewpoint. And text can contain graphics which favours the pluralist viewpoint. And so it goes. (None of the views is universally wrong unless they deny the other: but as a pluralist I suppose I would feel that whether it was right or wrong!) In any case, my suggestion is only that the BRM checks that the graphics is indeed substitutable: I don't see any particular benefit in removing VML and DrawingML, given the goals of the spec. In the back of my mind I have an idea from somewhere that actually there is a difference between what Office can accept and what it generates: DIS 29500 obviously needs to follow what it can (and will in the near term) accept (i.e. not the subset of what it generates.) I think it would be quite difficult to get rid of DrawingML and keep either PresentationML or SpreadsheetML, since both are thoroughly based on DrawingML, for example charting in Speadsheet ML. So that is why I don't include it as a touchstone issue. VML is a sitting duck. On the issue of modularity, actually there is a high degree of modularity at the part level: parts have relationship types that are independent of their schema so it is possible at the OPC level to have substitute (and sometimes multiple) alternate parts for the same relationship type (e.g. styles, or graphics). It is inside a particular part where there is usually no flexibility: the modularity is not of arbitrary grain but of the granularity of the OPC part. (Now there are a few other exceptions to this, but they are exceptions.) One way the standard could be substantially improved would be a clearer organization of the text against all the different namespaces, in particular to make it clear which where the real modularity (i.e. alternative/substitutable OPC parts) occurs and where a namespace is just a change in vocabulary but is not substitutable. (<rant>These kinds of issues are the things that NBs should have been looking at in their own independent reviews rather than dancing a panic-ridden tarantella to the piper's tune. Rather than just stopping at 'I think modularity is important' but actually figuring out some concrete proposal. But there still is five months, plenty of time.</rant>) hAl: I give UK checks in both the 'Indie' and 'Parrot' columns, they are not mutually exclusive. Then your table is screwed in both IE6 and IE7 because it definitly does not look that way to me. <p '> I've fixed it now. Thanks for the alert and apologies to IE users! When I released River of Life last week, I did it knowing that realistically only one VRML/X3D browser can support worlds at that complexity level: BS Contact. Irritatingly, we realized the new version dropped support for gif animation which plays a major role in that world. Can it be replaced by another format? Not cheaply. Do I still have the version that works with it? Yes, of course. Can I put that version up on my own site for others to download? Dubious legally. Interactive complex content becomes more the norm now that the web is an entertainment medium. This is a bifurcating point for the standards practices because where once office documents were a main focus for web formats and the most complex, that is shifting toward the integrated hypermedia formats where there are different wrappers (outer docs). Suddenly losing one of the inner document types after relying on it for an expensive project (or one that takes a long time to build) can be disastrous. A practice that says 'sure, we won't work on it, but here is the open source or here is the distro for free for your site' would help. Well, it shows the unfair bias of the chair. "and Jordan and Turkey both have dignified documents that explain their positive reasons." Shodder! Jordan and Turkey need to be told how the standard process works. "Some of the parroted comments are unnecessarily ranty, but only a few were mad: the US comments in one place want to remove OPC because it is not present in the “pre-existing binary format”" The OPC is a design problem because it makes the format artificially incompatible with ISO 26300 and does not further the goal of backwards compatibility with existing formats. "but then they want to get rid of compatability elenents because they are a “museum”:..they don’t need to worry about consistency because they are voting yes anyway:" You know very well, why they did. "some of the comments are like that, they are there to only allow the cake to be had and eaten. I expect that several NBs are not really attached to some of their comments." It seems to me that members are now waking up and prepare to fight back. In fact, OPC largely recreates the entity mechanism of IS8879 that XML simplified out. SC34 has long been a supporter of indirection mechanisms and linking, notably IS10747. In fact, there was even a comment that OPC should become a separately numbered standard because it was useful (and being part of IS29500 would make it difficult for some people to use without losing face, I suppose.) The standardization problems that I see with OPC are first that ZIP is not a standard (ODF has same issue of course) and second that it would have been better for them to use XLink or Topic Maps or RDF for the syntax of the relationship files: but these is a minor issue. I think it's important to say that blinking doesn't inherently cause epileptic fits... it's all to do with the pacing of the blink. An "On/Off" cycle can causes fits, whereas a MilSpec cycle of "On/On/Off" will not cause fits, and since the era of Netscape 2 (I think) browsers have not used On/Off pacing. Blinking text itself is used in The Real World (eg, road works signs) and I think it should be considered like any other animation. When used sparingly animation can be useful, but when used indiscriminately it causes problems. I've infrequently used blinking text on webpages to grab attention (a webapp security system to do with open doors after hours!) The current draft of the WAI has the latest thinking on this, and I see it is above three times a second that is dangerous: Three Flashes or Below Threshold: Content does not contain anything that flashes more than three times in any one second period, or the flash is below the general flash and red flash thresholds. So they say don't blink for more than three seconds unless you have taken all these rates into consideration. Content does not blink for more than three seconds, or a method is available to stop all blinking content in the Web page. general flash and red flash thresholds. If we are being exact, it is neither GB nor UK but BSI, originally an engineering committee that was granted a Royal Charter and not an organ of government AFAIK. People don't know the initials of the various National Bodies, so I put "Country" with the name that I thought would be most well-known to the widest number of readers, not to reunify of Ireland by stealth. So it is glib to say "Adopt SVG rather than DrawingML" as if it can be done just by clicking fingers (I am sure you weren't quite saying that!) SVG was created in part as a response to VML. And DrawingML was created in part as a response to VML and to SVG. The trouble with saying "Go standards" is that it is legitimate for a company to want to support a different feature set than the one the standard supports. Just as it is legimate for customers to reject applications that go beyond the standard set of features. the Netherlands is missing from the table. Wouter I can understand the Australian position (only new local comments) or the UK position (get everything on the table) but I think the countries who merely repeated an externally-fed list of objections word-for-word or idea-for-idea have pretty much failed in their review obligations and wasted the opportunity. There are quite a few what I consider to be unsolvables issues suggesting radical changes to the spec, removal of either entire markup languagues or entire parts of the spec or changing the fasttrack procedure. There are also quite a few silly issues like having 40-50 comment instances complaining that the zipped schema annexes are not in a humanly readable format. Quite amusing from a bunch of countries that a year ago approved a document format based on zip packages. Or my favorite the US comment that states the Open packaging convention needs to be stricken from the standard because it has capabilities that were not present in the previous binaries formats. Most duplicates found so far are the the above mentioned comment on the "x-bar is the mean" (or whatever) and the comments on legacy compatibility tags with 5-6 countries making a comment for individual legacy tags. I expect about 60-80% of the issues to be solved upfront because they are realtivly easily solvable. There is also a decent amount of comments that do not require solving. About 5-10% of the issues looks unsolvable in the current ballot resolution phase. About 50 issues are moderatly to difficult to solve issues. Difficult because either time constraints or the impact on the format specification or even because of the varying views by the ISO members (Parrots also have a digestive problem: they regurgitate what they have been spoonfed!) Certainly if you get rid of duplicates you will come to less than a thousand; but if you then categorize them by class or according to principle you end up with only a few score problems (e.g. typos, grammar, error, lack of openness.) If we are lucky, the BRM may in fact identify more problems than in the ballot issues: once the ballot issues are categorized into sui generis heads, other examples that come up can be dealt with too, as part of the same comment. The ballot issues are MacGuffins: they are the excuses for the action. The formal procedures certainly revolve around them, but it happen in the wider and over-arching reason for the BRM--to get the most agreement on the best spec given the constraints of fast-tracking. The issue of national date formats is one of the big objections I had to W3C XML Schemas. The rest of the XSD working group did not buy my argument that what was important in markup is not to have a single unified international format (and leave rendering it in localized forms to applications) but that real local data could be marked up (notations!) and mapped to some local forms. This approach is the one adopted by ISO DSDL's Data Type Library Language (DSDL part 4, now in committee draft). In future standards that adopt ISO DSDL (RELAX NG, NVRL, Schematron, DTTL, DSRL) there will be much greater capability to express and validate localized markup (localized element names and values too!). So allowing localized date formats into an XSD (or RELAX NG or DTD) schema at the current time unfortunately means that the data will not be validated. This is a step backwards for rigorous markup, but may still be worthwhile doing anyway. There is a balance between ease of use and ease of implementation: localized forms make it easy if the data is your region's form, but make it hard if you have to support multiple region's forms. My personal opinion is that ISO DTTL provides the way out, because the rules can be expressed declaratively in an executable form, which reduce the programming effort. Some of the parroted comments from NBs about the "Gregorian Calendar" are a little problematic, given that the international standard is ISO8601 and the XSD uses ISO8601. I would expect that ISO 8601 would be maintained as the date format, but that spreadsheet functions will be vetted to make sure that localized date formats are properly supported. There are some standards that may help here (ISO HyTime, ISO DSDL, ISO POSIX, ISO ODF) with mappings or functions. I think that one thing that will come out from the BRM phase is a greater realization of the enormous gaps in standardization that exist. What is the international standard for Persian calendar? Is there an English or French language translation suitable for inclusion in an ISO standard or even technical report? The trouble is that it may be true that DIS 29500 and IS 26300 should include detailed information on regional and national calendars, however, it may be that DIS 29500 and IS26300 are not the places for this information: the information may belong in a different standard, perhaps not in the perview of JTC1 SC34 even. Some issues may have to be resolved by the NB saying "Oh, we need the chicken before the egg: we need to set up a separate process for this other standard, and then in a later revision to DIS 29500 make specific reference". In which case the job of the editor becomes making sure that the text of IS29500 is future-proofed to allow future advances in standardization to be adopted with minimal effort. © 2016, O’Reilly Media, Inc. (707) 827-7019 (800) 889-8969 All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
http://archive.oreilly.com/pub/post/under_the_hood_of_the_ballot_c.html
CC-MAIN-2016-40
refinedweb
4,389
53.65
A Pelican Tutorial: Static, Python-Powered Blog with Search & CommentsMarch 29, 2018 In a rush? Skip to tutorial steps or live demo. Did you know Pelicans can eat freaking turtles? No wonder they walk around like badass OGs. Yeah: pelican the bird is indeed awesome. But so is Pelican the static site generator. Especially for whipping up a lean dev blog. In this Pelican tutorial, I'll show you how to use the Python-powered static generator to quickly create a sleek blog. I'll also spruce things up by adding static comments and a search function to the site. Note: this isn't my first rodeo with static sites—I've shown our readers how to add e-commerce to Jekyll, Hugo, Gatsby, and many others. But today, no e-commerce, no Snipcart. Just a plain, simple tutorial for a dev blog! :) This post will cover: - How to create a Pelican blog and change its theme - How to add the Tipue Search plugin - How to enable static comments with Staticman - How to host a Pelican site on GitHub Pages Ready for take-off? Pelican, a Python-powered static generator Simply put, Pelican is a neat static site generator (SSG) written in Python. Like all SSGs, it enables super fast website generation. No heavy docs, straightforward installation, and powerful features (plugins & extendability). Plus, you get all the benefits of a static site: cheap, portable, secure, lightweight, easy to host. As a blogging platform, Pelican also allows you to own all of your content—even comments, thanks to Staticman. No need to rely on trusted third parties like Medium. There's also a huge open source collection of themes to choose from. Sidenote: if you're a Python fan, check out our Django e-commerce tuts with Wagtail! Pelican Tutorial: a dev blog with comments & search All right amigos, let's get to the crux of the matter. Pre-requisite - Python installed with pip's package manager 1. Scaffolding the static blog First thing to do is simply scaffold a website using the CLI. It will give us the file structure needed to customize our setup right away. Create a new folder for your project and open a console in it. Install Pelican's Python package with: pip install pelican Once it's done, use the CLI straight away to do the scaffolding with: pelican-quickstart Here's how your configuration should look like: For the demo, I wanted to play around a bit with some themes, so I chose to clone the whole pelican-themes repo. You can do so with git clone git@github.com:getpelican/pelican-themes.git in the folder of your choice. 2. Creating blog content in Markdown To make this demo less contrived, I used real, "open source" Aeon content. You could decide to generate a new folder to keep content organized. But for the sake of keeping this demo simple, I created everything directly in the content folder. Fire up your favorite text editor and open the content folder. First file name: are-you-just-inside-your-skin-or-is-your-smartphone-part-of-you.md. As you can see, the file extension is .md, so we will use the Markdown format to define our content. A Markdown file is declared with metadata (at the start of the file), followed by the actual content. Pelican's files support many metadata fields—it's worth reading their docs about this here. Now, back to the file you just created. Open and fill it up with actual content (our Aeon source): Title: Are ‘you’ just inside your skin or is your smartphone part of you? Date: 2018-02-26 Category: Psychology Slug: are-you-just-inside-your-skin-or-is-your-smartphone-part-of-you In November 2017, a gunman entered a church in Sutherland Springs in Texas, where he killed 26 people and wounded 20 others. He escaped in his car, with police and residents in hot pursuit, before losing control of [...] You can repeat this step with all the content you need. Once you've got your content, you'll be ready to generate the blog. 3. Changing the Pelican theme Go into the folder cloned earlier, and copy your chosen theme in your project's root folder. Then, in the same folder, run pelican-themes -i {your_theme_name}. You're all set to give your site a first shot. To generate it, again, in the same folder, run pelican -t {your_theme_name}. This will generate your website with the specified theme and put it inside the output folder. Simply serve with whatever suits you after. I opted for Node's http-server. Here's my result at this point, using the monospace theme: Note: if you want to customize & create Pelican themes, check out its Python templating language Jinja2 4. Adding the Tipue search plugin Now now, I know there are tons of way to handle search on a static site. Third parties—Algolia et al. Server-side searches. Client-side searches. Truth is most of these are overkill for my humble demo. ¯\_(ツ)_/¯ So to add this feature to the blog, we'll use a Pelican-specific search plugin. There are many plugins in this sub-repo, but the one of interest to us here is tipue-search. Install the required Python package with pip install beautifulsoup4. Next, clone the project's folder, and register it inside your pelicanconf.py file. You'll be able to do so simply by adding the following line: PLUGINS = ['tipue_search.tipue_search']. If you re-generate your website, you'll see a new file; tipuesearch_content.json. That's the static content the search will use. Now, you only need to modify your theme's templates to add the search. Hop into monospace/base.html—the template used for every page. There, add both jQuery and tipue-search with the following HTML: <script src=""></script> <script src=""></script> <script src=""></script> <link rel="stylesheet" href=""/> Now add this code to the <div id ="sidebar"> section: <form action="/"> <div class="tipue_search_right"><input type="text" name="q" id="tipue_search_input" pattern=".{3,}" title="At least 3 characters" required></div> <div style="clear: both;"></div> </form> <div id="tipue_search_content"></div> And the following JavaScript, again in the same base.html file: <script> $(document).ready(function() { $('#tipue_search_input').tipuesearch({ 'mode': 'json', 'contentLocation': 'tipuesearch_content.json' }); }); </script> That's it! You should have static search directly on our website now. Rebuild your blog and see the result. Here's how my search box & results look: 5. Adding static comments with Staticman Most people default to Disqus to handle comments on their sites. There's also a Disqus static comment plugin for Pelican. Now I have no personal beef with Disqus. But I'd be hard-pressed to ignore the number one issue related to trusting this third party, even in its "static" form: Staticman solves all of the above. That and, of course, a simple problem most static sites suffer from: adding forms for user-generated content without a backend. Staticman is perfect for reader comments, but also for voting systems or user reviews. For more details on its superpowers, check out this full post by my colleague Jean-Seb aka Mumbledore. Disclaimer: Snipcart sponsors the Staticman open source project. So for the sake of transparency, here's a list of static comments alternatives you might consider. Now for the technical part: I will skip the default configuration of Staticman as it is really straightforward and well explained here. Once, you have a repo with the app as a contributor running, you'll need to add a configuration file and the necessary templates to send and render data. Create a staticman.yml file with the following content: comments: allowedFields: ["name", "email", "url", "message"] branch: "master" commitMessage: "Add Staticman data" filename: "entry{@timestamp}" format: "yaml" moderation: false name: "pelican-blog.netlify.com" path: "content/comments/{options.slug}" requiredFields: ["name", "email", "url", "message"] generatedFields: date: type: date options: format: "timestamp-seconds" Now, hop in monospace/templates/article.html and add the following just after the {{ article.content }} line: <div id="comment-post"> <form method="POST" action=""> <input name="options[redirect]" type="hidden" value="{{ SITEURL }}/{{ article.slug }}"> <input name="fields[url]" type="hidden" value="{{ article.slug }}"> <div><label>Name: <input name="fields[name]" type="text"></label></div> <div><label>E-mail: <input name="fields[email]" type="email"></label></div> <div><label>Message: <textarea name="fields[message]"></textarea></label></div> <button type="submit">Submit</button> </form> </div> This is the form used to send comments to Staticman. The latter will push then include them in your repo. This way your website will be able to render them without any external calls. To first render them, let's expose these comments in JSON to your templates, since they are in YML at the moment. First, download the pyyml python package with: pip install pyyaml. Once this is done, go in pelicanconf.py, this is where you'll expose comments. Add these following lines wherever you want: #Staticman Comments commentsPath = "./content/comments" def ymlToJson(file): with open(commentsPath + "/" + file) as stream: return yaml.load(stream) commentsYML = [f for f in listdir(commentsPath) if isfile(join(commentsPath, f))] COMMENTS = list(map(ymlToJson, commentsYML)) This will load every .yml comment files, parse them into JSON, and expose them as an array. Any all-caps variable in this file will be exposed inside Jinja2 templates, which means you'll have access to the comments in any template. What you want to do now is render the comments on the matching articles. In article.html, add this section just between the {{ article.content }} line and the form we just added: <div> <h3 id="comments">COMMENTS</h3> {% for comment in COMMENTS %} {% if comment.url == article.slug %} <p class="comment">{{ comment.name }}: {{ comment.message }}</p> {% endif %} {% endfor %} </div> Aaaand a quick look at our static comments now: Now let's host that static blog! 6. Hosting your Pelican blog on Netlify I would have liked to host everything on GitHub Pages, as it's a good fit with Pelican. But since I needed to rebuild the project once a comment is pushed to keep the website updated, I decided to go for Netlify. Once a new comment is pushed, Netlify will be notified, rebuild the website, and host it with the new comment. To do so, add a requirements.txt to your project's folder and add these lines to it: pelican pyyaml markdown beautifulsoup4 This is the file that will be used by Netlify to download the project's dependencies. Now, push your code to a repo and hit netlify.com. Once you're logged in, click the new site from GIT and choose your project's repo with these settings: The deploy will start right away, and your website should be live in a minute! Note that the site has to rebuild for new comments to appear. Live demo & GitHub repo Closing thoughts This demo took me about 1-2 hours, thanks to the Pelican documentation and Staticman's simplicity. I really enjoyed playing with Pelican! I had not worked with a static generator for a while—missed it! Docs were great and concise. The challenge was mostly with Python. I really didn't write much of it, but I had never developed with Python before, so it was fun to try! I would have liked to push the search further, at the moment it's easy to use and setup but it wouldn't be optimal for a lot of blog entries. The first thing I would do to scale this is outsource the search to something like Algolia. It would be much faster and wayyyy more powerful/scalable than what we have at the moment. Happy coding! If you've enjoyed this post, please take a second to share it on Twitter. Got comments, questions? Hit the section below!
https://snipcart.com/blog/pelican-blog-tutorial-search-comments
CC-MAIN-2018-34
refinedweb
1,985
65.83
I’m going to cross post this while I finish up my next few posts. If you’ve read it before, I apologize. I’ve been promising a few posts for a while now so I thought I would combine them all into one simple, concrete example. So, today we’re going to get these three components to play nice together and see what we can come up with. The structure of this post is for you to walk through this with me. I’ll warn you, I’m going to intentionally gloss over things. I’m going to bring in conventions that I use frequently and it’s up to you to dig into the code to understand them. My goal is to provide you with enough examples of Fubu In Action to give you an idea of how to do it yourself. So, having said all that… What you should do first: - Fork my Scratchpad repository: - Clone your fork locally The Setup You should be in the setup tag to begin with. This is bare bones. We’ve got just enough structure in here to get us up and running. If you run the application, you can go to: “/_fubu” and you’ll get the baseline diagnostics. You’ll want to make sure you can get this far before reading any further. Some Conventions Now, let’s checkout the endpoint-conventions tag. I haven’t added much, but this is close to how I usually have my url conventions setup. Let’s look at the Endpoints namespace: EndpointMarker is just a static type I use to mark the root of the namespace. All “controllers” follow a basic rule: The route is made up of the namespaces with “Endpoint” stripped from the handler type (e.g., DashboardEndpoint => /dashboard) and method names respond to the appropriate HTTP verb (e.g., Get, Post). We’ve also made DashboardEndpoint our default route so running the application should present you with a simple “Hello, World!”. Basic Views Now, checkout the spark-engine tag. Let’s walk through how we got Spark up and running: - Added a reference to FubuMVC.Spark - Added an explicit this.UseSpark() in our registry That’s it. Now, of course we added the actual views themselves, but the above steps are all that it currently takes to get Spark bootstrapped*(I explain this later). Regarding the views, it’s a requirement for Spark that the model in your viewdata statement is the full name of the type (e.g., Scratchpad.Web.Endpoints.DashboardViewModel). We currently do not make use of the “use namespace” elements for this resolution. Running the application now should show you a list of Users. Advanced Diagnostics I’m throwing this in here just as a side note because I know there’s not much documentation out there yet. Let’s checkout the adv-diag tag. You’ll now see a diagnostics.zip file in the root of your repo. If you’re in the git console, do three quick commands: - cmd - install-diagnostics.bat - ctrl+c This will install the FubuMVC.Diagnostics package to your application. Now run the application and go to: “/_diagnostics” (instead of “/_fubu”). Update: The latest NuGet packages allow you to install FubuMVC.Diagnostics into your application and it will replace the existing /_fubu routes. Validation We’ve covered Fubu, Spark, and Diagnostics. Now let’s checkout the validation tag. Let’s look at a few things with this, as they warrants some explanation. - We’re adding the ValidationConvention in our FubuRegistry and telling it that it’s applicable for our calls that a) have input and b) have input models with a name that contains “Input” - We’ve added the ScratchpadHtmlConventions that modify the editors for elements based on the required rule - We’ve decorated our FirstName and LastName properties with the Required attribute - We’ve added two new registries of importance: 1) ValidationBootstrapRegistry and 2) ScratchpadValidationRegistry. #2 Configure FubuValidation and #1 adapts it to StructureMap - We’ve added a custom failure policy (we’re matching all failures) to hijack the request and send back a JsonResponse with the validation errors – (note the hijacking used to work differently and now requires some more ceremony. I’m looking into this soon – that’s why you’re seeing the JsonActionSource) - There’s no validation code in CreateEndpoint.Post. We get it for free! As always, if you have any questions please take them to our mailing list. I’d more than happy to answer them for you and/or clarify anything you’ve found here. Post Footer automatically generated by Add Post Footer Plugin for wordpress.
http://lostechies.com/josharnold/2011/07/05/fubu-spark-diagnostics-and-validation/
CC-MAIN-2014-10
refinedweb
774
64.51
Technical Support On-Line Manuals RL-ARM User's Guide (MDK v4) #include <rtl.h> OS_ID os_tmr_kill ( OS_ID timer ); /* ID of the timer to kill */ The os_tmr_kill function deletes the timer identified by the function argument. timer is a user timer that was created using the os_tmr_create function. If you delete the timer before it expires, the os_tmr_call callback function does not get called. The os_tmr_kill function is in the RL-RTX library. The prototype is defined in rtl.h. The os_tmr_kill function returns NULL if the timer is killed successfully. Otherwise, it returns the timer value. os_tmr_call, os_tmr_create #include <rtl.h> OS_TID tsk1; OS_ID tmr1; __task void task1 (void) { .. if (os_tmr_kill (tmr1) != NULL) { printf ("\nThis timer is not on the list."); } else { printf ("\nTimer.
http://www.keil.com/support/man/docs/rlarm/rlarm_os_tmr_kill.htm
CC-MAIN-2019-43
refinedweb
125
62.24
This class stores info we want to provide to or retain within an alias query. More... #include "llvm/Analysis/AliasAnalysis.h" This class stores info we want to provide to or retain within an alias query. By default, the root query is stateless and starts with a freshly constructed info object. Specific alias analyses can use this query info to store per-query state that is important for recursive or nested queries to avoid recomputing. To enable preserving this state across multiple queries where safe (due to the IR not changing), use a BatchAAResults wrapper. The information stored in an AAQueryInfo is currently limitted to the caches used by BasicAA, but can further be extended to fit other AA needs. Definition at line 469 of file AliasAnalysis.h. Definition at line 480 of file AliasAnalysis.h. Definition at line 471 of file AliasAnalysis.h. Definition at line 496 of file AliasAnalysis.h. Create a new AAQueryInfo based on this one, but with the cache cleared. This is used for recursive queries across phis, where cache results may not be valid. Definition at line 501 of file AliasAnalysis.h. References CI, and Depth. Definition at line 481 of file AliasAnalysis.h. Location pairs for which an assumption based result is currently stored. Used to remove all potentially incorrect results from the cache if an assumption is disproven. Definition at line 494 of file AliasAnalysis.h. Definition at line 483 of file AliasAnalysis.h. Referenced by llvm::BasicAAResult::getModRefInfo(), and withEmptyCache(). Query depth used to distinguish recursive queries. Definition at line 486 of file AliasAnalysis.h. Referenced by withEmptyCache(). How many active NoAlias assumption uses there are. Definition at line 489 of file AliasAnalysis.h.
https://www.llvm.org/doxygen/classllvm_1_1AAQueryInfo.html
CC-MAIN-2022-40
refinedweb
283
60.61
How to populate a ListModel without for loop Hello everyone. I'm working on a Qt/QML software for data visualization that is meant to be quasi-real time. In the software I'm working on, I populate a ListModel object as follows: main.qml Test_Data { id: surfaceData } // some code function populate_model(x,y,my_data) { for(var i=0; i<array_data.length; i++) surfaceData.model.append({"row": y[i], "col": x[i], "value": my_data[i]); } Test_Data.qml import QtQuick 2.5 Item { property bool isempty: true property alias model: dataModel ListModel { id: dataModel } } mainwindow.cpp QObject *obj = my_widget->rootObject(); QMetaObject::invokeMethod(obj,"populate_model", Q_ARG(QVariant, QVariant::fromValue(array_x)), Q_ARG(QVariant, QVariant::fromValue(array_y)), Q_ARG(QVariant, QVariant::fromValue(array_data))); where my_widget is a QQuickWidget and array_x, array_y and array_data are std vectors. In short, is pass three arrays to the QML function and populate the ListModel with that for loop. The problem is that the arrays are generally very big (hundreds of thousands of elements) and populating such model list takes about one one second. Is it possible to avoid the for loop with the appends to make the populating process faster? @Davide87 Perhaps, you get the solution here: Thank you for your answer Bernd. However that topic is not actually much of help for me :-( However, I'm thinking about leaving the QML idea and try another way to solve my problem. Thank you again :-) @Davide87 If you want better performance you need to use C++. QAbstractListModelcould do the job I think. You can use this "smart models" if you don't want to implement your own model. Thank you daljit. I'll try it.
https://forum.qt.io/topic/91593/how-to-populate-a-listmodel-without-for-loop
CC-MAIN-2022-27
refinedweb
275
50.33
I returned from Build conference Friday night. It was a really exciting conference in my opinion with a lot of new ideas revealed. Microsoft had kept a very tight lid on upcoming changes for many months, and none really knew what was going to be announced at the event. There were a number of speculations, but nothing concrete showed up on the internet. The only exception was a 5 minute video that was put out by Microsoft a few months back, giving viewers a glimpse of the new operating system, Windows 8. In retrospect, I cannot disagree with Microsoft decision, as the changes that were announced are designed to differentiate Microsoft as an operating system provider, thus giving revealing the information prematurely would lessen a competitive advantage over rivals. So, what was unveiled at the conference? Microsoft demonstrated in a significant level of details its new operating system, Windows 8. At the high level, its user interface carries over the investments Microsoft has made in the area of design for Windows Phone 7. Windows 8 conforms to Metro design principles. The opening screen in Windows 8 is very similar to Windows Phone 7, consisting of a number of live tiles, grouped into a number of areas. Those groups are user defined, and this was demonstrated as well. User will be able to use gestures of course to control the appearance of the OS. They will be able to zoom out of the detailed view, find a group they are looking for, and zoom back into that group. Of course they will also be able to re-arrange any part of any group or groups themselves using similar gestures to the ones on the phone. What about old look and feel you ask? The new OS is built on top of Windows 7, and one can drop back to classical look and feel by clicking on Desktop tile. There are also a number of new features that exist in Windows 8. One of them is “charms”. Charms are located in the right hand area of the screen, and are typically hidden. The user can bring them into view by swiping from right hand edge to toward the center of the screen. Charms are common features to all the programs, such as printing, devices, networking, sharing, search, etc. All software written for Windows 8 should incorporate these charms to provide seamless user experience. Not only charms allow developers to integrate their applications deeply with Windows 8 OS, but also with each other. There is a number of contracts in WinRT that one application can implement, that other applications can utilize. For example, you can write a photo editor application, that implements search contract, and another application such as family tree can search photos and show them in its UI. Pretty cool, hah? Similar contracts also exist for devices such as printer. Now let me talk about programming for Windows 8. Developers will be able to use C#/VB.NET, C++ and JavaScript to write Windows 8 applications. Sounds strange at the first sight doesn’t it? Beforehand browser based application were not able to reach deeply into operating system. This broad functionality is being enabled view new Windows runtime for writing applications, WinRT. Unlike .NET, this new run time is built into Windows itself, and it not an additional layer on top of existing Windows functions, as it is the case with .NET. As a result, WinRT will have better performance. To ensure highly responsive applications, all the functionality in WinRT that is not instantaneous contains asynchronous methods. This would include things such as file I/O, networking operations, such as internet client, etc. I heard phrase “fast and fluid” to describe Windows 8 UI and applications dozens of times during the conference. Of course, not everything is contained within WinRT, thus .NET is also an integral part of building applications for Win 8. As a matter of fact, new version of Microsoft.NET, 4.5 will ship with Windows 8, and will be available as part of the operating system. There is a difference however between traditional .NET and new Metro style applications. When a developer builds Metro applications, only a subset of .NET is available to this person. For example, file IO functionality is greatly limited in preference to new WinRT pickers. These pickers such as open file or save file pickers replace traditional IO in favor of safer and asynchronous operations, where entire file system is not exposed to a Metro style application. You get the idea right? Metro apps run in a sandboxed environment. So, if you want to build Metro apps, you will use .NET and WinRT, but your tooling will remain the same. You will use Visual Studio v. next and your favorite language to build those applications. What about UI, you ask? You have options there as well. If you opt for JavaScript as your language of choice, you build UI in HTML. If you pick C#, VB.NET or C++, you will build UI for your applications in XAML. No, not Silverlight or WPF, but XAML. Your XAML skills transfer over, but namespaces you used will change. There will also be some new controls, such as GridView and FlipView. If you ever saw Windows Phone 7 applications, you understand that in order to enable Metro style UI and more importantly touch based UI, you need new set of controls, and Windows 8 is all about touch interfaces. A few words about legacy software. Microsoft pledged that all the software that successfully ran on Windows 7 will run on Windows 8. This would include platforms such as WinForms, WPF, Silverlight, HTML, etc. There were a number of devices shown that will run Windows 8. In addition to tablets, laptops and PCs, which all will incorporate traditional processors and likely solid state hard drives, there will be another class of lighter devices, running Windows 8 on RISC processors. This is drastically different from Apple’s approach that uses different OS for tablets. As a result, Microsoft tablets will be more functional, and will contains software such as Microsoft Office and other PC based applications. New version of Visual Studio, Expression Blend and Microsoft.NET will all ship to help developers build Metro style applications. Visual Studio will contain templates for Metro apps, Expression Blend will enable UI design, but not just XAML. Blend gets new set of functionality, enabling it to design HTML as well. Cool new editing features found their way into Blend. Because Blend actually runs your XAML and HTML, you actually see your applications running with data. All changes you make will update either XAML, HTML or even CSS in your Visual Studio project. Visual Studio got new XAML designer. It appears that old designer code name Cider is gone, and is replace with Blend designer!!! Yeah, it is about 4 times faster now. Personally, I always hated Cider’s performance and hardly ever used XAML view in studio because of that. Power tools for studio previously available on NuGet only, will be integrated into Studio directly when it ships. Another huge news that will interest developers is new Windows 8 App Store. If you create Metro style application, you will be able to sell it through new app store. I can only guess that the model will be largely similar to Windows Phone 7 app store. Potential market though is thousands of times larger. According to Microsoft, Windows is being run on almost half a billion computers. If you can imagine, one dollar app can make you a millionaire. Not that this will happen to too many people, but the promise is certainly there. Another software release was announced, and that is TFS in the cloud service from Microsoft. Beta has been released, and attendees all got beta account free of charge. Live Services will be an integral part of Windows 8. It looks like SkyDrive will enable many cool features, such as roaming profiles that will enable users to have exact same desktop on many computers. Developers will be able to use that feature as well, roaming state of their software across multiple computers, for example making sure that users of a software have the same state of the software available on all machines. In summary, here is are the most important points (IMHO). - Windows 8 is all about modern consumer experience. This includes touch based Metro UI. - Developers carry all their existing skills over to Metro applications, including XAML, .NET languages, .NET Framework, HTML and JavaScript. - NET is not dead , it is integral part of Metro applications along with WinRT. - Developers get to utilize new WinRT, making applications faster and highly integrated with OS and each other. - New tools will be shipped to enable developers to create applications faster with a uniform look and feel. - Money making opportunity is there for all developers. You can watch all the online content, including keynotes and sessions, from the conference on Please let me know if you have any questions, I would like to kick off a discussion that would benefit all of us, including me. Thanks! First I heard about *Charms*! This is awesome.
http://www.dotnetspeak.com/net/what-i-learned-at-the-build-conference/
CC-MAIN-2022-21
refinedweb
1,532
65.52
That it's not a typical company is precisely the point Freebies can range from tax preparation to education Join the NASDAQ Community today and get free, instant access to portfolios, stock ratings, real-time alerts, and more! Consistently, one of the more popular stocks people enter into their stock options watchlist at Stock Options Channel is Walt Disney Co. (Symbol: DIS). So this week we highlight one interesting put contract, and one interesting call contract, from the May expiration for DIS. The put contract our YieldBoost algorithm identified as particularly interesting, is at the $74.50 strike, which has a bid at the time of this writing of $1.37. Collecting that bid as the premium represents a 1.8% return against the $74.50 commitment, or a 14.6% annualized rate of return (at Stock Options Channel we call this the YieldBoost ). Turning to the other side of the option chain, we highlight one call contract of particular interest for the May expiration, for shareholders of Walt Disney Co. (Symbol: DIS) looking to boost their income beyond the stock's 1.1% annualized dividend yield. Selling the covered call at the $79 strike and collecting the premium based on the $2.09 bid, annualizes to an additional 21.3% rate of return against the current stock price (this is what we at Stock Options Channel refer to as the YieldBoost ), for a total of 22.4% annualized rate in the scenario where the stock is not called away. Any upside above $79 would be lost if the stock rises there and is called away, but DIS shares would have to advance 1.6% from current levels for that to occur, meaning that in the scenario where the stock is called, the shareholder has earned a 4.2% return from this trading level, in addition to any dividends collected before the stock was called. Top YieldBoost DIS?
http://www.nasdaq.com/article/interesting-may-stock-options-for-dis-cm344146
CC-MAIN-2015-06
refinedweb
318
64.51
#include <wchar.h> wchar_t *wcschr(const wchar_t *ws, wchar_t wc); The wcschr() function shall locate the first occurrence of wc in the wide-character string pointed to by ws. The application shall ensure that the value of wc is a character representable as a type wchar_t and a wide-character code corresponding to a valid character in the current locale. The terminating null wide-character code is considered to be part of the wide-character string. Upon completion, wcschr() shall return a pointer to the wide-character code, or a null pointer if the wide-character code is not found. No errors are defined. The following sections are informative. None. None. None. None. wcsrchr() , the Base Definitions volume of IEEE Std 1003.1-2001, <wchar.h>
http://www.makelinux.net/man/3posix/W/wcschr
CC-MAIN-2015-06
refinedweb
126
63.29
- Installing Python 3 on your system - Installing Python 3 packages Among the changes introduced by RoboFont 3 is the switchOS?. Running Python 3 in SublimeText - Go to Sublime Text to: Tools → Build System → New Build System and put the next lines in the editor: { "cmd": ["python3", "-i", "-u", "$file"], "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)", "selector": "source.python" } Then save it with a meaningful name like: python3.sublime-build - Create a new .py file, save it on disk, and write the following code import sys print(sys.version) Go to Tools → Build system → and check python3 (or whatever name you assigned to the build system) test it with: - Press: Cmd + B. You should read in the console something similar to 3.9.5 (default, May 4 2021, 03:36:27).
https://doc.robofont.com/documentation/tutorials/upgrading-from-py2-to-py3/
CC-MAIN-2021-39
refinedweb
129
83.46
[Tutorial] Creating your own menu inside the Episerver UI using MVC A few weeks ago we started a project to create a new solution for the Episerver Education store (more on this in upcoming blog posts) and one of things we had to do was to create a new administrative system to handle this. In order to make it easily acceissble for everyone working for the Education department at Episerver we decided to add links in the menu to manage everything. Sounds simple? Well yes and no, tag along and I will explore some of the problems I encountered along the way. (If you want to read more you can visit Episerver world page about menu items or visit my blog post about dynamic MVC menu routes for an example code and my aha moment.) Here is what are we trying to achieve. Our own custom Education store menu with some links to various functions. In this tutorial I will go through all steps needed to create the menu below. Menu items The menu consists of 3 elements: - The name Edu. platform is what's called the "product name". This is (besides being listed above) also what you will see in the waffle menu (9 dot menu to the left). - Next to the product name is menu level one. - And finally below menu level one is (lo and behold) menu level two. Tip: If menu level two does not have any menu items, it will not be shown. Why is this important to know? Well the menu is built on a child-parent relationship. If you have a menu item but no relation to the parent, it will not be display and when I say it will not be displayed, I mean it. This is what happens when one item is missing in the chain. So when you are building your own menu, you need to keep in mind that you always need to have a parent for your menu items except for the product name item (which uses the /global as parent.) MVC Controller Next up we need to create the a MVC controller for the URL. Once the method Active is called, we want to show the correct menu item. The code is standard .NET MVC and includes no EpiServer elements. (I have included a RedirectRoute. More about why later on.) Controller class that exposes one method with the route {mysite}/education/sessions/active. using System.Web.Mvc; namespace Episerver.Sessions { [Authorize(Roles = "WebAdmins")] [RoutePrefix("education/sessions")] public class EducationSessionController : Controller { [Route(""), HttpGet] public ActionResult Active() { return RedirectToAction("Active"); } [Route("active"), HttpGet] public ActionResult Active() { return View(); } } } View A blank cshtml page with one line to call @Html.Raw(Html.CreatePlatformNavigationMenu()) You can of course add whatever you want onto this view as long as you add the above line. Menu Provider Now that we have the controller and class ready, we can begin to construct the provider that will render the menu for us. Start with a new class, add the attribute [MenuProvider] and implement the interface IMenuProvider. using System.Collections.Generic; using EPiServer.Shell.Navigation; namespace Episerver.Sessions { [MenuProvider] public class MenuProvider : IMenuProvider { public IEnumerable<MenuItem> GetMenuItems() { // Menu comes here } } } Menu Items Before we create the menu I want to quickly go through the Menu Item class. Below we will use the UrlMenuItem which extends the MenuItem class by allowing us to define a url in the constructor at the same time as the text and path. No other difference exists between them. A menu item consists of several elements but I will only go into a few important ones here. Menu Sections A SectionMenuItem is an extended MenuItem with some smaller css fixes for the older rendering of the menu. However, this was more part of the legacy rendering and you do not need this to implement a menu. Adding menu items Now it is time to setup the items that should represent the structure. In our example we only have one method so technically it makes sense to only show the menu at level one. However, for the sake of this tutorial we will also do level two (like the picture shown above). We start by adding a string to contain the base url followed by the product name. Add the following inside the class. private readonly string PlatformPath = MenuPaths.Global + "/education"; public IEnumerable<MenuItem> GetMenuItems() { var items = new List<MenuItem>(); items.Add(new UrlMenuItem("Edu. platform", PlatformPath , "") { SortIndex = 10, IsAvailable = (_) => true }); // More items to be added here return items; } This will create the product name that is shown in the waffle menu. It has no url attached to it as it is part of the global menu. The next steps are the sessions (level one and two) menu items. Remember that in order to achieve the structure above /education/sessions/active we need to create 3 items. Add the following two items. items.Add(new UrlMenuItem("Sessions", EducationPlatform + "/sessions", "/education/sessions") { SortIndex = 20, IsAvailable = (_) => true }); items.Add(new UrlMenuItem("Active", EducationPlatform + "/sessions/active", "/education/sessions/active") { SortIndex = 30, IsAvailable = (_) => true }); As you might have noticed from the above, the first parameter is the Text followed by the Path and lastly the Url. Now if you were to run the project you would see your own menu link show up in the waffle menu and if you click on it, it should show 1 menu level one item called Sessions and 1 menu level two item called Active. Note: The Sessions item can also be created with a SectionMenuItem instead of a UrlMenuItem. The end result should be the same. Child-Parent relationship (Path) The structure is based on the path variable. This means that we do not have to explicitly tell Episerver who our parent is instead this is done for us by the MenuAssembler class that parses all items and their path property, and thus makes a menu structure for us. As I wrote in the beginning, all menu items except the product name item has to have a parent. An easy way to test this is if you omit the second item (Sessions) and run the code again. This will result in the menu being empty as no relationship can be found for the active menu item. Empty url (Url) Under the MVC Controller I added an empty method that only redirected to the active method. The reason for this is that if you don't supply a URL then the menu provider will pick the first child item and use that as the url. This might be fine but in many cases you want to control the menu and don't leave it up to the framwork to determine the url. So it is advisable to always supply a url even if it is optional. Visibility (IsAvailable) Lastly it is always important to include who should see this menu item. If this is not set then everyone will see the menu item which might not be what is intended. This should not be confused with access rights. Access to the method is controlled by the MVC Controller/Method and the Authorize attribute. The IsAvailable is for visualization only. Example: IsAvailable = (_) => PrincipalInfo.CurrentPrincipal.IsInRole("WebAdmins") Tip: If you use the MenuItemAttribute then this will be detected automatically if you have an AuthorizeAttribute tag for the specific method. Different menues In the example I used the MenuPaths.Global constant. There are however a few more possibilities like MenuPaths.Help, MenuPaths.User and MenuPaths.UserSettings that lets you put your menu items in different areas. Inner workings The inner working of Episerver is fetching all MenuProviders using reflection. (What, did you think yours was the only menu provider? No there are plenty of them and they are used to present different parts of the UI.) During start-up, all providers are loaded using the ServiceLocator - if they expose the attribute MenuProvider. There are a few classes that are responsible for the menu such as the MenuHelper (responsible for generating the menu code), NavigationService (middle layer that loads the menu items and returns them in the correct order to the MenuHelper) and the MenuAssembler (responsible for loading all MenuProviders and organize the menu items and their relations). Items are picked on a first come, first serve basis - same as routes in MVC - which means that, if you have 2 items that matches then the first one will be picked not the second one. Why is this relevant? Well you might see a different result than you expected to see. The reason is that the MenuAssembler is organized by depth of the path (/ = depth 1, /education = depth 2, /education/sessions = depth 3 etc) and not by the property sort order. Which means that if you have 2 items then the one with the shortest path will be picked before the one with the longer path. Therefore try to always have unique urls. Avoid this: /education/sessions /education/sessions/list In favor of: /education/sessions/active /education/sessions/list Wrapup I hope that you have gotten better understanding of the menu and how to create one yourself. Finally, the cleaver one will have noticed that I have not included dynamic routes in the tutorial above. The reason is that this requires some extra effort and you can read about it in my blog post here. Good walkthrough! Thx Patrik!
https://world.optimizely.com/blogs/patrik-fomin/dates/2020/7/creating-your-own-administrator-menu-inside-episerver/
CC-MAIN-2021-49
refinedweb
1,567
62.78
[edit] ok everything works perfectly thanks for all the help! This is a discussion on having trouble with some code for my class within the C++ Programming forums, part of the General Programming Boards category; [edit] ok everything works perfectly thanks for all the help!... [edit] ok everything works perfectly thanks for all the help! Last edited by green11420; 03-20-2008 at 11:34 AM. Reason: This problem is solved C and W are undefined identifiers. 'C' and 'W' on the other hand would be character constants. I might be wrong. Quoted more than 1000 times (I hope).Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away. wow, you guys are right. It works now. Thanks a bunch! Here is my code again, I fixed the first problem but now when I echo the initial height it shows a number like 0.94 which is what the update statement is producing. How do I set it so that it echos the intial height that the user inputs, while still working the way it does? here is the output by the way,here is the output by the way,Code:// File: Golf_Ball.cpp // Author: ---------------- // Class: ITCS 1214 TR 5pm // Date: 03/20/08 // Purpose: To determine number of bounces a golf ball // will make given type of surface and height from which // it is dropped. #include <iostream> using namespace std; int main () { string surface_name = " "; // Name of each type of surface float bounce_counter = 0.0, height; // Height given by user char surface_code; // Code for each type of surface, C, W, or R // Prompt for and read in height in feet cout << "Enter the drop height (in feet): "; cin >> height; // Prompt for and read in type of surface cout << "Enter the type of surface (C, W or R): "; cin >> surface_code; // Test for which type of surface entered and how many bounces will occur if (surface_code == 'C') { while (height > 1) { height = height * 0.85; bounce_counter = bounce_counter + 1; surface_name = "concrete"; } } else { if (surface_code == 'W') { while (height > 1) { height = height * 0.60; bounce_counter = bounce_counter + 1; surface_name = "wooden"; } } else { while (height > 1) { height = height * 0.20; bounce_counter = bounce_counter + 1; surface_name = "rug"; } } } // Echo surface type and height, then display number of bounces cout << "On a " << surface_name << " floor from " << height; cout << " feet the ball will bounce " << bounce_counter << " times.\n"; return 0; } Enter the drop height (in feet): 15 Enter the type of surface (C, W or R): C On a concrete floor from 0.946701 feet the ball will bounce 17 times. Everything is right, except the 0.94 should just be 15 again. Look at where you are echoing your output. It's after you have made all your calculations! You probably need to create another local variable for height (say, input_height), and set it equal to the input height value right after the user enters that value.
http://cboard.cprogramming.com/cplusplus-programming/100607-having-trouble-some-code-my-class.html
CC-MAIN-2015-48
refinedweb
488
81.53
Google Code Jam 2014 Solution - New Lottery Game Problem The lottery had a problem where people were cheating so they decided to upgrade their machines. Cassandra managed to get hold of a formula that, given values A, B and K would tell her how many potential wins she would get. Solution The text for this made this problem seem a lot harder than it was. Basically you needed to generate all the bitwise values that cassandra won with then compare them to the values that the machine generated...Really that simple. Originally I did this and stored all of the generated values for Cassandra & the lottery machine in a list and did a lotteryValues.count(i=>cassandraValues.Any(i)) comparison using Linq. However this was probably a rookie mistake as when the larger datasets came in the permutations rose making the lists huge and clogging up the memory which also made the query slow (Code Jam tip #1, never generate massive data structures). However I rewrote it to use the least amount of memory possible and it seems to have done the trick. Lesson learnt for the future! using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Question2 { class Program { private static StreamReader _input; private static StreamWriter _output; static int ReadLn() { return int.Parse(_input.ReadLine()); } static string[] ReadArray() { return _input.ReadLine().Split(' '); } static List<int> ReadIntList() { return ReadArray().Select(int.Parse).ToList(); } static void Main(string[] args) { _input = new StreamReader("in.txt"); _output = new StreamWriter("out.txt", false); var cases = ReadLn(); for (int @case = 1; @case <= cases; @case++) { Console.WriteLine("Case " + @case); var values = ReadIntList().ToArray(); var a = values[0]; var b = values[1]; var k = values[2]; var cassWinVals = new List<int>(); // generate values where Cassandra wins for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { var bitwise = i & j; if (!cassWinVals.Contains(bitwise)) { cassWinVals.Add(bitwise); } } } var wins = 0; // loop through all the combinations the two lottery machines can generate for (int i=0; i<a; i++) { for (int j=0; j<b; j++) { var bitwise = i & j; // check if the value is one of cassandas if so then she wins. if (cassWinVals.Contains(bitwise)) { wins++; } } } _output.WriteLine("Case #"+ @case + ": " + wins); } _output.Close(); } } }
https://blog.snapdragonit.com/google-code-jam-2014-solution-new-lottery-game/
CC-MAIN-2017-39
refinedweb
382
58.48
I got the program to work if the regions were displayed as 1, 2, 3, 4. Instead of the North, South and so on. I know I have to use char for storing words. But How do you write a counter while using char? so it only asks for those 4 regions and nothing else. Hope this makes sense. Below is how I got it to work displaying the numbers. Can someone give me a hint as to how to start correctly with it displaying things as North, South, East, West. Thanks guys. #include <iostream> using std::cout; using std::cin; using std::endl; int main() { // variables int regionGross = 0; int region = 1; int monthlyTotal = 0; while (region <=4) { cout << "Enter Region " << region << "'s monthly sales: "; cin >> regionGross; monthlyTotal = monthlyTotal + regionGross; region = region +1; } // end while cout << "Total monthly sales for the regions are: " << monthlyTotal << endl; return 0; } //end of main function
http://www.dreamincode.net/forums/topic/120075-need-help-using-char-correctly-in-this-program/
CC-MAIN-2017-22
refinedweb
152
71.55
Ads Via DevMavens One frequent task is to take images and convert them into thumbnails. This is certainly nothing new, but seeing this question is so frequently asked on newsgroups and message boards bears reviewing this topic here again. I was getting tired of constantly repeating this code for specific situations, so I created a generic page in my apps to handle resizing images from the current site dynamically in a page called CreateThumbnail. You call this page with a relative image name from the Web site on the querystring and it returns the image as a thumbnail. An example of how this might work looks like this: Size is an optional second parameter – it defaults to 120. Here’s what the implementation of this generic page looks like: using System.Drawing; using System.Drawing.Imaging; … public class CreateThumbNail : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { string Image = Request.QueryString["Image"]; if (Image == null) { this.ErrorResult(); return; } string sSize = Request["Size"]; int Size = 120; if (sSize != null) Size = Int32.Parse(sSize); string Path = Server.MapPath(Request.ApplicationPath) + "\\" + Image; Bitmap bmp = CreateThumbnail(Path,Size,Size); if (bmp == null) string OutputFilename = null; OutputFilename = Request.QueryString["OutputFilename"]; if (OutputFilename != null) if (this.User.Identity.Name == "") { // *** Custom error display here bmp.Dispose(); this.ErrorResult(); } try bmp.Save(OutputFilename); catch(Exception ex) return; // Put user code to initialize the page here Response.ContentType = "image/jpeg"; bmp.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); bmp.Dispose(); } private void ErrorResult() Response.Clear(); Response.StatusCode = 404; Response.End(); /// /// Creates a resized bitmap from an existing image on disk. /// Call Dispose on the returned Bitmap object /// Bitmap or null public static Bitmap CreateThumbnail(string lcFilename,int lnWidth, int lnHeight) System.Drawing; } This code doesn’t use the CreateThumbnail method of GDI+ because it doesn’t properly convert transparent GIF images as it draws the background color black. The code above compensates for this by first drawing the canvas white then loading the GIF image on top of it. Transparency is lost – unfortunately GDI+ does not handle transparency automatically and keeping Transparency intact requires manipulating the palette of the image which is beyond this demonstration. The Bitmap object is returned as the result. You can choose what to do with this object. In this example it’s directly streamed in the ASP. Net Output stream by default. If you specify another query string value of OutputFilename you can also force the file to be written to disk *if* you are logged in. This is definitely not something that you want to allow just ANY user access to as anything that writes to disk is potentially dangerous in terms of overloading your disk space. Writing files out in this fashion also requires that the ASPNET or NETWORK SERVICE or whatever account the ASP. Net app runs under has rights to write the file in the specified directory. I’ve provided this here as an example, but it’s probably best to stick file output functionality into some other more isolated component or page that is more secure. Notice also that all errors return a 404 file not found error. This is so that images act on failure just as if an image file is not available which gives the browser an X’d out image to display. Realistically this doesn’t matter – browsers display the X anyway even if you send back an HTML error message, but this is the expected response the browser would expect. In my West Wind Web Store I have several admin routines that allow to resize images on the fly and display them in a preview window. It’s nice to preview them before writing them out to disk optionally. You can also do this live in an application *if* the number of images isn’t very large and you’re not pushing your server to its limits already. Image creation on the fly is always slower than static images on disk. However, ASP. Net can be pretty damn efficient using Caching and this scenario is made for it. You can specify: <%@ OutputCache duration="10000" varybyparam="Image;Size" %> in the ASPX page to force images to cache once they’ve been generated. This will work well, but keep in mind that bitmap images can be memory intensive and caching them can add up quickly especially if you have large numbers of them. If you create images dynamically frequently you might also consider using an HTTP Handler to perform this task since raw Handlers have less overhead than the ASP.Net Page handler. For example, the Whidbey Dynamic Image control relies on an internal handler that provides image presentation 'dynamically' without having to save files to disk first.
http://west-wind.com/weblog/posts/283.aspx
crawl-002
refinedweb
787
56.76
1384919 story Shared Source? 241 Posted by michael on Friday May 18, 2001 @12:53PM from the may-the-best-meme-win dept. jmt(tm) sends in Microsoft's shared source webpage, and their FAQ. An AC sends in a LinuxToday story and shared-source.com. Discuss. It is an art, but it's not a new one (Score:2) (snip) It is almost an art the way MS does this stuff. Yes, but it's not a new art. There's a great breakdown of MS's use of the fine art of disinformation [consultingtimes.com] here. (The analysis is about a third of the way down) Re:GPL as Viral? (Score:2) Sharing? More like a source code loan. (Score:2) (Of course I'm sure the source code loan program probably doesn't have the same alliteration and "feel good" tendencies that sharing source code does.) Re:GPL as Viral? (Score:2) Is this viral? It seems to me that if we're looking for biological metaphors, it would be more accurate to call it hereditary or heritable. GPLed code doesn't go out and infect your work. Rather, if you choose to "breed" new software from GPLed code, that software inherits the licensing traits of its parent. Re:GPL as Viral? (Score:2) Furthermore, it is interesting to note, as you do, that "GPL hasn't been tested in court." Isn't that just another way of saying that nobody has ever been sued over GPLed code? Considering that the GPL has been around since 1984, that's some sort of track record. How many closed-source software companies are there which have been around for sixteen years and have never sued or been sued? Re:WARNING! (Score:2) [O]ne of the dominant open source license [sic] -- the GPL -- is the most infectious. It attempts to subject any work that includes GPL-licensed code to the GPL. Programmer: Here ya go, boss, the latest build of our really important software product... Manager: [scanning the source code] You idiot! See this line here? 'i++;' That's directly from the Gnu Emacs source! Its GPL License has infected our revision control system! Now we've got to release the whole thing to the world, source and all... there goes the quarter! I *knew* you should have set lawyer traps in the hallways! Programmer: How DARE they try to take the code I've written and make me give it away for free just because I took code someone else wrote and used it for free! Re:The FAQ... (satire, honest) (Score:2) That's the funniest thing I've read all day. Cool part is I can actually see the campchaos guys doing something like that We can only hope Re:Viral != Evil (Score:2) LGPL is more free than MicroSoft's libraries because besides the ability to use it in closed programs, you can also make derivative libraries (which must be open source, like GPL programs). Now not everything is rosey: 1. The LGPL has some strange wording that makes many people think the libraries have to be shared. I personally don't think so, but this belief puts a lot of annoying requirements on the library, and requires "installation" and "dll hell" for programs that use them. Rather than question this we have modified the LGPL to specifically say that static linking is allowed. 2. RMS has a strange idea that putting libraries under the GPL will force people to make the programs under the GPL due to the "virii" nature. This is absurdly untrue, the result is that people don't use the library at all, and they then use a commercial library that runs only on platforms that are made by large Seattle companies whose name starts with M. Putting useful libraries under GPL licenses is seriously hurting the acceptance of Linux as it is stopping the creation of commercial programs that port to Linux. Fortunately most everybody else appears to disagree with RMS and use the LGPL or Berkely licenses for libraries. Re:GPL as Viral? (Score:2) You can write all the code you want and not put it under the GPL, and can sell it for whatever you want! Oh, boo hoo, you can't take the source code with Linux and turn it into your own profit-making program. I'm just so sad for you. Hey, do you think you can take MicroSoft's code and turn it into a profit-making program without MicroSoft having something mean to say to you? Re:Impressionist FUD can be a serious problem! (Score:2) Excellent description of the equivalence. If GPL is "viral" then their own code is "viral". This point needs to be hammered home, there are people here on slashdot that show amazing ignorance of this, you can imagine what people in the real world think! The FAQ... (satire, honest) (Score:5) A. We have code. You don't. We make money by selling our code. You don't. We will let you look at the code, but don't touch it. We think this is balanced. Q: Why did Microsoft decide to highlight the Shared Source Philosophy at this time? A. We got scared by Open Source. Q: Is Microsoft's Shared Source Philosophy a Response to Linux? A. Yep. Q: What is Microsoft's concern with the GNU General Public License? A. We can't figure out a way to make money with code covered by the GPL. Q: How is intellectual property (IP) protection related to innovation? Why should society today rely on IP protection to foster innovation? A. IP protection works because we can make money off of it. If we couldn't make money, that would really piss us off. Society is a better place when we make money. Innovation is very important, as long as we make money. Basically the pattern is money==good. in their business section... (Score:5) Others have pointed out that this is indeed a PR/business strategy, not a technology one. MS is not arguing technology, code quality or any of such, they are pushing that the GPL is bad for business. MSDN does give away great quantities of source, most of which is example code, not core implementations that can be improved. Oh, and this is just my opinion, but [shared-source.com] needs some web design help. I think the PHB types that this should be aimed need eyecandy to feel good about the opinions stated. I'll try and throw something together this weekend but I'm sure there are more capable designers that could help. Chris Cothrun Curator of Chaos Re:IT rhetoric at it's worst (Score:2) It calls the GPL "complicated". However, _any_ use normally allowed by copyright laws is allowable with the GPL. It is MS who makes it complicated by revoking several user rights under copyright. You only get to the "complicated" parts of the GPL for the rights not granted by normal copyright. With MS, you never get extra rights. It's like saying, they have more features than we do, but on the features that they have that we don't, it's more complicated. Well, duh. Its rather funny because... (Score:5) When I quizzed him in detail he finally admitted that this was because they had the FULL source code from Microsoft and were patching (or at least flagging) their own fixes as they hit problems and giving these back to MS to integrate. But he wouldn't trust Linux, or any Open-Source model, and neither would MS.... Seems some people can have their cake, and eat it, and deny there was any cake there anyway T Why Linux Will Lose (Score:2) But where Linux loses is marketing. And that, alas, is exactly where Microsoft excels. MS could sell ice to the Inuit. The people who really count --that is, the people who decide to spend several million dollars on an operating system for their business: we're talking banks and big business, and the cumulative bijillion little businesses--are going to buy Microsoft Windows. Not because it's the best, but because they are businessmen, not computer geeks. They don't know how Linux can be to their advantage, they don't understand how Microsoft products have high cost-of-ownership, and they don't see any good business studies that prove Linux is going to save them an order of magnitude in costs. Indeed, what really drives them to buy are the glossy full-page advertisements with simple words. All the technical, moral and philosophical arguments in the world aren't going to make a dent. If Linux is to dominate, it needs to be marketed. It also needs a few missing killer apps, but, hey, that'll happen. -- Re:The FAQ... (satire, honest) (Score:2) Some Open Source companies will do well. It's only a matter of time. Cygnus was profitable before RedHat bought them. RedHat will most likely be profitable soon. Also, the King amasses a great deal of wealth, and wealth is important, but that doesn't mean we should have monarchies. speaking of FUD... (Score:2) Come on. The GPL a complicated liscense? The intent of the GPL is clearlt spelled out in terms even a non-lawyer can understand, is rather short as liscenses go, and is fairly non-obfuscated. Has whoever wrote the FAQ even read the GPL vs. your average MS EULA? Most people (IMNSHO) never get past the first paragraph in the EULA, because the obfuscation sets in almost immediately, even if they bother to read it at all! Sheesh... Re:GPL as Viral? (Score:4) Microsoft is entirely correct to say the GLP is viral because all derived works must also have the code to given away - so the orignal code infects any following work. Whether this is good or bad is left to the debate that is occurring now. Re:speaking of FUD... (Score:2) -- Re:Why Linux Will Lose (Score:2) -- Re:WARNING! (Score:2) The correct response to this is: All Microsoft licenses are viral, that is, they require that all derivative works be licensed on the same terms as the original program. These licenses are described as viral because they "infect" derivative programs. Microsoft licenses do notvary in how infectious they are, allprograms are derivative works. Re:in their business section... (Score:2) Yup. And guess what they think is bad for their business? They may as well have come out and said it...oh wait...they did: Linux is one of Microsoft's many competitors Need I say more? Viral Licenses ? (Score:2) Some open source licenses are viral, that is, they require that all derivative works be licensed on the same terms as the original program. These licenses are described as viral because they "infect" derivative programs. So I guess if you simply disallow derivative works, your license is not "viral" ? Seems kind of like whining to me, "Some open source licenses are protective of the developer's rights. That is they prevent MegaCorp Inc. from using the software without giving back to the community." Anyway, when was the last time a derivative of an MS product was made and licensed by someone besides MS ? A partial victory (Score:2) Think about that! How likely was this a few years ago? Re:At last! now I can ditch Linux and all the bigo (Score:2) Oh, and getting RH7.1 along with SGI's XFS installation image cost me nothing but download time and a few CDs. Just like the source costs me nothing for those products. I think you missed a few $s when you spelled Micro$$$$$$oft and gave an extra to RedHat. Re:At last! now I can ditch Linux and all the bigo (Score:2) Ahem. [redhat.com] for all your l337 0-day Linux w4r3z. Now, how is the above "Insightful" again? Call it what it really is. (Score:2) Why "poison source"? Quite frankly, I think "Shared source" might have a more dangerous viral aspect than some people claim of the GPL. Do you really think a developer will ever be allowed to work on an open-source project again, never mind a GPL one, after agreeing with MS' terms for looking at their source? If they do within at least eighteen months (what I believe current NDAs from MS are written for), you can bet MS will immediately launch legal action to have that project shut down due to "potential" copyright infringement. In this case, the virus doesn't even come from using the code, but just by looking at it. Hey, maybe MS will be nice and not force developers to sign an NDA and a no-compete in order to look over the code. However, MS has given me no reason to trust them before, and they certainly haven't done anything recently to get me to trust them now. Re:The FAQ... (satire, honest) (Score:2) ---------------------- (-1) (Score:2) Re:GPL as Viral? (Score:4) No, the GPL is not viral. It does not leap from unwilling host to unwilling host; your code will not suddenly come down with GPLitis out of the blue. If a genetic metaphor for creating a derived work is desired, consider the GPL as a dominant gene. It takes a deliberate propagative act to create a "child" that's GPLed; but having decided to "mate" your code with GPLed code you know the result will be GPLed - just as someone who carries two recessive genes for a trait and mates with someone carrying two dominant genes knows that the child will inherit the dominant trait. For example, if a blue-eyed woman mates with a man whose ancestors have been brown eyed for umpteen generations back, if I recall my biology correctly she's going to have a brown-eyed baby. (Barring mutation, crossover, etcetera, which is beyond the scope of this metaphor, okay?) If she doesn't want a brown-eyed kid, she's free to seek out another father. If you don't want your result to be GPL'd, you're free to seek out other code to derive your program from. The metaphor is not perfect, in that such a child would still be a carrier of the recessive gene, however it's a damn sight closer than "viral". Tom Swiss | the infamous tms | Re:I like this quote from the FAQ... (Score:2) Over the past 25 years, few people outside of the development community talked about source code and even fewer had access. Never mind that closed source is actually a relatively new thing...programmers started out by giving away source, because the hardware to run it on was what was important... As I recall, IBM used to more or less give away the source to OS/360 because what the customer was really paying for was the big iron to run it on. Ah, great MS FUD...defend your own business model by claiming it has a long, distinguished history, and make it sound as though these "open source" lunatics are some kind of crazy group of upstart hippies. Never mind the actual truth of the history of computer programming... Re:MS Tactic to end reverse-engineering? (Score:2) Re:Cool product idea (Score:2) Community and communism are not the same thing. --LP And you can tell ... (Score:3) --- GPL == viral, so M$ code == ? (Score:2) No one can force you to use GPL code, so the virus analogy doesn't really stand up anyway. I guess you could say that the GPL is like a non-communicable virus. Anyway, that's a pretty ridiculous argument from MS anyway, while you CAN use GPL code (with the limitations the GPL provides), you _CAN'T_ get access to Microsoft code at all. Well, you can if you pay out the ass for it I guess, but you can pay a GPL developer to license their code to you under a different license too. So, MS argument == NULL That's my take on it anyway... Mod up please. (Score:2) Microsoft can't compete with this. Their community in the early nineties was an open Dos and windows platform that businesses could profit from. They soon realized that Microsoft is hostile towards "middleware" businesses and many went out of business. In the Free Software community there is no monopolizing impulse, and businesses can happily coexist, peddling their proprietary middleware. Microsoft shut out IBM, and now IBM finds extraordinary value in linux. Other once profitable software companies that were shut out from windows by microsoft are also finding value in linux. Software companies dont want to compete with MS on their own monopoly platform. Internet companies dont want to pay licensing fees to microsoft to run their busines, avoiding draconian EULA's. Expect more of the exodus from windows to free software. A small taste of freedom is addictive. An intravenous injection of freedom is downright intoxicating. Fools! Not Microsoft . . . YOU! (Score:2) Let's take a look at the reverse of the power flow. First, assume that Slashdot is anti-Microsoft and pro Open Source. I hope we all agree this is basically true. Next, think about how Slashdot has pointed to Microsoft, directly no less. This, as I described above, gives them a bunch of juju and augments their position. It gives them credibility. Finally, think about this: Microsoft never points to Slashdot and rarely (if ever?) points to Open Source web sites. They are not powerful and rich for nothing. The folks here are foolish to think they have power through hacking and technology and fighting the good fight. Wrong! Many of the folks here wouldn't understand advertising mojo or marketing juju if it bit them on the ass with big, sharp, bunny teeth. Look folks, I'm not a total troll. I hope you are actually listening... Marketing, media, and propoganda, oh yes, all weapons of Microsoft. Slashdot is playing exactly into the hands of Microsoft. You are sheep! Nothing but sheep. (OK, that last bit about sheep was definitely out of line. Re:Look...this isn't funny anymore... (Score:2) Web sites can be shut down, folks. We are not very powerful compared to companies, or the government. To make matters worse, the community is not united. The community is fragmented. Why? I'm not sure because I am not close enough to it. I don't program and I don't hack. However, I do see that there are many egos. There are leaders, but there is no centralized power. Without centralized power (i.e., money, captial, intellectual resources) I don't think it will be possible to slow down the growing wave of Anti-Open Source. Think about that. So, here is where I start to really think. What is the true purpose of the Open Source Community? Is it for fun? Adventure? Because it is a small, exclusive club of smart people? Is it because you feel ownership? Do you have a giant itch to scratch? BULLSHIT to all of that. Bullshit, I say. You are going up against a company with over $25 BILLION in cash. What is the Open Source community worth? All of you? All of your work? All your effort? Pah! It ain't worth shit comared to that. And don't start telling me that the internet is driven by Open Source. That doesn't mean a thing. At this point in time, I would state that you could build the internet using commercial products. People would live with that. People would still have the internet, now, without Open Source. They'd pay if they needed to, to support their habits. It wouldn't be the same, but it would work. But back to my point about power and money. Microsoft, UNLIKE the Open Source community has a very clear goal: BILLIONS. They are driven by money, and they know how the system works. What are you driven by? Will your love of coding, or your developmental scratch, or your minor rebellion be enough to fight the BILLIONS backing Microsoft? I want to know what you plan. I'd LOVE to back Open Source if it had a battle plan. Re:Look...this isn't funny anymore... (Score:2) Re:Goddard's law (Score:2) Source Code (Score:4) Re:MS View of Innovation (Score:2) Now before someone jumps on my case for being anti-Microsoft, I am, and I have a right to be. I sat through this on Team OS/2, as well, and I'm seeing a lot of the same tactics (Almost word for word press releases etc) for Linux. While I don't think they can kill the system, they can make it much more difficult to find hardware that will work with it. And I like being able to use Linux at work if I want to. It's very clear to me that in Microsoft's world, I would not be able to do that (Or even work without one of their stupid certifications.) So if I'm very vocally against them, it's because I know they're not trustworthy and I know that they will do everything in their power to force me to use their products. MS View of Innovation (Score:5) 1) Discover something that someone else is doing that looks like it might make money. 2) Implement a less featureful version of it, give it away for free and start charging around version 5.0 once we've eliminated the original company. From gdict: 1. The act of innovating; introduction of something new, in customs, rites, etc. --Dryden. I think we're closing in on the disparity between the MS definition of Innovation and the one the rest of the world uses. (So yes, what I could stomach of their shared source FAQ was somewhat insightful.) As a side note I didn't notice them enumerating what source would be shared, nor what you could do with it, but the meaty parts of the page may have come after the gag reflex kicked in. Next time I hit a MS web page I'll be sure to take a dramamine first. Re:Viral != Evil (Score:5) Trust me, they aren't missing the point. They find magnificent ways to couch ideas that they don't like in a negative or deterring way. For example, if you want to rip a cd using windows media player, it defaults to having that security encryption crap turned on--meaning you can't play the ripped music on other computers (without breaking the encryption). If you go through the help and the menus, looking for some way to turn it off, you are going to have to look pretty carefully. It is in there, but they disguise the meaning. You turn it off by turning off "License Managment". The help file description of this is (paraphrased): "If you turn off license managment, and try to download a song to a portable player, Windows Media won't copy the license file over." While this is true, it won't copy the license file over, it is only true because the music file is not encrypted anymore and doesn't need a license! Whereas the helpfile text sort of implies that you still need a license to play the music, but now you have to manually copy said license over to the portable player. It is almost an art the way MS does this stuff. Re:Sounds suspicious... (Score:3) "When you download Microsoft, you're downloading COMMUNISM!" [er, warning, attention: humor attempted above.] Re:GPL is not Viral! (Score:2) The only circumstances under which you may make and distributge a derivative work is with the blessing of all authors of copyright. The GPL provides this blessing as long as the works are licensed under the GPL. This means you have more rights than copyright law would allow, if you use GPL software. The GPL also has the effect of making the distributed works the intellectual property of the community of free software users, in that they may be distributed only as free software. This thing that Microsoft claims is worth so much, the intellectual property, belongs to all free software users. And that scares Microsoft to death, and leads them to a clever marketing campaign in which the GPL is called viral. It is not. The only perspective from which it may even SEEM viral is the perspective of a BSD license. And that could not be further from Microsoft's perspective. Re:Viral != Evil (Score:2) There is indeed much confusion over this one. I, for one, would argue that a library by definition defines an API, and that anything that uses that API is NOT a derivative work, since the entire purpose of a library is to define and export an API for other applications to use. RMS believes that something that dynamically links against a library IS a derivative work. This belief is absolutely critical to TrollTech's business plan. They provide QT under the GPL, or you can buy a more standard copyright arrangement if you wish to incorporate QT code with your proprietary apps. But the GPL has a proviso that: If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. This proviso would seem to apply specifically to programs using an exported API. Others may argue that the linking program still must include the header files at compilation time, but again, it is the intent of a library to provide public headers and APIs. And also consider, a program dynamically linking to a library is analogous to ANY program running under linux. All system calls dynamically link to the kernel, which is GPL licensed. As far as I know, this aspect of the GPL has never been challenged legally, and it would seem to me that RMS is quite wrong in his assertion. Re:Viral != Evil (Score:5) Under copyright law you have no intrinsic rights to distribute anyone else's copyright. If you make a derivative work, you have no intrinsic right to distribute that derivative work. You may only distribute derivative works if all authors of copyright agree on terms. Under the GPL, the situation is substantially improved. You can distribute someone else's copyright. You can make and distribute a derivative work, with the added proviso that all the work must be released under the same license. Basically, Microsoft calls this viral because they would rather the author of a derivative work have ALL copyrights to the derivative and the original work. This is the BSD license. This is even more rights to the recipient of a copyrighted work. But please remember that GPL programs still give you as a software user MORE rights than you have intrinsically. The GPL has some protection for the community that would prefer if everything were open source, because it restrains any open source (GPLd) program from becoming proprietary. It in effect assigns the intellectual property to the open source (or free software) community. This is what Microsoft is attacking. The crown jewels for Microsoft are its intellectual property. It is fighting like mad because the GPL gives the free software community the same protection of its intellectual property that Microsoft has of its own. It is not a business model - it is a community software model. Why I Want Source (Score:2) There's the old argument of "if I need support or someone to sue, at least I have Microsoft" -- ask yourself this, when was the last time you got decent support from them? When you needed a new feature or reported a real defect, was it your business model or theirs which was given priority? And if you went to sue Microsoft, and were 100% in the right, given the deep pockets there... could you survive battle the court costs? With the source you can fix it or hire someone to fix it. The fact of the matter is, business doesn't like to ride technology waves. They want something that gets the job done, works right, and is reliable and as maintanence free as possible. As long as Microsoft misses this point, they're going to alienate customers. It still amazes me that even IE's about box reports that it stands on the shoulders of NCSA Mosaic. "Viral" (Score:2) Capitalism is viral - it's how the USSR lost the cold war - they couldn't compete with our markets and efficiency. Democracy is viral - almost every form of government that has tried to resist it has fallen. (With a few exceptions, and I'd argue that it's only a matter of time.) Brilliant ideas transform society in a way that cannot be opposed, cannot be ignored, and they have a way of making life better. The GNU GPL is a brilliant idea - and it's only a matter of time, Microsoft. We can do it better, cheaper, faster. What leg do you plan to stand on? Oh, right - legislation and name-calling. Sorry, I forgot. Standards? (Score:2) I'd like to know what standards Microsoft has been using to promote interoperability and support healthy competition. It seems like they just try to take something good and make it propriatary so it doesn't interoperate with anyone else. From my list I see BOOTP-DHCP, NFS-SMB, Kerbos(sp?), undisclosed file formats, and I'm sure the list goes on. Unless they mean that by supporting the TCP and IP connection protocols they are supporting standards and healthy competition, but I don't buy it. I know this is the standard 'Embrace and Extinguish' rant, but the fact that they are trying to claim that they don't follow these incompatibility practices and that shared source won't either is just wrong. I also wonder what they consider 'healthy competition' to be. They obviously consider Linux to be some sort of competition, and they are trying to squash it even though it has such a small market share on the desktop. I suppose their definition of 'healthy competition' and most business defintitions are a little different. Macs are probably considered competition, and I believe Microsoft ported it's office suite to Mac, but not Linux, why? That probably supported healthy competition, but maybe Linux is considered a threat and Macs aren't, hmmmm, makes you wonder... Re:a dissenting view? (Score:3) The entire software industry needs to get off its buff and become more professional. This is about SAVING your JOBS, should you actually WANT to be regarded as a professional software expert, rather than as a code-monkey. When companies want computer expertise they should know that theere are people who can and will support them. That person is you. Or would you rather be a code-mopnkey. to be retired as soon as cheaper labor comes along. Put it another way, why should the CEO of a company pay you to code when he could too, having also learnt programming during his college days. Simply becuase you can code better? Re:At last! now I can ditch Linux and all the bigo (Score:4) Guess what? Admission of the "comfort factor" argument is really discrediting yourself. Maybe you'd like to turn around and say "well you didn't check the source for your GPLed programs too". And guess what? I didn't. Becuase having the source is not just about being paranoid about trojans. It is about having a reference, having the ability to cross-check the code for correctness when I have to. Being able to fix it, and being able to make it better, and give it back. For any one of these reasons, "Shared Suorce" is not enough. Keep your paranioa to yourself. Re:Impressionist FUD can be a serious problem! (Score:2) Re:Viral != Evil (Score:3) Re:GPL as Viral? (Score:2) Isn't Microsoft licenses "viral" in that sense also? Fact: Any programmers working on Windows 2000 kernel must release his work under Microsoft's license... Fact: Any programmers working on Linux kernel must release his work under Linux's current kernel license (GPL)... How is this any more viral? Re:And you can tell ... (Score:2) Click->view->source HTML source from Microsoft! Open Source it! Viral is a bad name for describing the GPL (Score:2) Viral would mean that the GPL infects software, and sucks away vitility. "Recursive" would mean that the same license applies to related works and so on ad infinitum. Re:The FAQ... (satire, honest) (Score:4) The way I see it, Bill Gates would be in place of Lars Ulrich telling the story about how the GPL is bad and so on, Steve Balmer would take the place of James Hetfield saying Windows GOOD! Linux BAD! and so forth... Gates: "Like good afternoon, my name is like Bill Gates from the software giant Microsoft. I'm here today to to talk about open source software." Balmer: "Open Source BAD!" Gates: "Yeah so like these open source coders are out to destroy our company and destroy the American way. Open source licences are like a virus or something and they well infect you, and your mother fucking code if you use it. You will also turn into an evil communist if you write open source software." Balmer: "Communist BAD!" Gates: "We spend upwards of 24 to 48 hours writing our code and we don't want you open source zealots to steal our hard earned money!" Balmer: "Money GOOD! Open Source BAD!" Okay, so the story line isn't great, but I wrote it quickly... Re:Shared Source == SCSL (Score:2) how exactly is Sun threatened by Open Source At the time the SCSL was introduced, they were still licensing Solaris. Historicly, they weren't exactly open with their Java code either. It just so happened that Sun sells enough hardware and other services that it made sense for them to support OSI compliant licenses. Sun wanted to divide the cake and eat both pieces. They realized they couldn't do that, so they decided to eat the hardware/service piece. So, if you want Windows source just wait. MS appears to be trying to move towards hardware with Xbox, and towards services with .Net. At some point, MS may end up being more like Sun or IBM, and then it will actually make sense for them to release source in an OSI compliant manner. Desktop operating systems will probably have to be totally commoditized first, and MSFT will have to totally shift its business model away from shrink-wrapped licensing, but stranger things have happened. Those guys aren't dumb. They realize the clock is ticking on their business no matter what. I guess mindless bashing works better for you. I usually don't say this, because I think it's pretentious; but I just have to say it: ad hominem. Shared Source == SCSL (Score:4) Remember Sun's Community Source License? No? Good reason. It was just a lame attempt to respond to the Open Source threat. The funny thing is that Shared Source, if shared-source.com is to be believed, is worse than source code licenses that MS has used in the past. I'm referring to MFC. There was no prohibition against fixing bugs in MFC and incorporating them into your code. As far as I know, there was no prohibition against telling people how to fix bugs in MFC either. In fact, one of MS's fixes for an MFC bug actually told the user to change the source and rebuild it (although there were several alternatives, and that was listed as the least preferable). The MFC case just demonstrates that MS, like any other company, will release source to the degree that it makes sense. It just so happens that at this point in time, it doesn't make sense for MS to loosen up their source very much. Let's face it. How many of us, sitting on such a cash cow, would release source? I'm not suggesting that MS should go OSI compliant. That would be foolish for them. However, it might be a good idea if they made sources available to anyone who wanted them, and made it legal to distribute patches. This kind of distribution doesn't hurt the bottom line of book publishers, who's "source" is naturally open to all. Distributing patches would be analogous to writing reviews. Copyright law is strong enough to protect book publishers, and it would be strong enough to protect MS too. Re:GPL as Viral? (Score:2) But the line is almost certainly not defined by the GPL, per se, but by copyright law, on which the GPL depends. Any use of the GPLed code that doesn't rise to the level of copyright infringement shouldn't constitute a GPL violation, as the user only has to accept the GPL in order to avoid violating copyright. Therefore no copyright violation implies no GPL violation. The fact remains that what constitutes a copyright violation is rather fuzzy and has to be determined in court, but that's a potential problem with any license. What happened to the LGPL? (Score:5) Ok now I know that Loki owns the SDL library, but other companies can do this too. They can use and modify the SDL library in their programs, provided they give access to the changes they made to the library. "Intellectual property" is preserved in their proprietary section of code while still being required to release changes to the original source back to the community. From the FAQ... (Score:2) Q: Is Microsoft's Shared Source Philosophy a Response to Linux? A. Competition is a fundamental motivational force driving innovation and product improvements in many areas of business, ultimately benefiting the end consumer. Linux is one of Microsoft's many competitors. The issues that we are discussing in relation to the Commercial Software Model and Shared Source are much larger than Linux or Microsoft. There are fundamental concerns relating to the future of the software industry that need to be addressed. One such issue is the GNU General Public License. The wide use of Linux code and its licensing under the GPL presents a real threat to businesses and individuals who wish to obtain value from their intellectual property. Emphasis added. -- Re:Viral is a bad name for describing the GPL (Score:2) -- WARNING! (Score:3) Good lord! I had no idea running open source software was so dangerous! I mean, what with the liberal news media and their anti-microsoft slant you'd think it was good american programs like, oh, say.. Outlook that had 'viral' problems.. VBS must be open source. Licensing (Score:2) Re:MS View of Innovation (Score:2) This attitude has translated over to the Linux community. People post all the time about how Microsoft is "scared" of Linux. Which is completely untrue, as MS is fighting an offensive battle to gain ground in the webserver/database markets that had traditionally been owned by Unix. The day they start moaning about losing fileserver seats to Samba is the day they're on the defensive, but that hasn't happened yet. But yeah yeah, Stephen Bartko, one propaganda page at microsoft.com. Blah blah whatever. Don't learn your lesson and keep fighting the demons in your own head. It's just another defensive battle which you will lose. Re:MS View of Innovation (Score:2) Thinking of it as a "threat" is the paranoid looney take, and most Linux advocacy folks have gone there. "Market opportunity" is the way too look it. And writing me off as a "drone" is not only factually incorrect, it's completely unfair and completely stupid. Great fucking way to sell your product. I just don't want to sit here and watch another group of idiots blow their whole fucking leg off trying to flamewar Microsoft as the OS/2 guys did. Learn your fucking lesson or perish. There's even a HOW-TO. Read it. Re:MS View of Innovation (Score:2) No you're here to call a large nameless group "brain washed Microfoft (sic) drones". You seem possessed of the rather ridiculous idea that operating systems can "rise" and "fall", or be used or rejected by large segments of the operating system purchasing market, due to flamewars on technology discussion sites like this one Actually that's the exact idea I'm attacking. Calling your competitors a "threat" is an example of that sort of thinking. The lesson of OS/2 is that a looney fringe *can* hurt a platform's prospects, and that's exactly the tune that Mundie is playing. Re:MS Tactic to end reverse-engineering? (Score:3) Excluding "secret API" FUD, your description of Office development are the exact practices that Corel and Lotus have complained about for many years. You can tune your product using OS source, they can't. Will they be able to under "shared source"? Will (say) an IBM developer working on a juicy piece of middleware that MS wants supported on Windows be forbidden to transfer to the Lotus division? I guess it really comes down to if "shared source" is something new, or just a continuance of MS's existing source license policies. Agent Gates (Score:3) GPL as Viral? (Score:3) In fact Microsoft marketing is Viral, because it precludes the options of other solutions, where GPL allows for as many solutions as you desire. Correctly identifying the infection verse the AntiBodies is very important GPL acts as an AntiBody against certain infections. GPL as inoculation (Score:3) No. Read that part there. "...all derived works..." It's a bad analogy, because a viral infection is unintentional. Making a derived work is a very deliberate act. It's more akin to an inoculation where you affect an entire system purposefully. People don't say, "oh no, I'm infected with the polio vaccine; now I can't get polio. Help, I'm being repressed." They took the vaccine because they intended to effect themselves in that way. Re:In accordance with prophesy (Score:2) While we all know damn well that's what will happen in the long run, this could have some interesting applications right now. I think MS may have a good idea, just implemented poorly- it could be a possibility to bring a little bit of money back to the programmers, which everyone knows is a good step to encourage people to develop more. BTW- This article was short, sweet, to the point, and no editorial other than the neutral "Discuss." Are the editors feeling well?? Shared Source: Embrace and Extend (Score:2) Damn, who would have imagined that the Microsoft would try to, with their own proprietary extensions of course, Embrace and Extend the GPL itself!?! It sounds like MTV's new marketing campaign (Score:3) Bryguy Polio metaphor defuses "Viral" rhetoric (Score:4) How can we extend the analogy? The GPL is to a virus as M$'s EULA's are to shackles? The analogy won't extend properly because it's based on a faulty premise- that virii are all bad by definition. I propose the following: free software is more like the polio vaccine. When asked if he was going to patent the polio vaccine, Dr. Jonas Salk said that would be 'like patenting the sun'. Free software doesn't restrict freedom like a virus that crashes your computer or destroys your body, it preserves freedom by making sure that no one can take away the rights you've got, just as the polio vaccine prevents polio from ravaging the body. So which one's the vaccine and which one's the virus- that's the question we should be asking. I think the metaphor is apt and ought to embarass Micro$oft a little. Bryguy ps- feel free to use this metaphor. It's free as in speech. Idea from earlier story.... (Score:2) I like this quote from the FAQ... (Score:4) IE, Microsoft. To the end users, it represents a real benefit. -S Comparing the MSs license to GNU license (Score:2) GNU public license Source licensees can share source or other source-based work with other source licensees. :-) This means, the license is viral in a similar way to the GPL; in order to give the code to someone else, you have to infect the other person with the MSsl. Welcome to the club of viral licensors. MS Source is licensed to the requesting organization, not individuals to insure broad internal access. The GPL allows a single person to fulfill the american dream and write great code. Maybe you, but probably the organization you work for, can use the PARTS and CONCEPTS of the code that you developed yourself commerical. You are DISALLOWED to use parts of the source code of MS commercially or otherwise unless you subscribe to the MSsl. The GPL allows you to use all of the code source, but to withhold and use none of it commercially(but you still can base a business on it, just not on keeping the source). Microsoft is unable to ship source code under this program to all countries, due to limited resources. GNU and other sites are distributing source and binaries to gazillions of users, every one of which is allowed to use the code (Luke). I think the score is: 0:2 for GPL Possible weak links of the MSsl A university could decide to simply accept all living persons on earth as its members, such allowing everyone to look at MS source code. Re:At last! now I can ditch Linux and all the bigo (Score:2) If I had access to the source, I could fix it for myself. Sure, I'd rather be able to distribute the patched version. But as long as there isn't a realistic free alternative (I tried KSpread from CVS last night and it's getting there but not yet there), fixing it on my own box is better than nothing. Come to think of it, isn't that what RMS wanted to do with that printer driver in the first place? * Max, Clippy's slightly less annoying MacOS cousin. Unsettling MOTD at my ISP. Re:Yellow Journalism (Score:2) Slashdot readers (should) be/are fairly intelligent and can probably come to their own conclusions without being sent obviously biased articles. Oh, please. The shared-source.com web page makes adequate references to sources it cites, unlike non-biased news sites like zdnet or c|net, which rarely if ever give you an outside link to a citation. Readers of shared-source.com are more than free to leave the page and check on the veracity of just about anything stated on that web page. So, you've gotten just about everything wrong: Microsoft supports BSD licensing? (Score:4) Q: What is Microsoft's concern with the GNU General Public License? A: There is no question that the GPL is a complicated license that has led to a great deal of confusion. For the sake of clarity, we wish to reiterate our basic points in regard to the GPL and other OSS licenses. Some open source licenses are viral, that is, they require that all derivative works be licensed on the same terms as the original program. These licenses are described as viral because they "infect" derivative programs. Viral licenses vary in how infectious they are, depending on how they define which programs are derivative works. However, one of the dominant open source license-the GPL-is the most infectious. It attempts to subject any work that includes GPL-licensed code to the GPL. Thus, if a government or business uses even a few lines of GPL-licensed code in a program, and then re-distributes that program to others, it would be required to provide the program under the GPL. And, under the GPL, the recipient must be given access to the source code and the freedom to redistribute the program on a royalty-free basis. Open source licenses that are non-viral, on the other hand, permit software developers to integrate the licensed software and its source code into new products, often with much less significant restrictions. A prominent example of this type of license is the Berkeley Software Distribution (BSD) license. The BSD license allows programmers to use, modify, and redistribute the source code and binary code of the original software program, with or without modification. Moreover, programs containing code subject to the BSD license are subject to only limited obligations imposed by that license. This type of license gives users freedom to incorporate their own changes and redistribute them, without requiring them to publish the new source code or allow royalty-free redistribution. Q: We're confused. Does this mean that this is the model that you're going to be using for your own shared source strategies? A: Ha ha, no. We just wanted to take this opportunity to use certain words like "viral", a word which we unintentionally made popular, against our primary competition. Q: Oh. So you have no plans to release your source code free for public use for people to take and incorporate into their projects how they please. A: Of course not! What sort of fools do you take us for? Q: So your opinion of the GPL and BSD models and licenses is really irrelevent. A: Er... yes. But don't tell anyone, 'kay? Viral != Evil (Score:4) Now, Personally, I'm more of a BSD licence guy, myself, but Microsoft is totally missing the point here. Of course it's viral. It's supposed to be. The GPL's viral properties keep people from being able to steal GPLed code, in the exact same way that MS will try to keep people from stealing their code. MS treats this viral property as if it were a great evil communist conspiracy, and they need to grow up. The GPL prevents code from being reused without a price, the same way that MS will do the same to anyone who uses any of their shared source. The difference, in fact, is that the GPL will give you the choice to use the code, even with the "Viral" license. MS will not let anyone use their code, instead going for their 'Code Under Glass' philosophy. Obviously, there's no questioning which one leads to true 'innovation'. Re:MS Tactic to end reverse-engineering? (Score:2) I've tried to find fault with it but it doesn't seem blatently wrong; although perhaps anti-competitive, but not ilegal. --CTH -- Microsoft Advances the field of Computer Science (Score:2) See, Microsoft has contributed to computer science by making otherwise deterministic systems completely non-deterministic. Wait, Isn't that a requirement for true artificial inteligence. See It's a feature. People have been trying to create non-deterministic computing systems for 30 years... And Microsoft has succeeded. -- My question is... (Score:2) It's funny how competitive Microsoft is, a corporation trying to preserve its bottom line trying to dissuade other corporations from neglecting their bottomlines to purchase (and tether themselves into) their software. You can't argue with free... no matter how much propaganda money you throw at it. Death! (Score:2) If GPL is a Virus, than Microsoft's Shared-Source is Death! Use GPL and contribute to the community. Use Shared-Source and go to jail! Nice soundbite material, stuff the press can easily understand. Doesn't have to be inherently true, just argueable so. Re:MS Tactic to end reverse-engineering? (Score:2) Funny, Microsoft denies that these documents are offician and then impliments every one of the concepts.... Of course what they don't want you to see is something like the following: Secret Windows 98 code: #include "dos.h" #include "w311.h" #include "win95.h" #include "Oldstuff.h" #include "EvenMoreStuff.h" #include "bluescreen.h" int main (){ make_app_look_really_big (active_application); if (check_crashed = 0) \\ if we haven't crashed bluescreen (rand); sleep (5); create_gpf (rand); sleep (5); bluescreen (rand); sleep (5); leak_memory (rand); bluescreen (rand); } Strange economics (Score:2) But by this logic wouldn't we all be much better off if Microsoft increased all its prices by a factor of ten, or a hundred, or more? Think of all the extra tax revenue! I'm no business-as-usual Republican, but even I would agree that the economy improves as goods and services become cheaper. It's true that by using GPL software companies can save lots of money, but that money won't simply disappear, it can be used to expand the business itself or to give employees raises or be paid in taxes as a portion of the increased revenues accruing to owners. I guess all these are bad now. What are they trying to do? (Score:2) 1.Community: A strong support community of developers. Sorry, but what a crock of shit. It sounds like they want to take some of the ideals of the OSS and FSF to increase their image to developers. A good example is that this page is not on their developer page, but on there business page. It's good that they are showing some source finally (they probably did a grep -r The only statement that cannot be questioned, is that every statement can be questioned. We 'share', and you grant us back all your 'work' (Score:2) At last! now I can ditch Linux and all the bigotry (Score:2) Hell, how many people actually want the source code because they are going to actually compile it ? Not many i'd guess. But plenty of people want the source as a kind of comfort factor. I am one of those people. I could not give a flying fuck about whether it is GPL, LGPL, BSD or whatever (they differ only in technicalities) I just want to know that my software is safe and will not allow me to be penetrated via the backdoor with a trojan. Anyway, now Microsoft have gone "open source" do we actually need Linux any more ? I mean, sure Windoze costs $$S, but then so does Red$Hat these days... It's all in the marketing! (Score:2) So, why will Linux lose? Not because it is not good enough, but because the marketing behind Linux is not sexy enough. Just look at microsoft. Read about them, learn from them. Examples: I am serious. My manager is prepared to throw away his great working palm for a bigger, userUNfriendlier handheld. This is the problem Linux faces. Marketing. And this is the area in which Linux will lose big time unless something happens. Look at microsoft, study microsoft, learn from microsoft. Read "The Art of War". I did and learnt a lot from it. The first chapter handles about studying your enemy careful. Microsoft does this, Linux (or the whole OSS community) doesn't. This is logical, 99% of the community is coders. But when you want the suits to accept Linux (remember, the suits make the decisions, not the techs), you have to talk like a suit. Final note: I have submitted stories like these on here before, but no one listened. I hope this time it will be different (but I doubt it...) Closed source (Score:2) MS Hypocrites demand others souce code! (Score:2) Re:speaking of FUD... (Score:2) ----------------- MS Tactic to end reverse-engineering? (Score:5) Don't forget that the holy grail of reverse engineering is the Chinese wall between the guy who analyzes the original product and writes the spec documents and the guy(s) who then read the spec documents and design the compatible/replacement product. What am I getting at? The fundamental requirement for the guys who create the competing/replacement/compatible product is that they must never have viewed any of the original source (if it's software) or viewed the original drawings or workings if it's a machine. This is known as finding "virgins" to do the work. If MS spreads its source code wider via this "shared source" concept, they'll still have all the copyright protection they could ask for and now it will be much harder to find virgins who can work on competing/compatible products. Since university students are a huge part of the open source community, MS may be intentionally polluting the community by allowing universities (and their CIS or Computer Engineering students) to see the source to MS operating systems. Maybe I'm just being paranoid, but I have a hard time believing Microsoft wouldn't resort to such tactics if they thought they could get away with them. Cool product idea (Score:3) And no I'm not kidding or trolling. I do believe communism, in theory, is a good idea, and that free software is the only example of communist-like principles done right. -- "Fuck your mama."
https://slashdot.org/story/01/05/18/1659252/shared-source
CC-MAIN-2017-30
refinedweb
9,594
73.37
Pandas has got to be one of my most favourite libraries… Ever. Pandas allows us to deal with data in a way that us humans can understand it; with labelled columns and indexes. It allows us to effortlessly import data from files such as csvs, allows us to quickly apply complex transformations and filters to our! First thing to do its to import the star of the show, Pandas. import pandas as pd # This is the standard. # Reading a csv into Pandas. df = pd.read_csv('notebook_playground/data/uk_rain_2014.csv', header=0). Now we have our data in Pandas, we probably want to take a quick look at it and know some basic information about it to give us some direction before we really probe into it. To take a quick look at the first x rows of the data. # Getting first x rows. df.head(5) All we do is use the head() function and pass it the number of rows we want to retrieve. You’ll end up with table looking like this: Another thing you might want to do is get the last x rows. # Getting last x rows. df.tail(5). # Changing column labels. df.columns = ['water_year','rain_octsep', 'outflow_octsep', 'rain_decfeb', 'outflow_decfeb', 'rain_junaug', 'outflow_junaug'] df.head(5). # Finding out how many rows dataset has. len(df) This will give you an integer telling you the number of rows, in my dataset I have 33. One more thing that you might need to know is some basic statistics on your data, Pandas makes this delightfully simple. # Finding out basic statistical information on your dataset. pd.options.display.float_format = '{:,.3f}'.format # Limit output to 3 decimal places. df.describe() This will return a table of various statistics such as count, mean, standard deviation and more that will look at bit like this:. # Getting a column by label df['rain_octsep']. # Getting a column by label using . df.rain_octsep. # Creating a series of booleans based on a conditional df.rain_octsep < 1000 # Or df['rain_octsep] < 1000 The above code will return a dataframe of boolean values; ‘True’ if the rain in October-September what less than 1000mm and ‘False’ if not. We can then use these conditional expressions to filter an existing dataframe. # Using a series of booleans to filter df[df.rain_octsep < 1000] This will return a dataframe of only entries that had less than 1000mm of rain from October-September. You can also filter by multiple conditional expressions. # Filtering by multiple conditionals df[(df.rain_octsep < 1000) & (df.outflow_octsep < 4000)] # Can't use the keyword 'and'. # Filtering by string methods df[df.water_year.str.startswith('199')] Note that you have to use .str.[string method], you can’t just call a string method on it right away. This returns all entries in the 1990. # Getting a row via a numerical index df.iloc[30]). # Setting a new index from an existing column df = df.set_index(['water_year']) df.head(5). # Getting a row via a label-based index df.loc['2000/01']. # Getting a row via a label-based or numerical index df.ix['1999/00'] # Label based with numerical index fallback *Not recommended. df.sort_index(ascending=False).head(5) #inplace=True to apple the sorting in place. # Returning an index to data df = df.reset_index('water_year') df.head(5) This will return your index to it’s original column form.. # Applying a function to a column def base_year(year): base_year = year[:4] base_year= pd.to_datetime(base_year).year return base_year df['year'] = df.water_year.apply(base_year) df.head(5)… #Manipulating structure (groupby, unstack, pivot) # Grouby df.groupby(df.year // 10 * 10).max(). # Grouping by multiple columns decade_rain = df.groupby([df.year // 10 * 10, df.rain_octsep // 1000 * 1000])[['outflow_octsep', 'outflow_decfeb', 'outflow_junaug']].mean() decade_rain Next up unstacking which can be a little confusing at first. What it does is push a column up to become column labels. It’s best to just see it in action… # Unstacking decade_rain.unstack(0)’. # More unstacking decade_rain.unstack(1) Now before our next operation, we will first create a new dataframe to play with. # Create a new dataframe containing entries which # has rain_octsep values of greater than 1250 high_rain = df[df.rain_octsep > 1250] high_rain. #Pivoting #does set_index, sort_index and unstack in a row high_rain.pivot('year', 'rain_octsep')[['outflow_octsep', 'outflow_decfeb', 'outflow_junaug']].fillna(''). Sometimes you will have two separate datasets that relate to each other that you want to compare them together or combine them. Well, no problem; Pandas makes this easy. # Merging two datasets together rain_jpn = pd.read_csv('notebook_playground/data/jpn_rain.csv') rain_jpn.columns = ['year', 'jpn_rainfall'] uk_jpn_rain = df.merge(rain_jpn, on='year') uk_jpn_rain.head(5). # Using pandas to quickly plot graphs uk_jpn_rain.plot(x='year', y=['rain_octsep', 'jpn_rainfall'])! After cleaning, reshaping and exploring your dataset, you often end up with something very different and much more useful than what you started with. You should also ways keep your original data, but also saving your newly polished dataset is a good idea too. # Saving your data to a csv df.to_csv('uk_rain.csv'). Remember, don't forget to share this post so that other people can see it too!Also, make sure you subscribe to this blog's mailing list, follow me on Twitter and add me on Google+so that you don't miss out on any useful posts! I read all comments, so if you have something to say, something to share or questions and the like, leave a comment below! Jamal works as a developer for a Tokyo-based start up. He has a particular love for Python and likes to dabble in Data Science. Continue reading on
https://hackerfall.com/story/an-introduction-to-scientific-python-pandas
CC-MAIN-2019-04
refinedweb
930
68.97
“It’s unusual for a Beta 1 version of Windows to have both the final shipping name of the product and as many new features as this build shows. And that’s a strong sign of two things. Firstly: Windows Vista remains an ambitious release of Windows, despite some of the features that Microsoft has pushed off the side of the boat. Secondly: Microsoft is trying to get serious, both internally and externally, about this development program. Windows Vista is now the company’s top priority.” Read on, ten pages, here. Windows Vista Beta 1: a Guided Tour About The Author Thom Holwerda Follow me on Twitter @thomholwerda 72 Comments 2005-08-12 4:02 am Windows needs to seperate the users from the system imn more than name only… It is not the graphic part of the interface that sets the Mac apart. It is the fact that my small shareware apps do not need i have the security features or frameworks turned on to work as security. If I have a widget, or a shareware app that I need to install then I need to know the admin password. So my wife who has Physical access to the Server. (OSX server 10.4) but no passwords can add stuff to her <my node(the server)>/users/%home%/library like screensavers and fluff and ~/applications for her apps like Office, and I can add libraries and ‘mutations’ to ~/Developer and have them exist in my namespacepath, and my son by use of server ACLs will not be able to mount our “adult” content or media drives In Linux this sort of capacity take a while and in the Mac it takes minutes and works the first time… If Microsoft chooses to lift design from the Mac it will always be late. ‘longhornvista’ will be emulating 2004-5 MacOS in q3-2006 and Macos 10.5 [i]will <i/> be released q2-2006 then Microsoft will again be the last one to the watering hole of what we all want. Outside of x86 support MacTel what do we know about 10.5? Cupertino has 2 commodities the first being happy users, and the second being the dark horse that SAdmins use at home A.K.A. the Alpha Geek factor. I just bought an ibook 1.25 and it smokes the Dell inspiron that work gave me. The Gov’t ITSO (IT Security Officer) was amazed at the things I can do and the weight penalty v. the insprion is 2 iPods and my toshiba PDA Nobody has seen aero yet, except some MS-employees. Aero will be shipped with beta 2. It’s not in beta1 yet. While on the subject, why do they call it a beta? A beta is a program which has all the features but needs bugfixing. This Vista beta has only 60% of the features and lots more will be added in beta2. They should have called beta1 a pre-alpha or something. 2005-08-11 9:11 pm it is available to msdn subscribers. msdn subscription doesn’t mean your an ms employee. aero is already included, just not with the final theme. of course it is still too early to compare anyway. personally (and please don’t take that as trolling, it is just a matter of personal preference which is of course very subjective) i would prefer pretty much everything over os x, since i realy didn’t like it at all when i tried it.. 2005-08-12 12:14 am Where are all you “MS makes nothing new” people when the Linux articles come up explaining some new feature that has been in every single other major OS for years. Or how about the compositing engine being worked on for Linux. Everyone says it’s sooo cool, even though it is nothing new as compared to Quartz Extreme, and certainly doesn’t even come to what Vista’s DCE does. Or Glitz, or anything. 2005-08-12 4:23 am “Or how about the compositing engine being worked on for Linux. Everyone says it’s sooo cool, even though it is nothing new as compared to Quartz Extreme, and certainly doesn’t even come to what Vista’s DCE does. Or Glitz, or anything.” Seems to be on the rocks. 2005-08-12 5:02 am That’s not the point at all. The developers who work on Linux and its OS addons don’t try to make this stuff sound like its brand new and inovative. MS does. And a lot of the time MS is 30 years behind, much worse than Linux just now getting a composite engine. Also, the things I’ve used with Linux’s new graphics display engines (Luminocity and the such) seems to be more inovative then what I’ve heard of MS’s. They are doing things on integrated intel i810 graphics cards while Longhorn will need high end hardware for its complete graphics package of eye candy. 2005-08-12 5:14 amCPUGuy Microsoft, at least the programmers (not talking about Balmer or other corporate shillings), is not saying that everything is completely new either. While, some of their stuff is completely new, they are not claiming everything to be. Of course people like Alchin and Balmer are going to say that everything is new and innovative, it is their job. But if you read any of the programmers blogs, you’d see that they are really quite to the point about what they are doing. 2005-08-12 10:11 amkaiwai Of course people like Alchin and Balmer are going to say that everything is new and innovative, it is their job. But if you read any of the programmers blogs, you’d see that they are really quite to the point about what they are doing. But at the end of the day, does it actually matter whether it is a new thing or not? if the end user can get their job done – does it actually matter whether or not its a completely new idea? Hell, things we’re using today, are merely mutations and slight variations on concepts drempt up in the 1970s/1980s and early 1990s during the early days of the ‘computer boom’. Microsoft is just like any other company, take a good idea, and integrate it into their product – thats nothing new; where companies compete is how well those ideas are integrated in the product and how well they work with each other. But like I said, does it matter whether or not something is a new or inovative idea? I sure as heck don’t purchase something just because its ‘innovative’, I purchase something because it does something I want. 2005-08-12 7:11 pmkaiwai Thats the way it has always been; as long as there are some killer applications out there, along with it being made available via the Microsoft Select licencing package, coupled with the annnual upgrade, WIndows Vista is assured of moderate success. With that being said, its success isn’t so much derived from the product quality or features, but whether there are applications out there that customers want, and the only way they can run them is if they install Vista or that a new technology comes around and that Vista is the only vesion of Windows that properly exploits all the benefits of that technology. OS X all the way. Not because im a mac user… the reason being apple have had a few years of gui effects to work out how it can assist the user. Microsoft have finally catched up and now are creating all this stuff that is just gonna confuse people. Also you never know in OS 10.5 apple may revamp the gui a tab thanks to tiger’s core graphics technology which is sitting nice and quietly under the hood. Either way on my mac i find the gui actually enchances my working its not just eye candy it allows me to get things done. It may take up to SP1 on vista for m$ to realise what they can do with it. I am curious how far the virtual folders idiom can go. With virtual folders, can you combine metadata? For example, can you say “show me all the documents where author = jack AND keyword = programming”? If so, how? AFAIU, you enter the virtual folder “author”, then you see all the authors and you click “jack”. And then? 2005-08-12 2:03 amg2devi > If you delete things in a query in BeOS, it is deleted > in actuality from the filesystem. What happens if you copy a file into a virtual folder or move it outside it? Are these things allowed? If not, then isn’t having delete be the only operation on virtual folder items dangerously inconsistent? If so, then the virtual folder query must be implicitly be updated to specifically mention the item. I’d imagine that moving things in and out of virtual folders could really mess up the query over time. Also, how would moving something from a nonlocal device to a virtual folder be handled?? 2005-08-12 12:26 amn4cer). 2005-08-12 4:09 amma_d… 2005-08-12 4:34 amkmarius! 2005-08-12 7:06 amgonzalo.. I am a avid windows user that is having a hard time getting excited about Vista. I have heard some of the planned technology updates but i haven’t heard anything yet that motivates me to want to stand in line when vista is released. Am i the only one?(excluding zealots) I think once it is apparent that Mac X86 is actively supported by game writers i will probably retire my Windows PC and switch to Apple. My fastest Pc runs @ 1.8GHZ. Though that might be cool to run Vista; when it actually ships, I dont think I will have the full functionality if I do decide to buy and try. However,the de facto linux distro or Bsd release at that time will hum along just fine.Full throttle.That I am sure of.Not trolling or flaming but when Vista is released and you dont have a new pc and since its not a new paradigm in that it will have full backward compatibility;which screws things a bit, then whats the use of getting Vista if you have a bunch of old pcs like me in full working order? I know I am not alone in that.I am not an expert.Learning like the average joe public. But Windows actually works.. … as buggy or as feature lacking as windows is … it is good in it’s own ways. 2005-08-12 12:04 pmronaldst Dear Anonymous, I will tell you something that may shock you. 99% aren’t retarded. Yes, that’s right. They’re not retarded at all. Here’s the kicker: Those 99% of PC users don’t see computers as a religion/cult/movement. They see it as a tool or for entertainment purpose. Can you imagine that? If the only change in Vista was the removal of the “My” prefix from every damn folder in windows, I’d buy it. Or I would if I haddn’t just gotten a powerbook. Seriously though, I’m sure I’m not the only person who felt like he was being talked down to with the insistance on “My” this and “My” that. I have two XP machines here at home. I’m not a fan of XP at all, it does the job, but you have to fight with it every so often and give it a good shake to get things done. Why do I have XP? I’m a programmer, I need to write code for it. I love OS X, some things XP/NT have (such as completion ports) that I wish OS X had, but there is plenty of stuff OS X has which I don’t find as nicely done in XP. I also like the dev enviroment on the Mac, I prefer Cocoa/Obj-C to C++ and even C#, but that is purely a personal taste. I do wish Delphi existed on the Mac 🙂 Having said all this, I am now a little hopeful tht Vista will make my PC life a little better. From this article it does look good compared to XP, which is probably what we should be comparing against, not OS X or Linux. re: anonymouse-virtual folders – who said that new users will have a hard time understanding virtual folders / stacks, etc I have 1 word – itunes. (For the record Real Jukebox and WMP had it before itunes along with a few other jukebox apps). People understand smart playlists and static playlists. I show people their itunes/ WMP and how to sort and few people have asked me again. They may not understand all the power with these very simple, GUI’d up boolian searches but they understand enough to make it worthwhile. g2devi – here’s how I see it – copy/ move an item into a virtual folder and it takes on that attribute. ie move an item from 1 author to another it changes authors. Copy and it assigns both authors. I can see many instances where the paradigm would fail, but hopefully they’ve thought of that. I think most OSes will move to a Virtual Folders paradigm as the default view for the user space and leave the hard physical search for power users. We had a shift from spatial to explorer/browser and next we’ll have a similar evolution to virtualized filing system. It’ll have spatial/ browser roots, but it’ll be the next shift. Tiger (Smart Folders) already has its feet in it, if only a bit. This is a minor complaint and I know aero isn’t out and blah blah – but why the vertically oriented folders? I just don’t get it. I don’t leave folders laying on their side with contents spilling out. It seems they could have come up with a better “container” item. I don’t like OS X’s way of doing it with an icon for each container-type (the Sidebar) – music, movies, etc – (is this item a container, an application, or a file?) It is inconsistent – e.g. an icon in the sidebar but a filmstrip image on a folder on the right side. And Windows’ & OS X’s way of slapping a new image on top of/ inside a folder is irritating and the analogy fails (music in a folder, movies in a folder?). Just someone please come up with a consistent container image. It doesn’t have to be so literally rooted in the physical world. Start Menu – unimpressive. Breadcrumbs – nice Clock – Why is the clock so critical that a regular user cannot correct it? Why do you need admin privs to change the time? Why has this been here since the NT days. Sometimes you want to check another time zone and this is a quickn dirty way of doing so without downloading some widget. Nagware – seems like a lot of the security and system features are designed from the nag perspective (security, admin/ UAP, networking, etc). A lot of that needs to be ironed out. And why is it so hard to network 2 Windows machines in a simple home setup now? Used to be so easy. This isn’t an optional feature you can drop due to security. Active X and Java are expendable. But home networking? OS X is easier to network to an XP box than XP to XP or 2K to XP. This author says that Vista to XP is easier than Vista to Vista. I know a lot of people will say lalalala 2 minutes XP-to-XP lalalala. But try talking OTHER people through it and it becomes a whole new world of hurt. How about a simple handshake required on each computer with an admin password. The old way under Waste or any similar P2P or buddylist handshake mechanism is easy enough to implement. It’s good enough for home setups. Why does it have to be difficult? Its sad how people are bashing Vista without even looking on the Microsoft development site; the sexy parts are those that are under the hood, and how those advancements in the backend will eventually trickle down to the end user. As most of you know, I’m a Mac user, but at the same time, to blindly push any alternative to the side without even reading the material available, is pretty short sighted. I would also hope that ppl would stop stating that the avg PC is retarded. Remember the computer is just a tool. It’s ok that we all look under the hood, but for the majority of ppl it’s just a tool which they can use to print a letter, surf the web and write an email. In the same way that just because i don’t know the in’s and out’s of how my car works, doesn’t make me retarded. To the topic of Windows Vista, i am like a lot of other ppl still unimpressed with what i have seen. I switched to Mac in May and it has been the best thing ive ever done, apple is creating the excitement i expected from Vista. However it is early days, so fingers crossed for Beta 2, as i like using Mac OS X, Windows and FreeBSD, as they all have their uses. The scattered toolbar in IE7 confuses me. What is the point of splitting the toolbar up in to three parts? First you have the Back/Forward buttons next to the address field, which in turn is merged with the Refresh/Stop button. Finally, the rest of the toolbar buttons are placed below the tab bar along with the menu. I simply don’t understand the rationale behind these significant UI changes. Where are the studies that prove this is more user friendly? Funny how everyone extols the benefits of a new OS with all these glitzy features, yet when you look at what’s really important, like good security, true multi-usability, it’s not there. It’s still the same old single-user OS claiming to be ready for today’s modern and demanding multi-user environments. Pathetic really… 2005-08-12 4:23 pm When I tried OSX (Jag)I thought it was very cool, but slow? Of course you’ll ask what hardware I was using, I don’t know. Our graphics department had them and needed help getting SMB working. I remember thinking, “This system is slick…but slow as hell.” Is this a result of the PowerPC? No, it’s the resulting of the CPU doing almost all the work composing the 2D-screen since the display, called Quartz, on OS X is basically textured planes rendered with OpenGL. The way it worked on Jaguar needed a lot more CPU intervention than with Tiger. If you had a old/slow graphics card (basically anything slower/less memory than a 16 MB ATi Rage Pro) it was a lot worse. It’s basically the windows vista full aero mode but with the slower cpus and graphic cards of it’s day it wasn’t a very enjoyable experience. It would have been equally slow on a same generation x86 machine. I’ve seen OS X on non accelerated machines and it’s really not very funny. On a newish machine running Tiger you’ll notice very little lag. One thing that’s only really enjoyable on the fastest G5 PowerMacs though is the window resizing, but on the other hand, there’s no tearing as on current Windows.. 1. The same people have no problem using the variety of interfaces introduced on countless web sites. 2. The skills needed to deal with any OS at a low level will require quite a bit of thinking and problem solving. That includes most definately Windows in all the versions that have shipped. 3. Anyone who can use Windows for regular work can use Linux for regular work. The learning curve is not at all a problem. Yes, people freak out if you change the color of anything, let alone the design of the widgets, though that level of distress is similar regardless of the OS or OS revision. See #1 for the noted exceptions. That said, I could not convince my older sister to even look at non-IE browsers till IE was so encrusted with dreck that it no longer ran. “.”” while that sounds nifty, why not simply save all of one users stuff in the sasme folder? and if it is a public computer, say, at a library, and you allow people to save stuff on the computer, then you are not paying enough attention to security… I was wating when the switch came from Win 3.11 to 98. And 98 to ME – XP. But this, naah I’m better off with XP for now, I think Microsoft would have been better off consolidating the security fixes on Windows XP. Needless to say, its following the Linux madness of releasing a new version every 2 milli second. 2005-08-12 11:58 pmCPUGuy Except it’s been 4 years thus far since any desktop/WS Windows release. Not to mention the fact that Apple and the various Linux distros took the idea of releasing new versions often from Microsoft, only just after critcizing them for making frequent releases (and less frequent than what is current in said markets!) would smell as sweet … In short, Microsoft Windows Vista is not only a rebranding, changing horses in midstream because the last set of horses – Win 3.x, Win9x, WinNT, WinME, Win2k, WinXP and Win2k3 – got lamed in the middle of the stream, Microsoft Windows Vista is also an attempt to pass off common Unix and Linux standards as Microsoft innovations. I don’t know about you, but skinning a horse in midstream and wrapping him in pig-skin or bear-skin or potato-skin or tomato-skin – because you don’t like the brand he’s wearing on his hide -, while imagining you’re riding him, sounds a little tricky to me. Ummm, what sort of branding iron works best with potato-skin? any experienced potato-rustlers here able to help Microsoft out? <a href=”“>windows-vista.host.sk“>Windows which would you prefer?
https://www.osnews.com/story/11545/windows-vista-beta-1-a-guided-tour/
CC-MAIN-2020-24
refinedweb
3,768
70.94
Python/ltrx apis Overview Lantronix provides Python modules with APIs to access features of the PremierWave device more easily from your program. Note that these APIs require firmware version 7.10 or later. As 7.10 is Alpha firmware, APIs are subject to change! LtrxDsal Access to the Digital input/outputs on the device. from ltrxlib import LtrxDsal dsal = LtrxDsal() print 'Reading Digital Input 1...' state = dsal.readDigitalInput(1) print 'state=' + str(state) print 'Reading Digital Input 2...' state = dsal.readDigitalInput(2) print 'state=' + str(state) print 'Setting relay to true' result = dsal.setRelay(1, True) print 'Reading relay 1...' state = dsal.readRelay(1) print 'Relay is ' + state print 'Setting relay to false...' dsal.setRelay(1, False) print 'Reading Relay...' state = dsal.readRelay(1,) print 'Relay is ' + state print 'Reading temperature...' temp = dsal.readInternalTemperature(1) print 'Temperature is: ' + str(temp) LtrxCellular Send and receive SMS messages. from ltrxlib import LtrxCellular cell = LtrxCellular() print 'calling sendSMS()...' cell.sendSMS("1112223333", "Hello!", 0) # 3rd argument: 0=ASCII 7 bits, 1=ASCII 8 bits, 2=unicode/utf-8 print 'calling receiveSMS' msg = cell.receiveSMS() print 'message: ' + msg Receiving SMS best practices The Lantronix firmware does not store SMS messages. At the time that an SMS is received, any process that is waiting to receive SMS will be given the message, and then the message is deleted from the radio. To ensure that a message will be received by an application, the application should make the blocking call receiveSMS(). To avoid blocking the rest of the application, the programmer will want to place this on a separate thread or process. Below is an example of spawning a new thread just for waiting for SMS messages and putting them into a Queue, where the main thread of the application can check if the Queue has items and read them when needed: #!/usr/bin/python from ltrxlib import LtrxCellular from threading import Thread from Queue import Queue import time import serial def receiveSmsThread(smsQ, cell): # Infinite loop to wait for SMS and put them into a Queue while True: smsQ.put(cell.receiveSMS()) if __name__ == '__main__': smsQ = Queue() # Open serial port 1 on the PremierWave XC HSPA+ to output the # messages coming in ser = serial.Serial('/dev/ttyS1', 115200) cell = LtrxCellular() # Define and start the thread to receive the SMS t = Thread(target = receiveSmsThread, args = (smsQ,cell)) t.start() while True: # Check if the Queue has messages, and if so remove one and display the # message information if (smsQ.empty()!=True): msg = smsQ.get_nowait() # Note that this uses the new API where the message is a tuple # that includes both the message text and the sending number ser.write('From: '+str(msg[1])+'\rMessage says: '+str(msg[0])+'\r') else: time.sleep(5)
http://wiki.lantronix.com/developer/Python/ltrx_apis
CC-MAIN-2017-30
refinedweb
456
64.81
Posted 05 Apr 2011 Link to this post Posted 08 Apr 2011 Link to this post We tried several scenarios to reproduce the issue you are mentioning. The only problem we found was when "Reduce XAP size by using application library caching" Silverlight project option is enabled. The problem here consists in that the assemblies are loaded when demanded, so MEF is not able to find them initially. As a work around (which you could have found yourself) we can recommend the following:( RadEn_USDictionary(), System.Globalization.CultureInfo( "en-US" )); As MEF couldn't load the ControlSpellCheckers the dictionary you mentioned remains empty, so you can fill it with the ConWetrolSpellCheckersManager.RegisterControlSpellChecker method, providing an instance of a class derived from IControlSpellChecker as argument(such IControlSpellCheckers exist for TextBox, RadRichTextBox and RichTextBox in the Telerik.Windows.Control.Proofing namespace). We realize that this solution is far from perfect and we will do our best to find a better one. However for the time being we recommend this approach. Don't hesitate to contact us again. Posted 12 May 2011 Link to this post private void buttoncheckspelling_click(object sender, RoutedEventArgs e) {")); //RadSpellChecker.Check(this.KeyWordTextbox, SpellCheckingMode.AllAtOnce); //object reference not set to an instance... documentSpellChecker.CheckWordIsCorrect(this.KeyWordTextbox.Text); //does not bring up the SpellChecker box like in the demo } ???? Posted 16 May 2011 Link to this post The code you wrote, is necessary only when the Project Properties option "Reduce XAP size by using application library caching" is enabled. Then Silverlight downloads assemblies on demand so MEF can't load the ControlSpellCheckers and that's why we need to do that manually. Now to your question, the method you use DocumentSpellChecker.CheckWordIsCorrect(string text) returns boolean value indicating whether the word provided as argument is in the current dictionary. If you want to show the spellchecking window like in the demo, use RadSpellChecker.Check method.(which you have commented in your ticket) If you have other questions contact us again. Posted 18 May 2011 Link to this post Well, that happens because the SpellCheckAllAtOnce dialog uses RadRichTextBox to present the whole content of the control being spellchecked. So in order to make it work, first you need to register the ControlSpellChecker for the RadRichTextBox and then add a dictionary to it. The following code presents what i mean: TextBoxSpellChecker()); RadRichTextBoxSpellChecker()); (RadRichTextBox)); ISpellChecker spellChecker = controlSpellchecker.SpellChecker; DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker; RadSpellChecker.Check( this .textBox1, SpellCheckingMode.AllAtOnce); Posted 19 May 2011 Link to this post Most of the times this happens when there is no dictionary loaded. Probably you forgot to add a reference to "Telerik.Windows.Documents.Proofing.Dictionaries.En-US" assembly where our default dictionary resides. Posted 20 May 2011 Link to this post Posted 23 May 2011 Link to this post The only reason why no suggestions are shown in the context menu can be that there are no words "similar enough" in the dictionary. The spell checker uses an algorithm for calculating the distance between words in the dictionary and misspelled words. If that distance is bigger than a fixed value, the word is not considered fit for a suggestion. This is not the case for "foxxx". We suspect that there might be something with the theme you are using that messes up with the suggestion, so we would appreciate it if you could send us a sample project in a General Feedback ticket, so that we can look into the issue and solve the mystery. Posted 25 May 2011 Link to this post We are glad to hear that you managed to identify the problem and resolve it.
https://www.telerik.com/forums/throw-notimplementedexception
CC-MAIN-2017-43
refinedweb
600
53
Thanks Daniel, and others, for the hints. In the end I used your command line option, and all was fine. After submitting my pull request, I finally managed to get the test suite running using cabal, following a bit of trial-end-error (*), which has raised a couple of questions for me: 1. Is there a simple "one page" introduction to using cabal with an existing library/package - i.e. for building/testing a simple change? 2. Is there a simple way to get detailed test results displayed to the console when running tests through cabal? I tried -v but that didn't help. I ask as a very occasional Haskell user who is not steeped in, or even regularly exposed to, the traditions and practices of the GHC/Cabal toolchain. #g -- (*) the final sequence I used was: 541 autoreconf 555 cabal configure --enable-tests 557 cabal build 561 cabal test --log=a.tmp 563 cat dist/test/a.tmp On 30/12/2012 00:18, Daniel Fischer wrote: > On Samstag, 29. Dezember 2012, 18:25:45, Graham Klyne wrote: >> A couple of problems with Network.URI have been brought to my attention, so >> I thought I'd have a go at seeing if I could fix them. It's been a while >> (years) since I used the Haskell toolchain in anger, so I'm a bit out of >> touch with how thinks are working now. >> >> So far, I have: >> >> 1. Installed Haskell platform (64-bit version for MacOS). >> 2. Checked out the 'network' project from >> 3. cabal install test-framework >> 4. cabal install test-framework-hunit >> 5. changed to the 'test' directory of the checked out 'network' project >> >> Then when I try to run GHC, I get this error: > <snip> >> >> The problem seems to be with the following lines in URI.hs (starting at line >> 135): [[ >> # if MIN_VERSION_base(4,0,0) >> import Data.Data (Data) >> # else >> import Data.Generics (Data) >> # endif >> ]] >> >> If I remove these lines, and just leave >> [[ >> import Data.Generics (Data) >> ]] >> >> I can compile and run the test suite just fine: >> [[ >> Test Cases Total >> Passed 319 319 >> Failed 0 0 >> Total 319 319 >> ]] >> >> I'm _guessing_ the problem here is something to do with >> "MIN_VERSION_base(4,0,0)" - not being familiar with the current build >> environment setup, I'm not sure where it is or should be defined, or what it >> is intended to mean. > > The MIN_VERSION_package is a macro that cabal creates when building the > package, that checks whether the available package version satisfies the > minimum requirements. > > When hacking on a package without using cabal, you can > > a) remove the problematic macro > b) define it in the file yourself > c) pass -D"MIN_VERSION_base(x,y,z)=1" on the command line > > (I've tested option c only for C code, it might not work here, but afaik, > gcc's preprocessor is used, so I think it will). > > Since you will probably compile more than once, a) or b) would be the > preferable options. > > But you could also leave the macro as is and just > > $ cabal build > > the package. That needs one > > $ cabal configure > > before the first build, after that, a `cabal build` will only recompile > changed modules (and what depends on them), so the compilation should be > reasonably fast. > >> >> I did find these: >> * >> * >> but they didn't help me. >> >> It seems there's a fix that involves using __GLASGOW_HASKELL__ instead of >> MIN_VERSION_base(4,0,0), but I'm not sure exactly how that would play out - >> or indeed if that's the correct approach for a permanent fix. > > In principle, the MIN_VERSION macro is the right thing, because it tests for > the package version where things changed. For base, a suitable > __GLASGOW_HASKELL__ condition is of course equivalent to a base-version check. >
http://www.haskell.org/pipermail/libraries/2013-January/019221.html
CC-MAIN-2013-48
refinedweb
626
70.73
Let's make it easy yet powerful: To have a working case we will look how many wifi networks are detected in eachpoint ofa path using a Raspberry Pi and coding in JAVA. - Raspberry: I am using Raspberry 3, but there is no reason why you could not use another model (I didn't try yet), while it has a wlan interface to detect networks and to reach the web using the connection shared by your cell phone. - A cell phone: Any with data connection that can share a wifi... in other words: any. - USB external battery: Any that can power you Raspberry, like the ones used as extra external batteries for the cell phones. Used to move freely in the field. It should be 5-6V. Please note that with a supply of 1000mA I had some trouble for the Pi to recognize the USB connection, but with one of 4000mA (reasonably charged) it worked well. - A GPS receiver: I am using Globalsat BU-353S4. Is a bullet proof old friend and is not expensive at all. It communicates by USB at 4800bauds and provides NMEA frames containing the GPS information. I will provide a library, so you only have to carry about the coordinates and you don't have to study NMEA frames, nevertheless if you want to dive in take a look to this handy resource. While it is USB and NMEA there is no reason you can not use another receiver (I didn't try yet). - A free account at circusofthings.com: What can I say about my beloved community where easily interconnect your inventions. But let's focus on the fact that you will have a dashboard ready-to-use and you won't have to worry about the server side. You only need to create a free account. Create a free account at Circus: Once inside, go to the "Workshop" where you will create a signal to handle the data: Create a signal: Just give it a name, the description you think will fit to your signal, add tags, set visibility whether you want to show it or not, set the parameters (Note: those are only static information for people that will watch the signal, not actual variables): Now you have set the signal. It has only static information right now, but soon your hardware will be feeding the changing value and the changing location. Take note of the "key" displayed under the signal title, it will identify your signal when communicating with server. One more thing: Also take note of the "token", it will identify you when accessing the server. Find it clicking on your image, in the top-right corner, then "account".Setting up the software in the Raspberry The JAVA code I made a simple executable JAVA program called CircusField. It goes through a loop doing this tasks: - Takes GPS latitude, longitude, altitude coordinates (in decimal degrees). I use a library I made called jaumemirallesisern-gps.jarto read NMEA data from a GPS receiver through USB port. The object GPSNMEAserialneeds two parameters: serial baud rate and USB port descriptor. In my case where 4800 and "/dev/ttyUSB0". - Executes a Linux command ( sudo iw dev wlan0 scan) to get the number of SSIDs detected. If you don't have this command in your system, just install it: sudo apt-get updateand sudo apt-get install iw. - Reporting to Circus Of Things the latitude, longitude, altitude coordinates, and the value (for us is the number of SSID read above). It is made through the Write command defined in the REST API of the Circus. You don't have to code the API commands in JAVA as you can take profit of the ready-to-use library called circusofthings.jar. And looks like this: package circusfield; import com.circusofthings.api.ver110.CircusLib; import com.jaumemirallesisern.hardware.GPSNMEAserial; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CircusField { private static final String KEY = "your_key_signal_at_circus_here"; private static final String TOKEN = "your_circus_token_here"; private static final int FREC = 10000; // as set in signal's parameters private static GPSNMEAserial gpsnmea; private static void mountGPS() { try { gpsnmea = new GPSNMEAserial(4800,"/dev/ttyUSB0"); } catch (Exception e) { System.out.println("Error reaching gpsnmeaserial"); } } private static int runLinuxCommand(){ String s; Process p; int counter = 0; try { p = Runtime.getRuntime().exec("sudo iw dev wlan0 scan "); BufferedReader br = new BufferedReader( new InputStreamReader(p.getInputStream())); while ((s = br.readLine()) != null) { if(s.contains("SSID")){ System.out.println("line: " + s); counter++;} } p.waitFor(); System.out.println ("exit: " + p.exitValue()); p.destroy(); return counter; } catch (IOException | InterruptedException e) {return counter;} } protected static void delay(int t) { try { Thread.sleep(t); } catch(InterruptedException e) { } } public static void main(String[] args) { mountGPS(); CircusLib commands = new CircusLib(TOKEN); double lat; double lon; double alt; int nsats; double value; for (;;) { try { gpsnmea.receiveUARTData(); } catch(Exception e){System.out.println("Error reading serial");} delay(100); value = runLinuxCommand(); lat = gpsnmea.getLat(); lon = gpsnmea.getLon(); alt = gpsnmea.getAlt(); nsats = gpsnmea.getNsats(); if (!(lat==0&&lon==0)) { System.out.println("Write to Circus: "+KEY); System.out.println(lat+" - "+lon+" - "+alt+" - "+nsats); JSONObject obj = commands.writeValue(KEY, value, lat, lon, alt); System.out.println("Circus response: "+obj.toString()); } delay(FREC); } } } Remember to replace the "key" and "token" from Circus for the "KEY" and "TOKEN" values respectively in the code above. It can be executed in command line with: sudo java -cp .:/home/pi/dtest:/home/pi/javalibs/* circusfield.CircusField Libraries needed to be placed in your libraries folder: jaumemirallesisern-gps.jar Executing on boot I do like this because I want to be sure that in the field I just need to power on the raspberry for the data to be gathered. Place the above execution command in /ect/rc.local Just plug the GPS receiver in the USB. No further configurations or set up are needed.Share your cell connection In your cell share your data connection as a Wifi access point. So you will define a SSID name and a password. In your Raspberry, connect and check to this SSID normally. You can do it in your Raspbian desktop or via commands. There is plenty of documentation to do this in the net, so I won't stop on this.Check it all If everything goes right the JAVA program CircusField (executed manually or on boot) should throw an output like this: And in your Workshop at Circus you should see the same signal you defined but now with value and geolocation changing (it may take some seconds as it needs time to write, time to poll in the app... be patient). When you are outside you can watch this screen (always selecting the option "request desktop page" in your cell as we don't have a working responsive version) to see if the values are varying as they should. You can also monitor the track in real-time setting a panel-map as described in next points. Pack it I can't believe I never though about a rigid folder to chase my developments. It's easy, the excess of cables is tidied up and you can file your gadgets in the shelf. An absolute win-win. Walk out the door, greet your neighbours ( a geek is never impolite :| ), enjoy the walk, come back...Back at home Now you gathered the data, you may want to set up a panel in your dashboard to monitor a handle the data. To do so, follow this simple steps: Go to dashboard Create a panel Choose add a view Select your signal Change to map mode Now that you successfully got the map to display your path, it's time to recall the samples. Press recall and select the period of time when you went for the walk, and there you have it: Now you can: - Label this track for the next time have it easier to recall, pressing "save as" - Download it in KML or CSV - Share your track on map with other users - Among other features If you want to see my walk, this is the signal: signal.circusofthings.com/7717 once you add it to one of your panels recall my label "wifi-walk". Note: This will a particular case (counting SSIDs / Raspberry / JAVA), but you could use Circus for any value you can measure in the field, with whatever sensor you may think, with any hardware capable to reach the web, with any coding language... Find out more stories in our blog. Hope it helped and thanks for reading! Please, let us know your feedback.
https://www.hackster.io/jaume_miralles/basic-warwalking-with-a-raspberry-7ad9ce
CC-MAIN-2021-17
refinedweb
1,432
63.9
The Samba-Bugzilla – Bug 11033 The macro DEBUG is exposed if header file ndr.h is included. Last modified: 2015-04-21 19:32:12 UTC It is common to use the name "DEBUG" for debug macros/functions in c/c++ projects. With the recent changes in samba 4.2, macro "DEBUG" is defined if public header file "ndr.h" is included in c/c++ module Here is a part of build log from sssd: In file included from /usr/include/samba-4.0/util/fault.h:27:0, from /usr/include/samba-4.0/samba_util.h:62, from /usr/include/samba-4.0/ndr.h:30, from src/providers/ad/ad_gpo.c:52: /usr/include/samba-4.0/util/debug.h:182:0: warning: "DEBUG" redefined #define DEBUG( level, body ) \ ^ In file included from src/providers/ad/ad_gpo.c:38:0: ./src/util/util.h:126:0: note: this is the location of the previous definition #define DEBUG(level, format, ...) do { \ ^ src/providers/ad/ad_gpo.c: In function 'ad_gpo_parse_map_option_helper': src/providers/ad/ad_gpo.c:265:38: error: macro "DEBUG" passed 3 arguments, but takes just 2 hash_error_string(hret)); Full log file: The change can be caused by commit 8dac190ee1bc0e7f6d17eeca097f027fcaf584ed Author: Martin Schwenke <martin@meltin.net> Date: Mon Sep 22 19:43:27 2014 +1000 lib/util: Clean up includes for fault.c The commit added public header file "lib/util/fault.h", which includes '#include "debug.h"' There isn't such problem with samba-devel-4.1.14 Note, this is rather badly breaking Fedora Rawhide at present; it's stopping sssd from building, but sssd needs rebuilding against an updated library. This means you can't currently do a network install of most Fedora package sets, and nightly image composes are building. So, Samba devs who care about Fedora, please help :) fault.c already includes debug.h Does the build still work if #include "debug.h" is removed from fault.h ? Created attachment 10586 [details] Test patch Can you check if this works for Fedora ? Jeremy, If you look at the lines below where you removed debug.h you will notice that the SMB_ASSERT macro is defined at this position using the DEBUG macro. I guess it will not compile ... I think the right approach would be to protect the macros ... #ifndef DEBUG #define DEBUG(level, body) ... #endif and prefix the function with samba_ and the enums etc. too. (In reply to Andreas Schneider from comment #5) Oh that's strange, 'cos I just recompiled it successfully :-). Must have missed something. (In reply to Andreas Schneider from comment #6) Why are the DEBUG macros public at all? Are they considered public Samba API? Wouldn't it be better to prefix anything that's exported in public headers with a samba-specific prefix? Patch for master has been pushed to autobuild. Will cherry-pick into 4.2 when it lands in master. Created attachment 10603 [details] v4-2-test patch To avoid confusion, Jeremy's patch should be dropped, right? Also, is just one review in addition to Andreas' sign-off sufficient to reassign to Karolin? Karolin, please add the patch to 4.2.0. Thanks (In reply to Andreas Schneider from comment #12) Pushed to autobuild-v4-2-test. Pushed to v4-2-test. Closing out bug report. Thanks! The additional patch for this ticket was pushed to master few weeks ago. Would it be possible to back port it to samba v4-2? commit 9643a4b1ef2ada764f454ecc82aa6936217967fc Author: Lukas Slebodnik <lslebodn@redhat.com> AuthorDate: Thu Mar 5 11:26:46 2015 +0100 Commit: Jeremy Allison <jra@samba.org> CommitDate: Wed Mar 11 18:47:22 2015 +0100 lib/util: Include DEBUG macro in internal header files before samba_util.h Re-assigning to Jeremy. Created attachment 10959 [details] Extra patch for 4.2.next. If asn +1's it we'll get this into 4.2.2. Comment on attachment 10959 [details] Extra patch for 4.2.next. LGTM Karolin, please add the extra patch to the 4.2 branch. Thanks. (In reply to Andreas Schneider from comment #19) Pushed extra patch to autobuild-v4-2-test. Thank you very much (In reply to Karolin Seeger from comment #20) Pushed to v4-2-test. Closing out bug report. Thanks!
https://bugzilla.samba.org/show_bug.cgi?id=11033
CC-MAIN-2017-26
refinedweb
709
69.79
With the popularity of Facebook, Twitter, LinkedIn, and other social networks, we're increasingly defined by who we know and who's in our network. These websites help us manage who we know—whether personally, professionally, or in some other way—and our interactions with those groups and individuals. In exchange, we tell these sites who we are in the network. These companies, and many others, spend a lot of time on and pay attention to our social networks. What do they say about us, and how can we sell things to these groups? In this chapter, we'll walk through learning about and analyzing social networks: Analyzing social networks Getting the data Understanding graphs Implementing the graphs Measuring social network graphs Visualizing social network graphs Although the Internet and popular games such as Six Degrees of Kevin Bacon have popularized the concept, social network analysis has been around for a long time. It has deep roots in sociology. Although the sociologist John A. Barnes may have been the first person to use the term in 1954 in the article Class and communities in a Norwegian island parish (), he was building on a tradition from the 1930s, and before that, he was looking at social groups and interactions relationally. Researchers contended that the phenomenon arose from social interactions and not individuals. Slightly more recently, starting in the 1960s, Stanley Milgram has been working on a small world experiment. He would mail a letter to a volunteer somewhere in the mid-western United States and ask him or her to get it to a target individual in Boston. If the volunteer knew the target on a first-name basis, he or she could mail it to him. Otherwise, they would need to pass it to someone they knew who might know the target. At each step, the participants were to mail a postcard to Milgram so that he could track the progress of the letter. This experiment (and other experiments based on it) has been criticized. For one thing, the participants may decide to just throw the letter away and miss huge swathes of the network. However, the results are evocative. Milgram found that the few letters that made it to the target, did so with an average of six steps. Similar results have been born out by later, similar experiments. Milgram himself did not use the popular phrase six degrees of separation. This was probably taken from John Guare's play and film Six Degrees of Separation (1990 and 1993). He said he got the concept from Guglielmo Marconi, who discussed it in his 1909 Nobel Prize address. The phrase "six degrees" is synonymous with social networks in the popular imagination, and a large part of this is due to the pop culture game Six Degrees of Kevin Bacon. In this game, people would try to find a link between Kevin Bacon and some other actor by tracing the films in which they've worked together. In this chapter, we'll take a look at this game more critically. We'll use it to explore a network of Facebook () users. We'll visualize this network and look at some of its characteristics. Specifically, we're going to look at a network that has been gathered from Facebook. We'll find data for Facebook users and their friends, and we'll use that data to construct a social network graph. We'll analyze that information to see whether the observation about the six degrees of separation applies to this network. More broadly, we'll see what we can learn about the relationships represented in the network and consider some possible directions for future research. A couple of small datasets of the Facebook network data are available on the Internet. None of them are particularly large or complete, but they do give us a reasonable snapshot of part of Facebook's network. As the Facebook graph is a private data source, this partial view is probably the best that we can hope for. We'll get the data from the Stanford Large Network Dataset Collection (). This contains a number of network datasets, from Facebook and Twitter, to road networks and citation networks. To do this, we'll download the facebook.tar.gz file from. Once it's on your computer, you can extract it. When I put it into the folder with my source code, it created a directory named The directory contains 10 sets of files. Each group is based on one primary vertex (user), and each contains five files. For vertex 0, these files would be as follows: 0.edges: This contains the vertices that the primary one links to. 0.circles: This contains the groupings that the user has created for his or her friends. 0.feat: This contains the features of the vertices that the user is adjacent to and ones that are listed in 0.edges. 0.egofeat: This contains the primary user's features. 0.featnames: This contains the names of the features described in 0.featand 0.egofeat. For Facebook, these values have been anonymized. For these purposes, we'll just use the *.edges files. Now let's turn our attention to the data in the files and what they represent. Graphs are the Swiss army knife of computer science data structures. Theoretically, any other data structure can be represented as a graph, although usually, it won't perform as well. For example, binary trees can be seen as a graph in which each node has two outgoing edges at most. These edges link it to the node's children. Or, an array can be seen as a graph in which each item in the array has edges that link it to the items adjacent to it. However, in this case, the data that we're working with is naturally represented by a graph. The people in the network are the nodes, and their relationships are the edges. Graphs come in several flavors, but they all have some things in common. First, they are a series of nodes that are connected by edges. Edges can be unidirectional, in which case, the relationship they represent goes only one way (for example, followers on Twitter), or it goes bidirectional, in which the relationship is two-way (for example, friends on Facebook). Graphs generally don't have any hierarchy or structure like trees or lists do. However, the data they represent may have a structure. For example, Twitter has a number of users (vertices) who have a lot of followers (inbound edges). However, most users only have a few followers. This dichotomy creates a structure to the graph, where a lot of data flows through a few vertices. Graphs' data structures typically support a number of operations, including adding edges, removing edges, and traversing the graph. We'll implement a graph data structure later. At that point, we'll also look at these operations. This may not be the best performing graph, especially for very large datasets, but it should help make clear what graphs are all about. As the graph data structure is so central to this chapter, we'll take a look at it in more detail before we move on. There are a number of ways to implement graphs. In this case, we'll use a variation of an adjacency list, which maps each node to a list of its neighbors. We'll store the nodes in a hash map and keep separate hash maps for each node's data. This representation is especially good for sparse graphs, because we only need to store existing links. If the graph is very dense, then representing the set of neighboring nodes as a matrix instead of a hash table will take less memory. However, before we start looking at the code, let's check out the Leiningen 2 project.clj file. Apart from the Clojure library, this makes use of the Clojure JSON library, the me.raynes file utility library (), and the Simple Logging Facade for Java library (): }}]}) If you're keeping track, there are several sections related to ClojureScript () as well. We'll talk about them later in the chapter. For the first file that we'll work in, open up src/network_six/graph.clj. Use this for the namespace declaration: (ns network-six.graph (:require [clojure.set :as set] [clojure.core.reducers :as r] [clojure.data.json :as json] [clojure.java.io :as io] [clojure.set :as set] [network-six.util :as u])) In this namespace, we'll create a Graph record that contains two slots. One is for the map between vertex numbers and sets of neighbors. The second is for the data maps. We'll define an empty graph that we can use anywhere, as follows: (defrecord Graph [neighbors data]) (def empty-graph (Graph. {} {})) The primary operations that we'll use for this chapter are functions that modify the graph by adding or removing edges or by merging two graphs. The add and delete operations both take an optional flag to treat the edge as bidirectional. In that case, both functions just call themselves with the ends of the edges swapped so that they operate on the edge that goes in the other direction: (defn update-conj [s x] (conj (if (nil? s) #{} s) x)) (defn add ([g x y] (add g x y false)) ([g x y bidirectional?] ((if bidirectional? #(add % y x false) identity) (update-in g [:neighbors x] #(update-conj % y))))) (defn delete ([g x y] (delete g x y false)) ([g x y bidirectional?] ((if bidirectional? #(delete % y x false) identity) (update-in g [:neighbors x] #(disj % y))))) (defn merge-graphs [a b] (Graph. (merge-with set/union (:neighbors a) (:neighbors b)) (merge (:data a) (:data b)))) The final low-level functions to work with graphs are two functions that are used to set or retrieve data associated with the vertices. Sometimes, it's also useful to be able to store data of the edges, but we won't use that for this implementation. However, we will associate some information with the vertices themselves later on, and when we do that, we'll use these functions. All of these functions are overloaded. Passed in a graph, a vertex number, and a key, they set or retrieve a value on a hash map that is that vertex's value. Passed in just a graph and a vertex number, they set or retrieve the vertex's value—either the hash map or another value that is there in its place: (defn get-value ([g x] ((:data g) x)) ([g x k] ((get-value g x) k))) (defn set-value ([g x v] (assoc-in g [:data x] v)) ([g x k v] (set-value g x (assoc (get-value g x) k v)))) (defn update-value ([g x f] (set-value g x (f (get-value g x)))) ([g x k f] (set-value g x k (f (get-value g x k))))) We will also want to get the vertices and the edges for the graph. The vertices are the union of the set of all the nodes with outbound edges and the set of nodes with inbound edges. There should be some, or even a lot, of overlap between these two groups. If the graph is bidirectional, then get-edges will return each edge twice—one going from a to b and the other going from b to a: (defn get-vertices [graph] (reduce set/union (set (keys (:neighbors graph))) (vals (:neighbors graph)))) (defn get-edges [graph] (let [pair-edges (fn [[v neighbors]] (map #(vector v %) neighbors))] (mapcat pair-edges (:neighbors graph)))) We'll write some more basic utilities later, but right now, let's take a look at a function that is a slightly higher-level function, but still a fundamental operation on graphs: a breadth-first walk over the graph and a search based on that. A breadth-first walk traverses the graph by first looking at all the neighbors of the current node. It then looks at the neighbors of those nodes. It continues broadening the search one layer at a time. This is in opposition to a depth-first walk, which goes deep down one path until there are no outgoing edges to be tried. Then, it backs out to look down other paths. Which walk is more efficient really depends on the nature of the individual graph and what is being searched for. However, in our case, we're using a breadth-first walk because it ensures that the shortest path between the two nodes will be found first. A depth-first search can't guarantee that. The backbone of the breadth-first function is a First In, First Out (FIFO) queue. To keep track of the vertices in the paths that we're trying, we use a vector with the index of those vertices. The queue holds all of the active paths. We also keep a set of vertices that we've reached before. This prevents us from getting caught in loops. We wrap everything in a lazy sequence so that the caller can control how much work is done and what happens to it. At each step in the loop, the algorithm is pretty standard: If the queue is empty, then we've exhausted the part of the graph that's accessible from the start node. We're done, and we return null to indicate that we didn't find the node. Otherwise, we pop a path vector off the queue. The current vertex is the last one. We get the current vertex's neighbors. We remove any vertices that we've already considered. For each neighbor, we append it to the current path vector, creating that many new path vectors. For example, if the current path vector is [0, 171, 4]and the new neighbors are 7, 42and 532, then we'll create three new vectors: [0, 171, 4, 7], [0, 171, 4, 42], and [0, 171, 4, 532]. We push each of the new path vectors onto the queue. We add each of the neighbors onto the list of vertices that we've seen. We output the current path to the lazy sequence. Finally, we loop back to step one for the rest of the output sequence. The following code is the implementation of this. Most of it takes place in bf-seq, which sets up the processing in the first clause (two parameters) and constructs the sequence in the second clause (three parameters). The other function, breadth-first, is the public interface to the function: (defn bf-seq ([get-neighbors a] (bf-seq get-neighbors (conj clojure.lang.PersistentQueue/EMPTY [a]) #{a})) ([get-neighbors q seen] (lazy-seq (when-not (empty? q) (let [current (first q) nbors (remove seen (get-neighbors (last current)))] (cons current (bf-seq get-neighbors (into (pop q) (map #(conj current %) nbors)) (into seen nbors)))))))) (defn breadth-first [graph a] (bf-seq (:neighbors graph) a)) Notice that what makes this a breadth-first search is that we use a FIFO queue. If we used a LIFO (Last In, First Out) queue (a Clojure list works well for this), then this would be a depth-first search. Instead of going broadly and simultaneously trying a number of paths, it would dive deep into the graph along one path and not backtrack to try a new one until it had exhausted the first path. This is a flexible base on which one can build a number of functionalities. For example, a breadth-first search is now a two-line function: (defn bfs [graph a b] (first (filter #(= (last %) b) (breadth-first graph a)))) These are just filters that find all paths that start from a and end at b and then return the first of those. Now that we have the fundamental data structure that we're going to use, we can read the data files that we downloaded into a graph. For the purposes of analyzing the network itself, we're only interested in the *.edges files. This lists the edges in the graph, one edge per line. Each edge is defined by the node numbers that it connects. As Facebook relationships are two-way, the edges represented here are bidirectional. For example, the first few lines of 0.edges are shown as follows: 236 186 122 285 24 346 271 304 176 9 We'll first define a function that reads one edge file into a Graph, and then we'll define another function that walks a directory, reads each edge file, and merges the graphs into one. I'm keeping these in a new namespace, network-six.ego. This is defined in the src/network_six/ego.clj file. It uses the following namespace declaration: (ns network-six.ego (:require [clojure.java.io :as io] [clojure.set :as set] [clojure.string :as string] [clojure.data.json :as json] [clojure.core.reducers :as r] [network-six.graph :as g] [network-six.util :as u] [me.raynes.fs :as fs]) (:import [java.io File])) Now we'll define the function that reads the *.edges files from a data directory: (defn read-edge-file [filename] (with-open [f (io/reader filename)] (->> f line-seq (r/map #(string/split % #"\s+")) (r/map #(mapv (fn [x] (Long/parseLong x)) %)) (r/reduce #(g/add %1 (first %2) (second %2)) g/empty-graph)))) (defn read-edge-files [ego-dir] (r/reduce g/merge-graphs {} (r/map read-edge-file (fs/find-files ego-dir #".*\.edges$")))) We can use these from read-eval-print loop (REPL) to load the data into a graph that we can work with. We can get some basic information about the data at this point, and the following how we'll go about doing that: User=> (require '[network-six.graph :as g] '[network-six.ego :as ego]) user=> (def graph (ego/read-edge-files "facebook/")) #'user/graph user=> (count (g/get-vertices graph)) 3959 user=> (count (g/get-edges graph)) 168486 Now let's dive deeper into the graph and get some other metrics. There are a variety of metrics that we can use to describe graph data structures in particular and social network graphs in general. We'll look at a few of them and think about both, what they can teach us, and how we can implement them. Recall that a network's density is the number of actual edges versus the number of possible edges. A completely dense network is one that has an edge between each vertex and every other vertex. For example, in the following figure, the graph on the upper-right section is completely dense. The graph in the lower-left section has a density factor of 0.5333. The number of possible edges is given as N(N-1). We'll define the density formula as follows: (defn density [graph] (let [n (count (get-vertices graph)) e (count (get-edges graph))] (/ (* 2.0 e) (* n (dec n))))) We can use this to get some information about the number of edges in the graph: user=> (g/density graph) 0.021504657198130255 Looking at this, it appears that this graph is not very dense. Maybe some other metrics will help explain why. A vertex's degree is the number of other vertexes connected to it, and another summary statistic for social networks is the average degree. This is computed by the formula 2E/N. The Clojure to implement this is straightforward: (defn avg-degree [graph] (/ (* 2.0 (count (get-edges graph))) (count (get-vertices graph)))) Similarly, it is easy to use it: user=> (g/avg-degree graph) 85.11543319019954 So, the typical number of edges is around 85. Given that there are almost 4,000 vertices, it is understandable why the density is so low (0.022). We can get a number of interesting metrics based on all of the paths between two elements. For example, we'll need those paths to get the centrality of nodes later in this chapter. The average path length is also an important metric. To calculate any of these, we'll need to compute all of the paths between any two vertices. For weighted graphs that have a weight or cost assigned to each edge, there are a number of algorithms to find the shortest path. Dijkstra's algorithm and Johnson's algorithm are two common ones that perform well in a range of circumstances. However, for non-weighted graphs, any of these search algorithms evolve into a breadth-first search. We just implemented this. We can find the paths that use the breadth-first function that we walked through earlier. We simply take each vertex as a starting point and get all the paths from there. To make access easier later, we convert each path returned into a hash map as follows: (defn find-all-paths [graph] (->> graph get-vertices (mapcat #(breadth-first graph %)) (map #(hash-map :start (first %) :dest (last %) :path %)))) Unfortunately, there's an added complication; the output will probably take more memory than available. Because of this, we'll also define a couple of functions to write the paths out to a file and iterate over them again. We'll name them network-six.graph/write-paths and network-six.graph/iter-paths, and you can find them in the code download provided for this chapter on the Packt Publishing website. I saved it to the file path.json, as each line of the file is a separate JSON document. The first metric that we can get from the paths is the average path length. We can find this easily by walking over the paths. We'll use a slightly different definition of mean that doesn't require all the data to be kept in the memory. You can find this in the network-six.util namespace: user=> (double (u/mean (map count (map :path (g/iter-paths "path.json"))))) 6.525055748717483 This is interesting! Strictly speaking, the concept of six degrees of separation says that all paths in the network should be six or smaller However, experiments often look at the paths in terms of the average path length. In this case, the average distance between any two connected nodes in this graph is just over six. So, the six degrees of separation do appear to hold in this graph. We can see the distribution of path lengths more clearly by looking at a histogram of them: So, the distribution of path lengths appears to be more or less normal, centered on 6. The network diameter is the longest of the shortest paths between any two nodes in the graph. This is simple to get: user=> (reduce max Integer/MIN_VALUE (map count (map :path (g/iter-paths "path.json")))) 18 So the network diameter is approximately three times larger than the average. Clustering coefficient is a measure of how many densely linked clusters there are in the graph. This is one measure of the small world effect, and it's sometimes referred to as the "all my friends know each other" property. To find the clustering coefficient for one vertex, this basically cuts all of its neighbors out of the network and tries to find the density of the subgraph. In looking at the whole graph, a high clustering coefficient indicates a small world effect in the graph. The following is how to find the clustering coefficient for a single vertex: (defn clustering-coeff [graph n] (let [cluster ((:neighbors graph) n) edges (filter cluster (mapcat (:neighbors graph) cluster)) e (count edges) k (count cluster)] (if (= k 1) 0 (/ (* 2.0 e) (* k (dec k)))))) The function to find the average clustering coefficient for the graph is straightforward, and you can find it in the code download. The following is how it looks when applied to this graph: user=> (g/avg-cluster-coeff graph) 1.0874536731229358 So it's not overly large. Chances are, there are a few nodes that are highly connected throughout the graph and most others are less connected. There are several ways to measure how central a vertex is to the graph. One is closeness centrality. This is the distance of any particular vertex from all other vertices. We can easily get this information with the breadth-first function that we created earlier. Unfortunately, this only applies to complete networks, that is, to networks in which every vertex is reachable from every other vertex. This is not the case in the graph we're working with right now. There are some small pockets that are completely isolated from the rest of the network. However, there are other measures of centrality that we can use instead. Betweenness centrality counts the number of shortest paths that a vertex is found in. Betweenness finds the vertices that act as a bridge. The original intent of this metric was to identify people who control the communication in the network. To get this done efficiently, we can rely on the paths returned by the breadth-first function again. We'll get the paths from each vertex and call reduce over each. At every step, we'll calculate the total number of paths plus the number of times each vertex appears in a path: (defn accum-betweenness [{:keys [paths betweenness reachable]} [v v-paths]] (let [v-paths (filter #(> (count %) 1) v-paths)] {:paths (+ paths (count v-paths)), :betweenness (merge-with + betweenness (frequencies (flatten v-paths))), :reachable (assoc reachable v (count v-paths))})) Next, once we reach the end, we'll take the total number of paths and convert the betweenness and reachable totals for each vertex to a ratio, as follows: (defn ->ratio [total [k c]] [k (double (/ c total))]) (defn finish-betweenness [{:keys [paths betweenness reachable] :as metrics}] (assoc metrics :betweenness (->> betweenness (map #(->ratio paths %)) (into {})) :reachable (->> reachable (map #(->ratio paths %)) (into {})))) While these two functions do all the work, they aren't the public interface. The function metrics tie these two together in something we'd want to actually call: (defn metrics [graph] (let [mzero {:paths 0, :betweenness {}, :reachable {}}] (->> graph get-vertices (pmap #(vector % (breadth-first graph %))) (reduce accum-betweenness mzero) finish-betweenness))) We can now use this to find the betweenness centrality of any vertex as follows: user=> (def m (g/metrics graph)) user=> ((:betweenness m) 0) 5.092923145895773E-4 Or, we can sort the vertices on the centrality measure to get those vertices that have the highest values. The first number in each pair of values that are returned is the node, and the second number is the betweenness centrality of that node. So, the first result says that the betweenness centrality for node 1085 is 0.254: user=> (take 5 (reverse (sort-by second (seq (:betweenness m))))) ([1085 0.2541568423150047] [1718 0.1508391907570839] [1577 0.1228894724115601] [698 0.09236806137867479] [1505 0.08172539570689669]) This has all been interesting, but what about Kevin Bacon? We started this chapter talking about the Six Degrees of Kevin Bacon, a pop culture phenomenon and how this captures a fundamental nature of many social networks. Let's analyze our Facebook network for this. First, we'll create a function called degrees-between. This will take an origin vertex and a degree of separation to go out, and it will return a list of each level of separation and the vertices at that distance from the origin vertex. The degrees-between function will do this by accumulating a list of vertices at each level and a set of vertices that we've seen. At each step, it will take the last level and find all of those vertices' neighbors, without the ones we've already visited. The following is what this will look like: (defn degrees-between [graph n from] (let [neighbors (:neighbors graph)] (loop [d [{:degree 0, :neighbors #{from}}], seen #{from}] (let [{:keys [degree neighbors]} (last d)] (if (= degree n) d (let [next-neighbors (->> neighbors (mapcat (:neighbors graph)) (remove seen) set)] (recur (conj d {:degree (inc degree) :neighbors next-neighbors}) (into seen next-neighbors)))))))) Earlier, we included a way to associate data with a vertex, but we haven't used this yet. Let's exercise that feature to store the degrees of separation from the origin vertex in the graph. We can either call this function with the output of degrees-between or with the parameters to degrees-between: (defn store-degrees-between ([graph degrees] (let [store (fn [g {:keys [degree neighbors]}] (reduce #(set-value %1 %2 degree) g neighbors))] (reduce store graph degrees))) ([graph n from] (store-degrees-between graph (degrees-between graph n from)))) Finally, the full graph is a little large, especially for many visualizations. So, let's include a function that will let us zoom in on the graph identified by the degrees-between function. It will return both the original graph, with the vertex data fields populated and the subgraph of vertices within the n levels of separation from the origin vertex: (defn degrees-between-subgraph [graph n from] (let [marked (store-degrees-between graph n from) v-set (set (map first (filter second (:data marked)))) sub (subgraph marked v-set)] {:graph marked, :subgraph sub})) With these defined, we can learn some more interesting things about the network that we're studying. Let's see how much of the network with different vertices can reach within six hops. Let's look at how we'd do this with vertex 0, and then we can see a table that presents these values for several vertices: user=> (def v-count (count (g/get-vertices g))) #'user/v-count user=> (double (/ (count (g/get-vertices (:subgraph (g/degrees-between-subgraph g 6 0)))) v-count)) 0.8949229603435211 Now, it's interesting to see how the betweenness values for these track the amount of the graph that they can access quickly: These are some interesting data points. What does this look like for the network as a whole? This makes it clear that there's probably little correlation between these two variables. Most vertices have a very low betweenness, although they range between 0 and 100 in the percent of the network that they can access. At this point, we have some interesting facts about the network, but it would be helpful to get a more intuitive overview of it, like we just did for the betweenness centrality. Visualizations can help here. At this point, it would be really useful to visualize this graph. There are a number of different ways to visualize graphs. We'll use the JavaScript library D3 (data-driven documents,) to generate several graph visualizations on subgraphs of the Facebook network data, and we'll look at the pros and cons of each. Finally, we'll use a simple pie chart to visualize how much of the graph is affected as we move outward from a node through its degrees of separation. As I just mentioned, D3 is a JavaScript library. JavaScripts are not bad, but this is a book about Clojure. There's an implementation of the Clojure compiler that takes Clojure and generates JavaScript. So, we'll use that to keep our focus on Clojure while we call JavaScript libraries and deploy them on a browser. Before we can do that, however, we need to set up our system to use ClojureScript. The first thing we'll need to do is to add the configuration to our project.clj file for this project. This is fairly simple. We just need to declare lein-cljsbuild as a plugin for this project and then configure the ClojureScript compiler. Our project.clj file from earlier is shown as follows, with the relevant lines highlighted as follows: }}]}) The first line adds the lein-cljsbuild plugin to the project. The second block of lines tell Leiningen to watch the src-cljs directory for ClojureScript files. All of these files are then compiled into the www/js/main.js file. We'll need an HTML file to frame the compiled JavaScript. In the code download, I've included a basic page that's modified from an HTML5 Boilerplate template (). The biggest change is that I've taken out everything that's in the div content. Also, I added some script tags to load D3 and a D3 plugin for one of the types of graphs that we'll use later. After the tag that loads bootstrap.min.js, I added these: <script src=""></script> <script src=""></script> Finally, to load the data files asynchronously with AJAX, the www directory will need to be accessible from a web server. There are a number of different options, but if you have Python installed, the easiest option is to probably navigate to the www directory and execute the following command: $ cd www $ python -m SimpleHTTPServer Serving HTTP on 0.0.0.0 port 8000 ... Now we're ready to proceed. Let's make some charts! One of the standard chart types to visualize graphs is a force-directed layout. These charts use a dynamic-layout algorithm to generate charts that are more clear and look nice. They're modeled on springs. Each vertex repels all the other vertices, but the edges draw the vertices closer. To have this graph compiled to JavaScript, we start by creating a file named src-cljs/network-six/force.cljs. We'll have a standard namespace declaration at the top of the file: (ns network-six.force) Generally, when we use D3, we first set up part of the graph. Then, we get the data. When the data is returned, we continue setting up the graph. In D3, this generally means selecting one or more elements currently in the tree and then selecting some of their children using selectAll. The elements in this new selection may or may not exist at this point. We join the selectAll elements with the data. From this point, we use the enter method most of the time to enter the data items and the nonexistent elements that we selected earlier. If we're updating the data, assuming that the elements already exist, then the process is slightly different. However, the process that uses the enter method, which I described, is the normal workflow that uses D3. So, we'll start with a little setup for the graph by creating the color palette. In the graph that we're creating, colors will represent the node's distance from a central node. We'll take some time to understand this, because it illustrates some of the differences between Clojure and ClojureScript, and it shows us how to call JavaScript: (defn make-color [] (.. js/d3 -scale category10 (domain (array 0 1 2 3 4 5 6)))) Let's take this bit by bit so that we can understand it all. I'll list a line and then point out what's interesting about it: (.. js/d3 There are a couple of things that we need to notice about this line. First, .. is the standard member access macro that we use for Java's interoperability with the main Clojure implementation. In this case, we're using it to construct a series of access calls against a JavaScript object. In this case, the ClojureScript that the macro expands to would be (.domain (.category10 (.-scale js/d3)) (array 0 1 2 3 4 5 6)). In this case, that object is the main D3 object. The js/ namespace is available by default. It's just an escape hatch to the main JavaScript scope. In this case, it would be the same as accessing a property on the JavaScript window object. You can use this to access anything from JavaScript without having to declare it. I regularly use it with js/console for debugging, for example: -scale This resolves into the JavaScript d3.scale call. The minus sign before scale just means that the call is a property and not a function that takes no arguments. As Clojure doesn't have properties and everything here would look like a function call, ClojureScript needs some way to know that this should not generate a function call. The dash does that as follows: category10 This line, combined with the preceding lines, generates JavaScript that looks like d3.scale.category10(). In this case, the call doesn't have a minus sign before it, so the ClojureScript compiler knows that it should generate a function call in this case: (domain (array 0 1 2 3 4 5 6)))) Finally, this makes a call to the scale's domain method with an array that sets the domain to the integers between 0 and 6, inclusive of both. These are the values for the distances that we'll look at. The JavaScript for this would be d3.scale.category10().domain([0, 1, 2, 3, 4, 5, 6]). This function creates and returns a color object. This object is callable, and when it acts as a function that takes a value and returns a color, this will consistently return the same color whenever it's called with a given value from the domain. For example, this way, the distance 1 will also be associated with the same color in the visualization. This gives us an introduction to the rules for interoperability in ClojureScript. Before we make the call to get the data file, we'll also create the object that takes care of managing the force-directed layout and the D3 object for the svg element. However, you can check the code download provided on the Packt Publishing website for the functions that create these objects. Next, we need to access the data. We'll see that in a minute, though. First, we need to define some more functions to work with the data once we have it.For the first function, we need to take the force-layout object and associate the data with it. The data for all of the visualizations has the same format. Each visualization is a JSON object with three keys. The first one, nodes, is an array of JSON objects, each representing one vertex in the graph. The main property of these objects that we're interested in is the data property. This contains the distance of the current vertex from the origin vertex. Next, the links property is a list of JSON objects that represent the edges of the graph. Each link contains the index of a source vertex and a target vertex. Third, the graph property contains the entire graph using the same data structures as we did in Clojure. The force-directed layout object expects to work with the data from the nodes and the links properties. We set this up and start the animation with the setup-force-layout function: (defn setup-force-layout [force-layout graph] (.. force-layout (nodes (.-nodes graph)) (links (.-links graph)) start)) As the animation continues, the force-layout object will assign each node and link the object with one or more coordinates. We'll need to update the circles and paths with those values. We'll do this with a handler for a tick event that the layout object will emit: (defn on-tick [link node] (fn [] (.. link (attr "x1" #(.. % -source -x)) (attr "y1" #(.. % -source -y)) (attr "x2" #(.. % -target -x)) (attr "y2" #(.. % -target -y))) (.. node (attr "cx" #(.-x %)) (attr "cy" #(.-y %))))) Also, at this stage, we create the circle and path elements that represent the vertices and edges. We won't list these functions here. Finally, we tie everything together. First, we set up the initial objects, then we ask the server for the data, and finally, we create the HTML/SVG elements that represent the data. This is all tied together with the main function: (defn ^:export main [json-file] (let [width 960, height 600 color (make-color) force-layout (make-force-layout width height) svg (make-svg width height)] (.json js/d3 json-file (fn [err graph] (.. graph -links (forEach #(do (aset %1 "weight" 1.0) (aset %1 "index" %2)))) (setup-force-layout force-layout graph) (let [link (make-links svg graph color) node (make-nodes svg graph color force-layout)] (.on force-layout "tick" (on-tick link node))))))) There are a couple of things that we need to notice about this function, and they're both highlighted in the preceding snippet. The first is that the function name has an :export metadata flag attached to it. This just signals that the ClojureScript compiler should make this function accessible from JavaScript outside this namespace. The second is the call to d3.json. This function takes a URL for a JSON data file and a function to handle the results. We'll see more of this function later. Before we can use this, we need to call it from the HTML page. After the script tag that loads js/main.js, I added this script tag: <script> network_six.force.main('facebook-49.json'); </script> This loads the data file for vertex number 49. This vertex had a betweenness factor of 0.0015, and it could reach four percent of the larger network within six hops. This is small enough to create a meaningful, comprehensible graphic, as seen in the following figure: The origin vertex ( 49) is the blue vertex on the lower-right section, almost the farthest-right node of the graph. All the nodes at each hop away from that node will be of a different color. The origin vertex branches to three orange vertices, which link to some green ones. One of the green vertices is in the middle of the larger cluster on the right. Some aspects of this graph are very helpful. It makes it relatively easy to trace the nodes as they get farther from the origin. This is even easier when interacting with the node in the browser, because it's easy to grab a node and pull it away from its neighbors. However, it distorts some other information. The graph that we're working with today is not weighted. Theoretically, the links in the graph should be the same length because all the edges have the same weight. In practice, however, it's impossible to display a graph in two dimensions. Force-directed layouts help you display the graph, but the cost is that it's hard to tell exactly what the line lengths and the several clear clusters of various sizes mean on this graph. Also, the graphs themselves cannot be compared. If we then pulled out a subgraph around a different vertex and charted it, we wouldn't be able to tell much by comparing the two. So what other options do we have? The first option is a hive plot. This is a chart type developed by Martin Krzywinski (). These charts are a little different, and reading them can take some time to get used to, but they pack in more meaningful information than force-directed layout or other similar chart types do. In hive plots, the nodes are positioned along a number of radial axes, often three. Their positions on the axis and which axis they fall on are often meaningful, although the meanings may change between different charts in different domains. For this, we'll have vertices with a higher degree (with more edges attached to them) be positioned farther out from the center. Vertices closer in will have fewer edges and fewer neighbors. Again, the color of the lines represent the distance of that node from the central node. In this case, we won't make the selection of the axis meaningful. To create this plot, we'll open a new file, src-cljs/network-six/hive.cljs. At the top, we'll use this namespace declaration: (ns network-six.hive) The axis on which a node falls on is an example of a D3 scale; its color from the force layout plot is another scale. Scales are functions that also have properties attached and are accessible via getter or setter functions. However, primarily, when they are passed a data object and a key function, they know how to assign that data object a position on the scale. In this case, the make-angle function will be used to assign nodes to an axis: (defn make-angle [] (.. js/d3 -scale ordinal (domain (.range js/d3 4)) (rangePoints (array 0 (* 2.0 pi))))) We'll position the nodes along each axis with the get-radius function. This is another scale that takes a vertex and positions it in a range between 40 and 400 according to the number of edges that are connected to it: (defn get-radius [nodes] (.. js/d3 -scale linear (range (array 40 400)) (domain (array (.min js/d3 nodes #(.-count %)) (.max js/d3 nodes #(.-count %)))))) We use these scales, along with a scale for color, to position and style the nodes: (defn make-circles [svg nodes color angle radius] (.. svg (selectAll ".node") (data nodes) (enter) (append "circle") (attr "stroke" #(color (.-data %))) (attr "transform" #(str "rotate(" (degrees (angle (mod (.-n %) 3))) \))) (attr "cx" #(radius (.-count %))) (attr "r" 5) (attr "class" #(get-classes %)))) I've highlighted the scales that we use in the preceding code snippet. The circle's stroke property comes from the color, which represents the distance of the vertex from the origin for this graph. The angle is used to assign the circle to an axis using the circle's transform attribute. This is done more or less at random, based on the vertex's index in the data collection. Finally, the radius scale positions the circle along the axis. This sets the circle's position on the x axis, which is then rotated using the transform attribute and the angle scale. Again, everything is brought together in the main function. This sets up the scales, requests the data, and then creates and positions the nodes and edges: (defn ^:export main [json-file] (let [width 750, height 750 angle (make-angle), color (make-color) svg (make-svg width height)] (.json js/d3 json-file (fn [err data] (let [nodes (.-nodes data) radius (get-radius nodes)] (make-axes svg angle radius) (let [df (get-degreed nodes data)] (make-arcs svg nodes df color angle radius) (make-circles svg nodes color angle radius))))))) Let's see what this graph looks like: Again, the color represents the distance of the node from the central node. The distance from the center on each axis is the degree of the node. It's clear from the predominance of the purple-pink color and the bands that the majority of the vertices are six hops from the origin vertex. From the vertices' position on the axes, we can also see that most nodes have a moderate number of edges attached to them. One has quite a few, but most are much closer to the center. This graph is denser. Although the force-layout graph may have been problematic, it seemed more intuitive and easier to understand, whether it was meaningful or not. Hive plots are more meaningful, but they also take a bit more work to learn to read and to decipher. Our needs today are simpler than the complex graph we just created; however, we're primarily interested in how much of the network is covered within six hops from a vertex. Neither of the two graphs that we've looked at so far conveyed that well, although they have presented other information and they're commonly used with graphs. We want to know proportions, and the go-to chart for proportions is the pie chart. Maybe it's a little boring, and it's does not strictly speak of a graph visualization per se, but it's clear, and we know what we're dealing with in it. Generating a pie chart will look very similar to creating a force-directed layout graph or a hive plot. We'll go through the same steps, overall, even though some of the details will be different. One of the first differences is the function to create an arc. This is similar to a scale, but its output is used to create the d (path description) attribute of the pie chart's wedges: (defn make-arc [radius] (.. js/d3 -svg arc (outerRadius (- radius 10)) (innerRadius 0))) The pie layout controls the overall process and design of the chart. In this case, we say that we want no sorting, and we need to use the amount property of the data objects: (defn make-pie [] (.. js/d3 -layout pie (sort nil) (value #(.-amount %)))) The other difference in this chart is that we'll need to preprocess the data before it's ready to be fed to the pie layout. Instead of a list of nodes and links, we'll need to give it categories and counts. To make this easier, we'll create a record type for these frequencies: (defrecord Freq [degree amount]) Also, we'll need a function that takes the same data as the other charts, counts it by distance from the origin vertex, and creates Freq instances to contain that data: (defn get-freqs [data] (->> data .-nodes (map #(.-data %)) frequencies (map #(Freq. (first %) (second %))) into-array)) Again, we pull all these together in the main function, and we do things in the usual way. First, we set up the graph, then we retrieve the data, and finally, we put the two together to create the graph. In this case, this should give us an idea of how much of the graph this vertex can easily touch. The graph for vertex 49 is shown as follows. We can see that it really doesn't touch much of the network at all. 3799 vertices, more than 95 percent of the network, aren't within six hops of vertex 49. However, if we compare this with the pie chart for vertex 1085, which was the vertex with the highest betweenness factor, we see a very different picture. For that vertex, more than 95 percent of the network is reachable within 6 hops. It's also interesting that most of the vertices are four edges away from the origin. For smaller networks, most vertices are further away. However, in this case, it's almost as if it had started running out of vertices in the network. So, we discovered that this dataset does conform to a loose definition of the small world or a six-degree hypothesis. The average distance between any two nodes is about six. Also, as we're working with a sample, it's possible that working with a complete graph may fill in some links and bring the nodes closer together. We also had an interesting time looking at some visualizations. One of the important lessons that we learned was that more complicated isn't always better. Simple, perhaps even a little boring, graphs can sometimes answer the questions we have in a better manner. However, we've barely scratched the surface of what we can do with social graphs. We've primarily been looking at the network as a very basic, featureless graph, looking at the existence of people and their relationships without digging into the details. However, there are several directions we could go in to make our analysis more social. For one, we could look at the different types of relationships. Facebook and other social platforms allow you to specify spouses, for example, it might be interesting to look at an overlap between spouses' networks. Facebook also tracks interests and affiliations using their well-known Like feature. We could also look at how well people with similar interests find each other and form cliques. In the end, we've managed to learn a lot about networks and how they work. Many real-world social networks share very similar characteristics, and there's a lot to be learned from sociology as well. These structures have always defined us but never more so than now. Being able to effectively analyze social networks, and the insights we can get from them, can be a useful and effective part of our toolkit. In the next chapter, we'll look at using geographical analysis and applying that to weather data.
https://www.packtpub.com/product/mastering-clojure-data-analysis/9781783284139
CC-MAIN-2021-21
refinedweb
8,683
71.34
I need to write to a file before closing the console, how do I do it? Answer 1 Answer 2 I've done it, but if the user closes the console before everything is done, the file isn't wrote, I need to wrote it anyway, even if the user closes the console. Answer 3 I fear that this might not be possible. If your application is killed from outside, there is not much you can do. Maybe you want to build up a GUI application instead. Then it is still posisble for the user to kill the application (e.g. through task manager and then killing the process), but there is no easy "X" button to click. A possible trick could be to disable the close button (e.g. you search for the console window your application is running in and then try to modify this window directly. But you have to take care of special cases: a) it is possible, that no window is there. b) it is possible thta multiple windows are there because the tool was started multiple times. At the moment I have no idea how to change an existing window so that the close button is no longer enabled. And I have to confess that I don't really like this dirty hack. But maybe this codeproject article shows a little, how you could find a window: With kind regards, Konrad Answer 4 thanks Konrad, but I can't disable the close button, I really need that if the user close the program the file is wrote. I read something about how to disable the "X" button but that isn't what I want. anyway, thanks Konrad. Answer 5 //==============================================================privatevoid Form1_FormClosed(object sender, FormClosedEventArgs e) { MessageBox.Show("Closed."); } //============================================================== Answer 6 I know how to do it on a Windows Forms Application, but the problem is that I need it for a console application, so it's impossible to do it on a console application? I have a console application that was developed for Windows XP. It uses a control handler to trap the application close event so the application can be shut down gracefully before exiting. Unfortunately Windows 7 now ungracefully kills an application shortly after the control handler returns even if the control handler return value is TRUE. Previously in Windows XP the application was allowed to complete its shutdown logic, which may take several seconds, before the application died. In Windows Server 2008 I was able to modify my application to not return from the control handler until I knew the app was cleaned up but even this doesn't work anymore. Does Windows 7 have another mechanism that I can use to allow my application to complete its shutdown without being unceremoniously killed? The result is a nasty program error popup screen that I don't really want the user to see. hi all, I want to close the console application, when the work is done. but it does not get closed. wht to do??? plz help Hello, I am running Windows XP SP3 and I am programming a C++ application using Visual Studio 2008 SP1. The application start with a "_tmain" function (which create a background console for standard output). On top of that, I initialize SDL which create a normal window for the application rendering. It happens about 1 times on 100, and never managed to pinpoint how it actually happens, seems pretty random. Some time I start in debug mode, encounter a breakpoint (or crash) and then press the "stop" button in VS IDE to close the application, while sometime I press the X either on the SDL window or on the console window. What exactly happens is that even if I close my Visual Studio instance, and check the task manager to be sure there are no process running anymore with the name of my application (Launcher.exe) nor msdev.exe, the console window stick open with the last log in it. Bigger problem is that I can't close it. The X don't do anything, but I can still minimize/maximize it. I can still copy/paste text. If I go in "properties", the properties windows don't open (nothing happens). I can't type in it, but never did I so it's normal. Even stranger is that I can't even shut down Windows!! If I select either "shut down" or "restart", it close all other application and the few windows stuck open stay there with nothing else, and the computer never finish the shutdown process, I have hard-reset by cutting the power. I never had this problem in my 15+ year of computing before so I doubt this is a bug in Windows, and I also know that it's not a bug on my personal computer, because it also happened to my co-worker. Still can't find anything special that our application do that could be causing this. We have multiple threads, but a process shutdown should close everything anyway? hi all. i am beginner to .NET . i developed one mini project in asp.net. my problem is when i close the browser after running my application, only the browser isl closing. but i need to close whole application also. how can i achieve this. it doesnt seems good to click on "stop debugging" every time. please help me. Thank you. Good day! I've encountered a strange issue when writing simple console application in Visual C++ 2010 - when I pressed Ctrl+F5 to see the results of my program, console window had automatiacally closed. Also, I've tried this from main menu (Start without debugging), but result is the same - console keeps closing automatically. My program is empty project, my OS is Windows 7 32 bit. I'm attempting to use Visual C++ 6 on 64-bit Windows 7. I know; it sounds odd. When I run a project in the debugger as a Windows console program, the console window doesn't go away when I click on the Stop Debugging button. Clicking the X in the window won't close it, and neither will Task Manager or Process Explorer. Closing the Visual C++ IDE itself does make it disappear, but this is obviously inconvenient when trying to debug an issue. I've seen some Internet traffic about this issue, but it all seems related to Windows XP, not Windows 7. I previously had a 32-bit Windows 7 installation, and this problem did not occur. So I'm thinking the issue has something to do with 64-bit Windows 7. I suppose it could also be a recent Microsoft update, but the ones mentioned in the articles I read were apparently specific to Windows XP, because they aren't on my system. Can anything be done to make this problem stop? Thanks! I am debugging C++ code in VS 2008; when I stop debugging the console window remains open and cannot be killed. An active task is shown in the task manager but no process. Clicking on the window 'x', hitting "end task' in the task manager, or exiting VS does not kill it. If I debug again, it opens another window which again can not be killed. I installed the current windows updates this morning, after which this problem appeared. I have uninstalled the updates but have not fixed the problem. I also installed the updates on my laptop but it does not have this problem. VS 2008 9.0.21022 Professional edition .NET framework 3.5 SP1Windows XP Pro SP3 I am using C# 2010 and wrote a simple program. My problem is that the consonle displays the text from the console.writeline statement but then spits out a "Press any key to Continue.....". The problem is that the console window won't close regardless of what I do. The X doesn't work, any key doesn't work, and the Taskmanger end task doesn't even work. Man, I can't even program hello world in the console and have it work. Help. Stop the console from opening and closing instantly? if I use console.ReadKey(); it still opens and closes instantly. console.readline(); also does the same thing. Maybe its my code thats doing it so I have pasted it below. its not long or anything. also ALib is a custom made DLL. using System; using System.Collections.Generic; using System.Linq; using System.Text; using ALib; namespace SampleConsoleProgram { //This program shouls in theory reutn how many letters or numbers are with in this //chosen line of text. class Program { static void Main(string[] args) { Console.WriteLine("functions Client"); if (args.Length == 0) { Console.WriteLine("usage: Functionstest..."); return; } for (int i = 0; i < args.Length; i++) { int num = Int32.Parse(args[i]); Console.WriteLine( "The digit Count for String [{0}] is [{1}]", args[i], //invoke the class called by the DLL. //String Counter. StringCounter.numberOfdigits(args[i])); } //Stop the application from closing. Console.ReadLine(); } } } Hi, I wanted to check whether user has entered value in Sales Opportunity before closing it. If not then user should prompt to enter value in "Sales Opportunity" as he/she Click on Close Opportunity menuitem. Thanks in Advanced!! Plz help me If I open a connection to SQL Azure, master database, and attempt to query the data on a DMV, I get an error message indicating that I don't have permission. For example: select top 10 * from sys.dm_exec_connections Msg 297, Level 16, State 1, Line 1: The user does not have permission to perform this action. Is this by design? Do I need to configure a permission? I'm able to query the master DMVs in SQL Server 2008 R2 with no issues. I have developed a TCP server that manages several devices. When the application is closed I need to send a message to each of the devices to let them know the connection is closing. I set up a handler for the form_closing event and am trying to send the messages at that time; however, at the same time the system closes the IOCP which triggers my AsyncCallback function for my async receives. In the async callback the system throws an exception saying "The I/O operation has been aborted because of either a thread exit or an application request". To avoid this issue, where would be the appropriate place to shutdown the server so these operations are not aborted before I can clean-up my own resources? I have created a WPF project ,in one page i made remaining pages as tab mdi childs. How can i close the tab on clicking the mdi child button (or) how can i call tab closebutton click event in mdi child buttonclick I am working on a application in which When user clicks on a button he should be redirected to facebook login page and after successfull login he shud be reirected back to my page. It all is working fine but now I have to do like thiswhen user click on the Button the the facebookbacklogin page shud be opened in popUp and when login is done successfully the popup window shud be closed and the main page shud be refreshed. anf If user is already login the popup window shud not be opened.How can i do this..How can I KNow that a popup window is opened and how can I close that??How to refresh when popup window is closed. I ahve to do like on this site.. strange problem with closing one of my forms in my Windows Mobile application. In some cases (I don't know the exact reason or circumstances, I could reproduce this only one or two times, but our customer met this problem often) the Form.Close method has no any visible effect. In these cases the Form.Closing and the Form.Closed events don't even get fired. There is no exception thrown, every other functions work well only if the user clicks on the "Exit" menu item nothing happens. The Form.Close method is surely called, because I added debug logs immediately before and after the calling of the method so I could check it. If this bug once occurs then the Form.Close method has no effect anymore and the form can only be closed by killing the process from the task manager. Has somebody got any idea what can cause this bug? Thanks, Gorila
http://go4answers.webhost4life.com/Example/perform-actions-before-closes-when-195440.aspx
CC-MAIN-2015-48
refinedweb
2,081
73.17
Embedded GUI Using Linux Frame Buffer Device with LittlevGL LittlevGL is a graphics library targeting microcontrollers with limited resources. However it possible to use it to create embedded GUIs with high-end microprocessors and boards running Linux operation system. The most well know processors cores are the ARM Cortex A9 (e.g. NXP i.MX6) and ARM Cortex A53 (e.g. Raspbery PI 3). You can create an embedded GUI on this single board computers by simply using Linux’s frame buffer device (typically /dev/fb0). If you don’t know LittlevGL yet learn more about it here: LittlevGL Why use the frame buffer directly? The frame buffer device is a very low-level interface to display something on the screen. Speaking about an embedded GUI there are several reasons to use the frame buffer directly instead of a Window manager: - simple Just write the pixels to a memory - fast No window manager which means fast boot and less overhead - portable Independently from the distribution every Linux system has a frame buffer device so it’s compatible with all of them Maybe you are familiar with the Linux frame buffer device. It is a file usually located at /dev/fb0. This file contains the pixel data of your display. If you write something into the frame buffer file then the changes will be shown on the display. If you are using Linux on your PC you can try it using a terminal: - Press Ctrl + Alt + F1 to leave the desktop and change to simple character terminal - Type sudo suand type your password - Stop your Display manager (on Ubuntu it’s lightdm): service lightdm stopImportant: it will log you out, so all windows will be closed - Write random data to the frame buffer device: cat /dev/urandom > /dev/fb0You should see random colored pixels on the whole screen. - To go back to the normal Graphical User Interface: service lightdm start It should work on Linux based single board computer too like: Get LittlevGL to create embedded GUI Now you know how to change the pixels on your displays. But you still need something which creates GUI elements instead of random pixels. Here comes the Littlev Graphics Library into the picture. This software library is designed to create GUI elements (like labels, buttons, charts, sliders, checkboxes etc.) on an embedded system’s display. Check all the widgets here: Graphical object types. The graphics library is written in C so you can surely adapt it in your project. The make your GUI impressive opacity, smooth animations, anti-aliasing and shadows can be added. To use LittlevGL you need to clone it from GitHub or get from the Download page. The following components will be required: - lvgl The core of the graphics library - lv_drivers Contains a Linux frame buffer driver - lv_examples Optionally to load a demo application to test GUI project set-up The most simple case to test the frame buffer device based GUI on your Linux PC. Later you apply the same code on an embedded device too. - Create a new project in your preferred IDE - Copy the template configuration files next to lvgl and lv_drivers folders: - lvgl/lv_conf_templ.h as lv_conf.h - lv_drivers/lv_drv_conf_templ.h as lv_drv_conf.h - In the config files remove the first and last #if and #endif to enable their content. - In lv_drv_conf.h set USE_FBDEV 1 - In lv_conf.h change the color depth: LV_COLOR_DEPTH 32 - Add the projects root folder as include path Create an embedded GUI application - In main.c write the following code to create a hello world label: #include "lvgl/lvgl.h" #include "lv_drivers/display/fbdev.h" #include <unistd.h> int main(void) { /*LittlevGL init*/ lv_init(); /*Linux frame buffer device init*/ fbdev_init(); /*A small buffer for LittlevGL to draw the screen's content*/ static lv_color_t buf[DISP_BUF_SIZE]; /*Initialize a descriptor for the buffer*/ static lv_disp_buf_t disp_buf; lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE); /*Initialize and register a display driver*/ lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); disp_drv.buffer = &disp_buf; disp_drv.flush_cb = fbdev_flush; lv_disp_drv_register(&disp_drv); /*Create a "Hello world!" label*/ lv_obj_t * label = lv_label_create(lv_scr_act(), NULL); lv_label_set_text(label, "Hello world!"); lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); /*Handle LitlevGL tasks (tickless mode)*/ while(1) { lv_tick_inc(5); lv_task_handler(); usleep(5000); } return 0; } - Compile the code and go back to character terminal mode (Ctrl + Alt + F1 and service lightdm stop) - Go to the built executable file and type: ./file_name - Test with a demo application by replace the Hello world label create with: demo_create(); Download a ready-to-use project In lv_linux_frame_buffer repository you find an Eclipse CDT project to try out the plain frame buffer based GUI with a Linux PC. There is a Makefile too to compile the project on your embedded hardware without an IDE. Summary I hope you liked this tutorial and found it useful for your microprocessor-based embedded Linux projects. As you can see it’s super easy is to create an embedded GUI with LittlevGL using only a plain Linux frame buffer. To learn more about the graphics library start to read the Documentation or check the Embedded GUI building blocks. If you don’t have a embedded hardware right now you can begin the GUI development on PC. If you have questions use GitHub issue tracker.
https://blog.littlevgl.com/2018-01-03/linux_fb
CC-MAIN-2019-47
refinedweb
869
53
Setting up JNI development in Gradle project IntelliJ IDEA supports JNI development in Gradle projects. To add JNI support - Create a new or open an existing Gradle project. - Open the build.gradlefile. - Specify the C plugin and define a native library:If you want to see the whole project, refer to the project's build.gradle file. apply plugin: 'c' model { components { hello(NativeLibrarySpec) } } When you specified the native library, the shared and static library binaries are added to the Gradle projects tool window (build directory). - In the Project tool window, in the src | java directory create a Java class ( ) that will use C code. - Open the created class in the editor and enter your code. class HelloWorld { public native void print(); static { System.loadLibrary("hello"); } } - In the Project tool window, in the src directory, create the hello directory and the c subdirectory. - In the c subdirectory, create the hello.c file which is a file for your C programs. - Open the hello.cfile in the editor and specify the following code: #include <jni.h> #include <stdio.h> JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj) { printf("Hello World!\n"); return; } At this point you can start developing your application further using native codes as needed. Last modified: 14 June 2018
https://www.jetbrains.com/help/idea/2018.2/setting-up-jni-development-in-gradle-project.html
CC-MAIN-2018-26
refinedweb
211
59.7
On Jun 17, 2013, at 5:48 PM, James Y Knight <foom at fuhm.net> wrote: > I'm surprised that a thread with 32 messages about logging doesn't seem to have once mentioned windows events, osx structured syslog, or systemd journal as important design points. As it happens I was discussing exactly that! In a sense, they're just observers, and it's just a matter of persisting whatever fields are present to the various backend systems. > Maybe people are thinking about such things in the background but it looks a lot like this is being designed in a vacuum when there's plenty of air around. So yes, I, at least, have been thinking about them, abstractly. But you raise a good point: we should be talking about them concretely and making sure that we could at least take advantage of the facilities they offer before we finalize anything. However, then you fail to discuss them concretely :). Do you have any practical experiences with these systems that would indicate what features would be useful to abstract over or how they should be exposed? > And, no sane sysadmin should ever want a twisted-specific log file format or to write custom python log filters. That's crazy. Gimme a verbosity knob and the ability to emit structured log events to existing systems, with a fallback plain text file format. Great. There is a reason why we should support such a thing, by which I mean a "Twisted specific" format in the sense of something like line-delimited JSON (or whatever). We have an API for emitting log messages, and an API for observing log messages as they occur. If someone were to use the latter API to produce some software that does a useful thing, it would be very good to have a built-in, platform-independent format for logs that could easily be reconstituted into something that is a reasonable enough facsimile of the information available at runtime. That way log analysis using our log-analysis API would be possible offline without rewriting your online analysis tool to consume input from systemd, ASL, and windows event log instead of a Twisted observer. I agree that our existing text format is basically pointless, but there are two reasons to keep it around. First, it seem to be something that some sysadmins expect; there's definitely an archetype of sysadmin who prefers everything to be in "plain text" so they can run their perl scripts over it; someone more comfortable with regexes than structured data. Maybe you wouldn't characterize these people as sane, but they're definitely extant, and some of them, at least, run Twisted services. The second reason to keep the text format around is that even sysadmins who would _prefer_ structured data in an existing log facility have probably written some gross hacks to deal with twistd.log by now because we haven't previously exposed it in any meaningful way, so we need to preserve the existing format for some amount of compatibility. My hope is that we can convince them to upgrade to some sort of structured system on its own merits, at the very least a log file that can be parsed reliably. > The prime goal, it seems to me, should be exposing features useful for facilities present in existing log systems. That's certainly a goal, but it's a little longer term than the prime goal, which is to present a logging API that encourages any structure (and filtering based on that structure) to be expressed at all. It would of course be much better if that structure were aligned with existing logging systems. If we had logging with structured messages already, there'd at least be a hope of writing a somewhat useful translator to these back-end systems. As it is, sadly, we're going to have to touch almost every log.msg() call within Twisted to get any useful information out. > And having a logging system which doesn't even support a basic log level is just silly. Hopefully the new system can at least have that. The new system being proposed does have log levels. (And, for that matter, so does Twisted currently; we've had log levels for compatibility with stlib Python logging forever.) I still don't think that log levels are a particularly useful bit of structured information, and this is one reason I want to have our own structured format, to make sure that the other bits of more useful information hang around for longer in a useful form. I've been convinced that it's unhelpful to be contrarian and omit information which can be useful to a whole bunch of other systems and existing practices. (Also, the effort described therein is way too ambitious to do in any reasonable time frame unless someone wanted to make logging in Twisted their full-time job for at least a year.) Plus, I've seen some utility in Calendar Server from the use of the intersection of "level" and "namespace", although blanket application of log levels is still a crapshoot. (So, other than those caveats, everything I said about identifying the audience and intent of messages in <> still applies.) Do all the systems you mentioned have the same set of log levels, or will there be some need to harmonize them? -glyph -------------- next part -------------- An HTML attachment was scrubbed... URL: <>
https://twistedmatrix.com/pipermail/twisted-python/2013-June/027098.html
CC-MAIN-2018-22
refinedweb
906
65.05
Home > Products > triangle Suppliers Home > Products > triangle Suppliers > Compare Suppliers Company List Product List < Back to list items Page:1/6 China (mainland) The Nanyang Triangle Rose Imp. & Exp. Co., Ltd. is a large private enterprise, which is a scientific research center and big company of flower p... - Our Company TRIANGLE is a professional manufacturer and exporter that is concerned with the design, development and production a diverse rang... Double Shuenn Enterprise Co., Ltd. was established in 1996 which is specialized in a great variety of hardwares. With our massive a range of pro... Hong Kong (SAR) Taiwan We are manufacturer and exporter in Taiwan and China which produce various kind of pens for Hotel and Promotional use. Our hot pens as below: P... We have had about 30 years of experience of doing export & import business. Honest is the business policy excellent quality & prompt delivery ar... We are a manufacture and export company. Established in 1968, we are specialized in making screws. The features of our products lie in their price, promptly delivery, excellent and high... Farastar Industrial Co. Ltd. founded in 1982, is one of leading manufacturer and exporter of auto parts and accessories in Taiwan. With special ... We develop more ideal machine and equipment to our customers. Now we have: CNC tanner, triangle tanner, tanner, mortise tanner and carbon fiber ... Founded in 1988 by Mr. Chen, the President of the Torch Industrial Co., Ltd. is very proud of his product success as the manufacturer of all kin... Chung Fa has been well known in the windshield wiper blades wiper, arms and triangle reflectors manufacturer field for more than 20 years. Chung... We make various special screws, triangle screws, electronics screws, woodenware screws, hollow rivets, special eyelets. We are a professional manufacturer in inflatable water sport products in China. We have more than 25 years experience at inflatable products. ... We are engaged in exporting all kinds of textile products such as nightwear, gown, robe, scarves, ties, shawl, triangle and so on with different... Peaceful and friendly are this era's unique feature that can represent Chinese people and history. The red logo at the top of FV-04 acrylic cloc... Shun-iie Co. was founded in 1978. We mainly process metal wire into different shapes, such as circle, square, and triangle. We also produce m... We professional exporter of warning triangle, first aid kit, LED work light, spotlight, jump starter, jump cable, air compressor, etc auto acces... Shanghai Limin Traffic Equipment Facility Co. Ltd. serves in the traffic industry by developing in producing safety facilities and products for ... We are a newly established company with office in Beijing, China and office in Spain. We are mainly export to European countries but will be ... We are professional supplier of automobile parts and accessories in China with ten years experience. Our auto parts include high quality oil sea... Our company governs ?Chengjian Hardware & Tools?, ?Guangdong Foshan Yuexing Stainless Steel Ware Factory? and ?Yongkang Lanshi Yuexing Stainless... Greencar (Shenzhen) Co., Ltd. established in 2002, which is specialized in R&D, production and sales of decorative car accessories. This young c... We have been a professional manufacturer and exporter of parking sensors, car alarm system, warning triangle for several years. Our products ... Established in 1988, Shanghai Huahui Silk Products Co., Ltd. (formerly known as Shanghai Huashen Silk Co., Ltd.) is a specialized manufacturer o... Our company is specialized in developing, producing and exporting drawer slides, hinges, locks, handles and other hardware fittings with a produ... Expert Craftsmanship, Making Professional Products for You. Jeou Cherng Industrial Company Limited was found in 1969, and started out as primar... PengCheng Casing Co., Ltd., Hebei Dajiu Group, is located in the center of the triangle area formed by cities - Beijing, Shijiazhuang and Tianji... Wuzhou Meibo Gemstones Factory is located in Wuzhou City in China, one of the largest zirconia and gems producing basis in the world. Our mai... Show: 20 30 40 Showing 1 - 30 items Supplier Name Year Established Business Certification The Nanyang Triangle Rose Imp. & Exp. Co., Ltd. Triangle Homeware Enterprise Co.,Ltd. Double Shuenn Enterprise Co., Ltd. 5th Triangle China Fashion Jewelry Co., Ltd. Triangle Link Ltd. Pens-Inn Co., Ltd. Tong Ming Industry Co., Ltd. Jeannette Su Industrial Co., Ltd. Jin Chering Screw Industry Co., Ltd. Farstar Industrial Co., Ltd. Hsu Pen Machinery Co., Ltd. Torch Industrial Co., Ltd. Chung Fa Traffic Equipment Co., Ltd. Hung Chang Hardware Co., Ltd. Pan Asel Taiwan Co., Ltd. Brkpoint International Co., Ltd. Fuvillage Industry Co., Ltd. Shun-jie Co. Wuhan Best Machinery Co., Ltd. Shanghai Limin Traffic Equipment Facility Co., Ltd. ECP China Co., Ltd. Ningbo Haoyun Rubber Co./Ningbo Goodluck Rubber Co. Zhejiang Yongkang Chengjian Hardware Tools Co., Ltd. Greencar Auto Accessories Co., Ltd. Yin Li Auto Electron & Technology Co., Ltd. Shanghai Huahui Silk Products Co., Ltd. Shanghai Meaton Hardware Co., Ltd. Jeou Cherng Industrial Co., Ltd. Peng Cheng Casing Co., Ltd. Wuzhou Meibo Gemstones Factory 1 2 3 4 5 6
https://www.ttnet.net/hot-search/suppliers-triangle.html
CC-MAIN-2018-51
refinedweb
828
61.43
.7.x has been archived here. This documentation applies to sbt 1.0.1. See also the API Documentation, SXR Documentation, and the index of names and types. s! To create an sbt project, you’ll need to take these steps: Setup a simple hello world project Ultimately, the installation of sbt boils down to a launcher JAR and a shell script, but depending on your platform, we provide several ways to make the process less tedious. Head over to the installation steps for Mac, Windows, or Linux. If you have any trouble running sbt, see Setup Notes on terminal encodings, HTTP proxies, and JVM options. Download ZIP or TGZ package, and expand it. Note: Third-party packages may not provide the latest version. Please make sure to report any issues with these packages to the relevant maintainers. $ brew install sbt@1 $ port install sbt Download ZIP or TGZ package and expand it. Download msi installer and install it. Download ZIP or TGZ package and expand it.. Note: Please report any issues with these to the sbt-launcher-package project. The official tree contains ebuilds for sbt. To install the latest available version do: emerge dev-java/sbt This. This page assumes you’ve installed sbt and seen the Hello, World example. In sbt’s terminology, the “base directory” is the directory containing the project. So if you created a project hello containing hello/build.sbt as in the Hello, World example, hello is your base directory.. Source code can be placed in the project’s base directory as hello/app.scala, which may be for small projects, though for normal projects people tend to keep the projects in the src/main/ directory to keep things neat. The fact that you can place *.scala source code in the base directory might seem like an odd trick, but this fact becomes relevant later. The build definition is described in build.sbt (actually any files named *.sbt) in the project’s base directory. build.sbt In addition to build.sbt, project directory can contain .scala files that defines helper objects and one-off plugins. See organizing the build for more. build.sbt project/ Dependencies.scala You may see .sbt files inside project/ but they are not equivalent to .sbt files in the project’s base directory. Explaining this will come later, since you’ll need some background information first. Generated files (compiled classes, packaged jars, managed files, caches, and documentation) will be written to the target directory by default. Your .gitignore (or equivalent for other version control systems) should contain: target/ Note that this deliberately has a trailing / (to match only directories) and it deliberately has no leading / (to match project/target/ in addition to plain target/). This: This=1.0.1.3" ).3" ) build.sbt defines subprojects, which holds a sequence of key-value pairs called setting expressions using build.sbt DSL. lazy val root = (project in file(".")) .settings( name := "hello", organization := "com.example", scalaVersion := "2.12.3", Keys._ (In addition, if you have auto plugins, the names marked under autoImport will be imported.) Instead of defining Projects, bare .sbt build definition consists of a list of Setting[_] expressions. name := "hello" version := "1.0" scalaVersion := "2.12.3" This syntax is recommended mostly for using plugins. See later section about the plugins..3" ). Continuing] Setting version to 2.11.8 . This page describes scopes. It assumes you’ve read and understood the previous pages, build definition and task graph. Previously we pretended that a key like name corresponded to one entry in sbt’s map of key-value pairs. This was a simplification. In truth, each key can have an associated value in more than one context, called a scope. Some concrete examples: compilekey may have a different value for your main sources and your test sources, if you want to compile them differently. packageOptionskey (which contains options for creating jar packages) may have different values when packaging class files ( packageBin) or packaging source code ( packageSrc). There is no single value for a given key name, because the value may differ according to scope. However, there is a single value for a given scoped key. If you think about sbt processing a list of settings to generate a key-value map describing the project, as discussed earlier, the keys in that key-value map are scoped keys. Each setting defined in the build definition (for example in build.sbt) applies to a scoped key as well. Often the scope is implied or has a default, but if the defaults are wrong, you’ll need to mention the desired scope in build.sbt. A scope axis is a type constructor similar to Option[A], that is used to form a component in a scope. There are three scope axes: If you’re not familiar with the notion of axis, we can think of the RGB color cube as an example: In the RGB color model, all colors are represented by a point in the cube whose axes correspond to red, green, and blue components encoded by a number. Similarly, a full scope in sbt is formed by a tuple of a subproject, a configuration, and a task value: scalacOptions in (projA, Compile, console) To be more precise, it actually looks like this: scalacOptions in (Select(projA: Reference), Select(Compile: ConfigKey), Select(console.key)) If you put multiple projects in a single build, each project needs its own settings. That is, keys can be scoped according to the project. The project axis can also be set to ThisBuild, which means the “entire build”, so a setting applies to the entire build rather than a single project. Build-level settings are often used as a fallback when a project doesn’t define a project-specific setting. We will discuss more on build-level settings later in this page. A dependency configuration (or “configuration” for short) defines a graph of library dependencies, potentially with its own classpath, sources, generated packages, etc. The dependency configuration concept comes from Ivy, which sbt uses for managed dependencies Library Dependencies, and from MavenScopes. Some configurations you’ll see in sbt: Compilewhich defines the main build ( src/main/scala). Testwhich defines how to build tests ( src/test/scala). Runtimewhich defines the classpath for the runtask. By default, all the keys associated with compiling, packaging, and running are scoped to a configuration and therefore may work differently in each configuration. The most obvious examples are the task keys compile, package, and run; but all the keys which affect those keys (such as sourceDirectories or scalacOptions or fullClasspath) are also scoped to the configuration. Another thing to note about a configuration is that it can extend other configurations. The following figure shows the extension relationship among the most common configurations. Test and IntegrationTest extends Runtime; Runtime extends Compile; CompileInternal extends Compile, Optional, and Provided. Settings can affect how a task works. For example, the packageSrc task is affected by the packageOptions setting. To support this, a task key (such as packageSrc) can be a scope for another key (such as packageOptions). The various tasks that build a package ( packageSrc, packageBin, packageDoc) can share keys related to packaging, such as artifactName and packageOptions. Those keys can have distinct values for each packaging task. Each scope axis can be filled in with an instance of the axis type ) [info] runtime:fullClasspath On the first line, you can see this is a task (as opposed to a setting, as explained in .sbt build definition). The value resulting from the task will have type scala.collection.Seq[sbt.Attributed[java.io.File]]. “Provided by” points you to the scoped key that defines the value, in this case {file:/home/hp/checkout/hello/}default-aea33a/test:fullClasspath (which is the fullClasspath key scoped to the test configuration and the {file:/home/hp/checkout/hello/}default-aea33a project). “Dependencies” was discussed in detail in the previous page. We’ll discuss “Delegates” later. Try inspect fullClasspath (as opposed to the above example, inspect test:fullClasspath) to get a sense of the difference. Because the configuration is omitted, it is autodetected as compile. inspect compile:fullClasspath should therefore look the same as inspect fullClasspath. Try inspect *:fullClasspath for another contrast. fullClasspath is not defined in the Global scope by default. Again, for more details, see Interacting with the Configuration System. You need to specify the scope if the key in question is normally scoped. For example, the compile task, by default, is scoped to Compile and Test configurations, and does not exist outside of those scopes. To change the value associated with the compile key, you need to write compile in Compile or compile in Test. Using plain compile would define a new compile task scoped to the current project, rather than overriding the standard compile tasks which are scoped to a configuration. If you get an error like “Reference to undefined setting“, often you’ve failed to specify a scope, or you’ve specified the wrong scope. The key you’re using may be defined in some other scope. sbt will try to suggest what you meant as part of the error message; look for “Did you mean compile:compile?” One way to think of it is that a name is only part of a key. In reality, all keys consist of both a name, and a scope (where the scope has three axes). The entire expression packageOptions in (Compile, packageBin) is a key name, in other words. Simply packageOptions is also a key name, but a different one (for keys with no in, a scope is implicitly assumed: current project, global config, global task). An advanced technique for factoring out common settings across subprojects is to define the settings scoped to ThisBuild. If a key that is scoped to a particular subproject is not found, sbt will look for it in ThisBuild as a fallback. Using the mechanism, we can define a build-level default setting for frequently used keys such as version, scalaVersion, and organization. For convenience, there is inThisBuild(...) function that will scope both the key and the body of the setting expression to ThisBuild. Putting setting expressions in there would be equivalent to appending in ThisBuild where possible. lazy val root = (project in file(".")) .settings( inThisBuild(List( // Same as: // organization in ThisBuild := "com.example" organization := "com.example", scalaVersion := "2.12.3", version := "0.1.0-SNAPSHOT" )), name := "Hello", publish := (), publishLocal := () ) lazy val core = (project in file("core")) .settings( // other settings ) lazy val util = (project in file("util")) .settings( // other settings ) Due to the nature of scope delegation that we will cover later, we do not recommend using build-level settings beyond simple value assignments. A scoped key may be undefined, if it has no value associated with it in its scope. For each scope axis, sbt has a fallback search path made up of other scope values. Typically, if a key has no associated value in a more-specific scope, sbt will try to get a value from a more general scope, such as the ThisBuild scope. This feature allows you to set a value once in a more general scope, allowing multiple more-specific scopes to inherit the value. We will disscuss scope delegation in detail later. +=and ++=. You can compute values of some tasks or settings to define or append a value for another task. It’s done by using Def.task and taskValue as an argument to :=, +=, or ++=. As a first example, consider appending a source generator using the project base directory and compilation classpath. sourceGenerators in Compile += Def.task { myGenerator(baseDirectory.value, (managedClasspath in Compile).value) }.taskValue +=and ++=") This) } ) This. This( % . Please..") lazy val commonSettings = Seq( organization := "com.example", version := "0.1.0-SNAPSHOT" ) lazy val library = (project in file("library")) .settings( commonSettings,.") lazy val commonSettings = Seq( organization := "com.example", version := "0.1.0-SNAPSHOT" ) lazy val library = (project in file("library")) .settings( commonSettings,( commonSettings, page discusses the organization of the build structure. Please read the earlier pages in the Getting Started Guide first, in particular you need to understand build.sbt, task graph, Library dependencies, and Multi-project builds before reading this page. build.sbt conceals how sbt really works. sbt builds are defined with Scala code. That code, itself, has to be built. What better way than with sbt? The project directory is another build inside your build, which knows how to build your build. To distinguish the builds, we sometimes use the term proper build to refer to your build, and meta-build to refer to the build in project. The projects inside the metabuild can do anything any other project can do. Your build definition is an sbt project. And the turtles go all the way down. If you like, you can tweak the build definition of the build definition project, by creating a project/project/ directory. Here’s an illustration. hello/ # your build's root project's base directory Hello.scala # a source file in your build's root project # (could be in src/main/scala too) build.sbt # build.sbt is part of the source code for # meta-build's root project inside project/; # the build definition for your build project/ # base directory of meta-build's root project Dependencies.scala # a source file in the meta-build's root project, # that is, a source file in the build definition # the build definition for your build assembly.sbt # this is part of the source code for # meta-meta-build's root project in project/project; # build definition's build definition project/ # base directory of meta-meta-build's root project; # the build definition project for the build definition MetaDeps.scala # source file in the root project of # meta-meta-build in project/project/ Don’t worry! Most of the time you are not going to need all that. But understanding the principle can be helpful. By the way: any time files ending in .scala or .sbt are used, naming them build.sbt and Dependencies.scala are conventions only. This also means that multiple files are allowed. One way of using the fact that .scala files under project becomes part of the build definition is to create project/Dependencies.scala to track dependencies in one place. import sbt._ object Dependencies { // Versions lazy val akkaVersion = "2.3.8" // Libraries val akkaActor = "com.typesafe.akka" %% "akka-actor" % akkaVersion val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akkaVersion val specs2core = "org.specs2" %% "specs2-core" % "2.4.17" // Projects val backendDeps = Seq(akkaActor, specs2core % Test) } The Dependencies object will be available in build.sbt. To use the vals under it easier, import Dependencies._. import Dependencies._ lazy val commonSettings = Seq( version := "0.1.0", scalaVersion := "2.12.3" ) lazy val backend = (project in file("backend")) .settings( commonSettings, libraryDependencies ++= backendDeps ) This technique is useful when you have a multi-project build that’s getting large, and you want to make sure that subprojects to have consistent dependencies. .scalafiles In .scala files, you can write any Scala code, including top-level classes and objects. The recommended approach is to define most settings in a multi-project build.sbt file, and using project/*.scala files for task implementations or to share values, such as keys. The use of .scala files also depends on how comfortable you or your team are with Scala. For more advanced users, another way of organizing your build is to define one-off auto plugins in project/*.scala. By defining triggered plugins, auto plugins can be used as a convenient way to inject custom tasks and commands across all subprojects.. The community repository has the following guideline for artifacts published to it: This. Some notes on how to set up your sbt script. sbt-launch.jaron your classpath. Do not put sbt-launch.jar in your $SCALA_HOME/lib directory, your project’s lib directory, or anywhere it will be put on a classpath. It isn’t a library. The character encoding used by your terminal may differ from Java’s default encoding for your platform. In this case, you will need to add the option -Dfile.encoding=<encoding> in your sbt script to set the encoding, which might look like: java -Dfile.encoding=UTF8 If you find yourself running out of permgen space or your workstation is low on memory, adjust the JVM configuration as you would for any application. For example a common set of memory-related options is: java -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled sbt-launch.jar is just a bootstrap; the actual meat of sbt, and the Scala compiler and standard library, are downloaded to the shared directory $HOME/.sbt/boot/. To change the location of this directory, set the sbt.boot.directory system property in your sbt script. A relative path will be resolved against the current working directory, which can be useful if you want to avoid sharing the boot directory between projects. For example, the following uses the pre-0.11 style of putting the boot directory in project/boot/: java -Dsbt.boot.directory=project/boot/ On Unix, sbt will pick up any HTTP, HTTPS, or FTP proxy settings from the standard http_proxy, https_proxy, and ftp_proxy environment variables. If you are behind a proxy requiring authentication, your sbt script must also pass flags to set the http.proxyUser and http.proxyPassword properties for HTTP, and properties for FTP, or https.proxyUser and https.proxyPassword properties for HTTPS. For example, java -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword On Windows, your script should set properties for proxy host, port, and if applicable, username and password. For example, for HTTP: java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword Replace http with https or ftp in the above command line to configure HTTPS or FTP. Deploying"), ... Below. These are changes made in each sbt release. .copy(...) Many of the case classes are replaced with pseudo case classes generated using Contraband. Migrate .copy(foo = xxx) to withFoo(xxx). Suppose you have m: ModuleID, and you’re currently calling m.copy(revision = "1.0.1"). Here how you can migrate it: m.withRevision("1.0.1") If you are cross building an sbt plugin, one escape hatch we have is sbt version specific source directory src/main/scala-sbt-0.13 and src/main/scala-sbt-1.0. In there you can define an object named PluginCompat as follows: package sbtfoo import sbt._ import Keys._ object PluginCompat { type UpdateConfiguration = sbt.librarymanagement.UpdateConfiguration def subMissingOk(c: UpdateConfiguration, ok: Boolean): UpdateConfiguration = c.withMissingOk(ok) } Now subMissingOk(...) function can be implemented in sbt version specific way. Before sbt 0.13 (sbt 0.9 to 0.12) it was very common to see in builds the usage of three aspects of sbt: <<=, <+=, <++= (foo, bar) map { (f, b) => ... }) Buildtrait in project/Build.scala The release of sbt 0.13 (which was over 3 years ago!) introduced the .value DSL which allowed for much easier to read and write code, effectively making the first two aspects redundant and they were removed from the official documentation. Similarly, sbt 0.13’s introduction of multi-project build.sbt made the Build trait redundant. In addition, the auto plugin feature that’s now standard in sbt 0.13 enabled automatic sorting of plugin settings and auto import feature, but it made Build.scala more difficult to maintain. As they are removed in sbt 1.0.0, and here we’ll help guide you to how to migrate your code. With simple expressions such as: a <<= aTaskDef b <+= bTaskDef c <++= cTaskDefs it is sufficient to replace them with the equivalent: a := aTaskDef.value b += bTaskDef.value c ++= cTaskDefs.value As mentioned above, there are two tuple enrichments .apply and .map. The difference used to be for whether you’re defining a setting for a SettingKey or a TaskKey, you use .apply for the former and .map for the latter: val sett1 = settingKey[String]("SettingKey 1") val sett2 = settingKey[String]("SettingKey 2") val sett3 = settingKey[String]("SettingKey 3") val task1 = taskKey[String]("TaskKey 1") val task2 = taskKey[String]("TaskKey 2") val task3 = taskKey[String]("TaskKey 3") val task4 = taskKey[String]("TaskKey 4") sett1 := "s1" sett2 := "s2" sett3 <<= (sett1, sett2)(_ + _) task1 := { println("t1"); "t1" } task2 := { println("t2"); "t2" } task3 <<= (task1, task2) map { (t1, t2) => println(t1 + t2); t1 + t2 } task4 <<= (sett1, sett2) map { (s1, s2) => println(s1 + s2); s1 + s2 } (Remember you can define tasks in terms of settings, but not the other way round) With the .value DSL you don’t have to know or remember if your key is a SettingKey or a TaskKey: sett1 := "s1" sett2 := "s2" sett3 := sett1.value + sett2.value task1 := { println("t1"); "t1" } task2 := { println("t2"); "t2" } task3 := { println(task1.value + task2.value); task1.value + task2.value } task4 := { println(sett1.value + sett2.value); sett1.value + sett2.value } .dependsOn, .triggeredByor .runBefore When instead calling .dependsOn, instead of: a <<= a dependsOn b define it as: a := (a dependsOn b).value Note: You’ll need to use the <<= operator with .triggeredBy and .runBefore in sbt 0.13.13 and earlier due to issue #1444. Tasks For keys such as sourceGenerators and resourceGenerators which use sbt’s Task type: val sourceGenerators = settingKey[Seq[Task[Seq[File]]]]("List of tasks that generate sources") val resourceGenerators = settingKey[Seq[Task[Seq[File]]]]("List of tasks that generate resources") Where you previous would define things as: sourceGenerators in Compile <+= buildInfo for sbt 0.13.15+, you define them as: sourceGenerators in Compile += buildInfo or in general, sourceGenerators in Compile += Def.task { List(file1, file2) } InputKey When using InputKey instead of: run <<= docsRunSetting when migrating you mustn’t use .value but .evaluated: run := docsRunSetting.evaluated With Build trait based build such as: import sbt._ import Keys._ import xyz.XyzPlugin.autoImport._ object HelloBuild extends Build { val shared = Defaults.defaultSettings ++ xyz.XyzPlugin.projectSettings ++ Seq( organization := "com.example", version := "0.1.0", scalaVersion := "2.12.1") lazy val hello = Project("Hello", file("."), settings = shared ++ Seq( xyzSkipWrite := true) ).aggregate(core) lazy val core = Project("hello-core", file("core"), settings = shared ++ Seq( description := "Core interfaces", libraryDependencies ++= scalaXml.value) ) def scalaXml = Def.setting { scalaBinaryVersion.value match { case "2.10" => Nil case _ => ("org.scala-lang.modules" %% "scala-xml" % "1.0.6") :: Nil } } } You can migrate to build.sbt: val shared = Seq( organization := "com.example", version := "0.1.0", scalaVersion := "2.12.1" ) lazy val helloRoot = (project in file(".")) .aggregate(core) .enablePlugins(XyzPlugin) .settings( shared, name := "Hello", xyzSkipWrite := true ) lazy val core = (project in file("core")) .enablePlugins(XyzPlugin) .settings( shared, name := "hello-core", description := "Core interfaces", libraryDependencies ++= scalaXml.value ) def scalaXml = Def.setting { scalaBinaryVersion.value match { case "2.10" => Nil case _ => ("org.scala-lang.modules" %% "scala-xml" % "1.0.6") :: Nil } } project/Build.scalato build.sbt. import sbt._, import Keys._, and any auto imports. shared, helloRoot, etc) out of the object HelloBuild, and remove HelloBuild. Project(...)to (project in file("x"))style, and call its settings(...)method to pass in the settings. This is so the auto plugins can reorder their setting sequence based on the plugin dependencies. namesetting should be set to keep the old names. Defaults.defaultSettingsout of sharedsince these settings are already set by the built-in auto plugins, also remove xyz.XyzPlugin.projectSettingsout of sharedand call enablePlugins(XyzPlugin)instead. Note: Build traits is deprecated, but you can still use project/*.scala file to organize your build and/or define ad-hoc plugins. See Organizing the build. s). .previousfeature on tasks which can load the previous value. allcommand which can run more than tasks in parallel. lastand exporttasks to read from the correct stream. .+dependency ranges were not correctly translated to maven. .+revisions. SessionSettingsnow correctly overwrite existing settings. Logicsystem for inclusionary/dependency logic of plugins. LoggerReporterand TaskProgress. toTaskon Initialize[InputTask[T]]to apply the full input and get a plain task out. <none>instead of just _ TrapExitsupport for multiple, concurrent managed applications. Now enabled by default for all run-like tasks. (#831) -classpathto CLASSPATHwhen forking on Windows and length exceeds a heuristic maximum. (#755) scalacOptionsfor .scalabuild definitions are now also used for .sbtfiles error, warn, info, debugcommands to set log level and --error, … to set the level before the project is loaded. (#806) sLogsettings that provides a Loggerfor use by settings. (#806) --gets moved before other commands on startup and doesn’t force sbt into batch mode. -, --, and ---commands in favor of onFailure, sbtClearOnFailure, and resumeFromFailure. makePomno longer generates <type>elements for standard classifiers. (#728) Processmethods that are redirection-like no longer discard the exit code of the input. This addresses an inconsistency with Fork, where using the CustomOutput OutputStrategymakes the exit code always zero. reloadcommand in the scripted sbt handler. pom.xmlwith CustomPomParserto handle multiple definitions. (#758) -nowarnoption when compiling Scala sources. -doc-root-content(#837) :key:role enables links from a key name in the docs to the val in sxr/sbt/Keys.scala project/plugins/has been removed. It was deprecated since 0.11.2. setcommand. The new task macros make this tab completion obsolete. testsfor proper Maven compatibility. ~/.sbt/0.13/and global plugins in ~/.sbt/0.13/plugins/by default. Explicit overrides, such as via the sbt.global.basesystem property, are still respected. (gh-735) targetdirectory. scalaVersionfor those other Scala libraries. -Dsbt.log.format=false. ~/.inputrc. compileInputsis now defined in (Compile,compile)instead of just Compile bootOnlyto a repository in boot.properties to specify that it should not be used by projects by default. (Josh S., gh-608) Automatically link to external API scaladocs of dependencies by setting autoAPIMappings := true. This requires at least Scala apiURLfor their scaladoc location. Mappings may be manually added to the apiMappingstask as well. ++ scala-version=/path/to/scala/home. The scala-version part is optional, but is used as the version for any managed dependencies. publishM2task for publishing to ~/.m2/repository. (gh-485) export command - For tasks, prints the contents of the ‘export’ picklerphase instead of typerto allow compiler plugins after typer. (Adriaan M., gh-609) inspectshows the definition location of all settings contributing to a defined value. Build.rootProject. cacheDirectorymethod on streams. This supersedes the cacheDirectorysetting. runand testmay be set via envVars, which is a Task[Map[String,String]]. (gh-665) exportJars := truedue to scalac limitations) autoCompilerPluginsnow supports compiler plugins defined in a internal dependency. The plugin project must define exportJars := true. Depend on the plugin with ...dependsOn(... % Configurations.CompilerPlugin). consoleProjectunifies the syntax for getting the value of a setting and executing a task. See Console Project.. apply" The The.. The consoleProject task starts the Scala interpreter with access to your project definition and to sbt. Specifically, the interpreter is started up with these commands already executed: import sbt._ import Keys._ import <your-project-definition>._ import currentState._ import extracted._ import cpHelpers._ For example, running external processes with sbt’s process library (to be included in the standard library in Scala 2.9): > "tar -zcvf project-src.tar.gz src" ! > "find project -name *.jar" ! > "cat build.sbt" #| "grep version" #> new File("sbt-version") ! > "grep -r null src" #|| "echo null-free" ! > uri("").toURL #> file("About.html") ! consoleProject can be useful for creating and modifying your build in the same way that the Scala interpreter is normally used to explore writing code. Note that this gives you raw access to your build. Think about what you pass to IO.delete, for example. To get a particular setting, use the form: > val value = (<key> in <scope>).eval > IO.delete( (classesDirectory in Compile).eval ) Show current compile options: > (scalacOptions in Compile).eval foreach println Show additionally configured repositories. > resolvers.eval foreach println To evaluate a task (and its dependencies), use the same form: > val value = (<key> in <scope>).eval Show all repositories, including defaults. > fullResolvers.eval foreach println Show the classpaths used for compilation and testing: > (fullClasspath in Compile).eval.files foreach println > (fullClasspath in Test).eval.files foreach println The current build State is available as currentState. The contents of currentState are imported by default and can be used without qualification. Show the remaining commands to be executed in the build (more interesting if you invoke consoleProject like ; consoleProject ; clean ; compile): > remainingCommands Show the number of currently registered commands: > definedCommands.size Different versions of Scala can be binary incompatible, despite maintaining source compatibility. This page describes how to use sbt to build and publish your project against multiple versions of Scala and how to use libraries that have done the same.. To use a library built against multiple versions of Scala, double the first % in an inline dependency to be %%. This tells sbt that it should append the current version of Scala being used to build the library to the dependency’s name. For example: libraryDependencies += "net.databinder" %% "dispatch" % crossScalaVersions, prefix the action to run with +. For example: > + package A typical way to use this feature is to do development on a single Scala version (no + prefix) and then cross-build (using +) occasionally and when releasing. You can use ++ <version> to temporarily switch the Scala version currently being used to build. For example: > ++ 2.12.2 [info] Setting version to 2.12.2 > ++ 2.11.11 [info] Setting version to 2.11.11 > compile <version> should be either a version for Scala published to a repository or the path to a Scala home directory, as in ++ /path/to/scala/home. See Command Line Reference for details. The ultimate purpose of + is to cross-publish your project. That is, by doing: > + publish you make your project available to users for different versions of Scala. See Publishing for more details on publishing your project. In order to make this process as quick as possible, different output and managed dependency directories are used for different versions of Scala. For example, when building against Scala 2.10.0, ./target/becomes ./target/scala_2.10.0/ ./lib_managed/becomes ./lib_managed/scala_2.10/ Packaged jars, wars, and other artifacts have _<scala-version> appended to the normal artifact ID as mentioned in the Publishing Conventions section above. This means that the outputs of each build against each version of Scala are independent of the others. sbt will resolve your dependencies for each version separately. This way, for example, you get the version of Dispatch compiled against 2.8.1 for your 2.8.1 build, the version compiled against 2.10 for your 2.10.x builds, and so on. You can have fine-grained control over the behavior for different Scala versions by using the cross method on ModuleID These are equivalent: "a" % "b" % "1.0" "a" % "b" % "1.0" cross CrossVersion.Disabled These are equivalent: "a" %% "b" % "1.0" "a" % "b" % "1.0" cross CrossVersion.binary This overrides the defaults to always use the full Scala version instead of the binary Scala version: "a" % "b" % "1.0" cross CrossVersion.full CrossVersion.patch sits between CrossVersion.binary and CrossVersion.full in that it strips off any trailing -bin-... suffix which is used to distinguish varaint but binary compatible Scala toolchain builds. "a" % "b" % "1.0" cross CrossVersion.patch This uses a custom function to determine the Scala version to use based on the binary Scala version: "a" % "b" % "1.0" cross CrossVersion.binaryMapped { case "2.9.1" => "2.9.0" // remember that pre-2.10, binary=full case "2.10" => "2.10.0" // useful if a%b was released with the old style case x => x } This uses a custom function to determine the Scala version to use based on the full Scala version: "a" % "b" % "1.0" cross CrossVersion.fullMapped { case "2.9.1" => "2.9.0" case x => x } A custom function is mainly used when cross-building and a dependency isn’t available for all Scala versions or it uses a different convention than the default. Central. You s 1.0.1 "$@" For the REPL runner screpl, use sbt.ConsoleMain as the main class: $ java -Dsbt.main.class=sbt.ConsoleMain -Dsbt.boot.directory=/home/user/.sbt/boot -jar sbt-launch.jar "$@".12.2" libraryDependencies += "org.scala-sbt" %% "io" % "1.0.1" */ import sbt.io.IO import sbt.io.Path._ import sbt.io.syntax._. Compiling Scala code with scalac is slow, but sbt often makes it faster. By understanding how, you can even understand how to make compilation even faster. Modifying source files with many dependencies might require recompiling only those source files (which might take 5 seconds for instance) instead of all the dependencies (which might take 2 minutes for instance). Often you can control which will be your case and make development faster with a few coding practices. Improving the Scala compilation performance is a major goal of sbt, and thus the speedups it gives are one of the major motivations to use it. A significant portion of sbt’s sources and development efforts deal with strategies for speeding up compilation. To reduce compile times, sbt uses two strategies: A.scalais modified, sbt goes to great effort to recompile other source files depending on A.scala only if required - that is, only if the interface of A.scala was modified. With other build management tools (especially for Java, like ant), when a developer changes a source file in a non-binary-compatible way, she needs to manually ensure that dependencies are also recompiled - often by manually running the clean command to remove existing compilation output; otherwise compilation might succeed even when dependent class files might need to be recompiled. What is worse, the change to one source might make dependencies incorrect, but this is not discovered automatically: One might get a compilation success with incorrect source code. Since Scala compile times are so high, running clean is particularly undesirable. By organizing your source code appropriately, you can minimize the amount of code affected by a change. sbt cannot determine precisely which dependencies have to be recompiled; the goal is to compute a conservative approximation, so that whenever a file must be recompiled, it will, even though we might recompile extra files. sbt tracks source dependencies at the granularity of source files. For each source file, sbt tracks files which depend on it directly; if the interface of classes, objects or traits in a file changes, all files dependent on that source must be recompiled. At the moment sbt uses the following algorithm to calculate source files dependent on a given source file: The name hashing optimization is enabled by default since sbt 0.13.6. The heuristics used by sbt imply the following user-visible consequences, which determine whether a change to a class affects other classes. privatemethods does not require recompilation of client classes. Therefore, suppose you add a method to a class with a lot of dependencies, and that this method is only used in the declaring class; marking it private will prevent recompilation of clients. However, this only applies to methods which are not accessible to other classes, hence methods marked with private or private[this]; methods which are private to a package, marked with private[name], are part of the API. All the above discussion about methods also applies to fields and members in general; similarly, references to classes also extend to objects and traits. This sections goes into details of incremental compiler implementation. It’s starts with an overview of the problem incremental compiler tries to solve and then discusses design choices that led to the current implementation. The goal of incremental compilation is detect changes to source files or to the classpath and determine a small set of files to be recompiled in such a way that it’ll yield the final result identical to the result from a full, batch compilation. When reacting to changes the incremental compiler has to goals that are at odds with each other: The first goal is about making recompilation fast and it’s a sole point of incremental compiler existence. The second goal is about correctness and sets a lower limit on the size of a set of recompiled files. Determining that set is the core problem incremental compiler tries to solve. We’ll dive a little bit into this problem in the overview to understand what makes implementing incremental compiler a challenging task. Let’s consider this very simple example: // A.scala package a class A { def foo(): Int = 12 } // B.scala package b class B { def bar(x: a.A): Int = x.foo() } Let’s assume both of those files are already compiled and user changes A.scala so it looks like this: // A.scala package a class A { def foo(): Int = 23 // changed constant } The first step of incremental compilation is to compile modified source files. That’s minimal set of files incremental compiler has to compile. Modified version of A.scala will be compiled successfully as changing the constant doesn’t introduce type checking errors. The next step of incremental compilation is determining whether changes applied to A.scala may affect other files. In the example above only the constant returned by method foo has changed and that does not affect compilation results of other files. Let’s consider another change to A.scala: // A.scala package a class A { def foo(): String = "abc" // changed constant and return type } As before, the first step of incremental compilation is to compile modified files. In this case we compile A.scala and compilation will finish successfully. The second step is again determining whether changes to A.scala affect other files. We see that the return type of the foo public method has changed so this might affect compilation results of other files. Indeed, B.scala contains call to the foo method so has to be compiled in the second step. Compilation of B.scala will fail because of type mismatch in B.bar method and that error will be reported back to the user. That’s where incremental compilation terminates in this case. Let’s identify the two main pieces of information that were needed to make decisions in the examples presented above. The incremental compiler algorithm needs to: Both of those pieces of information are extracted from the Scala compiler. Incremental compiler interacts with Scala compiler in many ways: The API extraction phase extracts information from Trees, Types and Symbols and maps it to incremental compiler’s internal data structures described in the api.specification file.Those data structures allow to express an API in a way that is independent from Scala compiler version. Also, such representation is persistent so it is serialized on disk and reused between compiler runs or even sbt runs. The API extraction phase consist of two major components: The logic responsible for mapping Types and Symbols is implemented in API.scala. With introduction of Scala reflection we have multiple variants of Types and Symbols. The incremental compiler uses the variant defined in scala.reflect.internal package. Also, there’s one design choice that might not be obvious. When type corresponding to a class or a trait is mapped then all inherited members are copied instead of declarations in that class/trait. The reason for doing so is that it greatly simplifies analysis of API representation because all relevant information to a class is stored in one place so there’s no need for looking up parent type representation. This simplicity comes at a price: the same information is copied over and over again resulting in a performance hit. For example, every class will have members of java.lang.Object duplicated along with full information about their signatures. The incremental compiler (as it’s implemented right now) doesn’t need very fine grained information about the API. The incremental compiler just needs to know whether an API has changed since the last time it was indexed. For that purpose hash sum is enough and it saves a lot of memory. Therefore, API representation is hashed immediately after single compilation unit is processed and only hash sum is stored persistently. In earlier versions the incremental compiler wouldn’t hash. That resulted in a very high memory consumption and poor serialization/deserialization performance. The hashing logic is implemented in the HashAPI.scala file. The incremental compiler extracts all Symbols given compilation unit depends on (refers to) and then tries to map them back to corresponding source/class files. Mapping a Symbol back to a source file is performed by using sourceFile attribute that Symbols derived from source files have set. Mapping a Symbol back to (binary) class file is more tricky because Scala compiler does not track origin of Symbols derived from binary files. Therefore simple heuristic is used which maps a qualified class name to corresponding classpath entry. This logic is implemented in dependency phase which has an access to the full classpath. The set of Symbols given compilation unit depend on is obtained by performing a tree walk. The tree walk examines all tree nodes that can introduce a dependency (refer to another Symbol) and gathers all Symbols assigned to them. Symbols are assigned to tree nodes by Scala compiler during type checking phase. Incremental compiler used to rely on CompilationUnit.depends for collecting dependencies. However, name hashing requires a more precise dependency information. Check #1002 for details. Collection of produced class files is extracted by inspecting contents CompilationUnit.icode property which contains all ICode classes that backend will emit as JVM class files. Let’s consider the following example: // A.scala class A { def inc(x: Int): Int = x+1 } // B.scala class B { def foo(a: A, x: Int): Int = a.inc(x) } Let’s assume both of those files are compiled and user changes A.scala so it looks like this: // A.scala class A { def inc(x: Int): Int = x+1 def dec(x: Int): Int = x-1 } Once user hits save and asks incremental compiler to recompile it’s project it will do the following: A.scalaas the source code has changed (first iteration) A.scalaand detect it has changed B.scaladepends on A.scalaand since the API structure of A.scalahas changed B.scalahas to be recompiled as well ( B.scalahas been invalidated) B.scalabecause it was invalidated in 3. due to dependency change B.scalaand find out that it hasn’t changed so we are done To summarize, we’ll invoke Scala compiler twice: one time to recompile A.scala and then to recompile B.scala because A has a new method dec. However, one can easily see that in this simple scenario recompilation of B.scala is not needed because addition of dec method to A class is irrelevant to the B class as its not using it and it is not affected by it in any way. In case of two files the fact that we recompile too much doesn’t sound too bad. However, in practice, the dependency graph is rather dense so one might end up recompiling the whole project upon a change that is irrelevant to almost all files in the whole project. That’s exactly what happens in Play projects when routes are modified. The nature of routes and reversed routes is that every template and every controller depends on some methods defined in those two classes ( Routes and ReversedRoutes) but changes to specific route definition usually affects only small subset of all templates and controllers. The idea behind name hashing is to exploit that observation and make the invalidation algorithm smarter about changes that can possibly affect a small number of files. A change to the API of a given source file X.scala can be called irrelevant if it doesn’t affect the compilation result of file Y.scala even if Y.scala depends on X.scala. From that definition one can easily see that a change can be declared irrelevant only with respect to a given dependency. Conversely, one can declare a dependency between two source files irrelevant with respect to a given change of API in one of the files if the change doesn’t affect the compilation result of the other file. From now on we’ll focus on detection of irrelevant dependencies. A very naive way of solving a problem of detecting irrelevant dependencies would be to say that we keep track of all used methods in Y.scala so if a method in X.scala is added/removed/modified we just check if it’s being used in Y.scala and if it’s not then we consider the dependency of Y.scala on X.scala irrelevant in this particular case. Just to give you a sneak preview of problems that quickly arise if you consider that strategy let’s consider those two scenarios. We’ll see how a method not used in another source file might affect its compilation result. Let’s consider this structure: // A.scala abstract class A // B.scala class B extends A Let’s add an abstract method to class A: // A.scala abstract class A { def foo(x: Int): Int } Now, once we recompile A.scala we could just say that since A.foo is not used in B class then we don’t need to recompile B.scala. However, this is not true because B doesn’t implement a newly introduced, abstract method and an error should be reported. Therefore, a simple strategy of looking at used methods for determining whether a given dependency is relevant or not is not enough. Here we’ll see another case of newly introduced method (that is not used anywhere yet) that affects compilation results of other files. This time, no inheritance will be involved but we’ll use enrichment pattern (implicit conversions) instead. Let’s assume we have the following structure: // } Now, let’s add a foo method directly to A: // A.scala class A { def foo(x: Int): Int = x-1 } Now, once we recompile A.scala and detect that there’s a new method defined in the A class we would need to consider whether this is relevant to the dependency of B.scala on A.scala. Notice that in B.scala we do not use A.foo (it didn’t exist at the time B.scala was compiled) but we use AOps.foo and it’s not immediately clear that AOps.foo has anything to do with A.foo. One would need to detect the fact that a call to AOps.foo as a result of implicit conversion richA that was inserted because we failed to find foo on A before. This kind of analysis gets us very quickly to the implementation complexity of Scala’s type checker and is not feasible to implement in a general case. All of the above assumed we actually have full information about the structure of the API and used methods preserved so we can make use of it. However, as described in Hashing an API representation we do not store the whole representation of the API but only its hash sum. Also, dependencies are tracked at source file level and not at class/method level. One could imagine reworking the current design to track more information but it would be a very big undertaking. Also, the incremental compiler used to preserve the whole API structure but it switched to hashing due to the resulting infeasible memory requirements. As we saw in the previous chapter, the direct approach of tracking more information about what’s being used in the source files becomes tricky very quickly. One would wish to come up with a simpler and less precise approach that would still yield big improvements over the existing implementation. The idea is to not track all the used members and reason very precisely about when a given change to some members affects the result of the compilation of other files. We would track just the used simple names instead and we would also track the hash sums for all members with the given simple name. The simple name means just an unqualified name of a term or a type. Let’s see first how this simplified strategy addresses the problem with the enrichment pattern. We’ll do that by simulating the name hashing algorithm. Let’s start with the original code: // } During the compilation of those two files we’ll extract the following information: usedNames("A.scala"): A usedNames("B.scala"): B, AOps, a, A, foo, x, Int, richA, AOps, bar nameHashes("A.scala"): A -> ... nameHashes("B.scala"): B -> ..., AOps -> ..., foo -> ..., richA -> ..., bar -> ... The usedNames relation track all the names mentioned in the given source file. The nameHashes relation gives us a hash sum of the groups of members that are put together in one bucket if they have the same simple name. In addition to the information presented above we still track the dependency of B.scala on A.scala. Now, if we add a foo method to A class: // A.scala class A { def foo(x: Int): Int = x-1 } and recompile, we’ll get the following (updated) information: usedNames("A.scala"): A, foo nameHashes("A.scala"): A -> ..., foo -> ... The incremental compiler compares the name hashes before and after the change and detects that the hash sum of foo has changed (it’s been added). Therefore, it looks at all the source files that depend on A.scala, in our case it’s just B.scala, and checks whether foo appears as a used name. It does, therefore it recompiles B.scala as intended. You can see now, that if we added another method to A like xyz then B.scala wouldn’t be recompiled because nowhere in B.scala is the name xyz mentioned. Therefore, if you have reasonably non-clashing names you should benefit from a lot of dependencies between source files marked as irrelevant. It’s very nice that this simple, name-based heuristic manages to withstand the “enrichment pattern” test. However, name-hashing fails to pass the other test of inheritance. In order to address that problem, we’ll need to take a closer look at the dependencies introduced by inheritance vs dependencies introduced by member references. The core assumption behind the name-hashing algorithm is that if a user adds/modifies/removes a member of a class (e.g. a method) then the results of compilation of other classes won’t be affected unless they are using that particular member. Inheritance with its various override checks makes the whole situation much more complicated; if you combine it with mix-in composition that introduces new fields to classes inheriting from traits then you quickly realize that inheritance requires special handling. The idea is that for now we would switch back to the old scheme whenever inheritance is involved. Therefore, we track dependencies introduced by member reference separately from dependencies introduced by inheritance. All dependencies introduced by inheritance are not subject to name-hashing analysis so they are never marked as irrelevant. The intuition behind the dependency introduced by inheritance is very simple: it’s a dependency a class/trait introduces by inheriting from another class/trait. All other dependencies are called dependencies by member reference because they are introduced by referring (selecting) a member (method, type alias, inner class, val, etc.) from another class. Notice that in order to inherit from a class you need to refer to it so dependencies introduced by inheritance are a strict subset of member reference dependencies. Here’s an example which illustrates the distinction: // A.scala class A { def foo(x: Int): Int = x+1 } // B.scala class B(val a: A) // C.scala trait C // D.scala trait D[T] // X.scala class X extends A with C with D[B] { // dependencies by inheritance: A, C, D // dependencies by member reference: A, C, D, B } // Y.scala class Y { def test(b: B): Int = b.a.foo(12) // dependencies by member reference: B, Int, A } There are two things to notice: X does not depend on B by inheritance because B is passed as a type parameter to D; we consider only types that appear as parents to X Y does depend on A even if there’s no explicit mention of A in the source file; we select a method foo defined in A and that’s enough to introduce a dependency To sum it up, the way we want to handle inheritance and the problems it introduces is to track all dependencies introduced by inheritance separately and have a much more strict way of invalidating dependencies. Essentially, whenever there’s a dependency by inheritance it will react to any (even minor) change in parent types. One thing we skimmed over so far is how name hashes are actually computed. As mentioned before, all definitions are grouped together by their simple name and then hashed as one bucket. If a definition (for example a class) contains other definition then those nested definitions do not contribute to a hash sum. The nested definitions will contribute to hashes of buckets selected by their name. It is surprisingly tricky to understand which changes to a class require recompiling its clients. The rules valid for Java are much simpler (even if they include some subtle points as well); trying to apply them to Scala will prove frustrating. Here is a list of a few surprising points, just to illustrate the ideas; this list is not intended to be complete. super.methodNamein traits are resolved to calls to an abstract method called fullyQualifiedTraitName$$super$methodName; such methods only exist if they are used. Hence, adding the first call to super.methodNamefor a specific method name changes the interface. At present, this is not yet handled—see #466. sealedhierarchies of case classes allow to check exhaustiveness of pattern matching. Hence pattern matches using case classes must depend on the complete hierarchy - this is one reason why dependencies cannot be easily tracked at the class level (see Scala issue SI-2559 for an example.). Check #1104 for detailed discussion of tracking dependencies at class level. If you see spurious incremental recompilations or you want to understand what changes to an extracted interface cause incremental recompilation then sbt 0.13 has the right tools for that. In order to debug the interface representation and its changes as you modify and recompile source code you need to do two things: apiDebugoption. sbt.extraClasspathsystem property in the Command-Line-Reference. warning Enabling the apiDebugoption increases significantly the memory consumption and degrades the performance of the incremental compiler. The underlying reason is that in order to produce meaningful debugging information about interface differences the incremental compiler has to retain the full representation of the interface instead of just the hash sum as it does by default. Keep this option enabled when you are debugging the incremental compiler problem only. Below is a complete transcript which shows how to enable interface debugging in your project. First, we download the diffutils jar and pass it to sbt: curl -O sbt -Dsbt.extraClasspath=diffutils-1.2.1.jar [info] Loading project definition from /Users/grek/tmp/sbt-013/project [info] Set current project to sbt-013 (in build file:/Users/grek/tmp/sbt-013/) > set incOptions := incOptions.value.copy(apiDebug = true) [info] Defining *:incOptions [info] The new value will be used by compile:incCompileSetup, test:incCompileSetup [info] Reapplying settings... [info] Set current project to sbt-013 (in build file:/Users/grek/tmp/sbt-013/) Let’s suppose you have the following source code in Test.scala: class A { def b: Int = 123 } compile it and then change the Test.scala file so it looks like: class A { def b: String = "abc" } and run compile again. Now if you run last compile you should see the following lines in the debugging log > last compile [...] [debug] Detected a change in a public API: [debug] --- /Users/grek/tmp/sbt-013/Test.scala [debug] +++ /Users/grek/tmp/sbt-013/Test.scala [debug] @@ -23,7 +23,7 @@ [debug] ^inherited^ final def ##(): scala.this#Int [debug] ^inherited^ final def synchronized[ java.lang.Object.T0 >: scala.this#Nothing <: scala.this#Any](x$1: <java.lang.Object.T0>): <java.lang.Object.T0> [debug] ^inherited^ final def $isInstanceOf[ java.lang.Object.T0 >: scala.this#Nothing <: scala.this#Any](): scala.this#Boolean [debug] ^inherited^ final def $asInstanceOf[ java.lang.Object.T0 >: scala.this#Nothing <: scala.this#Any](): <java.lang.Object.T0> [debug] def <init>(): this#A [debug] -def b: scala.this#Int [debug] +def b: java.lang.this#String [debug] } You can see a unified diff of the two interface textual represetantions. As you can see, the incremental compiler detected a change to the return type of b method. This section explains why relying on type inference for return types of public methods is not always appropriate. However this is an important design issue, so we cannot give fixed rules. Moreover, this change is often invasive, and reducing compilation times is not often a good enough motivation. That is also why we discuss some of the implications from the point of view of binary compatibility and software engineering. Consider the following source file A.scala: import java.io._ object A { def openFiles(list: List[File]) = list.map(name => new FileWriter(name)) } Let us now consider the public interface of trait A. Note that the return type of method openFiles is not specified explicitly, but computed by type inference to be List[FileWriter]. Suppose that after writing this source code, we introduce some client code and then modify A.scala as follows: import java.io._ object A { def openFiles(list: List[File]) = Vector(list.map(name => new BufferedWriter(new FileWriter(name))): _*) } Type inference will now compute the result type as Vector[BufferedWriter]; in other words, changing the implementation lead to a change to the public interface, with two undesirable consequences: val res: List[FileWriter] = A.openFiles(List(new File("foo.input"))) Also the following code will break: val a: Seq[Writer] = new BufferedWriter(new FileWriter("bar.input")) A.openFiles(List(new File("foo.input"))) How can we avoid these problems? Of course, we cannot solve them in general: if we want to alter the interface of a module, breakage might result. However, often we can remove implementation details from the interface of a module. In the example above, for instance, it might well be that the intended return type is more general - namely Seq[Writer]. It might also not be the case - this is a design choice to be decided on a case-by-case basis. In this example I will assume however that the designer chooses Seq[Writer], since it is a reasonable choice both in the above simplified example and in a real-world extension of the above code. The client snippets above will now become val res: Seq[Writer] = A.openFiles(List(new File("foo.input"))) val a: Seq[Writer] = new BufferedWriter(new FileWriter("bar.input")) +: A.openFiles(List(new File("foo.input"))) The incremental compilation logic is implemented in. Some discussion on the incremental recompilation policies is available in issue #322, #288 and #1010..8 is implemented as a compiler plugin. You can use the compiler plugin support for this, as shown here. autoCompilerPlugins := true addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.8.1") scalacOptions += "-P:continuations:enable" Adding a version-specific compiler plugin can be done as follows: autoCompilerPlugins := true libraryDependencies += compilerPlugin("org.scala-lang.plugins" % "continuations" % scalaVersion.value) scalacOptions += "-P:continuations:enable" sbt needs to obtain Scala for a project and it can do this automatically or you can configure it explicitly. The Scala version that is configured for a project will compile, run, document, and provide a REPL for the project code. When compiling a project, sbt needs to run the Scala compiler as well as provide the compiler with a classpath, which may include several Scala jars, like the reflection jar. The most common case is when you want to use a version of Scala that is available in a repository. The only required configuration is the Scala version you want to use. For example, scalaVersion := "2.10.0" This will retrieve Scala from the repositories configured via the resolvers setting. It will use this version for building your project: compiling, running, scaladoc, and the REPL. By default, the standard Scala library is automatically added as a dependency. If you want to configure it differently than the default or you have a project with only Java sources, set: autoScalaLibrary := false In order to compile Scala sources, the Scala library needs to be on the classpath. When autoScalaLibrary is true, the Scala library will be on all classpaths: test, runtime, and compile. Otherwise, you need to add it like any other dependency. For example, the following dependency definition uses Scala only for tests: autoScalaLibrary := false libraryDependencies += "org.scala-lang" % "scala-library" % scalaVersion.value % "test" When using a Scala dependency other than the standard library, add it as a normal managed dependency. For example, to depend on the Scala compiler, libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value Note that this is necessary regardless of the value of the autoScalaLibrary setting described in the previous section. In order to compile Scala code, run scaladoc, and provide a Scala REPL, sbt needs the scala-compiler jar. This should not be a normal dependency of the project, so sbt adds a dependency on scala-compiler in the special, private scala-tool configuration. It may be desirable to have more control over this in some situations. Disable this automatic behavior with the managedScalaInstance key: managedScalaInstance := false This will also disable the automatic dependency on scala-library. If you do not need the Scala compiler for anything (compiling, the REPL, scaladoc, etc…), you can stop here. sbt does not need an instance of Scala for your project in that case. Otherwise, sbt will still need access to the jars for the Scala compiler for compilation and other tasks. You can provide them by either declaring a dependency in the scala-tool configuration or by explicitly defining scalaInstance. In the first case, add the scala-tool configuration and add a dependency on scala-compiler in this configuration. The organization is not important, but sbt needs the module name to be scala-compiler and scala-library in order to handle those jars appropriately. For example, managedScalaInstance := false // Add the configuration for the dependencies on Scala tool jars // You can also use a manually constructed configuration like: // config("scala-tool").hide ivyConfigurations += Configurations.ScalaTool // Add the usual dependency on the library as well on the compiler in the // 'scala-tool' configuration libraryDependencies ++= Seq( "org.scala-lang" % "scala-library" % scalaVersion.value, "org.scala-lang" % "scala-compiler" % scalaVersion.value % "scala-tool" ) In the second case, directly construct a value of type ScalaInstance, typically using a method in the companion object, and assign it to scalaInstance. You will also need to add the scala-library jar to the classpath to compile and run Scala sources. For example, managedScalaInstance := false scalaInstance := ... unmanagedJars in Compile += scalaInstance.value.libraryJar To use a locally built Scala version, configure Scala home as described in the following section. Scala will still be resolved as before, but the jars will come from the configured Scala home directory. The result of building Scala from source is a Scala home directory <base>/build/pack/ that contains a subdirectory lib/ containing the Scala library, compiler, and other jars. The same directory layout is obtained by downloading and extracting a Scala distribution. Such a Scala home directory may be used as the source for jars by setting scalaHome. For example, scalaHome := Some(file("/home/user/scala-2.10/")) By default, lib/scala-library.jar will be added to the unmanaged classpath and lib/scala-compiler.jar will be used to compile Scala sources and provide a Scala REPL. No managed dependency is recorded on scala-library. This means that Scala will only be resolved from a repository if you explicitly define a dependency on Scala or if Scala is depended on indirectly via a dependency. In these cases, the artifacts for the resolved dependencies will be substituted with jars in the Scala lib/ directory. As an example, consider adding a dependency on scala-reflect when scalaHome is configured: scalaHome := Some(file("/home/user/scala-2.10/")) libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value This will be resolved as normal, except that sbt will see if /home/user/scala-2.10/lib/scala-reflect.jar exists. If it does, that file will be used in place of the artifact from the managed dependency. Instead of adding managed dependencies on Scala jars, you can directly add them. The scalaInstance task provides structured access to the Scala distribution. For example, to add all jars in the Scala home lib/ directory, scalaHome := Some(file("/home/user/scala-2.10/")) unmanagedJars in Compile ++= scalaInstance.value.jars To add only some jars, filter the jars from scalaInstance before adding them. sbt needs Scala jars to run itself since it is written in Scala. sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.0.1, this version is Scala 2.12.2. Because this Scala version is needed before sbt runs, the repositories used to retrieve this version are configured in the sbt launcher. By default, the run task runs in the same JVM as sbt. Forking is required under certain circumstances, however. Or, you might want to fork Java processes when implementing new tasks. By default, a forked process uses the same Java and Scala versions being used for the build and the working directory and JVM options of the current process. This page discusses how to enable and configure forking for both run and test tasks. Each kind of task may be configured separately by scoping the relevant keys as explained below. The fork setting controls whether forking is enabled (true) or not (false). It can be set in the run scope to only fork run commands or in the test scope to only fork test commands. To fork all test tasks ( test, testOnly, and testQuick) and run tasks ( run, runMain, test:run, and test:runMain), fork := true To := true See Testing for more control over how tests are assigned to JVMs and what options to pass to each group. To change the working directory when forked, set baseDirectory in run or baseDirectory in test: // sets the working directory for all `run`-like tasks += "-Xmx8G" Select the Java installation to use by setting the javaHome directory: javaHome := Some(file("/path/to/jre/")) Note that if this is set globally, it also sets the Java installation used to compile Java sources. You can restrict it to running only by setting it in the run scope: javaHome in run := Some(file("/path/to/jre/")) As with the other settings, you can specify the configuration to affect only the main or test run tasks or just the test tasks. By default, forked output is sent to the Logger, with standard output logged at the Info level and standard error at the Error level. This can be configured with the outputStrategy setting, which is of type OutputStrategy. // send output to the build's standard output and error outputStrategy := Some(StdoutOutput) // send output to the provided OutputStream `someStream` outputStrategy := Some(CustomOutput(someStream: OutputStream)) // send output to the provided Logger `log` (unbuffered) outputStrategy := Some(LoggedOutput(log: Logger)) // send output to the provided Logger `log` after the process terminates outputStrategy := Some(BufferedOutput(log: Logger)) As with other settings, this can be configured individually for main or test run tasks or for test tasks. By default, the standard input of the sbt process is not forwarded to the forked process. To enable this, configure the connectInput setting: connectInput in run := true To fork a new Java process, use the Fork API. The values of interest are Fork.java, Fork.javac, Fork.scala, and Fork.scalac. These are of type Fork and provide apply and fork methods. For example, to fork a new Java process, : val options = ForkOptions(...) val arguments: Seq[String] = ... val mainClass: String = ... val exitCode: Int = Fork.java(options, mainClass +: arguments) ForkOptions defines the Java installation to use, the working directory, environment variables, and more. For example, : val cwd: File = ... val javaDir: File = ... val options = ForkOptions( envVars = Map("KEY" -> "value"), workingDirectory = Some(cwd), javaHome = Some(javaDir) )]) { val s = Demo.desugar(List(1, 2, 3).reverse) println(s) } } This can be then be run at the console: Actual tests can be defined and run as usual with macro/test. The main project can use the macro in the same way that the tests do. For example, core/src/main/scala/MainUsage.scala: package demo object Usage { def main(args: Array[String]) { val s = Demo.desugar(List(6, 4, 5).sorted) println. Sc" !. By default, logging is buffered for each test source file until all tests for that file complete. This can be disabled by setting logBuffered: logBuffered in Test :=Options in Test += Tests.Argument("-verbosity", "1") To specify them for a specific test framework only: testOptions in Test +=Options in Test += Tests.Setup( () => println("Setup") ) testOptions in Test += Tests.Cleanup( () => println("Cleanup") ) testOptions in Test += Tests.Setup( loader => ... ) testOptions in Test += Tests.Cleanup( loader => ... ) By default, sbt runs all tasks in parallel and within the same JVM as sbt itself.. If you want to only run test classes whose name ends with “Test”, use Tests.Filter: testOptions in Test := Seq(Tests.Filter(s => s.endsWith("Test"))) The setting: fork in Test :=ForkedParallel in Test := commonSettings = Seq( scalaVersion := "2.12.3", organization := "com.example" ) lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" lazy val root = (project in file(".")) .configs(IntegrationTest) .settings( commonSettings,(...) The previous example may be generalized to a custom test configuration. lazy val commonSettings = Seq( scalaVersion := "2.12.3", organization := "com.example" ) lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" lazy val FunTest = config("fun") extend(Test) lazy val root = (project in file(".")) .configs(FunTest) .settings( commonSettings,: testOptions in FunTest += ... Test tasks are run by prefixing them with fun: > fun:test An alternative to adding separate sets of test sources (and compilations) is to share sources. In this approach, the sources are compiled together using the same classpath and are packaged together. However, different tests are run depending on the configuration. lazy val commonSettings = Seq( scalaVersion := "2.12.3", organization := "com.example" ) lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" lazy val FunTest = config("fun") extend(Test) def itFilter(name: String): Boolean = name endsWith "ITest" def unitFilter(name: String): Boolean = (name endsWith "Test") && !itFilter(name) lazy val root = (project in file(".")) .configs(FunTest) .settings( commonSettings,"), prefix it with the configuration name as before: > fun:test > fun") ) sbt 0.12.1 addresses several issues with dependency management. These fixes were made possible by specific, reproducible examples, such as a situation where the resolution cache got out of date (gh-532). A brief summary of the current work flow with dependency management in sbt follows. update resolves dependencies according to the settings in a build file, such as libraryDependencies and resolvers. Other tasks use the output of update (an UpdateReport) to form various classpaths. Tasks that in turn use these classpaths, such as compile or run, thus indirectly depend on update. This means that before compile can run, the update task needs to run. However, resolving dependencies on every compile would be unnecessarily slow and so update must be particular about when it actually performs a resolution. updatetask (as opposed to a task that depends on it) will force resolution to run, whether or not configuration changed. This should be done in order to refresh remote SNAPSHOT dependencies. offline := true, remote SNAPSHOTs will not be updated by a resolution, even an explicitly requested update. This should effectively support working without a connection to remote repositories. Reproducible examples demonstrating otherwise are appreciated. Obviously, update must have successfully run before going offline. skip in update := truewill tell sbt to never perform resolution. Note that this can cause dependent tasks to fail. For example, compilation may fail if jars have been deleted from the cache (and so needed classes are missing) or a dependency has been added (but will not be resolved because skip is true). Also, update itself will immediately fail if resolution has not been allowed to run since the last clean. updateexplicitly. This will typically fix problems with out of date SNAPSHOTs or locally published artifacts. last updatecontains more information about the most recent resolution and download. The amount of debugging output from Ivy is high, so you may want to use lastGrep (run help lastGrep for usage). cleanand then update. If this works, it could indicate a bug in sbt, but the problem would need to be reproduced in order to diagnose and fix it. ~/.ivy2/cacherelated to problematic dependencies. For example, if there are problems with dependency "org.example" % "demo" % "1.0", delete ~/.ivy2/cache/org.example/demo/1.0/and retry update. This avoids needing to redownload all dependencies. ~/.ivy2/cache, especially if the first four steps have been followed. If deleting the cache fixes a dependency management issue, please try to reproduce the issue and submit a test case. These troubleshooting steps can be run for plugins by changing to the build definition project, running the commands, and then returning to the main project. For example: > reload plugins > update > reload return offline := truein ~/.sbt/1.0/global.sbt. A command that does this for the user would make a nice pull request. Perhaps the setting of offline should go into the output of about or should it be a warning in the output of update or both? ~/.ivy2/cache. Before doing this with 0.12.1, be sure to follow the steps in the troubleshooting section first. In particular, verify that a clean and an explicit update do not solve the issue. changing()because sbt configures Ivy to know this already.. Manually managing dependencies involves copying any jars that you want to use to the lib directory. sbt will put these jars on the classpath during compilation, testing, running, and when using the interpreter. You are responsible for adding, removing, updating, and otherwise managing the jars in this directory.: unmanagedJars in Compile := (baseDirectory.value ** "*.jar").classpath If you want to add jars from multiple directories in addition to the default directory, you can do: unmanagedJars in Compile ++= {.withDefault exluded: checksums in update := Nil To disable checksum creation during artifact publishing: checksums in publishLocal := Nil checksums in publish := "" resources in Compile ++=.: This. Res]" update &&. Cached. This part of the documentation has pages documenting particular sbt topics in detail. Before reading anything in here, you will need the information in the Getting Started Guide as a foundation. Tasks and settings are introduced in the getting started guide, which you may wish to read first. This page has additional details and background and is intended more as a reference. Both settings and tasks produce values, but there are two major differences between them: There are several features of the task system: valueon it within a task definition. try/catch/finally. These features are discussed in detail in the following sections. build.sbt: lazy val hello = taskKey[Unit]("Prints 'Hello World'") hello := println("hello world!") Run “sbt hello” from command line to invoke the task. Run “sbt tasks” to see this task listed. To declare a new task, define a lazy val of type TaskKey: lazy val sampleTask = taskKey[Int]("A sample task.") The name of the val is used when referring to the task in Scala code and at the command line. The string passed to the taskKey method is a description of the task. The type parameter passed to taskKey (here, Int) is the type of value produced by the task. We’ll define a couple of other keys for the examples: lazy val intTask = taskKey[Int]("An int task") lazy val stringTask = taskKey[String]("A string task") The examples themselves are valid entries in a build.sbt or can be provided as part of a sequence to Project.settings (see .scala build definition). There are three main parts to implementing a task once its key is defined: These parts are then combined just like the parts of a setting are combined. A task is defined using := intTask := 1 + 2 stringTask := System.getProperty("user.name") sampleTask := { val sum = 1 + 2 println("sum: " + sum) sum } As mentioned in the introduction, a task is evaluated on demand. Each time sampleTask is invoked, for example, it will print the sum. If the username changes between runs, stringTask will take different values in those separate runs. (Within a run, each task is evaluated at most once.) In contrast, settings are evaluated once on project load and are fixed until the next reload. Tasks with other tasks or settings as inputs are also defined using :=. The values of the inputs are referenced by the value method. This method is special syntax and can only be called when defining a task, such as in the argument to :=. The following defines a task that adds one to the value produced by intTask and returns the result. sampleTask := intTask.value + 1 Multiple settings are handled similarly: stringTask := "Sample: " + sampleTask.value + ", int: " + intTask.value As with settings, tasks can be defined in a specific scope. For example, there are separate compile tasks for the compile and test scopes. The scope of a task is defined the same as for a setting. In the following example, test:sampleTask uses the result of compile:intTask. sampleTask in Test := (intTask in Compile).value * 3 As a reminder, infix method precedence is by the name of the method and postfix methods have lower precedence than infix methods. =, except for !=, <=, >=, and names that start with =. Methods with names that start with a symbol and aren’t included in Therefore, the previous example is equivalent to the following: (sampleTask in Test).:=( (intTask in Compile).value * 3 ) Additionally, the braces in the following are necessary: helloTask := { "echo Hello" ! } Without them, Scala interprets the line as ( helloTask.:=("echo Hello") ).! instead of the desired helloTask.:=( "echo Hello".! ). The implementation of a task can be separated from the binding. For example, a basic separate definition looks like: // Define a new, standalone task implemention lazy val intTaskImpl: Initialize[Task[Int]] = Def.task { sampleTask.value - 3 } // Bind the implementation to a specific key intTask := intTaskImpl.value Note that whenever .value is used, it must be within a task definition, such as within Def.task above or as an argument to :=. In the general case, modify a task by declaring the previous task as an input. // initial definition intTask := 3 // overriding definition that references the previous definition intTask := intTask.value + 1 Completely override a task by not declaring the previous task as an input. Each of the definitions in the following example completely overrides the previous one. That is, when intTask is run, it will only print #3. intTask := { println("#1") 3 } intTask := { println("#2") 5 } intTask := { println("#3") sampleTask.value - 3 } The general form of an expression that gets values from multiple scopes is: <setting-or-task>.all(<scope-filter>).value The all method is implicitly added to tasks and settings. It accepts a ScopeFilter that will select the Scopes. The result has type Seq[T], where T is the key’s underlying type. A common scenario is getting the sources for all subprojects for processing all at once, such as passing them to scaladoc. The task that we want to obtain values for is sources and we want to get the values in all non-root projects and in the Compile configuration. This looks like: lazy val core = project lazy val util = project lazy val root = project.settings( sources := { val filter = ScopeFilter( inProjects(core, util), inConfigurations(Compile) ) // each sources definition is of type Seq[File], // giving us a Seq[Seq[File]] that we then flatten to Seq[File] val allSources: Seq[Seq[File]] = sources.all(filter).value allSources.flatten } ) The next section describes various ways to construct a ScopeFilter. A basic ScopeFilter is constructed by the ScopeFilter.apply method. This method makes a ScopeFilter from filters on the parts of a Scope: a ProjectFilter, ConfigurationFilter, and TaskFilter. The simplest case is explicitly specifying the values for the parts: val filter: ScopeFilter = ScopeFilter( inProjects( core, util ), inConfigurations( Compile, Test ) ) If the task filter is not specified, as in the example above, the default is to select scopes without a specific task (global). Similarly, an unspecified configuration filter will select scopes in the global configuration. The project filter should usually be explicit, but if left unspecified, the current project context will be used. The example showed the basic methods inProjects and inConfigurations. This section describes all methods for constructing a ProjectFilter, ConfigurationFilter, or TaskFilter. These methods can be organized into four groups: inProjects, inConfigurations, inTasks) inGlobalProject, inGlobalConfiguration, inGlobalTask) inAnyProject, inAnyConfiguration, inAnyTask) inAggregates, inDependencies) See the API documentation for details. ScopeFilters may be combined with the &&, ||, --, and - methods: a && bSelects scopes that match both a and b a || bSelects scopes that match either a or b a -- bSelects scopes that match a but not b -bSelects scopes that do not match b For example, the following selects the scope for the Compile and Test configurations of the core project and the global configuration of the util project: val filter: ScopeFilter = ScopeFilter( inProjects(core), inConfigurations(Compile, Test)) || ScopeFilter( inProjects(util), inGlobalConfiguration ) The all method applies to both settings (values of type Initialize[T]) and tasks (values of type Initialize[Task[T]]). It returns a setting or task that provides a Seq[T], as shown in this table: This means that the all method can be combined with methods that construct tasks and settings. Some scopes might not define a setting or task. The ? and ?? methods can help in this case. They are both defined on settings and tasks and indicate what to do when a key is undefined. The following contrived example sets the maximum errors to be the maximum of all aggregates of the current project. maxErrors := { // select the transitive aggregates for this project, but not the project itself val filter: ScopeFilter = ScopeFilter( inAggregates(ThisProject, includeRoot=false) ) // get the configured maximum errors in each selected scope, // using 0 if not defined in a scope val allVersions: Seq[Int] = (maxErrors ?? 0).all(filter).value allVersions.max } The target of all is any task or setting, including anonymous ones. This means it is possible to get multiple values at once without defining a new task or setting in each scope. A common use case is to pair each value obtained with the project, configuration, or full scope it came from. resolvedScoped: Provides the full enclosing ScopedKey (which is a Scope + AttributeKey[_]) thisProject: Provides the Project associated with this scope (undefined at the global and build levels) thisProjectRef: Provides the ProjectRef for the context (undefined at the global and build levels) configuration: Provides the Configuration for the context (undefined for the global configuration) For example, the following defines a task that prints non-Compile configurations that define sbt plugins. This might be used to identify an incorrectly configured build (or not, since this is a fairly contrived example): // Select all configurations in the current project except for Compile lazy val filter: ScopeFilter = ScopeFilter( inProjects(ThisProject), inAnyConfiguration -- inConfigurations(Compile) ) // Define a task that provides the name of the current configuration // and the set of sbt plugins defined in the configuration lazy val pluginsWithConfig: Initialize[Task[ (String, Set[String]) ]] = Def.task { ( configuration.value.name, definedSbtPlugins.value ) } checkPluginsTask := { val oddPlugins: Seq[(String, Set[String])] = pluginsWithConfig.all(filter).value // Print each configuration that defines sbt plugins for( (config, plugins) <- oddPlugins if plugins.nonEmpty ) println(s"$config defines sbt plugins: ${plugins.mkString(", ")}") } The examples in this section use the task keys defined in the previous section. Per-task loggers are part of a more general system for task-specific data called Streams. This allows controlling the verbosity of stack traces and logging individually for tasks as well as recalling the last logging for a task. Tasks also have access to their own persisted binary or text data. To use Streams, get the value of the streams task. This is a special task that provides an instance of TaskStreams for the defining task. This type provides access to named binary and text streams, named loggers, and a default logger. The default Logger, which is the most commonly used aspect, is obtained by the log method: myTask := { val s: TaskStreams = streams.value s.log.debug("Saying hi...") s.log.info("Hello!") } You can scope logging settings by the specific task’s scope: logLevel in myTask := Level.Debug traceLevel in myTask := 5 To obtain the last logging output from a task, use the last command: $ last myTask [debug] Saying hi... [info] Hello! The verbosity with which logging is persisted is controlled using the persistLogLevel and persistTraceLevel settings. The last command displays what was logged according to these levels. The levels do not affect already logged information. Def.taskDyn It can be useful to use the result of a task to determine the next tasks to evaluate. This is done using Def.taskDyn. The result of taskDyn is called a dynamic task because it introduces dependencies at runtime. The taskDyn method supports the same syntax as Def.task and := except that you return a task instead of a plain value. For example, val dynamic = Def.taskDyn { // decide what to evaluate based on the value of `stringTask` if(stringTask.value == "dev") // create the dev-mode task: this is only evaluated if the // value of stringTask is "dev" Def.task { 3 } else // create the production task: only evaluated if the value // of the stringTask is not "dev" Def.task { intTask.value + 5 } } myTask := { val num = dynamic.value println(s"Number selected was $num") } The only static dependency of myTask is stringTask. The dependency on intTask is only introduced in non-dev mode. Note: A dynamic task cannot refer to itself or a circular dependency will result. In the example above, there would be a circular dependency if the code passed to taskDyn referenced myTask. sbt 0.13.8 added Def.sequential function to run tasks under semi-sequential semantics. This is similar to the dynamic task, but easier to define. To demonstrate the sequential task, let’s create a custom task called compilecheck that runs compile in Compile and then scalastyle in Compile task added by scalastyle-sbt-plugin. This section discusses the failure, result, and andFinally methods, which are used to handle failure of other tasks. failure The failure method creates a new task that returns the Incomplete value when the original task fails to complete normally. If the original task succeeds, the new task fails. Incomplete is an exception with information about any tasks that caused the failure and any underlying exceptions thrown during task execution. For example: intTask := sys.error("Failed.") intTask := { println("Ignoring failure: " + intTask.failure.value) 3 } This overrides the intTask so that the original exception is printed and the constant 3 is returned. failure does not prevent other tasks that depend on the target from failing. Consider the following example: intTask := if(shouldSucceed) 5 else sys.error("Failed.") // Return 3 if intTask fails. If intTask succeeds, this task will fail. aTask := intTask.failure.value - 2 // A new task that increments the result of intTask. bTask := intTask.value + 1 cTask := aTask.value + bTask.value The following table lists the results of each task depending on the initially invoked task: The overall result is always the same as the root task (the directly invoked task). A failure turns a success into a failure, and a failure into an Incomplete. A normal task definition fails when any of its inputs fail and computes its value otherwise. result The result method creates a new task that returns the full Result[T] value for the original task. Result has the same structure as Either[Incomplete, T] for a task result of type T. That is, it has two subtypes: Inc, which wraps Incompletein case of failure Value, which wraps a task’s result in case of success. Thus, the task created by result executes whether or not the original task succeeds or fails. For example: intTask := sys.error("Failed.") intTask := intTask.result.value match { case Inc(inc: Incomplete) => println("Ignoring failure: " + inc) 3 case Value(v) => println("Using successful result: " + v) v } This overrides the original intTask definition so that if the original task fails, the exception is printed and the constant 3 is returned. If it succeeds, the value is printed and returned. The andFinally method defines a new task that runs the original task and evaluates a side effect regardless of whether the original task succeeded. The result of the task is the result of the original task. For example: intTask := sys.error("I didn't succeed.") lazy val intTaskImpl = intTask andFinally { println("andFinally") } intTask := intTaskImpl.value This modifies the original intTask to always print “andFinally” even if the task fails. Note that andFinally constructs a new task. This means that the new task has to be invoked in order for the extra block to run. This is important when calling andFinally on another task instead of overriding a task like in the previous example. For example, consider this code: intTask := sys.error("I didn't succeed.") lazy val intTaskImpl = intTask andFinally { println("andFinally") } otherIntTask := intTaskImpl.value If intTask is run directly, otherIntTask is never involved in execution. This case is similar to the following plain Scala code: def intTask(): Int = sys.error("I didn't succeed.") def otherIntTask(): Int = try { intTask() } finally { println("finally") } intTask() It is obvious here that calling intTask() will never result in “finally” being printed. Input Tasks parse user input and produce a task to run. Parsing Input describes how to use the parser combinators that define the input syntax and tab completion. This page describes how to hook those parser combinators into the input task system. A key for an input task is of type InputKey and represents the input task like a SettingKey represents a setting or a TaskKey represents a task. Define a new input task key using the inputKey.apply factory method: // goes in project/Build.scala or in build.sbt val demo = inputKey[Unit]("A demo input task.") The definition of an input task is similar to that of a normal task, but it can also use the result of a Parser applied to user input. Just as the special value method gets the value of a setting or task, the special parsed method gets the result of a Parser. The simplest input task accepts a space-delimited sequence of arguments. It does not provide useful tab completion and parsing is basic. The built-in parser for space-delimited arguments is constructed via the spaceDelimited method, which accepts as its only argument the label to present to the user during tab completion. For example, the following task prints the current Scala version and then echoes the arguments passed to it on their own line. import complete.DefaultParsers._ demo := { // get the result of parsing val args: Seq[String] = spaceDelimited("<arg>").parsed // Here, we also use the value of the `scalaVersion` setting println("The current Scala version is " + scalaVersion.value) println("The arguments to demo were:") args foreach println } The Parser provided by the spaceDelimited method does not provide any flexibility in defining the input syntax. Using a custom parser is just a matter of defining your own Parser as described on the Parsing Input page. The first step is to construct the actual Parser by defining a value of one of the following types: Parser[I]: a basic parser that does not use any settings Initialize[Parser[I]]: a parser whose definition depends on one or more settings Initialize[State => Parser[I]]: a parser that is defined using both settings and the current state We already saw an example of the first case with spaceDelimited, which doesn’t use any settings in its definition. As an example of the third case, the following defines a contrived Parser that uses the project’s Scala and sbt version settings as well as the state. To use these settings, we need to wrap the Parser construction in Def.setting and get the setting values with the special value method: import complete.DefaultParsers._ import complete.Parser val parser: Def.Initialize[State => Parser[(String,String)]] = Def.setting { (state: State) => ( token("scala" <~ Space) ~ token(scalaVersion.value) ) | ( token("sbt" <~ Space) ~ token(sbtVersion.value) ) | ( token("commands" <~ Space) ~ token(state.remainingCommands.size.toString) ) } This Parser definition will produce a value of type (String,String). The input syntax defined isn’t very flexible; it is just a demonstration. It will produce one of the following values for a successful parse (assuming the current Scala version is 2.12.2, the current sbt version is 1.0.1, and there are 3 commands left to run): Again, we were able to access the current Scala and sbt version for the project because they are settings. Tasks cannot be used to define the parser. Next, we construct the actual task to execute from the result of the Parser. For this, we define a task as usual, but we can access the result of parsing via the special parsed method on Parser. The following contrived example uses the previous example’s output (of type (String,String)) and the result of the package task to print some information to the screen. demo := { val (tpe, value) = parser.parsed println("Type: " + tpe) println("Value: " + value) println("Packaged: " + packageBin.value.getAbsolutePath) } It helps to look at the InputTask type to understand more advanced usage of input tasks. The core input task type is: class InputTask[T](val parser: State => Parser[Task[T]]) Normally, an input task is assigned to a setting and you work with Initialize[InputTask[T]]. Breaking this down, So, you can use settings or State to construct the parser that defines an input task’s command line syntax. This was described in the previous section. You can then use settings, State, or user input to construct the task to run. This is implicit in the input task syntax. The types involved in an input task are composable, so it is possible to reuse input tasks. The .parsed and .evaluated methods are defined on InputTasks to make this more convenient in common situations: .parsedon an InputTask[T]or Initialize[InputTask[T]]to get the Task[T]created after parsing the command line .evaluatedon an InputTask[T]or Initialize[InputTask[T]]to get the value of type Tfrom evaluating that task In both situations, the underlying Parser is sequenced with other parsers in the input task definition. In the case of .evaluated, the generated task is evaluated. The following example applies the run input task, a literal separator parser --, and run again. The parsers are sequenced in order of syntactic appearance, so that the arguments before -- are passed to the first run and the ones after are passed to the second. val run2 = inputKey[Unit]( "Runs the main class twice with different argument lists separated by --") val separator: Parser[String] = "--" run2 := { val one = (run in Compile).evaluated val sep = separator.parsed val two = (run in Compile).evaluated } For a main class Demo that echoes its arguments, this looks like: $ sbt > run2 a b -- c d [info] Running Demo c d [info] Running Demo a b c d a b Because InputTasks are built from Parsers, it is possible to generate a new InputTask by applying some input programmatically. (It is also possible to generate a Task, which is covered in the next section.) Two convenience methods are provided on InputTask[T] and Initialize[InputTask[T]] that accept the String to apply. partialInputapplies the input and allows further input, such as from the command line fullInputapplies the input and terminates parsing, so that further input is not accepted In each case, the input is applied to the input task’s parser. Because input tasks handle all input after the task name, they usually require initial whitespace to be provided in the input. Consider the example in the previous section. We can modify it so that we: run. We use nameand versionto show that settings can be used to define and modify parsers. run, but allow further input on the command line. Note: the current implementation of :=doesn’t actually support applying input derived from settings yet. lazy val run2 = inputKey[Unit]("Runs the main class twice: " + "once with the project name and version as arguments" "and once with command line arguments preceded by hard coded values.") // The argument string for the first run task is ' <name> <version>' lazy val firstInput: Initialize[String] = Def.setting(s" ${name.value} ${version.value}") // Make the first arguments to the second run task ' red blue' lazy val secondInput: String = " red blue" run2 := { val one = (run in Compile).fullInput(firstInput.value).evaluated val two = (run in Compile).partialInput(secondInput).evaluated } For a main class Demo that echoes its arguments, this looks like: $ sbt > run2 green [info] Running Demo demo 1.0 [info] Running Demo red blue green demo 1.0 red blue green The previous section showed how to derive a new InputTask by applying input. In this section, applying input produces a Task. The toTask method on Initialize[InputTask[T]] accepts the String input to apply and produces a task that can be used normally. For example, the following defines a plain task runFixed that can be used by other tasks or run directly without providing any input: lazy val runFixed = taskKey[Unit]("A task that hard codes the values to `run`") runFixed := { val _ = (run in Compile).toTask(" blue green").value println("Done!") } For a main class Demo that echoes its arguments, running runFixed looks like: $ sbt > runFixed [info] Running Demo blue green blue green Done! Each call to toTask generates a new task, but each task is configured the same as the original InputTask (in this case, run) but with different input applied. For example: lazy val runFixed2 = taskKey[Unit]("A task that hard codes the values to `run`") fork in run := true runFixed2 := { val x = (run in Compile).toTask(" blue green").value val y = (run in Compile).toTask(" red orange").value println("Done!") } The different toTask calls define different tasks that each run the project’s main class in a new jvm. That is, the fork setting configures both, each has the same classpath, and each run the same main class. However, each task passes different arguments to the main class. For a main class Demo that echoes its arguments, the output of running runFixed2 might look like: $ sbt > runFixed2 [info] Running Demo blue green [info] Running Demo red orange blue green red orange Done! A ("[", ", ", "]") } This. State ... This page motivates the task and settings system. You should already know how to use tasks and settings, which are described in the getting started guide and on the Tasks page. An important aspect of the task system is to combine two common, related steps in a build: Earlier versions of sbt configured these steps separately using To see why it is advantageous to combine them, compare the situation to that of deferring initialization of a variable in Scala. This Scala code is a bad way to expose a value whose initialization is deferred: // Define a variable that will be initialized at some point // We don't want to do it right away, because it might be expensive var foo: Foo = _ // Define a function to initialize the variable def makeFoo(): Unit = ... initialize foo ... Typical usage would be: makeFoo() doSomething(foo) This example is rather exaggerated in its badness, but I claim it is nearly the same situation as our two step task definitions. Particular reasons this is bad include: makeFoo()first. foocould be changed by other code. There could be a def makeFoo2(), for example. The first point is like declaring a task dependency, the second is like two tasks modifying the same state (either project variables or files), and the third is a consequence of unsynchronized, shared state. In Scala, we have the built-in functionality to easily fix this: lazy val. lazy val foo: Foo = ... initialize foo ... with the example usage: doSomething(foo) Here, lazy val gives us thread safety, guaranteed initialization before access, and immutability all in one, DRY construct. The task system in sbt does the same thing for tasks (and more, but we won’t go into that here) that lazy val did for our bad example. A task definition must declare its inputs and the type of its output. sbt will ensure that the input tasks have run and will then provide their results to the function that implements the task, which will generate its own result. Other tasks can use this result and be assured that the task has run (once) and be thread-safe and typesafe in the process. The general form of a task definition looks like: myTask := { val a: A = aTask.value val b: B = bTask.value ... do something with a, b and generate a result ... } (This is only intended to be a discussion of the ideas behind tasks, so see the sbt Tasks page for details on usage.) Here, aTask is assumed to produce a result of type A and bTask is assumed to produce a result of type B. As an example, consider generating a zip file containing the binary jar, source jar, and documentation jar for your project. First, determine what tasks produce the jars. In this case, the input tasks are packageBin, packageSrc, and packageDoc in the main Compile scope. The result of each of these tasks is the File for the jar that they generated. Our zip file task is defined by mapping these package tasks and including their outputs in a zip file. As good practice, we then return the File for this zip so that other tasks can map on the zip task. zip := { val bin: File = (packageBin in Compile).value val src: File = (packageSrc in Compile).value val doc: File = (packageDoc in Compile).value val out: File = zipPath.value val inputs: Seq[(File,String)] = Seq(bin, src, doc) x Path.flat IO.zip(inputs, out) out } The val inputs line defines how the input files are mapped to paths in the zip. See Mapping Files for details. The explicit types are not required, but are included for clarity. The zipPath input would be a custom task to define the location of the zip file. For example: zipPath := target.value / "out.zip" This part of the documentation has pages documenting particular sbt topics in detail. Before reading anything in here, you will need the information in the Getting Started Guide as a foundation. This. There.autoplugins descriptor files containing the names of sbt.AutoPlugin/1.0.12.2). ~/.sbt/1.0/1.0 = RootProject. This ... } ) } Travis Let’s talk about testing. Once you write a plugin, it turns into a long-term thing. To keep adding new features (or to keep fixing bugs), writing tests makes sense. sbt comes with scripted test framework, which lets you script a build scenario. It was written to test sbt itself on complex scenarios — such as change detection and partial compilation: Now, consider what happens if you were to delete B.scala but do not update A.scala. When you recompile, you should get an error because B no longer exists for A to reference. [… (really complicated stuff)] The scripted test framework is used to verify that sbt handles cases such as that described above. The framework is made available via scripted-plugin. The rest of this page explains how to include the scripted-plugin into your plugin. Before you start, set your version to a -SNAPSHOT one because scripted-plugin will publish your plugin locally. If you don’t use SNAPSHOT, you could get into a horrible inconsistent state of you and the rest of the world seeing different artifacts. Add scripted-plugin to your plugin build. project/scripted.sbt: libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } Then add the following settings to scripted.sbt: scriptedLaunchOpts := { scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) } scriptedBufferLog := false Make dir structure src/sbt-test/<test-group>/<test-name>. For starters, try something like src/sbt-test/<your-plugin-name>/simple. Now ready? Create an initial build in simple. Like a real build using your plugin. I’m sure you already have several of them to test manually. Here’s an example build.sbt: lazy val root = (project in file(".")) .settings( version := "0.1", scalaVersion := "2.10.6", assemblyJarName in assembly := "foo.jar" ) In project/plugins.sbt: sys.props.get("plugin.version") match { case Some(x) => addSbtPlugin("com.eed3si9n" % "sbt-assembly" % x) case _ => sys.error("""|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) } This a trick I picked up from JamesEarlDouglas/xsbt-web-plugin@feabb2, which allows us to pass version number into the test. I also have src/main/scala/hello.scala: object Main extends App { println("hello") } Now, write a script to describe your scenario in a file called test located at the root dir of your test project. # check if the file gets created > assembly $ exists target/scala-2.10/foo.jar Here is the syntax for the script: #starts a one-line comment > namesends a task to sbt (and tests if it succeeds) $ name arg*performs a file command (and tests if it succeeds) -> namesends a task to sbt, but expects it to fail -$ name arg*performs a file command, but expects it to fail File commands are: touch path+creates or updates the timestamp on the files delete path+deletes the files exists path+checks if the files exist mkdir path+creates dirs absent path+checks if the files don’t exist newer source targetchecks if sourceis newer must-mirror source targetchecks if sourceis identical pausepauses until enter is pressed sleep timesleeps exec command args*runs the command in another process copy-file fromPath toPathcopies the file copy fromPath+ toDircopies the paths to toDirpreserving relative structure copy-flat fromPath+ toDircopies the paths to toDirflat So my script will run assembly task, and checks if foo.jar gets created. We’ll cover more complex tests later. To run the scripts, go back to your plugin project, and run: > scripted This will copy your test build into a temporary dir, and executes the test script. If everything works out, you’d see publishLocal running, then: Running sbt-assembly / simple [success] Total time: 18 s, completed Sep 17, 2011 3:00:58 AM The file commands are great, but not nearly enough because none of them test the actual contents. An easy way to test the contents is to implement a custom task in your test build. For my hello project, I’d like to check if the resulting jar prints out “hello”. I can take advantage of scala.sys.process.Process to run the jar. To express a failure, just throw an error. Here’s build.sbt: import scala.sys.process.Process lazy val root = (project in file(".")) .settings( version := "0.1", scalaVersion := "2.10.6", assemblyJarName in assembly := "foo.jar", TaskKey[Unit]("check") := { val process = Process("java", Seq("-jar", (crossTarget.value / "foo.jar").toString)) val out = (process!!) if (out.trim != "bye") sys.error("unexpected output: " + out) () } ) I am intentionally testing if it matches “bye”, to see how the test fails. Here’s test: # check if the file gets created > assembly $ exists target/foo.jar # check if it says hello > check Running scripted fails the test as expected: [info] [error] {file:/private/var/folders/Ab/AbC1EFghIj4LMNOPqrStUV+++XX/-Tmp-/sbt_cdd1b3c4/simple/}default-0314bd/*:check: unexpected output: hello [info] [error] Total time: 0 s, completed Sep 21, 2011 8:43:03 PM [error] x sbt-assembly / simple [error] {line 6} Command failed: check failed [error] {file:/Users/foo/work/sbt-assembly/}default-373f46/*:scripted: sbt-assembly / simple failed [error] Total time: 14 s, completed Sep 21, 2011 8:00:00 PM Until you get the hang of it, it might take a while for the test itself to behave correctly. There are several techniques that may come in handy. First place to start is turning off the log buffering. > set scriptedBufferLog := false This for example should print out the location of the temporary dir: [info] [info] Set current project to default-c6500b (in build file:/private/var/folders/Ab/AbC1EFghIj4LMNOPqrStUV+++XX/-Tmp-/sbt_8d950687/simple/project/plugins/) ... Add the following line to your test script to suspend the test until you hit the enter key: $ pause If you’re thinking about going down to the sbt/sbt-test/sbt-foo/simple and running sbt, don’t do it. The right way, is to copy the dir somewhere else and run it. There are literally 100+ scripted tests under sbt project itself. Browse around to get inspirations. For example, here’s the one called by-name. > compile # change => Int to Function0 $ copy-file changes/A.scala A.scala # Both A.scala and B.scala need to be recompiled because the type has changed -> compile xsbt-web-plugin and sbt-assembly have some scripted tests too. That’s it! Let me know about your experience in testing plugins! s. Like we are able to cross build against multiple Scala versions, we can cross build sbt 1.0 plugins while staying on sbt 0.13. This is useful because we can port one plugin at a time. .settings( scalaVersion := "2.12.2", sbtVersion in Global := "1.0.1", scalaCompilerBridgeSource := { val sv = appConfiguration.value.provider.id.version ("org.scala-sbt" % "compiler-interface" % sv % "component").sources } ) Hopefully the last step will be simplified using @jrudolph’s sbt-cross-building in the future. If you run into problems upgrading a plugin, please report to GitHub issue.: Seq[File] = for) := "*.scala" || "*.java" includeFilter in (Test, unmanagedSources) := HiddenFileFilter || "*impl*" Note: By default, sbt includes .scalaand .javasources, excluding hidden files. When sbt traverses unmanagedResourceDirectories) := "*.txt" includeFilter in (Test, unmanagedSources) := "*. For efficiency, you would only want to generate sources when necessary and not every run.. Normally, you would only want to generate resources when necessary and not every run. The help command is used to show available commands and search the help for commands, tasks, or settings. If run without arguments, lists the available commands. > help help Displays this help message or prints detailed help on requested commands (run 'help <command>'). about Displays basic information about sbt and the build. reload (Re)loads the project in the current directory ... > help compile If the argument passed to help is the name of an existing command, setting or task, the help for that entity is displayed. Otherwise, the argument is interpreted as a regular expression that is used to search the help of all commands, settings and tasks. The tasks command is like help, but operates only on tasks. Similarly, the settings command only operates on settings. See also help help, help tasks, and help settings. The tasks command, without arguments, lists the most commonly used tasks. It can take a regular expression to search task names and descriptions. The verbosity can be increased to show or search less commonly used tasks. See help tasks for details. The settings command, without arguments, lists the most commonly used settings. It can take a regular expression to search setting names and descriptions. The verbosity can be increased to show or search less commonly used settings. See help settings for details. The inspect command displays several pieces of information about a given setting or task, including the dependencies of a task/setting as well as the tasks/settings that depend on the it. For example, > inspect test:compile ... [info] Dependencies: [info] test:compile:) ... For each task, inspect tree show the type of the value generated by the task. For a setting, the toString of the setting is displayed. See the Inspecting Settings page for details on the inspect command. While the settings, and tasks commands display a description of a task, the inspect command also shows the type of a setting or task and the value of a setting. For example: > inspect update [info] Task: sbt.UpdateReport [info] Description: [info] Resolves and optionally retrieves dependencies, producing a report. ... > inspect scalaVersion [info] Setting: java.lang.String = 2.9.2 [info] Description: [info] The version of Scala used for building. ... See the Inspecting Settings page for details. See the Inspecting Settings page for details. The inspect command can help find scopes where a setting or task is defined. The following example shows that different options may be specified to the Scala for testing and API documentation generation. > inspect scalacOptions ... [info] Related: [info] compile:doc::scalacOptions [info] test:scalacOptions [info] */*:scalacOptions [info] test:doc::scalacOptions See the Inspecting Settings page for details. The projects command displays the currently loaded projects. The projects are grouped by their enclosing build and the current project is indicated by an asterisk. For example, > projects [info] In file:/home/user/demo/ [info] * parent [info] sub [info] In file:/home/user/dep/ [info] sample session list displays the settings that have been added at the command line for the current project. For example, > session list 1. maxErrors := 5 2. scalacOptions += "-explaintypes" session list-all displays the settings added for all projects. For details, see help session. > about [info] This is sbt The inspect command shows the value of a setting as part of its output, but the show command is dedicated to this job. It shows the output of the setting provided as an argument. For example, > show organization [info] com.github.sbt The show command also works for tasks, described next. > show update ... <output of update> ... [info] Update report: [info] Resolve time: 122 ms, Download time: 5 ms, Download size: 0 bytes [info] compile: [info] org.scala-lang:scala-library:2.9.2: ... The show command will execute the task provided as an argument and then print the result. Note that this is different from the behavior of the inspect command (described in other sections), which does not execute a task and thus can only display its type and not its generated value. > show compile:dependencyClasspath ... [info] ArrayBuffer(Attributed(~/(~/.ivy2/cache/junit/junit/jars/junit-4.8.2.jar)) sbt detects the classes with public, static main methods for use by the run method and to tab-complete the runMain method. The discoveredMainClasses task does this discovery and provides as its result the list of class names. For example, the following shows the main classes discovered in the main sources: > show compile:discoveredMainClasses ... <runs compile if out of date> ... [info] List(org.example.Main) sbt detects tests according to fingerprints provided by test frameworks. The definedTestNames task provides as its result the list of test names detected in this way. For example, > show test:definedTestNames ... < runs test:compile if out of date > ... [info] List(org.example.TestA, org.example.TestB) By default, sbt’s interactive mode is started when no commands are provided on the command line or when the shell command is invoked. As the name suggests, tab completion is invoked by hitting the tab key. Suggestions are provided that can complete the text entered to the left of the current cursor position. Any part of the suggestion that is unambiguous is automatically appended to the current text. Commands typically support tab completion for most of their syntax. As an example, entering tes and hitting tab: > tes<TAB> results in sbt appending a t: > test To get further completions, hit tab again: > test<TAB> testFrameworks testListeners testLoader testOnly testOptions test: Now, there is more than one possibility for the next character, so sbt prints the available options. We will select testOnly and get more suggestions by entering the rest of the command and hitting tab twice: > testOnly<TAB><TAB> -- sbt.DagSpecification sbt.EmptyRelationTest sbt.KeyTest sbt.RelationTest sbt.SettingsTest The first tab inserts an unambiguous space and the second suggests names of tests to run. The suggestion of -- is for the separator between test names and options provided to the test framework. The other suggestions are names of test classes for one of sbt’s modules. Test name suggestions require tests to be compiled first. If tests have been added, renamed, or removed since the last test compilation, the completions will be out of date until another successful compile. Some commands have different levels of completion. Hitting tab multiple times increases the verbosity of completions. (Presently, this feature is only used by the set command.) JLine, used by both Scala and sbt, uses a configuration file for many of its keybindings. The location of this file can be changed with the system property jline.keybindings. The default keybindings file is included in the sbt launcher and may be used as a starting point for customization. By default, sbt only displays > to prompt for a command. This can be changed through the shellPrompt setting, which has type State => String. State contains all state for sbt and thus provides access to all build information for use in the prompt string. Examples: // set the prompt (for this build) to include the project id. shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " } // set the prompt (for the current project) to include the username shellPrompt := { state => System.getProperty("user.name") + "> " } Interactive mode remembers history even if you exit sbt and restart it. The simplest way to access history is to press the up arrow key to cycle through previously entered commands. Use Ctrl+r to incrementally search history backwards. The following commands are supported: !Show history command help. !!Execute the previous command again. !:Show all previous commands. !:nShow the last n commands. !nExecute the command with index n, as shown by the !:command. !-nExecute the nth command before this one. !stringExecute the most recent command starting with ‘string’ !?stringExecute the most recent command containing ‘string’ By default, interactive history is stored in the target/ directory for the current project (but is not removed by a clean). History is thus separate for each subproject. The location can be changed with the historyPath setting, which has type Option[File]. For example, history can be stored in the root directory for the project instead of the output directory: historyPath := Some(baseDirectory.value / ".history") The history path needs to be set for each project, since sbt will use the value of historyPath for the current project (as selected by the project command). The previous section describes how to configure the location of the history file. This setting can be used to share the interactive history among all projects in a build instead of using a different history for each project. The way this is done is to set historyPath to be the same file, such as a file in the root project’s target/ directory: historyPath := Some( (target in LocalRootProject).value / ".history") The in LocalRootProject part means to get the output directory for the root project for the build. If, for whatever reason, you want to disable history, set historyPath to None in each project it should be disabled in: > historyPath := None Interactive mode is implemented by the shell command. By default, the shell command is run if no commands are provided to sbt on the command line. To run commands before entering interactive mode, specify them on the command line followed by shell. For example, $ sbt clean compile shell This runs clean and then compile before entering the interactive prompt. If either clean or compile fails, sbt will exit without going to the prompt. To enter the prompt whether or not these initial commands succeed, prepend "onFailure shell", which means to run shell if any command fails. For example, $ sbt "onFailure shell" clean compile shell When.") } A project should define name and version. These will be used in various parts of the build, such as the names of generated artifacts. Projects that are published to a repository should also override organization. name := "Your project name" For published projects, this name is normalized to be suitable for use as an artifact name and dependency ID. This normalized name is stored in normalizedName. version := "1.0" organization := "org.example" By convention, this is a reverse domain name that you own, typically one specific to your project. It is used as a namespace for projects. A full/formal name can be defined in the organizationName setting. This is used in the generated pom.xml. If the organization has a web site, it may be set in the organizationHomepage setting. For example: organizationName := "Example, Inc." organizationHomepage := Some(url("")) homepage := Some(url("")) startYear := Some(2008) description := "A build tool for Scala." licenses += "GPLv2" -> url("") By default, a project exports a directory containing its resources and compiled class files. Set exportJars to true to export the packaged jar instead. For example, exportJars := true The jar will be used by run, test, console, and other tasks that use the full classpath. By default, sbt constructs a manifest for the binary package from settings such as organization and mainClass. Additional attributes may be added to the packageOptions setting scoped by the configuration and package task. Main attributes may be added with Package.ManifestAttributes. There are two variants of this method, once that accepts repeated arguments that map an attribute of type java.util.jar.Attributes.Name to a String value and other that maps attribute names (type String) to the String value. For example,) += { val file = new java.io.File("META-INF/MANIFEST.MF") val manifest = Using.fileInputStream(file)( in => new java.util.jar.Manifest(in) ) Package.JarManifest( manifest ) } The artifactName setting controls the name of generated packages. See the Artifacts page for details. The contents of a package are defined by the mappings task, of type Seq[(File,String)]. The mappings task is a sequence of mappings from a file to include in the package to the path in the package. See Mapping Files for convenience functions for generating these mappings. For example, to add the file in/example.txt to the main binary jar with the path “out/example.txt”,. sbt interprets each command line argument provided to it as a command together with the command’s arguments. Therefore, to run a command that takes arguments in batch mode, quote the command using double quotes, and its arguments. For example, $ sbt "project X" clean "~ compile" Multiple commands can be scheduled at once by prefixing each command with a semicolon. This is useful for specifying multiple commands where a single command string is accepted. For example, the syntax for triggered execution is ~ <command>. To have more than one command run for each triggering, use semicolons. For example, the following runs clean and then compile each time a source file changes: > ~ ;clean;compile The < command reads commands from the files provided to it as arguments. Run help < at the sbt prompt for details. The alias command defines, removes, and displays aliases for commands. Run help alias at the sbt prompt for details. Example usage: > alias a=about > alias a = about > a [info] This is sbt ... > alias a= > alias > a [error] Not a valid command: a ... The eval command compiles and runs the Scala expression passed to it as an argument. The result is printed along with its type. For example, > eval 2+2 4: Int Variables defined by an eval are not visible to subsequent evals, although changes to system properties persist and affect the JVM that is running sbt. Use the Scala REPL ( console and related commands) for full support for evaluating Scala code interactively., pollInterval := 1000 // in ms Consider A( scalaVersion in ThisBuild := "2.12.3", organization in ThisBuild := "com.example", name := "helloworld", dependencyUpdates := { println("hi") }, // onLoad is scoped to Global because there's only one. onLoad in Global := { val old = (onLoad in Global).value // compose the new transition on top of the existing one // in case your plugins are using this hook. startupTransition compose old } ) You can use this technique to switch the startup subproject too. One of the most frequently asked questions is in the form of “how do I do X and then do Y in sbt”? Generally speaking, that’s not how sbt tasks are set up. build.sbt is a DSL to define dependency graph of tasks. This is covered in Execution semantics of tasks. So ideally, what you should do is define task Y yourself, and depend on the task X. taskY := { val x = taskX.value x + 1 } This is more constrained compared to the imperative style plain Scala code with side effects such as the follows: def foo(): Unit = { doX() doY() } The benefit of the dependency-oriented programming model is that sbt’s task engine is able to reorder the task execution. When possible we run dependent tasks in parallel. Another benefit is that we can deduplicate the graph, and make sure that the task evaluation, such as compile in Compile, is called once per command execution, as opposed to compiling the same source many times. Because task system is generally set up this way, running something sequentially is possible, but you will be fighting the system a bit, and it’s not always going to be easy. s.1 addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") Looks like we were able to sequence these tasks. If.1.. // factor out common settings into a sequence lazy val commonSettings = Seq( organization := "org.myproject", version := "0.1.0", // set the Scala version used for the project scalaVersion := "2.12.3" ) // and is different // from the lib_managed/ in sbt 0.7.x..1" }) {} def err(s: => String) { } ) ) This } s.
http://www.scala-sbt.org/1.x/docs/Combined+Pages.html
CC-MAIN-2017-39
refinedweb
20,895
57.98
I am using os.walk to find all the .dbf files and then a for loop utilizing the dbfpy module to convert each .dbf file to a .csv. I am not receiving any errors but the files are not converting (staying as dbf files in path folder). Additionally, the dbf files are being emptied out (reduce to size of 0Kb) after the script is run. Note: the dbf files are stored in a subfolder of the Misc folder below. - Code: Select all import csv from dbfpy import dbf import os path = r"C:\Users\Stephen\Documents\House\Misc" for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith( '.DBF'): csv_fn = filename[:- 4]+ ".CSV" with open(csv_fn, 'wb ') as csvfile: in_db = dbf.Dbf(os.path.join(dirpath, filename), new= True) out_csv = csv.writer(csvfile) names = [] for field in in_db.header.fields: names.append(field.name) out_csv.writerow(names) for rec in in_db: out_csv.writerow(rec.fieldData) Any help appreciated....
http://www.python-forum.org/viewtopic.php?f=6&t=6285
CC-MAIN-2016-22
refinedweb
163
70.8
If you didn’t see the news up on the Word team blog announcing Word Automation Services, and you have any interest in server side conversion of .docx files into .pdf or .xps, you should definitely go take a look: Capturing Business Processes in Office. Printing and Re-Calcing on the Server. Server Side Document Assembly Example: - Client-side: Loan Template author generates the template for the loan application, and uses content controls to specify where the data should go. He saves it up to SharePoint so others can collaborate with him. - Client-side: Folks from the Legal department are able to work with in the document at the same time as the Template author because of the new co-authoring functionality in Word 2010. - Client-side: A financial analyst builds up a model for determining whether an applicant should be considered and what the terms of the loan should be. This model is saved up to SharePoint as an .xlsx - Server-side: As new applicants request an application, a server side process takes their data, and uses the Open XML SDK to inject it into xlsx. (Example 1; Example 2) - Server-side: The financial model (.xlsx) is then sent off to Excel Services to perform calculations and pull out the results - Server-side: The process takes the results of the calculation, and injects them into the Word template, using the content controls to determine what data should go where, producing a .docx file. (Example 1; Example 2) - Server-side: The .docx file is passed off to Word services where a .pdf file is generated, which can either then be sent on to a high volume printer, or e-mailed directly to the applicant. - Client-side: Any of the users can make updates to the documents (assuming this is allowed as part of the workflow), and those changes will automatically make their way into the bulk generation Brian: Question. Is it possible (perhaps with proper namespace markup)to add new user tags at the cell level of a sheet in the xl/worksheets/ folder? When I try I, get validation errors, and Excel repairs the sheet’s xml file. I also never heard the answer to the question about preventing Excel from moving string content into the ‘shairedStrings.xml’ file upon saving, and the difficulty that makes reading/extraction the sheet file data. Easy of reading is more important then compation sometimes. Thanks. Hey Jack, Excel does allow for custom XML markup, but not in the way that you’re asking. The two ways of adding "semantics" to the cell is either through the use of named ranges, or the custom XML mapping support. In both cases, the "labels" are stored outside of the grid, and they then reference the cell or range they apply to. Excel will roundtrip this information, and even update the references properly if new rows or columns are added at runtime. There is no way to tell Excel to not use the shared string table. One option however is to post process the output to move the strings back inline. Should be an easy example to pull together (I’ll see if Zeyad or I have some time to give it a shot). -Brian
https://blogs.msdn.microsoft.com/brian_jones/2009/11/03/open-xml-and-office-services/
CC-MAIN-2017-26
refinedweb
539
61.06
This chapter provides release notes about application and system programming on OpenVMS systems. 5.1 Programs Must Be Recompiled and Linked (I64 Only) V8.2 All programs must be recompiled for OpenVMS I64 Version 8.2. This is the case even if you have compiled and linked for an earlier evaluation or field test release of OpenVMS I64. (HP reserves the right to make incompatible changes to evaluation releases.) With this production release of OpenVMS I64 Version 8.2, HP's normal upward-compatibility policy goes into effect. For information about recompiling Alpha programs, refer to Section 5.2. 5.2 Privileged Programs May Need to Be Recompiled (Alpha Only). For information about recompiling I64 programs, refer to Section 5.1. 5.3.7 Per-Thread Security Impacts Privileged Code and Device Drivers V7.3-1.3.8 OpenVMS Version 8.2 contains new IEEE floating-point versions of LIB$ and OTS$ run-time library routines for use by applications using IEEE floating-point data. The function prototype definitions of these new routines are not included in the system-supplied header files. To use these functions you must define the function prototypes in your applications. Refer to the LIB$ and OTS$ run-time library reference manuals for descriptions of these functions. These function prototype definitions will be included in the system-supplied header files in a future release. 5.5 Ada Compiler Not Yet Available (I64 Only) The Ada compiler is supported on OpenVMS Alpha Version 8.2. HP is not porting the HP Ada 83 compiler from Alpha to I64; AdaCore is porting the Ada 95 compiler to OpenVMS I64. Customers can contact AdaCore directly when this product becomes available. 5 OpenVMS Utility Routines Manual for more information about registering callback routines. 5.7.8 C Run-Time Library The following sections describe changes and corrections to the C Run-Time Library (RTL). 5.8.1 Memory Leak in Programs Using socket_fd Fixed Previously, there was a memory leak in programs using socket_fd , which in certain circumstances consumed the page-file quota. This problem has been fixed. 5.8.2 vsnprintf and snprintf User Buffer Overwrite Fixed Previously, under certain conditions, the vsnprintf and snprintf functions could overwrite memory beyond the maximum count allowed in the user's buffer. For example, the following call to snprintf would overwrite user buffer t beyond the allowed t[2] , using the format string provided: snprintf(t, 3, "%2sxxxx", "a"); This problem has been fixed. 5.8.3 mmap and mprotect Changes Previously, a change in the C RTL for OpenVMS Versions 7.3-1 and 7.3-2 would return an error unless memory for the mprotect function had already been mapped by mmap . This problem has been fixed by restoring the legacy behavior: you can once again set protection using mprotect for memory that was not mapped by mmap . 5.8.4 getpwnam_r and getpwuid_r Pointer Problem Fixed Previously, programs calling the short-pointer version of getpwuid_r ( _getpwuid_r32 ) could incorrectly pass a long-pointer value for the third argument (buffer). This user-specified buffer was allocated to members of the resulting passwd structure, which are 32-bit pointers. This caused an incorrect result for those members ( pw_name , pw_dir , and pw_shell ) if the buffer was in high memory. The same problem existed for the short-pointer version of getpwnam_r ( _getpwnam_r32 ). This problem has been fixed. The prototypes for _getpwnam_r32 and _getpwuid_r32 have been changed so that the functions now accept only a 32-bit pointer for the buffer argument instead of allowing a 64-bit pointer. 5.8.5 _strtok_r32 and _strtok_r64 Now in Scope Previously, programs that included <string.h> and called _strtok_r32 or _strtok_r64 would not find a prototype in scope. This problem has been fixed. 5.8.6 const Type Qualifier Added to iconv Prototype (Alpha Only) To conform to the X/Open standard, the const qualifier will be added to the second argument of the iconv function prototype in <iconv.h> when the XOPEN_SOURCE feature test macro is defined to be 500 (#DEFINE XOPEN_SOURCE 500): size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); Previously, the C++ compiler did not recognize the result of the offsetof macro as an integral constant expression, which led to C++ compiler errors when used in that manner. This problem has been fixed. The <stddef.h> header file has been modified to provide an alternative definiton of the offsetof macro for use by C++ Version 6.5 and later. This alternative definition uses an EDG extension (__INTADDR__) to perform the otherwise nonstandard conversion from pointer to integer. This solution was provided by and recommended by EDG, and is the same as their solution (except for the use of nonpolluting names). 5.8.8 getc Macro Argument Now Protected by Parentheses (Alpha Only) To comply with the ISO C Standard (ISO/IEC 9899), the argument to the getc macro is now protected by parentheses. 5.8.9 CXXL Prefix Problems with Inlined Functions getc and getchar Fixed (Alpha Only) Previously, C++ compilations of getc and getchar resulted in undefined symbol warnings at link time. Under certain circumstances, the getc macro (in C) or inline function (in C++) called the actual decc$getc function. The problem was that the inline getc function declared the actual decc$getc function under extern_prefix "CXXL$". A similar problem occurs with getchar . This problem has been fixed. The <stdio.h> header file has been modified to provide a prototype for getc and getchar within the scope of the #pragma__extern_prefix "CXXL$" directive, while leaving the inlined implementation definition outside the scope of CXXL$ prefixing. 5.8.10 Non std Functions Declared in std Namespace (Alpha Only) Previously, C++ compilations of source files that reference v*scanf or *snprintf functions resulted in %CXX-E-UNDECLARED errors because the <stdio.h> header declared these functions in the std namespace, but did not inject them into the global namespace. This problem has been fixed. These function declarations have been moved to a location outside the std namespace. 5.8.11 lseek on Large File Offset Problem Fixed (Alpha Only) Previously, the lseek function failed to correctly position files on offsets larger than ULONG_MAX (4294967295) bytes (under the _LARGEFILE feature control macro). For example, calling lseek on a 6-gigabyte (16 megablock) file and specifying an offset of 0x100000000 left the file position at 0. This problem has been fixed. 5.8.12 New EABANDONED Code in <errno.h> A new errno code EABANDONED has been added to the <errno.h> header file. Pthreads functions can now return an EABANDONED ("Owner cannot release resource") code if the system has determined that the target process-shared mutex is locked by a process that has terminated (that is, the mutex is considered "abandoned" because the rightful owner cannot release it). 5.8.13 mktime Problem Fixed Previously, the UTC-time-based function mktime lost a day when the structure member tm_mday was supplied with 0 or negative values. mktime also generated inconsistent days. This problem has been fixed. 5.8.14 POLLWRNORM Now the Same as POLLOUT in <poll.h> According to the X/Open documentation for the <poll.h> header file, POLLWRNORM should equal POLLOUT. Previously it did not; now it does. 5.8.15 IPV6 Structures in <in6.h> Now Packed The IPV6 structure sockaddr_in6 in the <in6.h> header file was not packed, causing problems when applications expected and checked the size for packed structures. This structure should have been packed because the member alignment is on natural boundaries. This problem has been fixed. 5.8.16 __PAL_BUGCHK Fixed in <builtins.h> Previously, when using the C and C++ compilers, calling __PAL_BUGCHK with a parameter resulted in a fatal error. Also, many of the builtins had misleading comments about their implementation. This has been fixed. 5.8.17 C++ Compiler Error with statvfs Fixed The restrict type qualifier is added to the <decc$types.h> and <statvfs.h> header files when the C or C++ compiler or the X/Open standard (XPG6) supports it. This fixes the following problem: int statvfs(const char * __restrict path, struct statvfs * __restrictbuf); ....................................^ %CXX-E-EXPRPAREN, expected a ")" The following glob and globfree issues have been fixed: Previously, OpenVMS Version 7.3-2 did not correctly optimize the DECC$SHR_EV56.EXE image. The C RTL build is done with two sets of objects: one compiled normally, and one optimized for Alpha EV56 processors. The DECC$SHR_EV56.EXE image was not linked with the optimized objects. This problem has been fixed. 5.8.20 Zone Information Compiler (zic) Updates New time indicators have been added for the AT field in the Rule line. The letter "u" (or "g" or "z") indicates that the time in the AT field is UTC. For details about zic , refer to the HP C Run-Time Library Reference Manual for OpenVMS Systems.
http://h71000.www7.hp.com/doc/82final/6674/6674pro_prog.html
CC-MAIN-2015-06
refinedweb
1,481
56.45
Motivation Some time ago when I asked one of my colleagues, what whas his main motivation for becoming a programmer. He then replied in a sense that he wants his code be part of a software which can be useful for many years. Since my colleague worked as a Web Developer at that time, I was pretty skeptical of this answer. In my previous experience, the front-end part of an average project tends to be rewritten every three months or so, so this is not a very good place to look for "stable" and "unchanging" code. Later, however, I became more curious and decided to check, how long on average the line of code lives in our company's repository. The additional benefit was that I got myself a great excuse to play around with GitPython package during my work time! If you have not heard this name before, GitPython provides a Python-interface to git. Since we will use it heavily below, the basic familiarity is assumed and welcomed. I will also use pandas below pretty much as well. Finally, one last word before we embark on a journey. While working on this, I made myself an explicit goal to NOT to use anything except GitPython and pandas (remember, one of my goals was to learn the former). However, if you look for something more user-friendly, there are other packages built on top of GitPython, which provide much more rich and friendly interface. In particular, PyDriller popped out during my searches. But perhaps, plenty of others exist too. Main work Ok, so here we go. First, we initialize Repo object which will represent our repository. Make sure you have downloaded the repository and checked out the newest version. Replace PATH_TO_REPO below with path to your git repository on your disk. from git import Repo PATH_TO_REPO = "/Users/nailbiter/Documents/datawise/dtws-rdemo" repo = Repo("/Users/nailbiter/Documents/datawise/dtws-rdemo") assert not repo.bare Next, we check out the branch we want to investigate (see the variable BRANCH below). In your case it probably will be master, but our main branch is called development for some reasons. import pandas as pd BRANCH = "development" head = repo.commit(f"origin/{BRANCH}") from IPython.display import HTML def head_to_record(head): return {"sha":head.hexsha[:7], "parent(s)":[sha.hexsha[:7] for sha in head.parents], "name":head.message.strip(), "commit_obj":head } records = [] while head.parents: # print(f"parent(s) of {head.hexsha} is/are {[h.hexsha for h in head.parents]}") records.append(head_to_record(head)) head = head.parents[0] records.append(head_to_record(head)) pd.DataFrame(records) 303 rows × 4 columns Now, variables records in the code above represents all the commits on development branch since the beginning till the current moment. Next we need to go along these commits and collect info regarding every line which appeared/disappeared in that commit. This information later will help us to determine lifetime of each line which ever appeared in our repository. To do so, we create the variable res which is a dictionary. It's keys are tuples of the form (<line_content>,<commit>,<filename>) and its values are sets containing hashes of all the commits in which this line appeared. It is a rather big structure and computing it takes some time. Therefore, be ready that the code below will take some time to finish (around 100 seconds on my reasonably new MacBook Pro with our repository having only ~300 commits). I guess, there should be much more effective and elegant way to collect this data, but I have not came up with it yet. Suggestions are welcomed. import pandas as pd from tqdm import tqdm def collect_filestates(end,start=None): """this procedure collects names of all files which changed from commit `start` till commit `end` (these assumed to be adjacent)""" if start is not None: diffs = start.diff(other=end) fns = [diff.b_path for diff in diffs] change_types = [diff.change_type for diff in diffs] res = [{"filename":t[0],"status":t[1]} for t in zip(fns,change_types)] return res else: fns = end.stats.files.keys() return [{"filename":f,"status":"C"} for f in fns] def collect_lines(end,start=None): """collects information about all lines that changed from `start` to `end`""" filestates = [r for r in collect_filestates(end,start) if r["status"] != "D"] res = {} for fs in filestates: fn = fs["filename"] blame = repo.blame(end,file=fn) for k,v in blame: for vv in v: res[(vv,k.hexsha,fn)] = end.hexsha return res res = {} for i in tqdm(range(len(records))): _res = collect_lines(end=records[i]["commit_obj"],start=None if (i+1)==len(records) else records[i+1]["commit_obj"]) for k,v in _res.items(): if k in res: res[k].add(v) else: res[k] = {v} {k:v for k,v in list(res.items())[:5]} 100%|██████████| 303/303 [01:41<00:00, 2.99it/s] {('*.sw'}, ('*.sw'}, ('.pulled_data'}, ('.config.custom'}, ('.stderr.txt', '}} Now, as we have our marvelous res structure, we can easily compute the lifetime of every line which ever appeared in our repository: for every key in res we simply compute the duration between oldest and newest commit in its value set. But again, this may take some time (around 6 minutes on my machine). from datetime import datetime import pandas as pd from tqdm import tqdm _records = [] for k in tqdm(res): dates = [datetime.fromtimestamp(repo.commit(sha).committed_date) for sha in res[k]] _records.append(dict(line=k[0],commit=k[1],file=k[2],lifetime=max(dates)-min(dates))) lines_df = pd.DataFrame(_records) lines_df 100%|██████████| 1806272/1806272 [05:52<00:00, 5123.11it/s] 1806272 rows × 4 columns The table lines_df we assembled above contains the following columns: line-- that's line's content commit-- that's the first commit in which this line appeared. file-- filename in which this line appears lifetime-- lifetime of a line In the code below we add two more columns to this table: * author -- author of the line (to protect their privacy, I do not list real names, but rather one-letter nicknames) * ext -- file extension of filename from os.path import splitext, isfile import json if not isfile("author_masks.json"): to_author = lambda s:s else: with open("author_masks.json") as f: d = json.load(f) to_author = lambda s:d[s] lines_df.sort_values(by="lifetime",ascending=False) lines_df["author"] = [to_author(str(repo.commit(sha).author)) for sha in lines_df["commit"]] lines_df["ext"] = [splitext(fn)[1] for fn in lines_df["file"]] lines_df 1806272 rows × 6 columns Analysis Finally, having this info, we can then group, and average lifetime on various parameters. For example, below, we see the average lifetime of every line conditional on file extension: from datetime import timedelta from functools import reduce def averager(key, df=lines_df): ltk = "lifetime (days)" return pd.DataFrame([ {key:ext, ltk:(reduce(lambda t1,t2:t1+t2.to_pytimedelta(),slc["lifetime"],timedelta())/len(slc)).days } for ext,slc in df.groupby(key) ]).set_index(key).sort_values(by=ltk,ascending=False) averager("ext").plot.barh(figsize=(16,10),logx=True) You can see that ironically, the lines that stay unchanged the longest, belong to "insignificant" files like .lock (that's various yarn.lock's), .rules (that's Firabase rules), .html (that's index.html and since our project uses React, the main index.html also receives almost no changes) and others. In particular, files with empty extension refer to .gitignore's. And finally, we can see the average lifetime of a line of code, conditional on author. averager("author").plot.barh(figsize=(16,10)) We can see that the colleague I mentioned in the beginning (he goes by the nickname "J" here) indeed authored the longest-surviving lines in the whole repository. Good for him. However, let's look more closely at the secret of his success: _df = lines_df[[ext=="J" for ext in lines_df["author"]]].loc[:,["line","file","lifetime","ext"]] _df = averager(df=_df,key="ext") _df[[x>0 for x in _df["lifetime (days)"]]] Being the founder of the repository under consideration, he in particular mostly authored the aforementioned index.html, yarn.lock and *.rules files. As I explained before, these received almost no changes during the subsequent development. Further work Since we store the info on filenames as well, we can compute the averages conditional on folders, thus seeing, which parts of project are more "stable" than the others.
https://qiita.com/nailbiter/items/0fee2d55f63d2841e8ef
CC-MAIN-2020-50
refinedweb
1,397
57.16